Browse Source

Initial linear curve

pull/2/head
Wahyu Ramadhan 2 years ago
parent
commit
9d8f201345
  1. 21
      src/containers/DefaultLayout/DefaultLayout.js
  2. 1
      src/routes.js
  3. 21
      src/views/Dashboard/DashboardProject.js
  4. 1
      src/views/SimproV2/CreatedProyek/DialogHierarchy.js
  5. 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 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 * as router from 'react-router-dom';
import { Button, Container, UncontrolledDropdown, DropdownItem, DropdownMenu, DropdownToggle, Nav, NavItem } from 'reactstrap'; import { Button, Container, UncontrolledDropdown, DropdownItem, DropdownMenu, DropdownToggle, Nav, NavItem } from 'reactstrap';
import axios from 'axios'; import axios from 'axios';
@ -229,10 +229,25 @@ class DefaultLayout extends Component {
} }
render() { 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 ( return (
<div className="app"> <div className="app">
<div className="app-body"> <div className="app-body">
{!window.location.href.includes("dashboard-project") ? ( {!window.location.href.includes("dashboard-project") || renderSidebar ? (
<AppSidebar minimized={true} fixed display="lg"> <AppSidebar minimized={true} fixed display="lg">
{/* <div class="sidebar-header"> {/* <div class="sidebar-header">
<Suspense fallback={this.loading()}> <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', 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-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject }, { 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', exact: true, name: 'Projects', component: CreatedProyek },
{ path: '/projects/:id/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity }, { 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 }, { path: '/projects/:id/:project/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity },

21
src/views/Dashboard/DashboardProject.js

@ -39,7 +39,7 @@ const DashboardProject = () => {
"Authorization": `Bearer ${token}` "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 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 mapRef = useRef()
const [projectName, setProjectName] = useState(""); const [projectName, setProjectName] = useState("");
@ -505,6 +505,25 @@ const DashboardProject = () => {
} }
}, [mymap, reportDistribution]) }, [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(() => ( const RenderGantt = useMemo(() => (
<iframe <iframe
id="frame-gantt" 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: '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: '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, CHECKLIST_K3_LIST,
VERSION_GANTT_SEARCH, VERSION_GANTT_SEARCH,
PHASE_PROYEK, PHASE_PROYEK,
DIVISI_LIST DIVISI_LIST,
BASE_OSPRO
} from "../../../const/ApiConst"; } from "../../../const/ApiConst";
import { import {
formatNumber, formatNumber,
@ -74,7 +75,7 @@ import ViewProject from "./ViewProject";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp'; // import SubProyekComp from './SubProyekComp';
import { Link } from "react-router-dom"; import { Link, useHistory } from "react-router-dom";
const url = ""; const url = "";
const proyek_id = localStorage.getItem("proyek_id"); const proyek_id = localStorage.getItem("proyek_id");
@ -82,6 +83,7 @@ const role_id = localStorage.getItem("role_id");
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const CreatedProyek = ({ params, ...props }) => { const CreatedProyek = ({ params, ...props }) => {
const history = useHistory();
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
const HEADER = { const HEADER = {
headers: { headers: {
@ -131,6 +133,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [loadHierarchy, setLoadHierarchy] = useState(false); const [loadHierarchy, setLoadHierarchy] = useState(false);
const [dataVersionGantt, setDataVersionGantt] = useState([]); const [dataVersionGantt, setDataVersionGantt] = useState([]);
const [dataHierarchy, setDataHierarchy] = useState([]); const [dataHierarchy, setDataHierarchy] = useState([]);
const [dataDetail, setDataDetail] = useState(null);
const pageName = params.name; const pageName = params.name;
@ -435,6 +438,27 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogViewDetail(true); 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 getDataProject = async (proyek_id) => {
const url = PROYEK_GET_ID(proyek_id); const url = PROYEK_GET_ID(proyek_id);
const result = await axios const result = await axios
@ -988,6 +1012,12 @@ const CreatedProyek = ({ params, ...props }) => {
</span> </span>
<span className="menu-text">Gantt</span> <span className="menu-text">Gantt</span>
</div> </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> */} {/* </Link> */}
<div <div
className="menu-list" className="menu-list"

Loading…
Cancel
Save