Commit 6eeba545 authored by Internship UKSW 2019's avatar Internship UKSW 2019

Initial commit

parent f64839d1
......@@ -49,6 +49,14 @@ export class DataTableApprovalDocument extends Component {
orderable: false,
targets: 5
},
{
visible: false,
orderable: false,
targets: 6,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
......
import React, { Component } from 'react';
import axios from 'axios';
const $ = require('jquery');
$.DataTable = require('datatables.net');
export class DataTableExpiredDocument extends Component {
componentDidMount = () => {
this.$el = $(this.el)
var table = this.$el.DataTable({
scrollY: "250px",
scrollCollapse: true,
paging: false,
data: this.props.data,
columns: [
{ title: "No", width: 30 },
{ title: "Code" },
{ title: "Subject" },
{ title: "Status" },
{ title: "Tracking" },
{ title: "Creator" },
],
columnDefs: [
{
searchable: false,
orderable: false,
targets: 0
},
{
orderable: false,
targets: 1,
render: function (data, type, row) {
return "<a class='text-decoration-none' href='#'>" + data + "</a>";
}
},
{
orderable: false,
targets: 2
},
{
orderable: false,
targets: 3
},
{
orderable: false,
targets: 4
},
{
orderable: false,
targets: 5
},
{
visible: false,
orderable: false,
targets: 6,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
})
table.on("order.dt search.dt", function () {
table.column(0, { search: "applied", order: "applied" }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1;
});
}).draw();
table.on("click", "a", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[2], "_blank");
})
}
componentWillUnmount = () => {
this.$el.DataTable.destroy(true);
}
render() {
return (
<div>
<table className="display" width="100%" ref={el => this.el = el}></table>
</div>
)
}
}
\ No newline at end of file
......@@ -49,6 +49,18 @@ export class DataTableHome extends Component {
orderable: false,
targets: 5
},
{
orderable: false,
targets: 6,
},
{
visible: false,
orderable: false,
targets: 7,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
}
],
order: [[ 1, "asc" ]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
......
......@@ -31,7 +31,7 @@ export class DataTableMyDocument extends Component {
orderable: false,
targets: 1,
render: function (data, type, row) {
return "<a class='text-decoration-none' href='#'>" + data + "</a>";
return "<a id='revision' class='text-decoration-none' href='#'>" + data + "</a>";
}
},
{
......@@ -51,10 +51,18 @@ export class DataTableMyDocument extends Component {
targets: 5
},
{
visible: false,
orderable: false,
targets: 6,
render: function (data, type, row) {
return "&nbsp;&nbsp;<svg style='width:24px;height:24px' viewBox='0 0 24 24'><path fill='currentColor' d='M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z' /></svg>";
return "<div>" + data + "</div>";
}
},
{
orderable: false,
targets: 7,
render: function (data, type, row) {
return "&nbsp;&nbsp;<a id='withdraw' class='text-decoration-none text-dark' href='#'><svg style='width:24px;height:24px' viewBox='0 0 24 24'><path fill='currentColor' d='M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z' /></svg></a>";
}
}
],
......@@ -66,12 +74,12 @@ export class DataTableMyDocument extends Component {
cell.innerHTML = i + 1;
});
}).draw();
table.on("click", "a", function (e) {
table.on("click", "a#revision", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/formrevision?subject=" + data[2], "_self");
})
table.on("click", "svg", function (e) {
table.on("click", "a#withdraw", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
var parseString = require('xml2js').parseString;
......
......@@ -49,6 +49,14 @@ export class DataTablePublishDocument extends Component {
orderable: false,
targets: 5
},
{
visible: false,
orderable: false,
targets: 6,
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
......
......@@ -39,8 +39,57 @@ body {
background: rgb(50, 50, 50);
width: 100%;
}
.background-grey2 {
background: rgb(85, 85, 85);
width: 100%;
}
.scrolling-wrapper {
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
}
.headerPreview {
width: 21cm;
margin: 0 auto;
margin-bottom: 0.5cm;
text-align: right;
}
.A4 {
background: white;
width: 21cm;
height: 29.7cm;
display: block;
margin: 0 auto;
padding: 50px 70px;
margin-bottom: 0.5cm;
/* box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5); */
/* overflow-y: scroll; */
box-sizing: border-box;
font-size: 12pt;
}
@media print {
.page-break {
display: block;
page-break-before: always;
}
}
@media print {
body {
margin: 0;
padding: 0;
}
.A4 {
box-shadow: none;
margin: 0;
width: auto;
height: auto;
}
.noprint {
display: none;
}
.enable-print {
display: block;
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -11,7 +11,7 @@ class FormCreateUpdateRole extends Component {
this.state = {
isFetched: false,
isEdit: false,
optionRoles: ["Admin", "Approver", "Additional Approver", "Compliance Officer", "Creator", "Manager Representative", "Viewer"],
optionRoles: ["Admin", "Approver", "Additional Approver", "Compliance Officer", "Creator", "Management Representative", "Viewer"],
validFormUser: false,
userid: "",
username: "",
......@@ -127,7 +127,7 @@ class FormCreateUpdateRole extends Component {
var parseString = require('xml2js').parseString;
if (this.state.isEdit == true) {
try {
await this.setState({ submitForm: true })
await this.setState({ submitForm: true, validFormUser: false });
let userRole1 = "";
for (let i = 0; i < this.state.roles.length; i++) {
if (i > 0) {
......@@ -135,6 +135,22 @@ class FormCreateUpdateRole extends Component {
}
userRole1 = userRole1 + this.state.roles[i];
}
let isValidComplianceOfficer = true;
if (userRole1.includes("Compliance Officer")) {
let response = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/user', { headers: { 'accept': 'application/xml' } })
let data;
parseString(response.data, function (err, result) {
data = result.user_dataCollection.user_data;
})
if (data != undefined) {
for (let i = 0; i < data.length; i++) {
if (data[i].user_role[0].includes("Compliance Officer")) {
isValidComplianceOfficer = false;
}
}
}
}
if (isValidComplianceOfficer) {
let dataEdit = {
"user_name": this.state.username,
"user_dpt": this.state.department,
......@@ -156,13 +172,17 @@ class FormCreateUpdateRole extends Component {
alert("User role has been successfully edited");
this.props.history.push("/manageuser")
})
} else {
await this.setState({ submitForm: false });
alert("A user with compliance officer roles already exist");
}
} catch (error) {
this.setState({ submitForm: false })
this.setState({ submitForm: false, validFormUser: true })
alert(error + "");
}
} else {
try {
await this.setState({ submitForm: true })
await this.setState({ submitForm: true, validFormUser: false });
let responseCheckDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/userkey/' + this.state.email, { headers: { 'accept': 'application/xml' } })
let checkDataUser;
parseString(responseCheckDataUser.data, function (err, result) {
......@@ -200,35 +220,19 @@ class FormCreateUpdateRole extends Component {
this.props.history.push("/manageuser")
})
.catch(err => {
this.setState({ submitForm: false })
this.setState({ submitForm: false, validFormUser: true })
alert(err + "");
})
} else {
this.setState({ submitForm: false })
this.setState({ submitForm: false, validFormUser: true })
alert("Email is invalid!")
}
// let uri_email = encodeURIComponent(this.state.email);
// let API_token = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlpqUm1ZVE13TlRKak9XVTVNbUl6TWpnek5ESTNZMkl5TW1JeVkyRXpNamRoWmpWaU1qYzBaZz09In0.eyJhdWQiOiJodHRwOlwvXC9vcmcud3NvMi5hcGltZ3RcL2dhdGV3YXkiLCJzdWIiOiJhZG1pbkBjYXJib24uc3VwZXIiLCJhcHBsaWNhdGlvbiI6eyJvd25lciI6ImFkbWluIiwidGllciI6IjEwUGVyTWluIiwibmFtZSI6ImFwcGwiLCJpZCI6MTMsInV1aWQiOm51bGx9LCJzY29wZSI6ImFtX2FwcGxpY2F0aW9uX3Njb3BlIGRlZmF1bHQiLCJpc3MiOiJodHRwczpcL1wvMTAuMTAuODguMTI6OTQ0M1wvb2F1dGgyXC90b2tlbiIsInRpZXJJbmZvIjp7IlVubGltaXRlZCI6eyJzdG9wT25RdW90YVJlYWNoIjp0cnVlLCJzcGlrZUFycmVzdExpbWl0IjowLCJzcGlrZUFycmVzdFVuaXQiOm51bGx9fSwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJzdWJzY3JpYmVkQVBJcyI6W3sic3Vic2NyaWJlclRlbmFudERvbWFpbiI6ImNhcmJvbi5zdXBlciIsIm5hbWUiOiJlbXBsb3llZV9wcm9maWxlIiwiY29udGV4dCI6IlwvZW1weWxcLzEuMC4wIiwicHVibGlzaGVyIjoiYWRtaW4iLCJ2ZXJzaW9uIjoiMS4wLjAiLCJzdWJzY3JpcHRpb25UaWVyIjoiVW5saW1pdGVkIn1dLCJjb25zdW1lcktleSI6ImlqMHNnaWVLVVprdFBTbElkcl9mU2tFanI1a2EiLCJleHAiOjE2MzUyOTk3NDYsImlhdCI6MTU4MDk3ODc0NiwianRpIjoiNDFlM2FlMGYtMmYzZC00NWIzLTllN2YtMjI5YjRiNTkwOWE1In0.ZZ1_-3Z2bnsa5ar7b-QnuNGy95Olh5rQSMifJCTnW09T9omU1Zzql1Wllaey7veC9xy6yi-WxPpPeRee_-UtZdloGE9PCd99rMdNLsNuXWxmN0MvyXjMYqUvOYe9lbXzirE99yQhywa7LzVxpJVccGl42a5HhJ-BHF85IXiSSKK_-ykssK2WNfQhyUySJoz-lUj44-Eur2svbEWTVX6sOaejdwdv3xBFya8WoAAXPaelaE0Fm2SONQdh4DZZx0OdJS794fcYGNKshdTJiAG7Kau1jQMjy6-Pa3fv8wpFxV7GQuQy24TeTBo3jNxX2Fu5b2-P_YFIgA1KuqSM9Fnp2Q";
// fetch('http://10.10.88.12:8280/empyl/1.0.0/employee/' + uri_email, {
// headers: { 'Authorization': API_token }
// })
// .then(response => response.text())
// .then(text => {
// let dataEmployee;
// parseString(text, function (err, result) {
// dataEmployee = result.VU_EmployeeMACCollection.VU_EmployeeMAC;
// })
// console.log("dataEmployee", dataEmployee)
// })
// .catch(err => {
// alert(err + "");
// })
} else {
this.setState({ submitForm: false })
await this.setState({ submitForm: false, validFormUser: true })
alert("Email is already exist");
}
} catch (error) {
this.setState({ submitForm: false })
await this.setState({ submitForm: false, validFormUser: true })
alert(error + "");
}
}
......
......@@ -17,6 +17,7 @@ class FormPublish extends Component {
dataRevisionHistory: [],
dataAuditTrail: [],
statusPublish: false,
validSubmitPublish: true,
remark: "",
doc_id: "",
user_id: "",
......@@ -187,7 +188,7 @@ class FormPublish extends Component {
let isPublish = window.confirm("Are you sure want to " + labelPublish + " document " + this.state.subject + "?");
if (isPublish) {
try {
await this.setState({ submitForm: true });
await this.setState({ submitForm: true, validSubmitPublish: false });
var js2xmlparser = require('js2xmlparser');
var parseString = require('xml2js').parseString;
if (actionPublish == "Publish Document") {
......@@ -322,7 +323,7 @@ class FormPublish extends Component {
alert("Document has been successfully " + labelPublish);
this.props.history.push("/yourdocument");
} catch (err) {
await this.setState({ submitForm: false });
await this.setState({ submitForm: false, validSubmitPublish: true });
alert(err + "");
}
}
......@@ -463,7 +464,7 @@ class FormPublish extends Component {
</div>
<div className="col-xl-9 col-lg-9 col-md-9 col-sm-9 text-right">
<Button color="primary" className="button-2" onClick={() => this.handleClickPreview()}>Preview</Button>&nbsp;
<Button color="primary" className="button-2" onClick={() => this.handleClickPublish()}>{this.handleShowLabelPublish()}&nbsp;
<Button color="primary" className="button-2" onClick={() => this.handleClickPublish()} disabled={!this.state.validSubmitPublish}>{this.handleShowLabelPublish()}&nbsp;
{
this.state.submitForm &&
<img src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
......@@ -561,7 +562,7 @@ class FormPublish extends Component {
}
{
this.state.documentType == "FORM" &&
<a href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
<a className="text-decoration-none" href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
}
</label>
</div>
......
......@@ -890,7 +890,8 @@ class FormRevision extends Component {
}
handleSaveChanges = async () => {
try {
await this.setState({ submitForm: true });
this.state.validPage[2] = false;
await this.setState({ submitForm: true, validPage: this.state.validPage });
var js2xmlparser = require('js2xmlparser');
var parseString = require('xml2js').parseString;
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + this.state.doc_id, { headers: { 'Content-Type': 'application/xml' } })
......@@ -1089,7 +1090,8 @@ class FormRevision extends Component {
alert("Document has been successfully updated");
this.props.history.push("/yourdocument");
} catch (error) {
await this.setState({ submitForm: false })
this.state.validPage[2] = true;
await this.setState({ submitForm: false, validPage: this.state.validPage })
alert(error + "");
}
}
......@@ -1140,7 +1142,7 @@ class FormRevision extends Component {
{({ getRootProps, getInputProps }) => (
<section>
<div {...getRootProps()} className="p-4 text-center" style={{ height: "250px", backgroundColor: "lightgrey", border: "1px solid black", borderRadius: "20px", borderStyle: "dashed" }}>
<input {...getInputProps()} />
<input {...getInputProps()} accept=".doc,.docx,.xls,.xlsx"/>
{
this.state.contentForm.title == "" &&
<div>
......@@ -1213,7 +1215,7 @@ class FormRevision extends Component {
plugins: [
'advlist autolink table lists link image charmap print preview anchor',
'searchreplace wordcount visualblocks code fullscreen',
'insertdatetime media table contextmenu paste responsivefilemanager code'
'insertdatetime media table contextmenu paste code'
],
toolbar:
'undo redo | image code | table tabledelete | \
......@@ -1221,13 +1223,8 @@ class FormRevision extends Component {
tableinsertrowbefore tableinsertrowafter tabledeleterow | \
tableinsertcolbefore tableinsertcolafter tabledeletecol | \
formatselect | bold italic underline strikethrough | \
responsivefilemanager | link unlink | \
alignleft aligncenter alignright alignjustify | \
link unlink | alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help',
image_advtab: true,
external_filemanager_path: '/filemanager/',
filemanager_title: 'Responsive Filemanager',
external_plugins: { 'responsivefilemanager': '/filemanager/plugin.min.js' },
content_css: '//www.tinymce.com/css/codepen.min.css',
file_picker_types: 'image',
file_picker_callback: function (callback, value, meta) {
......@@ -1556,7 +1553,7 @@ class FormRevision extends Component {
}
{
this.state.documentType == "FORM" &&
<a href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
<a className="text-decoration-none" href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
}
</label>
</div>
......
......@@ -17,7 +17,7 @@ class Home extends Component {
componentDidMount = async () => {
console.log(JSON.parse(localStorage.getItem("dataLogin")).email[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) {
......@@ -26,6 +26,24 @@ class Home extends Component {
if (data != undefined) {
for (let i = 0; i < data.length; i++) {
let datarow = [];
let content = "";
let apiContent = "contentkey";
if (data[i].doc_code[0].includes("FORM")) {
apiContent = "contentkey2";
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/' + apiContent + '/' + data[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && data[i].doc_type[0] != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
content += "<p>" + dataContent[j].cont_title[0] + "</p>" + dataContent[j].cont[0];
}
}
if (dataContent != undefined && data[i].doc_type[0] == "FORM") {
content = "<p>" + dataContent[0].cont_title[0] + "</p>";
}
datarow.push("");
datarow.push(data[i].doc_code[0]);
datarow.push(data[i].subject[0]);
......@@ -41,6 +59,7 @@ class Home extends Component {
}
datarow.push(new_effdate);
datarow.push(data[i].usr_dpt[0]);
datarow.push(content);
this.state.dataDocument.push(datarow);
}
}
......
......@@ -18,7 +18,7 @@ class ManageUser extends Component {
componentDidMount = async () => {
try {
var parseString = require('xml2js').parseString;
let response = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/user', { headers: { 'accept': 'application/xml' } });
let response = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/user', { headers: { 'accept': 'application/xml' } })
let data;
parseString(response.data, function (err, result) {
data = result.user_dataCollection.user_data;
......
This diff is collapsed.
This diff is collapsed.
......@@ -12,7 +12,7 @@ const YourDocumentRoute = ({ component: Component, ...rest }) => {
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Additional Approver") ||
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Compliance Officer") ||
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Creator") ||
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Manager Representative")) ? (
JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Management Representative")) ? (
<Component {...props} />
) : (
<Redirect to={{ pathname: '/', state: { from: props.location } }} />
......
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