From e28a399b82f75681773a5552441304c0eaed1c72 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Mon, 3 Apr 2023 16:02:22 +0700 Subject: [PATCH 1/3] Hierarchy --- .../CreatedProyek/DIalogFormHierarchy.js | 117 ++++++++++++++++++ .../SimproV2/CreatedProyek/DIalogHierarchy.js | 80 ++++++++++-- 2 files changed, 189 insertions(+), 8 deletions(-) create mode 100644 src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js diff --git a/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js b/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js new file mode 100644 index 0000000..4af59ff --- /dev/null +++ b/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js @@ -0,0 +1,117 @@ +import React, { useEffect, useState } from 'react' +import { + Modal, ModalHeader, ModalBody, ModalFooter, + Button, Form, FormGroup, Label, Input, Col, Row +} from 'reactstrap'; +import { DatePicker, Tooltip, Select } from 'antd'; +import { formatRupiah, formatNumber } from '../../../const/CustomFunc' +import moment from 'moment'; +import 'antd/dist/antd.css'; +import { useTranslation } from 'react-i18next'; + +const DialogFormHierarchy = ({ openDialog, closeDialog, toggleDialog, typeDialog, parentId, idProject }) => { + console.log('parentId', parentId); + const [id, setId] = useState(0) + const [nameDaerah, setNameDaerah] = useState('') + const [nameArea, setNameArea] = useState('') + const { t } = useTranslation(); + const handleSaveDaerah = () => { + let data = ''; + if (typeDialog === "Save") { + data = { + project_id: idProject, + name: nameDaerah, + } + console.log('data', data); + closeDialog('save', data); + } else { + data = { + id, + name: nameDaerah, + } + closeDialog('edit', data); + } + + } + const handleSaveArea = () => { + let data = ''; + if (typeDialog === "SaveArea") { + data = { + project_id: idProject, + parent_id: parentId, + name: nameArea, + } + console.log('data', data); + closeDialog('save', data); + } else { + data = { + id, + project_id: idProject, + parent_id: parentId, + name: nameArea, + } + closeDialog('edit', data); + } + + } + + const handleCancel = () => { + closeDialog('cancel', 'none') + } + const renderFormDaerah = () => { + return ( +
+ + + + + setNameDaerah(e.target.value)} placeholder={t('inputName')} /> + + + +
+ ) + } + const renderFormArea = () => { + return ( +
+ + + + + setNameArea(e.target.value)} placeholder={t('inputName')} /> + + + +
+ ) + } + return ( + <> + {typeDialog === "SaveArea" ? ( + + {typeDialog == "SaveArea" ? `Add` : "Edit"} Area + + {renderFormArea()} + + + {' '} + + + + ) : ( + + {typeDialog == "Save" ? `Add` : "Edit"} Daerah + + {renderFormDaerah()} + + + {' '} + + + + )} + + ) +} +export default DialogFormHierarchy; \ No newline at end of file diff --git a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js index 720c401..540f1de 100644 --- a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js @@ -5,11 +5,15 @@ import { Table, Tooltip } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; import SweetAlert from 'react-bootstrap-sweetalert'; -import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_SEARCH, USER_LIST } from '../../../const/ApiConst'; +import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_SEARCH, HIERARCHY_FTTH_ADD, USER_LIST } from '../../../const/ApiConst'; import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import DialogUserGantt from './DialogUserGantt'; - +import DialogForm from './DIalogFormHierarchy' +import { useTranslation } from 'react-i18next'; +import { async } from '@dabeng/react-orgchart'; +import { Link } from 'react-router-dom'; +import { use } from 'i18next'; const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { const token = localStorage.getItem("token") const HEADER = { @@ -19,6 +23,9 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek } } + const [id, setId] = useState(0) + const [parentId, setParentId] = useState(0) + const [typeDialog, setTypeDialog] = useState("add") const [openDialogForm, setOpenDialogForm] = useState(false) const [openDialogUserGantt, setOpenDialogUserGantt] = useState(false) const [dataHierarchy, setDataHierarchy] = useState([]) @@ -26,12 +33,12 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek const [idDelete, setIdDelete] = useState(0) const [idGantt, setIdGantt] = useState(0) const [humanResource, setHumanResource] = useState([]) - + const { t } = useTranslation(); useEffect(() => { if (idTask > 0) { getdataHierarchy(); } - }, [idTask, openDialog]) + }, [idTask, openDialog, closeDialog]) useEffect(() => { getDataHumanResource(); @@ -43,7 +50,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek } else { } - }, [openDialog]) + }, [openDialog, closeDialog]) const getDataHumanResource = async () => { const result = await axios @@ -70,7 +77,45 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek setHumanResource(finalData) } + const handleAdd = async () => { + await setTypeDialog("Save") + setOpenDialogForm(true) + } + const handleAddArea = async (id) => { + setParentId(id) + await setTypeDialog("SaveArea") + setOpenDialogForm(true) + } + + + const closeDialogFromHierarchy = (type, data) => { + if (type == 'save') { + saveHierarchy(data) + setId(0); + setOpenDialogForm(false); + } else { + updateHierarchy(data) + setId(0); + setOpenDialogForm(false); + } + } + + const saveHierarchy = async (data) => { + const result = await axios.post(HIERARCHY_FTTH_ADD, data, HEADER) + .then(res => res) + .catch((error) => error.response); + + if (result && result.data && result.data.code === 200) { + getdataHierarchy() + NotificationManager.success(`${result.data.message}`, 'Success!!'); + } else { + NotificationManager.error(`${result.data.message}`, 'Failed!!'); + } + } + + const updateHierarchy = async (data) => { + } const getdataHierarchy = async () => { const payload = { @@ -114,14 +159,22 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek className: "nowrap", render: (text, record) => <> - - + + + {" "} + + {" "} + + + + {" "} , }, { title: 'Nama', dataIndex: 'name', key: 'name' }, { title: 'Tanggal dibuat', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY") : "-"}
) }, + { title: 'Progress', dataIndex: '-', key: '-' }, ]; @@ -198,7 +251,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek <> -
Hierarchy Project {proyekName}
+
Hierarchy Project {proyekName}
+ + +
@@ -223,6 +279,14 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek > Delete this data + Date: Mon, 3 Apr 2023 16:13:01 +0700 Subject: [PATCH 2/3] Merge changes from master into Dev-Farhan branch --- src/const/ApiConst.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index d90b6af..f71bc15 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -463,8 +463,9 @@ export const PANIC_BUTTON_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/panic- export const HIERARCHY_FTTH_GET = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths` export const HIERARCHY_FTTH_ADD = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths` export const HIERARCHY_FTTH_SEARCH = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/search` -export const HIERARCHY_FTTH_SHOW = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`} -export const HIERARCHY_FTTH_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`} -export const HIERARCHY_FTTH_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`} +export const HIERARCHY_FTTH_SHOW = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } +export const HIERARCHY_FTTH_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } +export const HIERARCHY_FTTH_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } +export const HIERARCHY_FTTH_TREE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search` From 99d780f70fce5a8228c752a30be819efb301cc89 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Wed, 5 Apr 2023 17:01:12 +0700 Subject: [PATCH 3/3] hierarcy gantt --- src/const/ApiConst.js | 3 +- .../CreatedProyek/DIalogFormHierarchy.js | 8 +- .../SimproV2/CreatedProyek/DIalogHierarchy.js | 93 +++++++++++++------ .../SimproV2/CreatedProyek/DialogFormGantt.js | 73 ++++++++------- .../SimproV2/CreatedProyek/DialogGantt.js | 43 ++++++--- 5 files changed, 140 insertions(+), 80 deletions(-) diff --git a/src/const/ApiConst.js b/src/const/ApiConst.js index f71bc15..777c583 100644 --- a/src/const/ApiConst.js +++ b/src/const/ApiConst.js @@ -466,6 +466,5 @@ export const HIERARCHY_FTTH_SEARCH = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/searc export const HIERARCHY_FTTH_SHOW = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } export const HIERARCHY_FTTH_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } export const HIERARCHY_FTTH_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } -export const HIERARCHY_FTTH_TREE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}` } - +export const HIERARCHY_FTTH_TREE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/tree/${id}` } export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search` diff --git a/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js b/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js index 4af59ff..11296b5 100644 --- a/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DIalogFormHierarchy.js @@ -10,7 +10,6 @@ import 'antd/dist/antd.css'; import { useTranslation } from 'react-i18next'; const DialogFormHierarchy = ({ openDialog, closeDialog, toggleDialog, typeDialog, parentId, idProject }) => { - console.log('parentId', parentId); const [id, setId] = useState(0) const [nameDaerah, setNameDaerah] = useState('') const [nameArea, setNameArea] = useState('') @@ -22,7 +21,6 @@ const DialogFormHierarchy = ({ openDialog, closeDialog, toggleDialog, typeDialog project_id: idProject, name: nameDaerah, } - console.log('data', data); closeDialog('save', data); } else { data = { @@ -38,10 +36,12 @@ const DialogFormHierarchy = ({ openDialog, closeDialog, toggleDialog, typeDialog if (typeDialog === "SaveArea") { data = { project_id: idProject, - parent_id: parentId, name: nameArea, } - console.log('data', data); + + if (parentId && parentId > 0) { + data['parent_id'] = parentId + } closeDialog('save', data); } else { data = { diff --git a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js index 540f1de..27a43b9 100644 --- a/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js +++ b/src/views/SimproV2/CreatedProyek/DIalogHierarchy.js @@ -1,15 +1,16 @@ import React, { useEffect, useState, useMemo } from 'react' import { Modal, ModalHeader, ModalBody, } from 'reactstrap'; import { Button } from 'reactstrap'; -import { Table, Tooltip } from 'antd'; +import { Space, Table, Tooltip } from 'antd'; import 'antd/dist/antd.css'; import moment from 'moment'; import SweetAlert from 'react-bootstrap-sweetalert'; -import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_SEARCH, HIERARCHY_FTTH_ADD, USER_LIST } from '../../../const/ApiConst'; +import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_TREE, VERSION_GANTT_SEARCH, HIERARCHY_FTTH_ADD, USER_LIST } from '../../../const/ApiConst'; import axios from "../../../const/interceptorApi" import { NotificationContainer, NotificationManager } from 'react-notifications'; import DialogUserGantt from './DialogUserGantt'; import DialogForm from './DIalogFormHierarchy' +import DialogFormGantt from './DialogFormGantt'; import { useTranslation } from 'react-i18next'; import { async } from '@dabeng/react-orgchart'; import { Link } from 'react-router-dom'; @@ -25,8 +26,10 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek const [id, setId] = useState(0) const [parentId, setParentId] = useState(0) + const [dataGantt, setDataGantt] = useState([]) const [typeDialog, setTypeDialog] = useState("add") const [openDialogForm, setOpenDialogForm] = useState(false) + const [openDialogFormGantt, setOpenDialogFormGantt] = useState(false) const [openDialogUserGantt, setOpenDialogUserGantt] = useState(false) const [dataHierarchy, setDataHierarchy] = useState([]) const [alertDelete, setAlertDelete] = useState(false) @@ -81,23 +84,39 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek await setTypeDialog("Save") setOpenDialogForm(true) } - const handleAddArea = async (id) => { + const handleAddWithParent = async (id) => { setParentId(id) await setTypeDialog("SaveArea") setOpenDialogForm(true) } + const handleAddGant = (id) => { + + setParentId(id) + setOpenDialogFormGantt(true) + } + + const toggleDialogFormGantt = () => { + setOpenDialogFormGantt(!openDialogFormGantt) + } + + const closeDialogFromGantt = (status) => { + if (status == "success") { + NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!'); + } else if (status == "failed") { + NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!'); + } + setOpenDialogFormGantt(false) + } const closeDialogFromHierarchy = (type, data) => { if (type == 'save') { saveHierarchy(data) - setId(0); - setOpenDialogForm(false); } else { updateHierarchy(data) - setId(0); - setOpenDialogForm(false); } + setId(0); + setOpenDialogForm(false); } const saveHierarchy = async (data) => { @@ -116,15 +135,17 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek const updateHierarchy = async (data) => { } + + const getdataHierarchy = async () => { const payload = { - "columns": [ - { "name": "project_id", "logic_operator": "=", "value": idTask, "operator": "AND" } - ] + "columns": [{ "name": "project_id", "logic_operator": "=", "value": idTask, "operator": "AND" }], + "joins": [{ "name": "m_version_gantt", "column_join": "hierarchy_ftth_id", "column_results": "progress" }], } + const url = HIERARCHY_FTTH_TREE(idTask) const result = await axios - .post(HIERARCHY_FTTH_SEARCH, payload, HEADER) + .get(url, HEADER) .then(res => res) .catch((error) => error.response); @@ -162,31 +183,47 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek {" "} - - + + {" "} - - - - {" "} + + + , }, - { title: 'Nama', dataIndex: 'name', key: 'name' }, + { + title: 'Nama', dataIndex: 'name', key: 'name' + }, { title: 'Tanggal dibuat', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY") : "-"}
) }, - { title: 'Progress', dataIndex: '-', key: '-' }, + { title: 'Progress', dataIndex: 'progress', key: 'progress' }, ]; return ( { + if (Array.isArray(record.dataGantt)) { + return record.dataGantt.map((data) => ( + + +

{data.name_version}

+
+ + )); + } else { + return null; // or some default content if dataGantt is not an array + } + }, + }} + rowKey="id" dataSource={dataHierarchy} pagination={{ position: ["bottomLeft"] }} /> - ) + ); }, [dataHierarchy]) const cancelDelete = () => { @@ -212,10 +249,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek } } - const handleOpenDialogForm = () => { - setOpenDialogForm(true) - } - const toggleDialogForm = () => { setOpenDialogForm(!openDialogForm) } @@ -279,6 +312,14 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek > Delete this data + + + { +const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask, parentId }) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -18,7 +18,7 @@ const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask }) => { const [name, setName] = useState("") const [description, setDesctription] = useState("") const [calculationType, setCalculationType] = useState("detail") - + console.log('parentId', parentId); const handleCLearData = () => { setId(0) setName("") @@ -34,23 +34,26 @@ const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask }) => { handleCLearData() } - const saveVersionGantt= async () => { + const saveVersionGantt = async () => { const formData = { - name_version:name, - description, - calculation_type: calculationType, - proyek_id:idTask + name_version: name, + description, + calculation_type: calculationType, + proyek_id: idTask, + id_hierarcy_ftth: parentId + } + console.log('formData', formData); const result = await axios .post(VERSION_GANTT_ADD, formData, HEADER) .then(res => res) .catch((error) => error.response); - if(result && result.status==200){ + if (result && result.status == 200) { closeDialog('success') - }else{ + } else { closeDialog('failed') } } @@ -64,35 +67,35 @@ const DialogFormGantt = ({ openDialog, closeDialog, toggleDialog, idTask }) => { return (
- - setName(e.target.value)} placeholder='' /> + + setName(e.target.value)} placeholder='' /> + + + + setDesctription(e.target.value)} placeholder='' /> - - setDesctription(e.target.value)} placeholder='' /> + +
+ setCalculationType(v)} - options={[ - { - value: 'detail', - label: 'Detail', - }, - { - value: 'simple', - label: 'Simple', - }, - ]} - /> -
-
Notes: diff --git a/src/views/SimproV2/CreatedProyek/DialogGantt.js b/src/views/SimproV2/CreatedProyek/DialogGantt.js index 9c76af6..97628ad 100644 --- a/src/views/SimproV2/CreatedProyek/DialogGantt.js +++ b/src/views/SimproV2/CreatedProyek/DialogGantt.js @@ -13,7 +13,7 @@ import DialogUserGantt from './DialogUserGantt'; import { Link } from 'react-router-dom'; -const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => { +const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, hierarchyId }) => { const token = localStorage.getItem("token") const HEADER = { headers: { @@ -34,7 +34,10 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName if (idTask > 0) { getdataGantt(); } - }, [idTask, openDialog]) + if (hierarchyId > 0) { + getdataGantt(); + } + }, [hierarchyId, idTask, openDialog]) useEffect(() => { getDataHumanResource(); @@ -75,11 +78,19 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName const getdataGantt = async () => { - - const payload = { - "columns": [ - { "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" } - ] + let payload; + if (hierarchyId) { + payload = { + "columns": [ + { "name": "hierarchy_ftth_id", "logic_operator": "=", "value": hierarchyId, "operator": "AND" } + ] + } + } else { + payload = { + "columns": [ + { "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" } + ] + } } const result = await axios .post(VERSION_GANTT_SEARCH, payload, HEADER) @@ -118,21 +129,22 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName render: (text, record) => <> - + {" "} - + {" "} {" "} + + {" "} + - + {" "} , @@ -141,6 +153,7 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName { title: 'Tipe kalkulasi', dataIndex: 'calculation_type', key: 'calculation_type' }, { title: 'Deskripsi', dataIndex: 'description', key: 'description' }, { title: 'Tanggal dibuat', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (
{text ? moment(text).format("D-M-YYYY") : "-"}
) }, + { title: 'Progress', dataIndex: 'progress', key: 'progress' } ]; @@ -217,7 +230,11 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName <> -
Gantt Project {proyekName}
+ + +
Gantt Project {proyekName}
{!hierarchyId && (<> + + )}