Commit 0fd4b5e7 authored by Internship UKSW 2019's avatar Internship UKSW 2019

Initial commit

parent a0ad902e
This diff is collapsed.
......@@ -5,6 +5,7 @@
"proxy": "https://app.visionet.co.id/api/employee",
"dependencies": {
"@material-ui/core": "^4.7.0",
"@react-pdf/renderer": "^1.6.8",
"axios": "^0.19.1",
"bootstrap": "^4.3.1",
"cors": "^2.8.5",
......
......@@ -8,6 +8,9 @@
.content-loading {
margin-top: 20%;
}
.content-loading-2 {
margin-top: 15%;
}
.login-form {
padding-top: 5rem;
padding-bottom: 5rem;
......
This diff is collapsed.
......@@ -185,18 +185,9 @@ class FormCreate extends Component {
return "<a class='text-decoration-none text-dark' href='#'>" + data + "</a>";
}
},
{
targets: 2,
render: function (data, type, row) {
return "<a class='text-decoration-none text-dark' href='#'>" + data + "</a>";
}
},
{
orderable: false,
targets: 3,
render: function (data, type, row) {
return "<a class='text-decoration-none text-dark' href='#'>" + data + "</a>";
}
},
{
className: 'select-checkbox',
......@@ -226,25 +217,26 @@ class FormCreate extends Component {
tableReference.on("click", "a", function (e) {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
let listReference = document.getElementsByName("listReference[]");
for (let i = 0; i < listReference.length; i++) {
if (listReference[i].value == data[1]) {
if (listReference[i].checked) {
listReference[i].checked = false;
let j = self.state.copyReferences.indexOf(listReference[i].value);
self.state.copyReferences.splice(j, 1);
if (self.state.copyReferences.length == 0) {
self.state.validAddReference = false;
}
} else {
listReference[i].checked = true;
self.state.copyReferences.push(listReference[i].value);
self.state.validAddReference = true;
}
self.setState({ validAddReference: self.state.validAddReference });
break;
}
}
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[1], "_blank");
// let listReference = document.getElementsByName("listReference[]");
// for (let i = 0; i < listReference.length; i++) {
// if (listReference[i].value == data[1]) {
// if (listReference[i].checked) {
// listReference[i].checked = false;
// let j = self.state.copyReferences.indexOf(listReference[i].value);
// self.state.copyReferences.splice(j, 1);
// if (self.state.copyReferences.length == 0) {
// self.state.validAddReference = false;
// }
// } else {
// listReference[i].checked = true;
// self.state.copyReferences.push(listReference[i].value);
// self.state.validAddReference = true;
// }
// self.setState({ validAddReference: self.state.validAddReference });
// break;
// }
// }
})
} catch (err) {
console.log(err + "");
......
This diff is collapsed.
......@@ -9,6 +9,7 @@ class Home extends Component {
constructor(props) {
super(props)
this.state = {
fetchError: false,
fetchStatus: false,
dataDocument: []
}
......@@ -16,7 +17,7 @@ class Home extends Component {
componentDidMount = async () => {
console.log(JSON.parse(localStorage.getItem("dataLogin")).user_name[0]);
try {
let response = await axios.get(process.env.REACT_APP_MAIN_APIURL +'/DocumentManagement/home', { headers: { 'accept': 'application/xml' } });
let response = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/home', { headers: { 'accept': 'application/xml' } });
var parseString = require('xml2js').parseString;
let data;
parseString(response.data, function (err, result) {
......@@ -29,14 +30,8 @@ class Home extends Component {
datarow.push(data[i].doc_code[0]);
datarow.push(data[i].subject[0]);
datarow.push(data[i].doc_type[0]);
let new_revdate = data[i].rev_date[0];
let new_revdate = "-";// data[i].rev_date[0]
let new_effdate = data[i].eff_date[0];
if (data[i].rev_date[0].includes("+00:00")) {
new_revdate = data[i].rev_date[0].replace("+00:00", "");
}
if (data[i].doc_code[0].includes("R0")) {
new_revdate = "-";
}
datarow.push(new_revdate);
if (data[i].eff_date[0].includes("+00:00")) {
new_effdate = data[i].eff_date[0].replace("+00:00", "");
......@@ -46,12 +41,17 @@ class Home extends Component {
this.state.dataDocument.push(datarow);
}
}
this.setState({ fetchStatus: true})
this.setState({ fetchStatus: true });
} catch (error) {
this.setState({ fetchStatus: true})
this.setState({ fetchStatus: true, fetchError: true });
console.log(error + "");
}
}
retryRetrievingData = (e) => {
e.preventDefault();
this.setState({ fetchStatus: false, fetchError: false });
this.componentDidMount();
}
render() {
const { session } = this.props;
return (
......@@ -61,7 +61,7 @@ class Home extends Component {
this.state.fetchStatus == false &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading">
<div className="content-loading-2">
<div className="form-group row">
<h3 className="text-center">Retrieving Data </h3>
<ReactLoading type="bubbles" color="dark" width="40px" height="20px"></ReactLoading>
......@@ -71,7 +71,20 @@ class Home extends Component {
</div>
}
{
this.state.fetchStatus == true &&
this.state.fetchStatus == true && this.state.fetchError == true &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading-2">
<div className="form-group">
<h3 className="text-center">Something wrong when retrieving data. Please try again.</h3>
<div className="text-center"><h3><a className="text-dark text-decoration-none" onClick={(e) => this.retryRetrievingData(e)} href="#"><img src="refresh.png" alt="refresh" height="30" width="30" /> Tap to Retry</a></h3></div>
</div>
</div>
</div>
</div>
}
{
this.state.fetchStatus == true && this.state.fetchError == false &&
<div className="container-fluid">
<DataTableHome data={this.state.dataDocument}></DataTableHome>
</div>
......
......@@ -10,6 +10,7 @@ class ManageUser extends Component {
constructor(props) {
super(props)
this.state = {
fetchError: false,
fetchStatus: false,
dataUser: [],
}
......@@ -35,12 +36,17 @@ class ManageUser extends Component {
this.state.dataUser.push(datarow);
}
}
this.setState({ fetchStatus: true })
this.setState({ fetchStatus: true });
} catch (error) {
this.setState({ fetchStatus: true })
this.setState({ fetchStatus: true, fetchError: true });
console.log(error + "");
}
}
retryRetrievingData = (e) => {
e.preventDefault();
this.setState({ fetchStatus: false, fetchError: false });
this.componentDidMount();
}
render() {
const { session } = this.props;
return (
......@@ -56,7 +62,7 @@ class ManageUser extends Component {
this.state.fetchStatus == false &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading">
<div className="content-loading-2">
<div className="form-group row">
<h3 className="text-center">Retrieving Data </h3>
<ReactLoading type="bubbles" color="dark" width="40px" height="20px"></ReactLoading>
......@@ -66,7 +72,20 @@ class ManageUser extends Component {
</div>
}
{
this.state.fetchStatus == true &&
this.state.fetchStatus == true && this.state.fetchError == true &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading-2">
<div className="form-group">
<h3 className="text-center">Something wrong when retrieving data. Please try again.</h3>
<div className="text-center"><h3><a className="text-dark text-decoration-none" onClick={(e) => this.retryRetrievingData(e)} href="#"><img src="refresh.png" alt="refresh" height="30" width="30" /> Tap to Retry</a></h3></div>
</div>
</div>
</div>
</div>
}
{
this.state.fetchStatus == true && this.state.fetchError == false &&
<DataTableManageUser data={this.state.dataUser}></DataTableManageUser>
}
</div>
......
import React, { Component } from 'react';
import { connect } from 'react-redux';
import queryString from 'query-string';
import axios from 'axios';
import { Button } from 'reactstrap';
......@@ -12,6 +11,7 @@ class PreviewDocument extends Component {
this.state = {
isNotValidLocation: false,
isDocumentNotFound: false,
fetchError: false,
isFetched: false,
subject: "",
documentType: "",
......@@ -47,6 +47,7 @@ class PreviewDocument extends Component {
})
let documentType = dataDocument[0].doc_type[0];
let documentCode = dataDocument[0].doc_code[0];
console.log(dataDocument[0].rev_date[0])
let revisionDate = dataDocument[0].rev_date[0];
let effectiveDate = dataDocument[0].eff_date[0];
let purpose = JSON.parse(dataDocument[0].information).purpose;
......@@ -56,7 +57,7 @@ class PreviewDocument extends Component {
if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (!dataRevision[dataRevision.length - 1].status.includes("Document Rejected By")) {
if (dataRevision[dataRevision.length - 1].rev_code.includes("R0")) {
revisionDate = "-";
}
if (effectiveDate.includes("+00:00")) {
......@@ -86,17 +87,18 @@ class PreviewDocument extends Component {
}
this.state.contents.push(datarow2);
}
this.setState({ isFetched: true })
this.setState({ isFetched: true });
} else {
this.setState({ isFetched: true, isDocumentNotFound: true })
this.setState({ isFetched: true, isDocumentNotFound: true });
}
} else {
this.setState({ isNotValidLocation: true })
this.setState({ isNotValidLocation: true });
}
} else {
this.setState({ isNotValidLocation: true })
this.setState({ isNotValidLocation: true });
}
} catch (error) {
this.setState({ isFetched: true, fetchError: true });
console.log(error + "");
}
}
......@@ -122,7 +124,7 @@ class PreviewDocument extends Component {
</div>
}
{
this.state.approvalDocument.length !=0 &&
this.state.approvalDocument.length != 0 &&
this.state.approvalDocument.map((approval, index) => {
return (
<div key={index}>
......@@ -147,8 +149,12 @@ class PreviewDocument extends Component {
}
return <h3 className="text-center">{showText}</h3>
}
retryRetrievingData = (e) => {
e.preventDefault();
this.setState({ isFetched: false, fetchError: false });
this.componentDidMount();
}
render() {
const { session } = this.props;
return (
<div>
{
......@@ -164,6 +170,19 @@ class PreviewDocument extends Component {
</div>
</div>
}
{
this.state.isFetched == true && this.state.fetchError == true &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading">
<div className="form-group">
<h3 className="text-center">Something wrong when retrieving data. Please try again.</h3>
<div className="text-center"><h3><a className="text-dark text-decoration-none" onClick={(e) => this.retryRetrievingData(e)} href="#"><img src="refresh.png" alt="refresh" height="30" width="30" /> Tap to Retry</a></h3></div>
</div>
</div>
</div>
</div>
}
{
this.state.isNotValidLocation == true &&
<div className="header-top-2">
......@@ -179,7 +198,7 @@ class PreviewDocument extends Component {
</div>
}
{
this.state.isFetched == true && this.state.isDocumentNotFound == false &&
this.state.isFetched == true && this.state.isDocumentNotFound == false && this.state.fetchError == false &&
<div className="container">
<div className="row justify-content-center">
<div className="col-xl-9 col-lg-10 col-md-11 col-sm-12 text-right my-2">
......@@ -327,10 +346,4 @@ class PreviewDocument extends Component {
}
}
const mapStateToProps = (state) => {
return {
session: state.session
}
}
export default connect(mapStateToProps)(PreviewDocument);
\ No newline at end of file
export default PreviewDocument;
\ No newline at end of file
......@@ -11,6 +11,7 @@ class YourDocument extends Component {
constructor(props) {
super(props)
this.state = {
fetchError: false,
fetchStatus: false,
dataDocument: [],
dataApprovalDocument: [],
......@@ -92,10 +93,15 @@ class YourDocument extends Component {
}
await this.setState({ fetchStatus: true });
} catch (error) {
await this.setState({ fetchStatus: true });
await this.setState({ fetchStatus: true, fetchError: true });
console.log(error + "");
}
}
retryRetrievingData = (e) => {
e.preventDefault();
this.setState({ fetchStatus: false, fetchError: false });
this.componentDidMount();
}
render() {
const { session } = this.props;
return (
......@@ -111,7 +117,7 @@ class YourDocument extends Component {
this.state.fetchStatus == false &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading">
<div className="content-loading-2">
<div className="form-group row">
<h3 className="text-center">Retrieving Data </h3>
<ReactLoading type="bubbles" color="dark" width="40px" height="20px"></ReactLoading>
......@@ -121,7 +127,20 @@ class YourDocument extends Component {
</div>
}
{
this.state.fetchStatus == true && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Creator") &&
this.state.fetchStatus == true && this.state.fetchError == true &&
<div className="container">
<div className="row justify-content-center">
<div className="content-loading-2">
<div className="form-group">
<h3 className="text-center">Something wrong when retrieving data. Please try again.</h3>
<div className="text-center"><h3><a className="text-dark text-decoration-none" onClick={(e) => this.retryRetrievingData(e)} href="#"><img src="refresh.png" alt="refresh" height="30" width="30" /> Tap to Retry</a></h3></div>
</div>
</div>
</div>
</div>
}
{
this.state.fetchStatus == true && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Creator") && this.state.fetchError == false &&
<div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
......@@ -132,7 +151,7 @@ class YourDocument extends Component {
</div>
}
{
this.state.fetchStatus == true &&
this.state.fetchStatus == true && this.state.fetchError == false &&
(
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Approver") ||
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Additional Approver") ||
......@@ -150,7 +169,7 @@ class YourDocument extends Component {
</div>
}
{
this.state.fetchStatus == true && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Compliance Officer") &&
this.state.fetchStatus == true && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Compliance Officer") && this.state.fetchError == false &&
<div>
<hr />
<div className="form-group row">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment