Browse Source

remove unused codes

pull/2/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
39a2b533d7
  1. 487
      src/views/DashboardSimpro/index.js
  2. 6852
      src/views/Map/Map_16.js
  3. 414
      src/views/Report/ControlMonitoring/index.js

487
src/views/DashboardSimpro/index.js

@ -20,18 +20,18 @@ import { Pagination, Tooltip, Tree, List, Checkbox } from 'antd';
import { getChildrenTree, formatRupiah, DATE_TIME_FORMAT } from '../../const/CustomFunc.js';
import { projectTreeConst } from '../../const/LayerTreeConst.js';
import {
Card, Modal, ModalHeader, ModalBody, ModalFooter, Button,
CardBody, CardHeader, Col, Dropdown, DropdownItem, DropdownMenu, DropdownToggle, Row
Card, Modal, ModalHeader, ModalBody, ModalFooter, Button,
CardBody, CardHeader, Col, Dropdown, DropdownItem, DropdownMenu, DropdownToggle, Row
} from 'reactstrap';
import {
DONE_COLOR, IZIN_COLOR, NOT_YET_COLOR,
PRESENT_COLOR, TOTAL_COLOR,
RED_COLOR,
ORANGE_COLOR,
GREEN_COLOR,
DARK_GREY_COLOR,
BLUE_COLOR,
PURPLE_COLOR
DONE_COLOR, IZIN_COLOR, NOT_YET_COLOR,
PRESENT_COLOR, TOTAL_COLOR,
RED_COLOR,
ORANGE_COLOR,
GREEN_COLOR,
DARK_GREY_COLOR,
BLUE_COLOR,
PURPLE_COLOR
} from '../../const/AppConst.js';
const id_org = window.localStorage.getItem('id_org');
const roleName = window.localStorage.getItem('role_name');
@ -40,268 +40,269 @@ Chart.plugins.register(ChartDataLabels);
const { RangePicker } = DatePicker;
let menu = [
{
"id": 3,
"title": "PANIC BUTTON",
"key": "absent",
"color": IZIN_COLOR
},
{
"id": 4,
"title": "WASPANG ACTIVE",
"key": "karyawan telat",
"color": GREEN_COLOR
},
{
"id": 5,
"title": "WASPANG ABSENT",
"key": "karyawan tanpa keterangan",
"color": ORANGE_COLOR
}
{
"id": 3,
"title": "PANIC BUTTON",
"key": "absent",
"color": IZIN_COLOR
},
{
"id": 4,
"title": "WASPANG ACTIVE",
"key": "karyawan telat",
"color": GREEN_COLOR
},
{
"id": 5,
"title": "WASPANG ABSENT",
"key": "karyawan tanpa keterangan",
"color": ORANGE_COLOR
}
]
const defaultPersentaseProyek = {
labels: [],
datasets: [
{
label: 'Progress',
data: [],
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
labels: [],
datasets: [
{
label: 'Progress',
data: [],
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
const defaultCostProyek = {
labels: [],
datasets: [
{
label: 'Perencanaan',
data: [],
fill: false,
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgba(255, 99, 132, 0.2)',
yAxisID: 'y-axis-1',
},
{
label: 'Realisasi',
data: [],
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
labels: [],
datasets: [
{
label: 'Perencanaan',
data: [],
fill: false,
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgba(255, 99, 132, 0.2)',
yAxisID: 'y-axis-1',
},
{
label: 'Realisasi',
data: [],
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
const defaultStatusProyek = {
labels: ['Aman', 'Alert', 'Critical'],
datasets: [
{
label: '# of Votes',
data: [],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(255, 99, 132, 1)',
],
borderWidth: 1,
},
],
labels: ['Aman', 'Alert', 'Critical'],
datasets: [
{
label: '# of Votes',
data: [],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(255, 99, 132, 1)',
],
borderWidth: 1,
},
],
};
const DashboardSimpro = () => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [openPlanRealisasi, setopenPlanRealisasi] = useState(false);
const [openCostPlanRealisasi, setopenCostPlanRealisasi] = useState(false);
const [dataChart, setDataChart] = useState([]);
const [projectTree, setProjectTree] = useState([]);
const [allProyek, setAllProyek] = useState(true);
const [dataStatusProyek, setDataStatusProyek] = useState(null);
const [dataPersentaseProyek, setDataPersentaseProyek] = useState(null);
const [dataCostProyek, setdataCostProyek] = useState(null);
const [projectTreeVisible, setProjectTreeVisible] = useState(false);
const [checkedKeysProjectTree, setCheckedKeysProjectTree] = useState([]);
const [openModalTable, setOpenModalTable] = useState(false);
const [dataDashboard, setDataDashboard] = useState(null);
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [openPlanRealisasi, setopenPlanRealisasi] = useState(false);
const [openCostPlanRealisasi, setopenCostPlanRealisasi] = useState(false);
const [dataChart, setDataChart] = useState([]);
const [projectTree, setProjectTree] = useState([]);
const [allProyek, setAllProyek] = useState(true);
const [dataStatusProyek, setDataStatusProyek] = useState(null);
const [dataPersentaseProyek, setDataPersentaseProyek] = useState(null);
const [dataCostProyek, setdataCostProyek] = useState(null);
const [projectTreeVisible, setProjectTreeVisible] = useState(false);
const [checkedKeysProjectTree, setCheckedKeysProjectTree] = useState([]);
const [openModalTable, setOpenModalTable] = useState(false);
const [dataDashboard, setDataDashboard] = useState(null);
const handleGetDataDashboard = async () => {
const URL = `${BASE_SIMPRO}/dashboard-proyek/search`
const payload = {
"columns": [
{ "name": "created_at", "logic_operator": "range", "value": "2021-11-06 00:00:00", "value1": "2021-11-06 23:59:59", "operator": "AND" }
],
"paging": { "start": 0, "length": -1 }
}
const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response)
if (result.data.code === 200) {
setDataDashboard(result.data.data);
} else {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
const handleGetDataDashboard = async () => {
const URL = `${BASE_SIMPRO}/dashboard-proyek/search`
const payload = {
"columns": [
{ "name": "created_at", "logic_operator": "range", "value": "2021-11-06 00:00:00", "value1": "2021-11-06 23:59:59", "operator": "AND" }
],
"paging": { "start": 0, "length": -1 }
}
const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response)
}
if (result.data.code !== 200) {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
const handleGetDataDashboardChart = async () => {
const URL = `${BASE_SIMPRO}/dashboard-status/search`
let str = ''
checkedKeysProjectTree.map((res, idx) => {
if (idx == 0) str += `${res}`
if (idx != 0) str += `,${res}`
})
const payload = {
"columns": [
{ "name": "id", "logic_operator": "in", "value": str ? str : "0", "operator": "AND" }
],
"orders": { "columns": ["nama"], "ascending": true }
}
const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response)
if (result.data.code === 200) {
setDataDashboard(result.data.data);
}
const { persentase_progress, progress_cost_planning, progress_cost_realisasi, status_proyek } = result.data.data
const handleGetDataDashboardChart = async () => {
const URL = `${BASE_SIMPRO}/dashboard-status/search`
let str = ''
const labelPersentaseProyek = persentase_progress ? persentase_progress.map(res => res.label) : []
const valuePersentaseProyek = persentase_progress ? persentase_progress.map(res => res.total) : []
const persentaseProyek = {
labels: labelPersentaseProyek,
datasets: [
{
label: 'Progress',
data: valuePersentaseProyek,
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
setDataPersentaseProyek(persentaseProyek)
const labelCostPlaning = progress_cost_planning ? progress_cost_planning.map(res => res.label) : []
const valueCostPlaning = progress_cost_planning ? progress_cost_planning.map(res => res.total) : []
const valueCostRealisasi = progress_cost_realisasi ? progress_cost_realisasi.map(res => res.total) : []
checkedKeysProjectTree.map((res, idx) => {
if (idx == 0) str += `${res}`
if (idx != 0) str += `,${res}`
})
const costProyek = {
labels: labelCostPlaning,
datasets: [
{
label: 'Perencanaan',
data: valueCostPlaning,
fill: false,
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgba(255, 99, 132, 0.2)',
yAxisID: 'y-axis-1',
},
{
label: 'Realisasi',
data: valueCostRealisasi,
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
setdataCostProyek(costProyek)
const payload = {
"columns": [
{ "name": "id", "logic_operator": "in", "value": str ? str : "0", "operator": "AND" }
],
"orders": { "columns": ["nama"], "ascending": true }
}
const valueStatusProyek = status_proyek ? status_proyek.map(res => res.total) : []
const result = await axios.post(URL, payload, HEADER).then(res => res).catch(err => err.response)
const statusProyek = {
labels: ['Aman', 'Alert', 'Critical'],
datasets: [
{
label: '# of Votes',
data: valueStatusProyek,
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(255, 99, 132, 1)',
],
borderWidth: 1,
},
],
};
if (result.data.code !== 200) {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
setDataStatusProyek(statusProyek)
const { persentase_progress, progress_cost_planning, progress_cost_realisasi, status_proyek } = result.data.data
const labelPersentaseProyek = persentase_progress ? persentase_progress.map(res => res.label) : []
const valuePersentaseProyek = persentase_progress ? persentase_progress.map(res => res.total) : []
const persentaseProyek = {
labels: labelPersentaseProyek,
datasets: [
{
label: 'Progress',
data: valuePersentaseProyek,
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
setDataPersentaseProyek(persentaseProyek)
const labelCostPlaning = progress_cost_planning ? progress_cost_planning.map(res => res.label) : []
const valueCostPlaning = progress_cost_planning ? progress_cost_planning.map(res => res.total) : []
const valueCostRealisasi = progress_cost_realisasi ? progress_cost_realisasi.map(res => res.total) : []
} else {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
const costProyek = {
labels: labelCostPlaning,
datasets: [
{
label: 'Perencanaan',
data: valueCostPlaning,
fill: false,
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgba(255, 99, 132, 0.2)',
yAxisID: 'y-axis-1',
},
{
label: 'Realisasi',
data: valueCostRealisasi,
fill: false,
backgroundColor: 'rgb(54, 162, 235)',
borderColor: 'rgba(54, 162, 235, 0.2)',
yAxisID: 'y-axis-1',
},
],
};
setdataCostProyek(costProyek)
}
const valueStatusProyek = status_proyek ? status_proyek.map(res => res.total) : []
const getProyek = async () => {
const URL = `${BASE_SIMPRO}/proyek/list?start=0&length=-1&orderby=nama&asc=true`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
if (result.data.code === 200) {
setProjectTree(result.data.data);
const arr = result.data.data.map(res => res.id)
setCheckedKeysProjectTree(arr)
} else {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
}
const statusProyek = {
labels: ['Aman', 'Alert', 'Critical'],
datasets: [
{
label: '# of Votes',
data: valueStatusProyek,
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(255, 99, 132, 0.2)',
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(255, 99, 132, 1)',
],
borderWidth: 1,
},
],
};
const renderDailyInfo = () => {
return (
<>
<div className="daily-info-card" style={{ backgroundColor: IZIN_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.panic_button : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>PANIC BUTTON</p>
</div>
<div className="daily-info-card" style={{ backgroundColor: GREEN_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.waspang_status.presensi : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>WASPANG ACTIVE</p>
</div>
<div className="daily-info-card" style={{ backgroundColor: ORANGE_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.waspang_status.absensi : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>WASPANG ABSENT</p>
</div>
</>
)
}
setDataStatusProyek(statusProyek)
const handleClickChart = param => {
if (!param.length) return;
const { _datasetIndex, _index } = param[0];
const data = dataPersentaseProyek.datasets[_datasetIndex].label
setOpenModalTable(true)
}
const handleClickProyek = id => {
const arr = [...checkedKeysProjectTree]
const idx = arr.indexOf(id)
if (idx == -1) {
arr.push(id)
} else {
arr.splice(idx, 1)
}
setCheckedKeysProjectTree(arr)
}
}
return (
<>
<SiopasMap />
</>
const getProyek = async () => {
const URL = `${BASE_SIMPRO}/proyek/list?start=0&length=-1&orderby=nama&asc=true`
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
if (result.data.code !== 200) {
NotificationManager.error('Gaga Menambah Data!!', 'Failed');
}
setProjectTree(result.data.data);
const arr = result.data.data.map(res => res.id)
setCheckedKeysProjectTree(arr)
}
);
const renderDailyInfo = () => {
return (
<>
<div className="daily-info-card" style={{ backgroundColor: IZIN_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.panic_button : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>PANIC BUTTON</p>
</div>
<div className="daily-info-card" style={{ backgroundColor: GREEN_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.waspang_status.presensi : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>WASPANG ACTIVE</p>
</div>
<div className="daily-info-card" style={{ backgroundColor: ORANGE_COLOR, cursor: 'pointer' }} >
<p className="number-style1">{dataDashboard ? dataDashboard.waspang_status.absensi : 0}</p>
<p style={{ color: "#FFFFFF", fontWeight: "bold" }}>WASPANG ABSENT</p>
</div>
</>
)
}
const handleClickChart = param => {
if (!param.length) return;
const { _datasetIndex, _index } = param[0];
const data = dataPersentaseProyek.datasets[_datasetIndex].label
setOpenModalTable(true)
}
const handleClickProyek = id => {
const arr = [...checkedKeysProjectTree]
const idx = arr.indexOf(id)
if (idx == -1) {
arr.push(id)
} else {
arr.splice(idx, 1)
}
setCheckedKeysProjectTree(arr)
}
return (
<>
<SiopasMap />
</>
);
}
export default DashboardSimpro;

6852
src/views/Map/Map_16.js

File diff suppressed because it is too large Load Diff

414
src/views/Report/ControlMonitoring/index.js

@ -1,32 +1,56 @@
import '../../../assets/css/customscroll.css'
import './ControlMonitoring.css'
import * as XLSX from 'xlsx';
import ContentLoader from "react-content-loader"
import DialogEdit from './DialogEdit';
import DialogForm from './DialogForm';
import DialogUpdateProgress from './DialogUpdateProgress';
import DialogView from './DialogView';
import React, { Component } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup, UncontrolledAccordion, UncontrolledCollapse } from 'reactstrap';
import { Button } from 'reactstrap';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import data from '@iconify/icons-ion/save-outline';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import DialogEdit from './DialogEdit';
import { Button } from 'reactstrap';
import { CONTROL_MONITORING_SEARCH, PLANNING_SEARCH, PROYEK_SEARCH, PROYEK_EDIT } from '../../../const/ApiConst.js';
import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup, UncontrolledAccordion, UncontrolledCollapse } from 'reactstrap';
import { DatePicker, Badge } from 'antd';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Tree } from 'antd';
import { DatePicker, Badge } from 'antd';
import * as XLSX from 'xlsx';
import { CONTROL_MONITORING_SEARCH, PLANNING_SEARCH, PROYEK_SEARCH, PROYEK_EDIT } from '../../../const/ApiConst.js';
import DialogView from './DialogView';
import DialogUpdateProgress from './DialogUpdateProgress';
import { formatNumber } from '../../../const/CustomFunc.js';
import { getChildrenTree, formatRupiah, DATE_TIME_FORMAT } from '../../../const/CustomFunc.js';
import { projectTreeConst } from '../../../const/LayerTreeConst.js';
import ContentLoader from "react-content-loader"
import { formatNumber } from '../../../const/CustomFunc.js';
import {
RED_COLOR,
ORANGE_COLOR,
GREEN_COLOR
} from '../../../const/AppConst'
import '../../../assets/css/customscroll.css'
import './ControlMonitoring.css'
import data from '@iconify/icons-ion/save-outline';
const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
}
};
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const column = [
{ name: "No" },
{ name: "Nama Activity" },
{ name: "UOM" },
{ name: "Activity Mulai" },
{ name: "Activity Selesai" },
{ name: "Jumlah Report"},
{ name: "Lihat" },
]
const LENGTH_DATA = 10
/*
Logic Control Monitoring:
@ -35,7 +59,6 @@ ada variable
- projectTree
- checkedProjectTree
- dataTable (filteran dari tanggal)
-
1. ambil proyek_id yang ada id projectTree yang tercentang saja
2. kalau ada yg sama, maka satu saja yg tercentang (dibikin unique proyek_id)
@ -88,77 +111,48 @@ ada variable
]
*/
const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization : `Bearer ${token}`,
"Content-type" : `application/json`
}
};
const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id');
const column = [
{ name: "No" },
// { name: "Proyek" },
{ name: "Nama Activity" },
{ name: "UOM" },
{ name: "Activity Mulai" },
{ name: "Activity Selesai" },
{ name: "Jumlah Report"},
{ name: "Lihat" },
]
const LENGTH_DATA = 10
export default class index extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
dataExport: [],
openDialog: false,
openDialogEdit:false,
typeDialog: 'Save',
dataEdit: null,
activityName: "",
alertDelete: false,
idDelete: 0,
checkedKeysProjectTree: [],
choosenSubProyekId:[],
chosenProyekIds: [],
controlMonitoringData: [],
currentDay: 'today',
currentPage: 1,
dataEdit: null,
dataExport: [],
dataGs: [],
dataIdHo: [],
search: "",
dataMap:"",
dataRealisasi: [],
dataTable: [],
dataUpdateProgress: null,
endDate:moment(moment().format("YYYY-M-D")),
idDelete: 0,
idPlanning:0,
listReport:[],
openDialog: false,
openDialogEdit:false,
openDialogPlan: false,
openDialogUpdateProgress: false,
page: 0,
projectTree: [],
projectTreeVisible: false,
rowsPerPage: LENGTH_DATA,
currentPage: 1,
totalPage: 0,
tooltipMap: false,
tooltipDelete: false,
typeClock: "All",
search: "",
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentDay: 'today',
dataMap:"",
tooltipDelete: false,
tooltipExport:false,
openDialogPlan: false,
dataRealisasi: [],
projectTreeVisible: false,
projectTree: [],
checkedKeysProjectTree: [],
openDialogUpdateProgress: false,
chosenProyekIds: [], // buat di samping kanan (setelah dicentang dari tree dan difilter dari tanggal)
choosenSubProyekId:[],
controlMonitoringData: [],
listReport:[],
activityName: "",
dataUpdateProgress: null,
idPlanning:0
tooltipMap: false,
totalPage: 0,
typeClock: "All",
typeDialog: 'Save',
}
// this.updateProgress = this.updateProgress.bind(this);
this.chosenProyekTemp = [];
this.choosenSubProyekTemp = [];
}
@ -202,12 +196,6 @@ export default class index extends Component {
if(proyekIds.length < 1){
proyekIds.push(0);
}
// {
// "name": "created_at",
// "logic_operator": "range",
// "value": dateStart,
// "value1": dateEnd
// }
let dateStart = moment(this.state.startDate).format("YYYY-MM-DD 00:00:00");
let dateEnd = moment(this.state.endDate).format("YYYY-MM-DD 23:59:59");
@ -241,32 +229,11 @@ export default class index extends Component {
}
}
// if(parseInt(role_id)!==1){
// formData.columns.push(
// {
// "name": "id",
// "logic_operator": "=",
// "value": proyek_id,
// "operator": "AND",
// "table_name": "m_proyek"
// }
// )
// }
// console.log("cek choosenSubProyekId", this.state.chosenProyekIds.join())
// if (this.state.choosenSubProyekId.length > 0) {
// formData.columns.push({
// "name": "subproyek_id",
// "logic_operator": "in",
// "value": this.state.choosenSubProyekId.join(),
// "operator": "AND"
// })
// }
const result = await axios
.post(CONTROL_MONITORING_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code==200){
console.log("cek data res", result.data.data)
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }, () => this.buildProyekView() );
@ -283,30 +250,13 @@ export default class index extends Component {
"orders": { "columns": ["id"], "ascending": false }
}
// if(parseInt(localStorage.getItem('role_id'))!==1){
// payload.columns.push(
// {
// "name": "id",
// "logic_operator": "=",
// "value": localStorage.getItem('proyek_id') ? localStorage.getItem('proyek_id') : '0',
// "operator": "AND"
// }
// )
// }
const config = {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
// mode: 'cors', // no-cors, *cors, same-origin
// cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
// credentials: 'same-origin', // include, *same-origin, omit
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+window.localStorage.getItem('token')
// 'Content-Type': 'application/x-www-form-urlencoded',
},
// redirect: 'follow', // manual, *follow, error
// referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify(payload) // body data type must match "Content-Type" header
body: JSON.stringify(payload)
}
const result = await fetch(PROYEK_SEARCH, config).then(response => response.json()).then(res => res);
@ -314,7 +264,6 @@ export default class index extends Component {
if (result && result.code == 200) {
let children = getChildrenTree(result.data);
projectTreeConst[0].children = children;
// console.log('projectTreeConst', projectTreeConst);
this.setState({projectTree: projectTreeConst, projectTreeVisible: true});
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
@ -326,11 +275,9 @@ export default class index extends Component {
}
handleOpenDialogPlan = (param, name) => {
// console.log("cek cek list report", param)
this.setState({listReport:param, activityName: name}, () => {
this.setState({openDialogPlan: true})
})
// await this.setState({idPlanning: param})
}
toggleAddDialogPlan = () => {
@ -350,8 +297,6 @@ export default class index extends Component {
this.setState({ openDialogUpdateProgress: true })
this.showDialogUpdateProgress();
}
}
handleCloseDialog = () => {
@ -455,7 +400,6 @@ export default class index extends Component {
"column_results": [
"nama",
"biaya",
// "color_progress",
"jumlah_pekerja",
"pic",
"mulai_proyek",
@ -498,19 +442,7 @@ export default class index extends Component {
"length": -1
}
}
// if(parseInt(role_id)!==1){
// payload.columns.push(
// {
// "name": "id",
// "logic_operator": "=",
// "value": proyek_id,
// "operator": "AND",
// "table_name": "m_proyek"
// }
// )
// }
// console.log("cek choosenSubProyekId", this.state.choosenSubProyekId)
if (this.state.choosenSubProyekId.length > 0) {
payload.columns.push({
"name": "subproyek_id",
@ -519,25 +451,15 @@ export default class index extends Component {
"operator": "AND"
})
}
const result = await axios
.post(CONTROL_MONITORING_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
let resData = result.data.data;
const excelData = [];
// <td>{index + 1}</td>
// <td>{ n.join ? n.join.m_proyek_nama : "-" }</td>
// <td>{ n.nama ? n.nama : "-"}</td>
// <td>{ n.jumlah_titik ? n.jumlah_titik : "0" }</td>
// <td>{ n.realisasi ? this.renderActual(n.realisasi) : "0" }</td>
// <td>{ n.join.m_subproyek_pic ? `${n.join.m_subproyek_pic}` : "-" }</td>
// <td>{ n.join.m_users_name ? `${n.join.m_users_name}` : "-" }</td>
// <td>{ n.target_planning ? moment(n.target_planning).format("DD-MM-YYYY") : "-" }</td>
resData.map((n, index) => {
let dataRow = {
"Proyek": n.join ? n.join.m_proyek_nama : "-",
@ -549,12 +471,10 @@ export default class index extends Component {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
this.setState({dataExport:excelData})
// exportExcel();
}else{
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
}
exportExcel = () => {
@ -580,7 +500,6 @@ export default class index extends Component {
.post(url, formData)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data){
if (result.data.code_status == 200) {
NotificationManager.success('Berhasil update status response!!', 'Success!');
@ -605,32 +524,18 @@ export default class index extends Component {
}
renderTable = (realisasi) => {
// const dataTable2 = this.state.dataTable || [];
return (
<tbody>
{realisasi.length!==0 ? realisasi.map((n, index) => {
// console.log("real real real", n)
return (
<tr key={index}>
<td>{index + 1}</td>
{/* <td>{ n.join ? n.join.m_proyek_nama : "-" }</td> */}
<td>{ n.name ? n.name : "-"}</td>
{/* <td>{ n.jumlah_pekerja ? jumlah_pekerja : "0" }</td> */}
<td>{ n.uom ? n.uom : "-" }</td>
<td>{ n.start_date ? `${ moment(n.start_date).format("DD-MM-YYYY") }` : "-" }</td>
<td>{ n.end_date ? `${ moment(n.end_date).format("DD-MM-YYYY") }` : "-" }</td>
<td>{ n.list_report ? n.list_report.length : 0 }</td>
<td>{ n.start_date ? `${ moment(n.start_date).format("DD-MM-YYYY") }` : "-" }</td>
<td>{ n.end_date ? `${ moment(n.end_date).format("DD-MM-YYYY") }` : "-" }</td>
<td>{ n.list_report ? n.list_report.length : 0 }</td>
<td>
{/* <i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => this.handleDelete(n.id)}></i>
<Tooltip placement="right" isOpen={this.state.tooltipDelete} target="TooltipDelete" toggle={() => this.toggle("delete")}>
Delete
</Tooltip>*/}
{/* <i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(n)}></i>
<Tooltip placement="right" isOpen={this.state.tooltipEdit} target="TooltipEdit" toggle={() => this.toggle("edit")}>
Edit
</Tooltip>
{' '} */}
<Tooltip title="Lihat Report List">
<i onClick={() => this.handleOpenDialogPlan(n.list_report ? n.list_report : [], n.name)} id="tooltipMap" className="fa fa-eye fa-lg" style={{ color: 'black', cursor: "pointer" }}></i>
</Tooltip>
@ -640,7 +545,7 @@ export default class index extends Component {
}) : <tr>
<td colSpan="9" align="center">No Data Available</td>
</tr>
}
}
</tbody>
)
}
@ -649,46 +554,36 @@ export default class index extends Component {
const val = e.target.value;
this.setState({ currentDay:val });
if(val==="today"){
// console.log("test 1 test",val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="3 day"){
// console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="7 day"){
// console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else{
// console.log("test 2 test",val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}
}
// when checking chekbox on Layer Tree Panel
onCheckOpt = (state, checkedKeys) => {
this.setState({[state]: checkedKeys});
}
// updateProgress = (item) => {
// console.log('update progress', item);
// this.setState({dataUpdateProgress: item, openDialogUpdateProgress: true});
// }
getChosenProyekRealisasi = () => {
const { chosenProyek, projectTree, checkedKeysProjectTree } = this.state;
@ -697,14 +592,12 @@ export default class index extends Component {
let chosenProyekId = [];
if (checkedKeysProjectTree.length > 0) {
chosenProyekId = this.getChosenProyekId(); // ini yang sudah diambil uniquenya
chosenProyekId = this.getChosenProyekId();
}
else {
chosenProyekId = []
}
// console.log('choosenSubProyekTemp', this.choosenSubProyekTemp);
// this.setState({choosenSubProyekId: this.choosenSubProyekTemp});
this.setState({chosenProyekIds: chosenProyekId});
}
@ -717,7 +610,6 @@ export default class index extends Component {
// ambil unique nya aja lalu return uniquenya
getChosenProyekId = () => {
const { checkedKeysProjectTree, projectTree } = this.state;
// console.log('checkedKeysProjectTree', checkedKeysProjectTree);
if (checkedKeysProjectTree.length > 0) {
if (checkedKeysProjectTree.includes('project-0')) {
// langsung ambil semua children di level pertama
@ -726,105 +618,26 @@ export default class index extends Component {
}
}
else {
// for (let i=0; i < projectTree[0].children.length; i++) {
this.getChosenProyekIdByKey(projectTree[0].children);
// }
}
}
// usage example:
// var myArray = ['a', 1, 'a', 2, '1'];
// var unique = myArray.filter((v, i, a) => a.indexOf(v) === i);
let unique = this.chosenProyekTemp.filter((v, i, a) => a.indexOf(v) === i);
// console.log("cek unique", unique)
return unique;
}
getChosenProyekIdByKey = (dataTree) => {
const { checkedKeysProjectTree } = this.state;
// console.log("dataTree", dataTree)
for (let i=0; i < dataTree.length; i++) {
if (checkedKeysProjectTree.includes(dataTree[i].key)) {
console.log('matched!!!', dataTree[i].id);
this.chosenProyekTemp.push(dataTree[i].id);
// get the proyek_id, then stop
// if (dataTree[i].parent_id === undefined) {
// this.chosenProyekTemp.push(dataTree[i].id) // ambil idnya, karena dia adalah level paling atas (proyek)
// this.getSubProyeksFromProyek(dataTree[i]);
// }
// else if (dataTree[i].parent_id !== undefined && dataTree[i].parent_id === null) { // dia adalah subproyek pertama
// this.chosenProyekTemp.push(dataTree[i].proyek_id);
// this.choosenSubProyekTemp.push(dataTree[i].id); // ambil proyek_id
// }
// else if (dataTree[i].parent_id !== undefined && dataTree[i].parent_id !== null) { // dia adalah subproyek kedua, dst
// this.chosenProyekTemp.push(dataTree[i].proyek_id);
// this.choosenSubProyekTemp.push(dataTree[i].id); // ambil proyek_id
// }
}
// else {
// console.log('not matched, keep looping!', dataTree[i]);
// keep looping until get the matched key
// if (dataTree[i].subproyeks) {
// this.getChosenProyekIdByKey(dataTree[i].children);
// }
// }
}
}
// get subproyeks_id
// getSubProyeksFromProyek = (dataProyek) => {
// console.log("dataProyek getSubProyeksFromProyek", dataProyek)
// if(dataProyek.children){
// dataProyek.children.map((val, index) => {
// if(val.children){
// this.getSubProyeksFromProyek(val.children)
// }else{
// this.choosenSubProyekTemp.push(val.id);
// }
// });
// }else{
// this.choosenSubProyekTemp.push(dataProyek.id);
// }
// }
// loopForSubProyekId = (dataSubproyek) => {
// }
// proses menampilkan proyek yg terselect dan data realisasinya
buildProyekView = () => {
const {dataTable} = this.state;
// let finalData = [];
// console.log("projectTree build view", projectTree)
// ambil object project yg terseleksi dan masukin ke controlMonitoringData
// if (chosenProyekIds.length > 0) {
// for (let i=0; i < chosenProyekIds.length; i++) {
// if (projectTree && projectTree.length > 0) {
// let found = projectTree[0].children.find((item) => item.id === chosenProyekIds[i]);
// // remove children and subproyeks object
// // if (found.children) delete found.children;
// // if (found.subproyeks) delete found.subproyeks;
// // add key realisasi
// if (found) {
// found.realisasi = [];
// finalData.push(found);
// }
// }
// }
// console.log("dataTable build view", dataTable)
// plot response planning-realisasi api dan masukin ke controlMonitoringData
// if (dataTable.length > 0) {
// for (let i=0; i < dataTable.length; i++) {
// let foundProyekIndex = finalData.findIndex((item) => item.id === dataTable[i].proyek_id);
// finalData[foundProyekIndex].realisasi.push(dataTable[i]);
// }
// }
// }
// else {
// finalData = [];
// }
// console.log('finalData', finalData);
this.setState({controlMonitoringData: dataTable});
}
@ -899,7 +712,6 @@ export default class index extends Component {
<Row style={{paddingTop:'10%'}}>
<Col md={9}>
<div>
{/* <Button color="success" size="sm" onClick={() => this.handleUpdateProgress(item)} disabled={parseInt(localStorage.getItem('role_id'))!==1 ? true : false}>Update</Button> */}
</div>
</Col>
<Col md={3}>
@ -935,9 +747,7 @@ export default class index extends Component {
pageSizeOptions={["10", "15", "20", "25", "30", "35", "40"]}
/>
</UncontrolledCollapse>
<hr style={{marginTop: 50}} />
</div>
)
})
@ -962,18 +772,11 @@ export default class index extends Component {
sendUpdateProgress = async (data) => {
let urlEdit = PROYEK_EDIT(data.id)
const formData = data
const result = await axios.put(urlEdit, formData, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
NotificationManager.success(`Data proyek berhasil diupdate`, 'Success!!');
// this.setState({controlMonitoringData: []}, () => {
// this.getLayerTreeData();
// this.getDataReportPlanning();
// this.renderControlMonitoringData();
// })
window.location.reload(); // solusi sementara, soalnya pas rebuilding tree pada missing key karena keynya random
} else {
NotificationManager.error(`Data proyek gagal diupdate`, `Failed!!`);
@ -986,19 +789,6 @@ export default class index extends Component {
return (
<div>
<NotificationContainer />
{/* <SweetAlert
show={this.state.alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data tipe karyawan akan terhapus!!
</SweetAlert> */}
<DialogForm
openDialog={openDialog}
closeDialog={this.handleCloseDialog}
@ -1017,31 +807,10 @@ export default class index extends Component {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>Control & Monitoring</h4>
<div>
{/* <Button color="primary" onClick={() => this.handleOpenDialog('Save')}>Tambah Broadcast</Button>{' '} */}
{/* <Tooltip title="Export Excel">
<Button id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> */}
</div>
</CardHeader>
<CardBody>
{/* <div style={{ display: "flex", justifyContent: "space-between", marginBottom:"25px" }}>
<div style={{ width:"100%",display:"inline-flex",alignItems:"center" }}>
<div style={{ width:"50%",marginRight:"10px",maxWidth:"200px" }}>
<Input type="select" onChange={(e) => this.handleChangeDay(e)} defaultValue={this.state.currentDay}>
<option value="today">Hari Ini</option>
<option value="3 day">3 Hari yang lalu</option>
<option value="7 day">7 Hari yang lalu</option>
</Input>
</div>
<div style={{ width:"50%" }}>
<RangePicker size="default" allowClear={false} value={[this.state.startDate, this.state.endDate]} onChange={this.handleDatePicker}/>{' '}
<Button color="primary" onClick={() => this.getDataReportPlanning()}>Cari</Button>
</div>
</div>
<Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari Nama Pekerjaan" style={{ maxWidth: "200px", marginBottom: "20px" }} />
</div> */}
<Row style={{marginBottom: 15}}>
{/* <Col md={12}>Breadcrumbs of proyek here...</Col> */}
</Row>
<Row>
<Col md={projectTreeVisible? 3 : 1}>
@ -1070,10 +839,10 @@ export default class index extends Component {
<option value="7 day">7 Hari yang lalu</option>
</Input>
</div>
<RangePicker
size="default"
allowClear={false}
value={[this.state.startDate, this.state.endDate]}
<RangePicker
size="default"
allowClear={false}
value={[this.state.startDate, this.state.endDate]}
onChange={this.handleDatePicker}
/>
<hr style={{marginVertical: 15}} />
@ -1088,7 +857,7 @@ export default class index extends Component {
style={{marginLeft: -10}}
/>
:
<ContentLoader
<ContentLoader
speed={2}
width="100%"
height={150}
@ -1098,11 +867,11 @@ export default class index extends Component {
style={{marginLeft: 24, marginTop: -25}}
>
<rect x="4" y="13" rx="3" ry="3" width="25" height="25" />
<rect x="45" y="17" rx="5" ry="5" width="290" height="16" />
<rect x="45" y="17" rx="5" ry="5" width="290" height="16" />
<rect x="45" y="50" rx="3" ry="3" width="25" height="25" />
<rect x="80" y="54" rx="5" ry="5" width="251" height="16" />
<rect x="45" y="90" rx="3" ry="3" width="25" height="25" />
<rect x="80" y="94" rx="5" ry="5" width="251" height="16" />
<rect x="80" y="94" rx="5" ry="5" width="251" height="16" />
<rect x="45" y="130" rx="3" ry="3" width="25" height="25" />
<rect x="80" y="134" rx="5" ry="5" width="251" height="16" />
</ContentLoader>
@ -1129,7 +898,6 @@ export default class index extends Component {
toggleDialog={() => this.toggleAddDialogPlan()}
listReport={this.state.listReport}
activityName={this.state.activityName}
// nameProyekParent={nameProyek}
/>
<DialogUpdateProgress
openDialog={this.state.openDialogUpdateProgress}

Loading…
Cancel
Save