Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-frontend into Dev-Farhan

pull/2/head
farhan048 1 year ago
parent
commit
6a20e77aa5
  1. 2
      src/routes.js
  2. 17
      src/views/Dashboard/DashboardBOD.js
  3. 33
      src/views/Dashboard/DashboardCustomer.js
  4. 28
      src/views/Dashboard/DashboardProject.js
  5. 23
      src/views/Pages/Login/Login.js
  6. 16
      src/views/SimproV2/CreatedProyek/AsignCustProject.js
  7. 21
      src/views/SimproV2/CreatedProyek/AsignHrProject.js
  8. 290
      src/views/SimproV2/CreatedProyek/AssignK3Project.js
  9. 688
      src/views/SimproV2/CreatedProyek/DialogDocument.js
  10. 41
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  11. 14
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  12. 173
      src/views/SimproV2/CreatedProyek/ReportAnalysis.js
  13. 62
      src/views/SimproV2/CreatedProyek/index.js
  14. 24
      src/views/SimproV2/Gantt/GanttFrame.js
  15. 28
      src/views/SimproV2/Gantt/index.js
  16. 12
      src/views/SimproV2/ResourceWorker/index.js

2
src/routes.js

@ -54,7 +54,7 @@ const routes = [
{ path: '/', exact: true, name: 'Home' },
// { path: '/dashboard', name: 'Dashboard', component: Dashboard},
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
{ path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer },
// { path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', name: 'DashboardCustomer', component: DashboardCustomer },
{ path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID/:SCURVE', name: 'DashboardCustomer', component: DashboardCustomer },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID/:SCURVE', exact: true, name: 'Dashboard Project', component: DashboardProject },

17
src/views/Dashboard/DashboardBOD.js

@ -13,8 +13,21 @@ import toRupiah from '@develoka/angka-rupiah-js';
import Icon from '@iconify/react';
import { HealthByBudget, HealthBySchedule } from './Components';
const DashboardBOD = () => {
const token = localStorage.getItem("token")
const DashboardBOD = (props) => {
let role_id = '', user_id='',isLogin='',token='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
console.error('undefined in props.location.state');
}
const HEADER = {
headers: {
"Content-Type": "application/json",

33
src/views/Dashboard/DashboardCustomer.js

@ -25,8 +25,21 @@ const center = {
lng: 106.816666
}
const DashboardCustomer = () => {
const token = localStorage.getItem("token")
const DashboardCustomer = (props) => {
let role_id = '', user_id='',isLogin='',token='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
console.error('Undefined in props.location.state');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -34,8 +47,7 @@ const DashboardCustomer = () => {
}
}
const { PROJECT_ID, GANTT_ID, SCURVE } = useParams();
const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`;
const mapRef = useRef()
const URL_GANTT = `https://adw-gantt.ospro.id/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${GANTT_ID}&proyek_id=${PROJECT_ID}&token=${token}&ro=1`; const mapRef = useRef()
const [projectName, setProjectName] = useState("");
const [projectManagerName, setProjectManagerName] = useState('');
const [customerName, setCustomerName] = useState("");
@ -101,8 +113,11 @@ const DashboardCustomer = () => {
const getProjectDetail = async () => {
setIsReadyProjectDetail(false);
const URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`;
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
let URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}`;
URL = `${BASE_OSPRO}/api/project/detail/${PROJECT_ID}/${GANTT_ID}/1`
const result = await axios.get(URL, HEADER)
.then(res => res)
.catch(err => err.response)
console.log('getProjectDetail', result);
if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed");
@ -195,7 +210,9 @@ const DashboardCustomer = () => {
const URL = `${BASE_OSPRO}/api/project/get-overdue-activities`;
const payload = {
"id": PROJECT_ID.toString(),
"till_date": moment(new Date()).format('YYYY-MM-DD')
"till_date": moment(new Date()).format('YYYY-MM-DD'),
'gantt': GANTT_ID.toString(),
'scurve': SCURVE ? SCURVE.toString() : null
}
const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response)
console.log('getOverdueActivities', result);
@ -431,7 +448,7 @@ const DashboardCustomer = () => {
<div style={{ display: 'flex', flexDirection: 'row', marginBottom: 10 }}>
<div style={{ flex: 20, display: 'flex', flexDirection: 'column' }}>
<div style={{fontSize: 16, fontWeight: 'bold', marginBottom: 10}}>Project</div>
<div style={{fontSize: 14}}>{isReadyProjectDetail
<div style={{fontSize: 14}}>{isReadyProjectDetail
? projectName
? calculationStatus
? projectName + " - S-Curve Ready"

28
src/views/Dashboard/DashboardProject.js

@ -124,12 +124,11 @@ const DashboardProject = () => {
const [dataGanttParents, setDataGanttParents] = useState({});
const [isReadyGanttParents, setIsReadyGanttParents] = useState(false);
const [calculationStatus, setCalculationStatus] = useState(false);
const [isHierarchy, setIsHierarchy] = useState(false);
const [isHierarchy, setIsHierarchy] = useState(null);
let history = useHistory();
useEffect(() => {
getProjectDetail();
getSCurve();
getOverdueActivities();
getReportDistribution();
getComments();
@ -140,6 +139,17 @@ const DashboardProject = () => {
};
}, []);
useEffect(() => {
if (isHierarchy != null) {
getSCurve();
}
window.addEventListener("message", handleIframeMessage);
return () => {
window.removeEventListener("message", handleIframeMessage);
};
}, [isHierarchy]);
useEffect(() => {
if (activeTabIdx === 1) {
initMap();
@ -187,6 +197,8 @@ const DashboardProject = () => {
setDataGantt(response);
if (response.data.data.hierarchy_ftth_id) {
setIsHierarchy(true);
} else {
setIsHierarchy(false);
}
setIsReadyGantt(true);
} catch (error) {
@ -313,12 +325,14 @@ const DashboardProject = () => {
);
setPlannedFinish(
SCURVE
? result.data.data.akhir_proyek
? result.data.data.type_proyek_id === 9
? result.data.data.akhir_proyek
: null
? result.data.data.akhir_proyek
: null
: result.data.data.header?.planned_end
? result.data.data.header?.planned_end
: null
: result.data.data.header?.planned_end
? result.data.data.header?.planned_end
: null
);
setActualStart(
result.data.data.header?.start_date
@ -709,7 +723,7 @@ const DashboardProject = () => {
// Send the URL back to the iframe
event.source.postMessage(
{ action: "sendUrl", url: childUrl },
{ action: "sendUrl", url: childUrl, isHierarchy: isHierarchy },
event.origin
);
}

23
src/views/Pages/Login/Login.js

@ -133,7 +133,7 @@ class Login extends Component {
}
}
getDataMenu = async (token, role_id) => {
getDataMenu = async (token, role_id, user_id) => {
const config = {
headers:
{
@ -157,15 +157,28 @@ class Login extends Component {
this.props.history.push("/dashboard-customer/58/63");
}
else {
this.props.history.push("/dashboard");
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
});
}
if (this.state.defaultPage) {
this.props.history.push(this.state.defaultPage);
if (role_id === 44) {
this.props.history.push({
pathname: this.state.defaultPage,
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
});
} else {
this.props.history.push(this.state.defaultPage);
}
} else if (role_id == 28) {
this.props.history.push("/dashboard-customer/58/63");
}
else {
this.props.history.push("/dashboard");
this.props.history.push({
pathname: "/dashboard",
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
});
}
} else {
NotificationManager.error('Login Failed', 'Failed');
@ -209,7 +222,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id, data_user.id)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);
window.localStorage.setItem('user_id', data_user.id);

16
src/views/SimproV2/CreatedProyek/AsignCustProject.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import {
@ -25,9 +25,11 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [openDialogFormTools, setOpenDialogFormTools] = useState(false)
const [loading, setLoading] = useState(true);
useEffect(() => {
if (idTask > 0) {
if (idTask > 0) {
setLoading(true);
getDataAssignHr();
}
}, [openDialog]);
@ -63,8 +65,10 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []
const filteredData = dataRes.filter(item => item.is_customer === true);
setdataUserToProject(filteredData);
setdataUserToProject(filteredData);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -185,8 +189,10 @@ const AssignCustProject = ({ openDialog, closeDialog, toggleDialog, idTask, proy
<div>Assign Customer - {proyekName}</div> <Button onClick={handleOpenDialogFormTools} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</ModalHeader>
<ModalBody>
{renderForm()}
<ModalBody>
<Spin tip="Loading..." spinning={loading}>
{renderForm()}
</Spin>
</ModalBody>
</Modal>
<FormAsignCust

21
src/views/SimproV2/CreatedProyek/AsignHrProject.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import { API_ADW, TOKEN_ADW, ASSIGN_HR_PROJECT_SEARCH, ASSIGN_HR_PROJECT_DELETE, USER_LIST, PROJECT_ROLE_SEARCH, ASSIGN_HR_PROJECT_ADD, ASSIGN_HR_PROJECT_EDIT } from '../../../const/ApiConst';
@ -25,16 +25,18 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
const [openDialogFormTools, setOpenDialogFormTools] = useState(false)
const [dataEdit, setDataEdit] = useState(null)
const [listUser, setListUser] = useState([])
const [listRole, setListRole] = useState([])
const [listRole, setListRole] = useState([])
const [loading, setLoading] = useState(true);
useEffect(() => {
if (idTask > 0) {
setLoading(true);
getDataAssignHr();
}
}, [openDialog]);
useEffect(() => {
if (openDialog) {
if (openDialog) {
getDataProjectRole();
getDataUser();
}
@ -70,9 +72,10 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []
setdataUserToProject(dataRes);
setdataUserToProject(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -158,7 +161,7 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
}
const handleOpenDialogFormTools = () => {
setOpenDialogFormTools(true)
setOpenDialogFormTools(true)
}
const handleCancel = () => {
@ -280,8 +283,10 @@ const AssignHrProject = ({ openDialog, closeDialog, toggleDialog, idTask, toolsR
<div>Assign Human Resource - {proyekName}</div> <Button onClick={handleOpenDialogFormTools} size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</ModalHeader>
<ModalBody>
{renderForm()}
<ModalBody>
<Spin tip="Loading..." spinning={loading}>
{renderForm()}
</Spin>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Close</Button>

290
src/views/SimproV2/CreatedProyek/AssignK3Project.js

@ -1,141 +1,149 @@
import React, { useEffect, useState } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import axios from "../../../const/interceptorApi";
import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import 'antd/dist/antd.css';
const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [id, setId] = useState(0)
const [targetKeys, setTargetKeys] = useState([])
const handleClearData = () => {
setId(0)
setTargetKeys([])
}
useEffect(() => {
if(!openDialog){
handleClearData()
}
}, [openDialog])
useEffect(() => {
if(idTask && idTask > 0){
getK3toProject()
}
}, [idTask])
const getK3toProject = async () => {
const payload = {
"columns": [
{ "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" }
]
}
const result = await axios
.post(PROJECT_TO_CHECKLIST_K3_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
console.log("cek get project to checklist k3",result.data.data)
let data = result.data.data || []
let newTargetKeys = []
if (data.length > 0) {
data.map((val,index)=> {
newTargetKeys.push(val.checklist_k3_id)
});
}
setTargetKeys(newTargetKeys)
}else{
}
}
const handleSave = async () => {
await saveAssign()
handleClearData()
}
const saveAssign= async () => {
const formData = {
checklist_k3_id:targetKeys,
proyek_id:idTask
}
const result = await axios
.post(PROJECT_TO_CHECKLIST_K3_ADDS, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
closeDialog('success')
}else{
closeDialog('failed')
}
}
const handleCancel = () => {
closeDialog('cancel')
handleClearData()
}
const handleChange = targetKeys => {
setTargetKeys(targetKeys)
};
const renderForm = () => {
return (
<div style={{
alignContent: "center",
justifyContent: "center !imporant",
paddingLeft: 20,
paddingRight: 20,
overflow: "auto"
}}>
<Transfer
showSearch
titles={['Available K3', 'Assigned to Project']}
dataSource={dataK3}
targetKeys={targetKeys}
onChange={handleChange}
render={item => item.title}
listStyle={{
width: 250,
height: 300,
}}
/>
</div>
)
}
return (
<>
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader>
<ModalBody>
{renderForm()}
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button>
</ModalFooter>
</Modal>
</>
)
}
export default AssignK3Project;
import React, { useEffect, useState } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap';
import axios from "../../../const/interceptorApi";
import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst';
import { Transfer, Spin } from 'antd';
import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => {
const token = localStorage.getItem("token")
const [loading, setLoading] = useState(true);
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [id, setId] = useState(0)
const [targetKeys, setTargetKeys] = useState([])
const handleClearData = () => {
setId(0)
setTargetKeys([])
}
useEffect(() => {
if(!openDialog){
handleClearData()
}
}, [openDialog])
useEffect(() => {
if (idTask && idTask > 0) {
setLoading(true);
getK3toProject()
}
}, [idTask])
const getK3toProject = async () => {
const payload = {
"columns": [
{ "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" }
]
}
const result = await axios
.post(PROJECT_TO_CHECKLIST_K3_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
console.log("cek get project to checklist k3",result.data.data)
let data = result.data.data || []
let newTargetKeys = []
if (data.length > 0) {
data.map((val,index)=> {
newTargetKeys.push(val.checklist_k3_id)
});
}
setTargetKeys(newTargetKeys)
setLoading(false);
}else{
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const handleSave = async () => {
await saveAssign()
handleClearData()
}
const saveAssign= async () => {
const formData = {
checklist_k3_id:targetKeys,
proyek_id:idTask
}
const result = await axios
.post(PROJECT_TO_CHECKLIST_K3_ADDS, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if(result && result.status==200){
closeDialog('success')
}else{
closeDialog('failed')
}
}
const handleCancel = () => {
closeDialog('cancel')
handleClearData()
}
const handleChange = targetKeys => {
setTargetKeys(targetKeys)
};
const renderForm = () => {
return (
<div style={{
alignContent: "center",
justifyContent: "center !imporant",
paddingLeft: 20,
paddingRight: 20,
overflow: "auto"
}}>
<Transfer
showSearch
titles={['Available K3', 'Assigned to Project']}
dataSource={dataK3}
targetKeys={targetKeys}
onChange={handleChange}
render={item => item.title}
listStyle={{
width: 250,
height: 300,
}}
/>
</div>
)
}
return (
<>
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader>
<ModalBody>
<Spin tip="Loading..." spinning={loading}>
{renderForm()}
</Spin>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Cancel</Button>
</ModalFooter>
</Modal>
</>
)
}
export default AssignK3Project;

688
src/views/SimproV2/CreatedProyek/DialogDocument.js

@ -1,341 +1,347 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button } from 'reactstrap';
import { Table, Tooltip, Popover } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogRequest from './FormDocument';
import DialogRequestFolder from './FormFolderDocument';
const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const [dataDocument, setDataDocument] = useState([])
const [openDialogReq, setOpenDialogReq] = useState(false)
const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false)
const [alertDelete, setAlertDelete] = useState(false)
const [alertDeleteFolder, setAlertDeleteFolder] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataEdit, setDataEdit] = useState(null)
const [parentIdNewFolder, setParentIdNewFolder] = useState(0)
useEffect(() => {
if (idTask > 0) {
getDataDocument();
}
}, [idTask, openDialog])
useEffect(() => {
if (!openDialog) {
setDataDocument([]);
} else {
}
}, [openDialog])
const getDataDocument = async () => {
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask)
const result = await axios
.get(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setDataDocument(result.data.data);
} else {
NotificationManager.error('Gagal mengambil data, Silahkan coba lagi!!', 'Failed');
}
}
const handleCancel = () => {
setDataDocument([]);
closeDialog('cancel', 'none')
}
const handleDelete = (id) => {
setIdDelete(id)
setAlertDelete(true)
}
const handleDeleteFolder = (id) => {
setIdDelete(id)
setAlertDeleteFolder(true)
}
const handleDownload = (id, file) => {
fetch(DOCUMENT_DOWNLOAD(id), {
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
})
})
.then(response => {
response.blob().then(blob => {
const url = window.URL.createObjectURL(new Blob([blob]));
let a = document.createElement('a');
a.href = url;
a.download = file;
a.click();
a.remove();
});
//window.location.href = response.url;
});
// const urlDownload = DOCUMENT_DOWNLOAD(id);
// window.open(urlDownload);
}
const handleShow = (file) => {
const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}`
window.open(urlShow);
}
const handleNewFolderParent = (folderId) => {
setParentIdNewFolder(folderId)
setOpenDialogNewFolder(true)
}
const handleNewFolderWOParent = () => {
setParentIdNewFolder(0)
setOpenDialogNewFolder(true)
}
const handleNewFileParent = (folderId) => {
setParentIdNewFolder(folderId)
openDialogRequest()
}
const handleNewFileWOParent = () => {
setParentIdNewFolder(0)
openDialogRequest()
}
const renderShowDokumen = (file) => {
let arrayFile = file.split(".")
let length = arrayFile.length
length = length - 1
const fileExt = arrayFile[length];
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") {
return (
<Tooltip title="View Document">
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button>
</Tooltip>
)
}
}
const RenderTable = useMemo(() => {
const columns = [
{
title: 'Action',
dataIndex: '',
key: 'id',
className: "nowrap",
render: (text, record) =>
<>
{!record.isDir && <Tooltip title="Delete Document">
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="Delete Folder">
<Button size={"sm"} color='danger' onClick={() => handleDeleteFolder(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>}{" "}
{!record.isDir && <Tooltip title="Download Document">
<Button size={"sm"} color='primary' onClick={() => handleDownload(text.id, text.file)}><i className="fa fa-download"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="New Folder">
<Button size="sm" color="success" onClick={() => handleNewFolderParent(record.id)}><i className="fa fa-folder"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="New File">
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button>
</Tooltip>}{" "}
{text.file ? renderShowDokumen(text.file) : ""}
</>
,
},
{ title: 'Document Name', dataIndex: 'name_folder', key: 'name_folder', render: (text, record) => record.isDir ? record.name_folder : record.file },
{ title: 'Type', dataIndex: 'isDir', key: 'isDir', render: (text, record) => record.isDir ? 'Folder' : 'File' },
{ title: 'Upload Date', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) }
];
return (
<Table
size="small"
columns={columns}
rowKey={"id"}
dataSource={dataDocument}
pagination={{ position: ["bottomLeft"] }}
/>
)
}, [dataDocument])
const closeDialogReq = (type) => {
if (type == "upload") {
getDataDocument();
}
setOpenDialogReq(false);
}
const toggleDialogReq = () => {
setOpenDialogReq(!openDialogReq)
}
const openDialogRequest = () => {
setOpenDialogReq(true)
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const cancelDeleteFolder = () => {
setAlertDeleteFolder(false)
setIdDelete(0)
}
const onConfirmDelete = async () => {
let urlDel = DOCUMENT_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataDocument()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Dokumen project berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Dokumen project gagal dihapus`, 'Failed!!');
}
}
const onConfirmDeleteFolder = async () => {
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataDocument()
setIdDelete(0)
setAlertDeleteFolder(false)
NotificationManager.success(`Folder berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDeleteFolder(false)
NotificationManager.error(`Folder gagal dihapus`, 'Failed!!');
}
}
const closeDialogNewFolder = (type) => {
if (type == "upload") {
getDataDocument();
}
setOpenDialogNewFolder(false);
setParentIdNewFolder(0);
}
const toggleDialogNewFolder = () => {
setOpenDialogNewFolder(!openDialogNewFolder)
}
return (
<>
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
<div>Project Documents - {proyekName} </div>
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-plus'></i></Button> */}
{/* <Popover placement="bottom" title="Add" content={popupAddDoc()} trigger="click">
<Button size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</Popover> */}
<div>
<Tooltip title="New Folder">
<Button size="sm" color="success" onClick={handleNewFolderWOParent}><i className="fa fa-folder"></i></Button>
</Tooltip>
<span style={{ marginLeft: 5, marginRight: 5 }}></span>
<Tooltip title="New File">
<Button size="sm" color="primary" onClick={handleNewFileWOParent}><i className="fa fa-file"></i></Button>
</Tooltip>
</div>
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-folder'></i></Button> */}
</ModalHeader>
<ModalBody>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
</div>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter> */}
</Modal>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<SweetAlert
show={alertDeleteFolder}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDeleteFolder}
onCancel={() => cancelDeleteFolder()}
focusCancelBtn
>
Delete this folder
</SweetAlert>
<DialogRequest
openDialog={openDialogReq}
closeDialog={closeDialogReq}
toggleDialog={toggleDialogReq}
idTask={idTask}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
/>
<DialogRequestFolder
openDialog={openDialogNewFolder}
closeDialog={closeDialogNewFolder}
toggleDialog={toggleDialogNewFolder}
idTask={idTask}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
/>
</>
)
}
export default DialogDocument;
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button } from 'reactstrap';
import { Table, Tooltip, Popover, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
import { DOCUMENT_DOWNLOAD, DOCUMENT_GET, BASE_SIMPRO_LUMEN_FILE, REQUEST_MATERIAL_EDIT, DOCUMENT_DELETE, DOCUMENT_SEARCH, FOLDER_DOCUMENT_PROYEK_GET_TREE, FOLDER_DOCUMENT_PROYEK_DELETE } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogRequest from './FormDocument';
import DialogRequestFolder from './FormFolderDocument';
const DialogDocument = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const [dataDocument, setDataDocument] = useState([])
const [openDialogReq, setOpenDialogReq] = useState(false)
const [openDialogNewFolder, setOpenDialogNewFolder] = useState(false)
const [alertDelete, setAlertDelete] = useState(false)
const [alertDeleteFolder, setAlertDeleteFolder] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataEdit, setDataEdit] = useState(null)
const [parentIdNewFolder, setParentIdNewFolder] = useState(0)
const [loading, setLoading] = useState(true);
useEffect(() => {
if (idTask > 0) {
setLoading(true);
getDataDocument();
}
}, [idTask, openDialog])
useEffect(() => {
if (!openDialog) {
setDataDocument([]);
} else {
}
}, [openDialog])
const getDataDocument = async () => {
const url = FOLDER_DOCUMENT_PROYEK_GET_TREE(idTask)
const result = await axios
.get(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
setDataDocument(result.data.data);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error('Gagal mengambil data, Silahkan coba lagi!!', 'Failed');
}
}
const handleCancel = () => {
setDataDocument([]);
closeDialog('cancel', 'none')
}
const handleDelete = (id) => {
setIdDelete(id)
setAlertDelete(true)
}
const handleDeleteFolder = (id) => {
setIdDelete(id)
setAlertDeleteFolder(true)
}
const handleDownload = (id, file) => {
fetch(DOCUMENT_DOWNLOAD(id), {
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
})
})
.then(response => {
response.blob().then(blob => {
const url = window.URL.createObjectURL(new Blob([blob]));
let a = document.createElement('a');
a.href = url;
a.download = file;
a.click();
a.remove();
});
//window.location.href = response.url;
});
// const urlDownload = DOCUMENT_DOWNLOAD(id);
// window.open(urlDownload);
}
const handleShow = (file) => {
const urlShow = `${BASE_SIMPRO_LUMEN_FILE}/${file}`
window.open(urlShow);
}
const handleNewFolderParent = (folderId) => {
setParentIdNewFolder(folderId)
setOpenDialogNewFolder(true)
}
const handleNewFolderWOParent = () => {
setParentIdNewFolder(0)
setOpenDialogNewFolder(true)
}
const handleNewFileParent = (folderId) => {
setParentIdNewFolder(folderId)
openDialogRequest()
}
const handleNewFileWOParent = () => {
setParentIdNewFolder(0)
openDialogRequest()
}
const renderShowDokumen = (file) => {
let arrayFile = file.split(".")
let length = arrayFile.length
length = length - 1
const fileExt = arrayFile[length];
if (fileExt == "pdf" || fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg" || fileExt == "gif") {
return (
<Tooltip title="View Document">
<Button size={"sm"} color='info' style={{ color: "#FFFFFF" }} onClick={() => handleShow(file)}><i className="fa fa-eye"></i></Button>
</Tooltip>
)
}
}
const RenderTable = useMemo(() => {
const columns = [
{
title: 'Action',
dataIndex: '',
key: 'id',
className: "nowrap",
render: (text, record) =>
<>
{!record.isDir && <Tooltip title="Delete Document">
<Button size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="Delete Folder">
<Button size={"sm"} color='danger' onClick={() => handleDeleteFolder(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>}{" "}
{!record.isDir && <Tooltip title="Download Document">
<Button size={"sm"} color='primary' onClick={() => handleDownload(text.id, text.file)}><i className="fa fa-download"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="New Folder">
<Button size="sm" color="success" onClick={() => handleNewFolderParent(record.id)}><i className="fa fa-folder"></i></Button>
</Tooltip>}{" "}
{record.isDir && <Tooltip title="New File">
<Button size="sm" color="primary" onClick={() => handleNewFileParent(record.id)}><i className="fa fa-file"></i></Button>
</Tooltip>}{" "}
{text.file ? renderShowDokumen(text.file) : ""}
</>
,
},
{ title: 'Document Name', dataIndex: 'name_folder', key: 'name_folder', render: (text, record) => record.isDir ? record.name_folder : record.file },
{ title: 'Type', dataIndex: 'isDir', key: 'isDir', render: (text, record) => record.isDir ? 'Folder' : 'File' },
{ title: 'Upload Date', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) }
];
return (
<Table
size="small"
columns={columns}
rowKey={"id"}
dataSource={dataDocument}
pagination={{ position: ["bottomLeft"] }}
/>
)
}, [dataDocument])
const closeDialogReq = (type) => {
if (type == "upload") {
getDataDocument();
}
setOpenDialogReq(false);
}
const toggleDialogReq = () => {
setOpenDialogReq(!openDialogReq)
}
const openDialogRequest = () => {
setOpenDialogReq(true)
}
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const cancelDeleteFolder = () => {
setAlertDeleteFolder(false)
setIdDelete(0)
}
const onConfirmDelete = async () => {
let urlDel = DOCUMENT_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataDocument()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Dokumen project berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Dokumen project gagal dihapus`, 'Failed!!');
}
}
const onConfirmDeleteFolder = async () => {
let urlDel = FOLDER_DOCUMENT_PROYEK_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataDocument()
setIdDelete(0)
setAlertDeleteFolder(false)
NotificationManager.success(`Folder berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDeleteFolder(false)
NotificationManager.error(`Folder gagal dihapus`, 'Failed!!');
}
}
const closeDialogNewFolder = (type) => {
if (type == "upload") {
getDataDocument();
}
setOpenDialogNewFolder(false);
setParentIdNewFolder(0);
}
const toggleDialogNewFolder = () => {
setOpenDialogNewFolder(!openDialogNewFolder)
}
return (
<>
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
<div>Project Documents - {proyekName} </div>
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-plus'></i></Button> */}
{/* <Popover placement="bottom" title="Add" content={popupAddDoc()} trigger="click">
<Button size='sm' color="primary"><i className='fa fa-plus'></i></Button>
</Popover> */}
<div>
<Tooltip title="New Folder">
<Button size="sm" color="success" onClick={handleNewFolderWOParent}><i className="fa fa-folder"></i></Button>
</Tooltip>
<span style={{ marginLeft: 5, marginRight: 5 }}></span>
<Tooltip title="New File">
<Button size="sm" color="primary" onClick={handleNewFileWOParent}><i className="fa fa-file"></i></Button>
</Tooltip>
</div>
{/* <Button onClick={openDialogRequest} size='sm' color="primary"><i className='fa fa-folder'></i></Button> */}
</ModalHeader>
<ModalBody>
<Spin tip="Loading..." spinning={loading}>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
</div>
</Spin>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter> */}
</Modal>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<SweetAlert
show={alertDeleteFolder}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDeleteFolder}
onCancel={() => cancelDeleteFolder()}
focusCancelBtn
>
Delete this folder
</SweetAlert>
<DialogRequest
openDialog={openDialogReq}
closeDialog={closeDialogReq}
toggleDialog={toggleDialogReq}
idTask={idTask}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
/>
<DialogRequestFolder
openDialog={openDialogNewFolder}
closeDialog={closeDialogNewFolder}
toggleDialog={toggleDialogNewFolder}
idTask={idTask}
parentIdNewFolder={parentIdNewFolder}
dataEdit={dataEdit}
/>
</>
)
}
export default DialogDocument;

41
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Breadcrumb, BreadcrumbItem} from 'reactstrap';
import { Button } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import { Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
@ -13,8 +13,20 @@ import DialogUserGantt from './DialogUserGantt';
import { Link } from 'react-router-dom';
const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy }) => {
const token = localStorage.getItem("token")
const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId, hierarchyName, openDialogHierarchy, isLogin, token, role_id, user_id }) => {
if (role_id && user_id && token && isLogin) {
role_id = role_id;
user_id = user_id;
token = token;
isLogin = isLogin;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
console.error('Undefined in props.location.state');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -31,9 +43,11 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
const [humanResource, setHumanResource] = useState([])
const [dataEdit, setDataEdit] = useState([])
const [typeDialog, setTypeDialog] = useState('')
const [loading, setLoading] = useState(true);
useEffect(() => {
if (openDialog && hierarchyId > 0 || idTask > 0 && !openDialogHierarchy) {
setLoading(true);
getdataGantt();
}
if (!openDialog) {
@ -92,8 +106,13 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
.catch((error) => error.response);
if (result && result.status == 200) {
setDataGantt(result.data.data);
const sortedData = result.data.data.sort((a, b) => {
return a.name_version.toLowerCase().localeCompare(b.name_version.toLowerCase());
});
setDataGantt(sortedData);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!');
}
}
@ -144,7 +163,15 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
</Tooltip>{" "}
</Link>
<Link to={`/projects/${text.id}/${idTask}/gantt`}>
<Link to={{
pathname: `/projects/${text.id}/${idTask}/gantt`,
state: {
isLogin: isLogin,
token: token,
role_id: role_id,
user_id: user_id,
}
}}>
<Tooltip title="Gantt">
<Button size={"sm"} color='primary'><i className="fa fa-gears"></i></Button>
</Tooltip></Link>{" "}
@ -251,7 +278,9 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
</ModalHeader>
<ModalBody>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
<Spin tip="Loading..." spinning={loading}>
{RenderTable}
</Spin>
</div>
</ModalBody>
{/* <ModalFooter>

14
src/views/SimproV2/CreatedProyek/DialogHierarchy.js

@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, } from 'reactstrap';
import { Button } from 'reactstrap';
import { Space, Table, Tooltip } from 'antd';
import { Space, Table, Tooltip, Spin } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
@ -41,8 +41,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([])
const { t } = useTranslation();
const [loading, setLoading] = useState(true);
useEffect(() => {
if (idTask > 0) {
setLoading(true);
getdataHierarchy();
}
}, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt])
@ -157,7 +159,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
if (result && result.status == 200) {
const sortedData = _.orderBy(result.data.data, ['name'], ['asc']);
setDataHierarchy(sortedData);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!');
}
}
@ -285,9 +289,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
</Tooltip>
</ModalHeader>
<ModalBody>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
</div>
<Spin tip="Loading..." spinning={loading}>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
</div>
</Spin>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>

173
src/views/SimproV2/CreatedProyek/ReportAnalysis.js

@ -1,7 +1,21 @@
import React, {useState, useEffect} from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Card, CardHeader, CardBody } from 'reactstrap';
import { TabContent, TabPane, Nav, NavItem, NavLink, Row, Col, Input } from 'reactstrap';
import { Button } from 'reactstrap';
import {
Modal,
ModalHeader,
ModalBody,
ModalFooter,
Card,
CardHeader,
CardBody,
TabContent,
TabPane,
Nav,
NavItem,
NavLink,
Row,
Col,
Button
} from 'reactstrap';
import axios from "../../../const/interceptorApi";
import {
NotificationManager,
@ -9,7 +23,7 @@ import {
import { BASE_SIMPRO_LUMEN } from "../../../const/ApiConst";
import 'antd/dist/antd.css';
import './style.css'
import { Select, Table, Tooltip } from 'antd';
import { Select, Table, Tooltip, Spin } from 'antd';
import DialogFormAnalysis from './DialogFormAnalysis';
import moment from "moment";
const { Option } = Select
@ -21,12 +35,15 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
const [openDialogFormAnalysis, setOpenDialogFormAnalysis] = useState(false);
const [dataDetail, setDataDetail] = useState(null);
const [avgActivityHr, setAvgActivityHr] = useState(0);
const [sumVolPlan, setSumVolPlan] = useState(0);
const [sumVolAct, setSumVolAct] = useState(0);
const [avgActivity, setAvgActivity] = useState(0);
const [dataTable, setDatatable] = useState([]);
const [dataTableActivityToHr, setDataTableActivityToHr] = useState([]);
const [hrList, setHrList] = useState([]);
const [groupedActivity, setGroupedActivity] = useState([]);
const [selectedHr, setSelectedHr] = useState(null);
const [loading, setLoading] = useState(false);
const toggle = (tab) => {
if (activeTab !== tab) {
@ -57,7 +74,57 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
const columns = [
{title: "Gantt", dataIndex: "name_version", key: "name_version"},
{title: "Assign HR", dataIndex: "user_name", key: "user_name"},
{title: "Baseline Start", dataIndex: "planned_start", key: "planned_start",
render: (text, record) => (
<>
{record.planned_start ? moment(record.planned_start).format("DD-MM-YY") : ''}
</>
),
},
{title: "Baseline Finish", dataIndex: "planned_end", key: "planned_end",
render: (text, record) => (
<>
{record.planned_end ? moment(record.planned_end).format("DD-MM-YY") : ''}
</>
),
},
{title: "Early Start", dataIndex: "start_date", key: "start_date",
render: (text, record) => (
<>
{moment(record.start_date).format("DD-MM-YY")}
</>
),
},
{title: "Early Finish", dataIndex: "end_date", key: "end_date",
render: (text, record) => (
<>
{moment(record.end_date).format("DD-MM-YY")}
</>
),
},
{title: "Actual Start", dataIndex: "actual_start", key: "actual_start",
render: (text, record) => (
<>
{record.actual_start ? moment(record.actual_start).format("DD-MM-YY") : ""}
</>
),
},
{title: "Actual Finish", dataIndex: "actual_end", key: "actual_end",
render: (text, record) => (
<>
{record.actual_end ? moment(record.actual_end).format("DD-MM-YY") : ""}
</>
),
},
{title: "Assign HR", dataIndex: "user_name", key: "user_name", width: "8%",
ellipsis:{
showTitle: true
},
render: (text) =>
<Tooltip placement="topLeft" title={text}>
{text}
</Tooltip>
},
{title: "Volume Plan", dataIndex: "qty_planning", key: "qty_planning",
render: (text, record) =>
<>
@ -81,7 +148,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
);
},
},
{title: "Progress Actual (%)", dataIndex: "persentase_progress", key: "persentase_progress"},
{title: "Progress Actual (%)", dataIndex: "persentase_progress", key: "persentase_progress", width: "8%"},
{
title: 'Action',
dataIndex: '',
@ -100,17 +167,45 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
const columnActivityToHr = [
{title: "Activity", dataIndex: "join_second_name", key: "join_second_name"},
{title: "Gantt", dataIndex: "join_fourth_name_version", key: "join_fourth_name_version"},
{title: "Start Date", dataIndex: "start_date", key: "start_date",
{title: "Baseline Start", dataIndex: "join_second_planned_start", key: "join_second_planned_start",
render: (text, record) => (
<>
{moment(record.join_second_planned_start).format("DD-MM-YY")}
</>
),
},
{title: "Baseline Finish", dataIndex: "join_second_planned_end", key: "join_second_planned_end",
render: (text, record) => (
<>
{moment(record.start_date).format("DD-MM-YYYY")}
{moment(record.join_second_planned_end).format("DD-MM-YY")}
</>
),
},
{title: "End Date", dataIndex: "end_date", key: "end_date",
{title: "Early Start", dataIndex: "join_second_start_date", key: "join_second_start_date",
render: (text, record) => (
<>
{moment(record.end_date).format("DD-MM-YYYY")}
{moment(record.join_second_start_date).format("DD-MM-YY")}
</>
),
},
{title: "Early Finish", dataIndex: "join_second_end_date", key: "join_second_end_date",
render: (text, record) => (
<>
{moment(record.join_second_end_date).format("DD-MM-YY")}
</>
),
},
{title: "Actual Start", dataIndex: "join_second_actual_start", key: "join_second_actual_start",
render: (text, record) => (
<>
{record.join_second_actual_start ? moment(record.join_second_actual_start).format("DD-MM-YY") : ""}
</>
),
},
{title: "Actual Finish", dataIndex: "join_second_actual_end", key: "join_second_actual_end",
render: (text, record) => (
<>
{record.join_second_actual_end ? moment(record.join_second_actual_end).format("DD-MM-YY") : ""}
</>
),
},
@ -155,12 +250,14 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
useEffect(() => {
if (search) {
setLoading(true);
getDataActivity()
}
}, [search]);
useEffect(() => {
if (selectedHr) {
setLoading(true);
getDataActivityToHr()
}
}, [selectedHr]);
@ -279,7 +376,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
{
name: "m_activity",
column_join: "activity_id",
column_results: ["name", "persentase_progress", "start_date", "end_date", "duration"]
column_results: ["name", "persentase_progress", "actual_start", "actual_end", "planned_start", "planned_end", "start_date", "end_date", "duration"]
},
{
name1: "m_activity",
@ -318,7 +415,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
});
setAvgActivityHr(sum / dataRes.length);
setDataTableActivityToHr(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
@ -352,8 +451,12 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
const getDataActivity = async () => {
setAvgActivity(0);
setSumVolPlan(0);
setSumVolAct(0);
setDatatable([]);
let sum = 0;
let sumPlan = 0;
let sumAct = 0;
const payload = {
columns: [
{
@ -383,10 +486,16 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
dataRes.forEach(element => {
element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0;
element.qty_planning ? sumPlan += parseInt(element.qty_planning) : sumPlan += 0;
element.qty ? sumAct += parseInt(element.qty) : sumAct += 0;
});
setAvgActivity(sum / dataRes.length);
setSumVolPlan(sumPlan);
setSumVolAct(sumAct);
setDatatable(dataRes);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
@ -434,21 +543,25 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
</Col>
</Row>
</CardHeader>
<CardBody>
<CardBody style={{ width: '100%' }}>
<div style={{ textAlign: 'center' }}>
<h1>
{
search && avgActivity ? `Activity ${search} adalah ${avgActivity.toFixed(2)} %` : null
search ? `Activity ${search}, Total Plan = ${sumVolPlan ? sumVolPlan.toFixed(0) : 0} dan Total Actual = ${sumVolAct ? sumVolAct.toFixed(0) : 0}` : null
}
</h1>
</div>
<Table
size="small"
columns={columns}
dataSource={dataTable}
pagination={false}
rowKey={"id"}
/>
<div style={{ width: '100%', overflowX: 'auto' }}>
<Spin tip="Loading..." spinning={loading}>
<Table
size="small"
columns={columns}
dataSource={dataTable}
pagination={false}
rowKey="id"
/>
</Spin>
</div>
</CardBody>
</Card>
</TabPane>
@ -467,14 +580,18 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
</Col>
</Row>
</CardHeader>
<CardBody>
<Table
size="small"
columns={columnActivityToHr}
dataSource={dataTableActivityToHr}
pagination={false}
rowKey={"id"}
/>
<CardBody style={{ width: '100%' }}>
<div style={{ width: '100%', overflowX: 'auto' }}>
<Spin tip="Loading..." spinning={loading}>
<Table
size="small"
columns={columnActivityToHr}
dataSource={dataTableActivityToHr}
pagination={false}
rowKey={"id"}
/>
</Spin>
</div>
</CardBody>
</Card>
</TabPane>

62
src/views/SimproV2/CreatedProyek/index.js

@ -89,19 +89,29 @@ import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject";
import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp';
import { Link, useHistory } from "react-router-dom";
import { Link, useHistory, withRouter } from "react-router-dom";
const url = "";
const proyek_id = localStorage.getItem("proyek_id");
const role_id = localStorage.getItem("role_id");
const user_id = localStorage.getItem("user_id");
const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
let role_id = '', user_id='',proyek_id='',isLogin='',token='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
console.error('Undefined in props.location.state');
}
const history = useHistory();
const token = localStorage.getItem("token");
const HEADER = {
headers: {
"Content-Type": "application/json",
@ -200,7 +210,7 @@ const CreatedProyek = ({ params, ...props }) => {
}, [openDialogProyek]);
useEffect(() => {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
}, [search, rowsPerPage, currentPage]);
useEffect(() => {
@ -266,8 +276,8 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const handleDashboard = async (text) => {
const URL = `${BASE_OSPRO}/api/project/detail/${text.id}`;
const handleDashboard = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios
.get(URL, HEADER)
.then((res) => res)
@ -284,9 +294,10 @@ const CreatedProyek = ({ params, ...props }) => {
);
return;
} else if (result.status == 200 && result.data.data) {
history.push(
`dashboard-customer/${text.id}/${result.data.gantt}/1`
);
history.push({
pathname: `/dashboard-customer/${id}/${result.data.gantt}/1`,
state: { role_id: role_id, user_id: user_id, token: token, isLogin: true }
});
}
};
@ -527,6 +538,7 @@ const CreatedProyek = ({ params, ...props }) => {
};
const handleOpenDialogViewDetail = async (data) => {
setLoading(true);
setidTask(data.id);
// setDataView(data)
await getDataProject(data.id);
@ -598,6 +610,10 @@ const CreatedProyek = ({ params, ...props }) => {
getProjectDetail(data.id);
};
const handleDashboardCustomer = async (data) => {
handleDashboard(data.id);
};
const handleOpenReport = async (data) => {
setOpenDialogRA(true);
setProjectId(data.id);
@ -696,7 +712,10 @@ const CreatedProyek = ({ params, ...props }) => {
.then((res) => res)
.catch((err) => err.response);
if (result && result.data && result.data.code === 200) {
setLoading(false)
setProjectImage(result.data.data);
}else{
setLoading(false)
}
}
@ -888,7 +907,7 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
getProjectImage(idDelete);
deleteImage(idDelete);
setIdDelete(0);
@ -959,7 +978,7 @@ const CreatedProyek = ({ params, ...props }) => {
NotificationManager.success(`${result.data.message}`, "Success!!");
}
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
}
@ -1138,7 +1157,7 @@ const CreatedProyek = ({ params, ...props }) => {
);
}
if (result && result.status === 200) {
role_id !== "44" ? getDataProyek() : getDataProyekByCustomer();
parseInt(role_id) !== 44 ? getDataProyek() : getDataProyekByCustomer();
NotificationManager.success(`Data proyek berhasil Ubah`, "Success!!");
} else {
NotificationManager.error(`${result.data.message}`, "Failed!!");
@ -1612,12 +1631,12 @@ const CreatedProyek = ({ params, ...props }) => {
dataIndex: "",
key: "x",
render: (text, record) =>
role_id == "44" ? (
parseInt(role_id) == 44 ? (
<>
<Tooltip title="Dashboard Project">
<Button
size="small"
onClick={() => handleDashboard(text)}
onClick={() => handleDashboardCustomer(text)}
type="link"
style={{ color: "green" }}
>
@ -1926,6 +1945,10 @@ const CreatedProyek = ({ params, ...props }) => {
closeDialog={closeDialogGantt}
toggleDialog={toggleDialogGantt}
idTask={idTask}
role_id={role_id}
user_id={user_id}
token={token}
isLogin={isLogin}
proyekName={proyekName}
/>
),
@ -1991,7 +2014,7 @@ const CreatedProyek = ({ params, ...props }) => {
/>
</Col>
<Col>
{role_id == "44" ? null : ( // role kustomer
{parseInt(role_id) == 44 ? null : ( // role kustomer
<Tooltip title="Add Project">
<Button
style={{ background: "#4caf50", color: "#fff" }}
@ -2062,5 +2085,4 @@ const CreatedProyek = ({ params, ...props }) => {
</div>
);
};
export default CreatedProyek;
export default withRouter(CreatedProyek);

24
src/views/SimproV2/Gantt/GanttFrame.js

@ -1,16 +1,30 @@
import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useHistory, withRouter } from 'react-router-dom';
import { BASE_SIMPRO_LUMEN } from '../../../const/ApiConst';
const GanttFrame = React.memo((props) => {
let role_id = '', user_id='',proyek_id='',isLogin='',token='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
isLogin = props.location.state.isLogin;
token = props.location.state.token;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
isLogin = localStorage.getItem("isLogin");
token = localStorage.getItem("token");
console.error('Undefined in props.location.state');
}
const history = useHistory();
const { versionGanttId, idProject, token, ro, timestamp } = props;
const { versionGanttId, idProject, ro, timestamp } = props;
const iframeSrc = `https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}`;
const [batchEntityData, setBatchEntityData] = useState(null);
useEffect(() => {
const handleMessage = (event) => {
if (event.data && event.data.batchEntity) {
@ -46,4 +60,4 @@ const GanttFrame = React.memo((props) => {
);
});
export default GanttFrame;
export default withRouter(GanttFrame);

28
src/views/SimproV2/Gantt/index.js

@ -11,18 +11,30 @@ import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { useHistory } from "react-router-dom";
import GanttFrame from "./GanttFrame";
const token = localStorage.getItem("token");
const userId = parseInt(localStorage.getItem("user_id"));
const HEADER = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
};
let roCount = 0;
const Gantt = (props) => {
let role_id = '', userId='',isLogin='',token='';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
userId = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
console.log('props.location.state success');
} else {
role_id = localStorage.getItem("role_id");
userId = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
console.error('Undefined in props.location.state');
}
const HEADER = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
};
const versionGanttId = props.match.params ? props.match.params.id : 0;
const idProject = props.match.params.project ? props.match.params.project : 0;
const timestamp = props.match.params.timestamp

12
src/views/SimproV2/ResourceWorker/index.js

@ -8,7 +8,7 @@ import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
} from '../../../const/ApiConst';
@ -18,6 +18,7 @@ const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token');
const config = {
headers:
{
@ -55,12 +56,15 @@ const ResourceWorker = ({ params }) => {
const [typeDialogShift, setTypeDialogShift] = useState('Save')
const pageName = params.name;
const { t } = useTranslation();
const [loading, setLoading] = useState(true);
useEffect(() => {
getRoleList()
getDivisiList()
}, [])
useEffect(() => {
setLoading(true);
getDataUser()
}, [search, rowsPerPage, currentPage])
@ -218,7 +222,9 @@ const ResourceWorker = ({ params }) => {
if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
setLoading(false);
} else {
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
@ -583,7 +589,9 @@ const ResourceWorker = ({ params }) => {
</Row>
</CardHeader>
<CardBody>
{RenderTable}
<Spin tip="Loading..." spinning={loading}>
{RenderTable}
</Spin>
<Pagination
style={{ marginTop: "25px" }}
showSizeChanger

Loading…
Cancel
Save