Browse Source

Merge pull request 'Fix health by budget' (#60) from dev-wahyu into staging

Reviewed-on: ordo/adw-frontend#60
pull/2/head
ibnu 2 years ago
parent
commit
fb1566a05f
  1. 21
      src/containers/DefaultLayout/DefaultLayout.js
  2. 1
      src/routes.js
  3. 2
      src/views/Dashboard/Components/index.js
  4. 2
      src/views/Dashboard/DashboardBOD.js
  5. 21
      src/views/Dashboard/DashboardProject.js
  6. 1
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  7. 34
      src/views/SimproV2/CreatedProyek/index.js

21
src/containers/DefaultLayout/DefaultLayout.js

@ -1,5 +1,5 @@
import React, { Component, Suspense, Divider } from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import { Redirect, Route, Switch, withRouter } from 'react-router-dom';
import * as router from 'react-router-dom';
import { Button, Container, UncontrolledDropdown, DropdownItem, DropdownMenu, DropdownToggle, Nav, NavItem } from 'reactstrap';
import axios from 'axios';
@ -229,10 +229,25 @@ class DefaultLayout extends Component {
}
render() {
const { location } = this.props;
const { pathname } = location;
let renderSidebar = false
if (pathname.includes("/dashboard-project")) {
// Remove the base URL and hash
const path = pathname.replace("/dashboard-project/", "");
// Split the remaining path by "/"
const parts = path.split("/");
if (parts[2] == "1") {
renderSidebar = true
}
}
return (
<div className="app">
<div className="app-body">
{!window.location.href.includes("dashboard-project") ? (
{!window.location.href.includes("dashboard-project") || renderSidebar ? (
<AppSidebar minimized={true} fixed display="lg">
{/* <div class="sidebar-header">
<Suspense fallback={this.loading()}>
@ -302,4 +317,4 @@ class DefaultLayout extends Component {
}
}
export default DefaultLayout;
export default withRouter(DefaultLayout);

1
src/routes.js

@ -55,6 +55,7 @@ const routes = [
{ path: '/dashboard', name: 'DashboardBOD', component: DashboardBOD },
{ path: '/dashboard-customer/:PROJECT_ID/:GANTT_ID', 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 },
{ path: '/projects', exact: true, name: 'Projects', component: CreatedProyek },
{ path: '/projects/:id/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity },
{ path: '/projects/:id/:project/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity },

2
src/views/Dashboard/Components/index.js

@ -106,7 +106,7 @@ export const HealthByBudget = ({status}) => {
let bgColor = '#52AC0B'; // on-budget
if (status && status !== '-') {
if (status === 'warning') bgColor = '#ED7014';
else if (status === 'danger') bgColor = '#D0312D';
else if (status === 'overrun') bgColor = '#D0312D';
}
return (
<div style={{backgroundColor: bgColor, color: '#FFFFFF', padding: 5, borderRadius: 10, marginBottom: 10, minHeight: 25}}>

2
src/views/Dashboard/DashboardBOD.js

@ -347,7 +347,7 @@ const DashboardBOD = () => {
"invoice": item.invoice?.invoiced ? toRupiah(item.invoice.invoiced) : '-',
"cash_in": item.invoice?.paid ? toRupiah(item.invoice.paid) : '-',
"outstanding_balance": outstanding_balance,
"budget": <HealthByBudget status {...item.budget_health} />,
"budget": <HealthByBudget status={item.budget_health} />,
"schedule": <HealthBySchedule status={statusHealthBySchedule} />
})
});

21
src/views/Dashboard/DashboardProject.js

@ -39,7 +39,7 @@ const DashboardProject = () => {
"Authorization": `Bearer ${token}`
}
}
const { PROJECT_ID, GANTT_ID } = useParams();
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 [projectName, setProjectName] = useState("");
@ -505,6 +505,25 @@ const DashboardProject = () => {
}
}, [mymap, reportDistribution])
useEffect(() => {
// Add event listener for receiving messages from the iframe
window.addEventListener('message', handleIframeMessage);
// Clean up the event listener on component unmount
return () => {
window.removeEventListener('message', handleIframeMessage);
};
}, []);
const handleIframeMessage = (event) => {
if (event.data && event.data.action === 'getUrl') {
const childUrl = window.location.href;
// Send the URL back to the iframe
event.source.postMessage({ action: 'sendUrl', url: childUrl }, event.origin);
}
};
const RenderGantt = useMemo(() => (
<iframe
id="frame-gantt"

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

@ -204,6 +204,7 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
},
{ title: 'Tanggal dibuat', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) },
{ title: 'Progress', dataIndex: 'progress', key: 'progress' },
{ title: 'Bobot', dataIndex: 'bobot_planning', key: 'bobot_planning' },
];

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

@ -51,7 +51,8 @@ import {
CHECKLIST_K3_LIST,
VERSION_GANTT_SEARCH,
PHASE_PROYEK,
DIVISI_LIST
DIVISI_LIST,
BASE_OSPRO
} from "../../../const/ApiConst";
import {
formatNumber,
@ -74,7 +75,7 @@ import ViewProject from "./ViewProject";
import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp';
import { Link } from "react-router-dom";
import { Link, useHistory } from "react-router-dom";
const url = "";
const proyek_id = localStorage.getItem("proyek_id");
@ -82,6 +83,7 @@ const role_id = localStorage.getItem("role_id");
const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => {
const history = useHistory();
const token = localStorage.getItem("token");
const HEADER = {
headers: {
@ -131,6 +133,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [loadHierarchy, setLoadHierarchy] = useState(false);
const [dataVersionGantt, setDataVersionGantt] = useState([]);
const [dataHierarchy, setDataHierarchy] = useState([]);
const [dataDetail, setDataDetail] = useState(null);
const pageName = params.name;
@ -435,6 +438,27 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogViewDetail(true);
};
const getProjectDetail = async (id) => {
const URL = `${BASE_OSPRO}/api/project/detail/${id}`;
const result = await axios.get(URL, HEADER).then(res => res).catch(err => err.response)
if (!result) {
NotificationManager.error(`Could not connect to internet.`, "Failed");
return;
}
if (result.status !== 200) {
NotificationManager.error(`Get project detail failed, ${result.data.message}`, "Failed");
return;
}
else if (result.status == 200 && result.data.data) {
history.push(`/dashboard-project/${id}/${result.data.gantt.last_gantt_id}/1`);
}
}
const handleSCurve = async (data) => {
getProjectDetail(data.id)
};
const getDataProject = async (proyek_id) => {
const url = PROYEK_GET_ID(proyek_id);
const result = await axios
@ -988,6 +1012,12 @@ const CreatedProyek = ({ params, ...props }) => {
</span>
<span className="menu-text">Gantt</span>
</div>
<div className="menu-list" onClick={() => handleSCurve(text)}>
<span className="menu-icon">
<i className="fa fa-line-chart"></i>
</span>
<span className="menu-text">S Curve</span>
</div>
{/* </Link> */}
<div
className="menu-list"

Loading…
Cancel
Save