From e1efc0049d5f592e10fbbcd346e4cf60f71d1a44 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Tue, 21 Nov 2023 14:19:24 +0700 Subject: [PATCH 1/2] delete saveHierarchy --- src/views/SimproV2/CreatedProyek/DialogHierarchy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js b/src/views/SimproV2/CreatedProyek/DialogHierarchy.js index feeedf9..2bb089d 100644 --- a/src/views/SimproV2/CreatedProyek/DialogHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DialogHierarchy.js @@ -47,7 +47,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek setLoading(true); getdataHierarchy(); } - }, [saveHierarchy, idTask, openDialog, closeDialog, openDialogFormGantt]) + }, [idTask, openDialog, closeDialog, openDialogFormGantt]) useEffect(() => { if (!openDialog) { From a4404bc2ac77b3a5fb234dce43154484b8e29fbe Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 22 Nov 2023 16:15:10 +0700 Subject: [PATCH 2/2] dummy data --- .../Dashboard/DashboardProjectCarousell.js | 1081 +++++++++++++---- 1 file changed, 857 insertions(+), 224 deletions(-) diff --git a/src/views/Dashboard/DashboardProjectCarousell.js b/src/views/Dashboard/DashboardProjectCarousell.js index 64e9f94..e5b595c 100644 --- a/src/views/Dashboard/DashboardProjectCarousell.js +++ b/src/views/Dashboard/DashboardProjectCarousell.js @@ -104,7 +104,7 @@ const DashboardProject = (args) => { useEffect(() => { setLoading(true); - getAllData(); + getReportDistribution(); },[]); useEffect(() => { @@ -145,50 +145,6 @@ const DashboardProject = (args) => { sourceData(dataResault); setIsReadyGantt(true); setIsReadyProjectDetail(true); - // // SCurve - // let statusHealthBySchedule = "on-schedule"; - // let selisihProgress = 0; - // dataResault.map((item, idx) => { - // item.SCurve.map((itemSCurve, idx) => { - // let planningProgress = 0; - // let actualProgress = 0; - // let now = new Date().toISOString().slice(0, 10); - // let dates = itemSCurve.data?.date; - // let n = dates.findIndex( - // (element) => new Date(now) < new Date(element) - // ); - // if ( - // itemSCurve.length > 0 && - // itemSCurve.data?.percentagePlan && - // itemSCurve.data?.percentagePlan.length > 0 - // ) { - // planningProgress = itemSCurve.data?.percentagePlan[n]; - // if (n < 0) { - // planningProgress = 100; - // } - // setPlanningProgress(planningProgress); - // } - // if ( - // itemSCurve.length > 0 && - // itemSCurve.data?.percentageReal && - // itemSCurve.data?.percentageReal.length > 0 - // ) { - // actualProgress = - // itemSCurve.data?.percentageReal[ - // itemSCurve.data?.percentageReal.length - 1 - // ]; - // setActualProgress(actualProgress); - // } - // }); - // }); - - // selisihProgress = planningProgress - actualProgress; - // if (selisihProgress > 0 && selisihProgress <= 5) { - // statusHealthBySchedule = "warning"; - // } else if (selisihProgress > 5) { - // statusHealthBySchedule = "danger"; - // } - // setHealthBySchedule(statusHealthBySchedule); setIsReadySCurve(true); // setHierarchy setIsHierarchy(true); @@ -202,6 +158,39 @@ const DashboardProject = (args) => { } }; + const getReportDistribution = async () => { + const URL = `${BASE_OSPRO}/api/project/get-report-distribution`; + const payload = { + project_id: 138, + start_date: moment() + .startOf("month") + .subtract(1, "years") + .format("YYYY-MM-DD"), + end_date: moment(new Date()).subtract(1, "years").format("YYYY-MM-DD"), + }; + const result = await axios + .post(URL, payload, HEADER) + .then((res) => res) + .catch((err) => err.response); + console.log("getReportDistribution", result); + if (!result) { + NotificationManager.error(`Could not connect to internet.`, "Failed"); + return; + } + + if (result.status !== 200) { + NotificationManager.error( + `Get report distribution failed, ${result.data.message}`, + "Failed" + ); + setLoading(false); + return; + } else if (result.status == 200 && result.data.data) { + setLoading(false); + setReportDistribution(result.data.data); + } + }; + const initMap = () => { let mymap = L.map("map-area", { center: center, @@ -217,15 +206,13 @@ const DashboardProject = (args) => { useEffect(() => { if (mymap) { - reportDistribution.map((item, idx) => { - if (item.report_distribution.length > 0) { - item.report_distribution.map((itemDistribution, idx) => { - L.marker([itemDistribution.lat, itemDistribution.lon]) - .addTo(mymap) - .bindPopup(PopupContent(itemDistribution)); - }) - } - }); + if (reportDistribution.length > 0) { + reportDistribution.map((item, idx) => { + L.marker([item.lat, item.lon]) + .addTo(mymap) + .bindPopup(PopupContent(item)); + }); + } } }, [mymap, reportDistribution]); @@ -253,13 +240,13 @@ const DashboardProject = (args) => { const next = () => { if (animating) return; - const nextIndex = activeIndex === allDataMaster.length - 1 ? 0 : activeIndex + 1; + const nextIndex = activeIndex === dummyData.length - 1 ? 0 : activeIndex + 1; setActiveIndex(nextIndex); }; const previous = () => { if (animating) return; - const nextIndex = activeIndex === 0 ? allDataMaster.length - 1 : activeIndex - 1; + const nextIndex = activeIndex === 0 ? dummyData.length - 1 : activeIndex - 1; setActiveIndex(nextIndex); }; @@ -268,56 +255,756 @@ const DashboardProject = (args) => { setActiveIndex(newIndex); }; - const slides = allDataMaster.map((item, index) => { - let URL_GANTT = ""; - let version_gantt = ""; - item.project.gantt.map((itemGantt, index) => { - URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${itemGantt.gantt_id}&proyek_id=${itemGantt.proyek_id}&token=${token}&ro=1`; - version_gantt = itemGantt.name_version - }); - const today = moment(); - const assignedList = item.assigned - .filter((itemAssigned) => - today.isBetween(moment(itemAssigned.start_date), moment(itemAssigned.end_date)) - ) - .map((itemMap) => itemMap.user_id); - // SCurve - let statusHealthBySchedule = "on-schedule"; - let selisihProgress = 0; - let SetplanningProgress = 0; - let SetactualProgress = 0; - let now = new Date().toISOString().slice(0, 10); - let dates = item.SCurve[0].data?.date; - let n = dates.findIndex( - (element) => new Date(now) < new Date(element) - ); - if ( - item.SCurve[0].length > 0 && - item.SCurve[0].data?.percentagePlan && - item.SCurve[0].data?.percentagePlan.length > 0 - ) { - SetplanningProgress = item.SCurve[0].data?.percentagePlan[n]; - if (n < 0) { - SetplanningProgress = 100; - } - } - if ( - item.SCurve[0].length > 0 && - item.SCurve[0].data?.percentageReal && - item.SCurve[0].data?.percentageReal.length > 0 - ) { - SetactualProgress = - item.SCurve[0].data?.percentageReal[ - item.SCurve[0].data?.percentageReal.length - 1 - ]; + const dummyData = [ + { + "project": { + "id": 138, + "nama":"Survey Tanah Bidang", + "budget_health":"on-budget", + "schedule_health":"on-schedule", + "company": "Kementrian PUPR", + "gantt": { + "gantt_id": 896, + "name_version":"Proses Tender", + } + }, + "manpower":1, + "assigned":0, + "actual":0, + "project_manager": "FATHAN", + "activity" : { + "start_date":"-", + "end_date":"13 September 2023", + "planned_start":"-", + "planned_end":"-", + "planning":0, + "actual":0 + }, + "key":1 + }, + { + "project": { + "id": 138, + "nama":"Survey Tanah Bidang", + "budget_health":"on-budget", + "schedule_health":"on-schedule", + "company": "Kementrian PUPR", + "gantt": { + "gantt_id": 897, + "name_version":"Eksekusi", + } + }, + "manpower":1, + "assigned":0, + "actual":0, + "project_manager": "FATHAN", + "activity" : { + "start_date":"11 September 2023", + "end_date":"11 September 2023", + "planned_start":"-", + "planned_end":"-", + "planning":0, + "actual":0 + }, + "key":2 + }, + { + "project": { + "id": 138, + "nama":"Survey Tanah Bidang", + "budget_health":"on-budget", + "schedule_health":"on-schedule", + "company": "Kementrian PUPR", + "gantt": { + "gantt_id": 898, + "name_version":"Document meeting", + } + }, + "manpower":1, + "assigned":0, + "actual":0, + "project_manager": "FATHAN", + "activity" : { + "start_date":"11 September 2023", + "end_date":"11 September 2023", + "planned_start":"-", + "planned_end":"-", + "planning":0, + "actual":0 + }, + "key":3 } + ] + // const slides = allDataMaster.map((item, index) => { + // let URL_GANTT = ""; + // let version_gantt = ""; + // item.project.gantt.map((itemGantt, index) => { + // URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${itemGantt.gantt_id}&proyek_id=${itemGantt.proyek_id}&token=${token}&ro=1`; + // version_gantt = itemGantt.name_version + // }); + // const today = moment(); + // const assignedList = item.assigned + // .filter((itemAssigned) => + // today.isBetween(moment(itemAssigned.start_date), moment(itemAssigned.end_date)) + // ) + // .map((itemMap) => itemMap.user_id); + // // SCurve + // let statusHealthBySchedule = "on-schedule"; + // let selisihProgress = 0; + // let SetplanningProgress = 0; + // let SetactualProgress = 0; + // let now = new Date().toISOString().slice(0, 10); + // let dates = item.SCurve[0].data?.date; + // let n = dates.findIndex( + // (element) => new Date(now) < new Date(element) + // ); + // if ( + // item.SCurve[0].length > 0 && + // item.SCurve[0].data?.percentagePlan && + // item.SCurve[0].data?.percentagePlan.length > 0 + // ) { + // SetplanningProgress = item.SCurve[0].data?.percentagePlan[n]; + // if (n < 0) { + // SetplanningProgress = 100; + // } + // } + // if ( + // item.SCurve[0].length > 0 && + // item.SCurve[0].data?.percentageReal && + // item.SCurve[0].data?.percentageReal.length > 0 + // ) { + // SetactualProgress = + // item.SCurve[0].data?.percentageReal[ + // item.SCurve[0].data?.percentageReal.length - 1 + // ]; + // } - selisihProgress = SetplanningProgress - SetactualProgress; - if (selisihProgress > 0 && selisihProgress <= 5) { - statusHealthBySchedule = "warning"; - } else if (selisihProgress > 5) { - statusHealthBySchedule = "danger"; - } + // selisihProgress = SetplanningProgress - SetactualProgress; + // if (selisihProgress > 0 && selisihProgress <= 5) { + // statusHealthBySchedule = "warning"; + // } else if (selisihProgress > 5) { + // statusHealthBySchedule = "danger"; + // } + // return ( + // setAnimating(true)} + // onExited={() => setAnimating(false)} + // key={parseInt(item.key)}> + // + // + // + // + //
+ //
+ //
+ //
+ // Project + //
+ //
+ // {isReadyProjectDetail && + // isReadyGantt ? ( + // (() => { + // let parentNames = ""; + // if (item.hierarchy.length > 0) + // { + // for ( let i = item.hierarchy.length - 1; i >= 0; i--) { + // parentNames += " - "; + // parentNames += item.hierarchy[i].name; + // } + // } + // return item.project.nama + + // parentNames + + // " - " + + // version_gantt + // })() + // ) : ( + // + // )} + //
+ //
+ //
+ // + //
+ //
+ //
+ // + // + //
+ //
+ //
+ //
+ // Project Manager + //
+ //
+ // {isReadyProjectDetail ? ( + // item.project_manager + // ) : ( + // + // )} + //
+ //
+ //
+ // + //
+ //
+ //
+ // + // + //
+ //
+ //
+ //
+ // Customer + //
+ //
+ // {isReadyProjectDetail ? ( + // item.project.company + // ) : ( + // + // )} + //
+ //
+ //
+ // + //
+ //
+ //
+ // + //
+ // + // + //
+ //
+ //
+ //
+ // Schedule + //
+ //
+ //
+ // + // + // + // Planned Start + // + // + // {isReadyProjectDetail ? ( + // item.activity.planned_start ? ( + // moment(item.activity.planned_start).format("D MMMM YYYY") + // ) : ( + // "-" + // ) + // ) : ( + // + // )} + // + // + // + // + // + // Actual Start + // + // + // {isReadyProjectDetail ? ( + // item.activity.start_date ? ( + // moment(item.activity.start_date).format("D MMMM YYYY") + // ) : ( + // "-" + // ) + // ) : ( + // + // )} + // + // + // + // + // + // Planned Finish + // + // + // {isReadyProjectDetail ? ( + // item.activity.planned_end ? ( + // moment(item.activity.planned_end).format("D MMMM YYYY") + // ) : ( + // "-" + // ) + // ) : ( + // + // )} + // + // + // + // + // + // Estimated Finish + // + // + // {isReadyProjectDetail ? ( + // item.activity.end_date ? ( + // moment(item.activity.end_date).format("D MMMM YYYY") + // ) : ( + // "-" + // ) + // ) : ( + // + // )} + // + // + //
+ //
+ //
+ // + //
+ //
+ // + // + //
setActiveTabIdx(0)} + // > + // S Curve + //
+ // + // + //
setActiveTabIdx(1)} + // > + // Maps + //
+ // + //
+ // + // + //
+ //
+ // + //
+ // {activeTabIdx === 1 && ( + //
+ // )} + //
+ // + //
+ //
+ // + // + //
+ // + // + //
+ //
+ // Progress + //
+ // {isReadySCurve ? ( + // 100 ? 100 : SetplanningProgress} + // /> + // ) : ( + // + // )} + //
+ // {isReadySCurve ? ( + // 100 || SetactualProgress > 100 + // ? parseFloat( + // (SetactualProgress / SetplanningProgress) * 100 + // ).toFixed(0) + // : SetactualProgress + // } + // /> + // ) : ( + // + // )} + //
+ // + //
+ // + // + //
+ // {isReadyOverdueActivities && ( + // + // )} + // {isReadySCurve && ( + // + // )} + //
+ // + // + // + // + //
+ // Manpower : {item.manpower} + //
+ // + //
+ // + // + //
+ // Assigned: {item.assigned && assignedList.length} + //
+ // + // + //
+ // Actual : {item.actual} + //
+ // + //
+ // + //
+ // + // + //
+ // + // + //
setActiveTabCommentIdx(0)} + // > + // Behind Task + //
+ // + // + //
setActiveTabCommentIdx(1)} + // > + // Comment From Customer + //
+ // + //
+ //
+ // {activeTabCommentIdx === 0 && ( + //
+ // {isReadyOverdueActivities && item.overdueActivities != [] && item.overdueActivities.length > 0 ? ( + // item.overdueActivities.map((overdueItem, idx) => { + // let end_date; + // let planned_end; + // let diffDays = 0; + // let message = ""; + + // if (overdueItem.end_date && overdueItem.end_date !== null) { + // end_date = moment(overdueItem.end_date); + // planned_end = moment(overdueItem.planned_end); + // diffDays = end_date.diff(planned_end, "days"); + + // if (isNaN(diffDays)) { + // return null; + // } else { + // if (diffDays > 0) { + // message = `Overdue by ${diffDays + 1} days`; + // } else { + // return null; + // } + // } + // } + + // return ; + // }) + // ) : ( + //
+ // No overdue activity found. + //
+ // )} + //
+ // )} + // {activeTabCommentIdx === 1 &&( + //
+ // {item.project_comment && item.project_comment != [] ? ( + // item.project_comment.map((commentItem, idx) => { + + // return + // }) + // ) : ( + //
+ // No comments found. + //
+ // )} + //
+ // )} + //
+ //
+ // + //
+ //
+ // + //
+ // + //
+ // ); + // }); + const slides = dummyData.map((item, index) => { + const URL_GANTT = `http://localhost:8444/adw-gantt/view-mode/index.html?base_url=${BASE_OSPRO}/api&gantt_id=${item.project.gantt.gantt_id}&proyek_id=${item.project.id}&token=${token}&ro=1`; return ( setAnimating(true)} @@ -360,22 +1047,8 @@ const DashboardProject = (args) => { Project
- {isReadyProjectDetail && - isReadyGantt ? ( - (() => { - let parentNames = ""; - if (item.hierarchy.length > 0) - { - for ( let i = item.hierarchy.length - 1; i >= 0; i--) { - parentNames += " - "; - parentNames += item.hierarchy[i].name; - } - } - return item.project.nama + - parentNames + - " - " + - version_gantt - })() + {item.project ? ( + item.project.nama + "-" + item.project.gantt.name_version ) : ( )} @@ -424,7 +1097,7 @@ const DashboardProject = (args) => { Project Manager
- {isReadyProjectDetail ? ( + {item.project_manager ? ( item.project_manager ) : ( @@ -471,7 +1144,7 @@ const DashboardProject = (args) => { Customer
- {isReadyProjectDetail ? ( + {item.project ? ( item.project.company ) : ( @@ -527,12 +1200,8 @@ const DashboardProject = (args) => { Planned Start - {isReadyProjectDetail ? ( - item.activity.planned_start ? ( - moment(item.activity.planned_start).format("D MMMM YYYY") - ) : ( - "-" - ) + {item.activity ? ( + item.activity.planned_start ) : ( )} @@ -550,12 +1219,8 @@ const DashboardProject = (args) => { Actual Start - {isReadyProjectDetail ? ( - item.activity.start_date ? ( - moment(item.activity.start_date).format("D MMMM YYYY") - ) : ( - "-" - ) + {item.activity ? ( + item.activity.start_date ) : ( )} @@ -573,12 +1238,8 @@ const DashboardProject = (args) => { Planned Finish - {isReadyProjectDetail ? ( - item.activity.planned_end ? ( - moment(item.activity.planned_end).format("D MMMM YYYY") - ) : ( - "-" - ) + {item.activity ? ( + item.activity.planned_end ) : ( )} @@ -596,12 +1257,8 @@ const DashboardProject = (args) => { Estimated Finish - {isReadyProjectDetail ? ( - item.activity.end_date ? ( - moment(item.activity.end_date).format("D MMMM YYYY") - ) : ( - "-" - ) + {item.activity ? ( + item.activity.end_date ) : ( )} @@ -705,22 +1362,22 @@ const DashboardProject = (args) => { > Progress
- {isReadySCurve ? ( + {item.activity ? ( 100 ? 100 : SetplanningProgress} + progress={item.activity.planning > 100 ? 100 : item.activity.planning} /> ) : ( )}
- {isReadySCurve ? ( + {item.activity ? ( 100 || SetactualProgress > 100 + item.activity.planning > 100 || item.activity.actual > 100 ? parseFloat( - (SetactualProgress / SetplanningProgress) * 100 + (item.activity.actual / item.activity.planning) * 100 ).toFixed(0) - : SetactualProgress + : item.activity.actual } /> ) : ( @@ -739,11 +1396,11 @@ const DashboardProject = (args) => { marginRight: 2, }} > - {isReadyOverdueActivities && ( + {item.project.budget_health && ( )} - {isReadySCurve && ( - + {item.project.schedule_health && ( + )} @@ -782,7 +1439,7 @@ const DashboardProject = (args) => { marginRight: 2, }} > - Assigned: {item.assigned && assignedList.length} + Assigned: {item.assigned} @@ -856,74 +1513,50 @@ const DashboardProject = (args) => { className="custom-scroll" style={{ maxHeight: "37vh", overflow: "auto" }} > - {activeTabCommentIdx === 0 && ( -
- {isReadyOverdueActivities && item.overdueActivities != [] && item.overdueActivities.length > 0 ? ( - item.overdueActivities.map((overdueItem, idx) => { - let end_date; - let planned_end; - let diffDays = 0; - let message = ""; - - if (overdueItem.end_date && overdueItem.end_date !== null) { - end_date = moment(overdueItem.end_date); - planned_end = moment(overdueItem.planned_end); - diffDays = end_date.diff(planned_end, "days"); - - if (isNaN(diffDays)) { - return null; - } else { - if (diffDays > 0) { - message = `Overdue by ${diffDays + 1} days`; - } else { - return null; - } - } - } - - return ; - }) - ) : ( -
- No overdue activity found. -
- )} -
+ {activeTabCommentIdx === 0 && ( +
+ No overdue activity found. +
)} - {activeTabCommentIdx === 1 &&( -
- {item.project_comment && item.project_comment != [] ? ( - item.project_comment.map((commentItem, idx) => { - - return - }) - ) : ( -
- No comments found. -
- )} -
+ {activeTabCommentIdx === 1 && ( + <> +
+