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

Initial commit

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