Browse Source

perubahan api

pull/2/head
wahyuun 1 year ago
parent
commit
3f4f5ee201
  1. 1
      .env
  2. 967
      src/const/ApiConst.js
  3. 2458
      src/views/Dashboard/DashboardProject.js
  4. 187
      src/views/SimproV2/Gantt/index.js

1
.env

@ -1,3 +1,4 @@
PORT=3000 PORT=3000
CHOKIDAR_USEPOLLING=true CHOKIDAR_USEPOLLING=true
GENERATE_SOURCEMAP=false GENERATE_SOURCEMAP=false
SKIP_PREFLIGHT_CHECK=true

967
src/const/ApiConst.js

File diff suppressed because it is too large Load Diff

2458
src/views/Dashboard/DashboardProject.js

File diff suppressed because it is too large Load Diff

187
src/views/SimproV2/Gantt/index.js

@ -1,108 +1,119 @@
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from "react";
import Timeline from 'react-calendar-timeline' import Timeline from "react-calendar-timeline";
import 'react-calendar-timeline/lib/Timeline.css' import "react-calendar-timeline/lib/Timeline.css";
import { USER_VERSION_GANTT_SEARCH, BASE_SIMPRO_LUMEN, BASE_URL_GANTT } from '../../../const/ApiConst'; import {
import axios from "../../../const/interceptorApi" USER_VERSION_GANTT_SEARCH,
import { Fab, Action } from 'react-tiny-fab'; BASE_SIMPRO_LUMEN,
import 'react-tiny-fab/dist/styles.css'; BASE_URL_GANTT,
} from "../../../const/ApiConst";
import axios from "../../../const/interceptorApi";
import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
const token = localStorage.getItem("token") const token = localStorage.getItem("token");
const userId = parseInt(localStorage.getItem("user_id")); const userId = parseInt(localStorage.getItem("user_id"));
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": `Bearer ${token}` Authorization: `Bearer ${token}`,
} },
} };
let roCount = 0; let roCount = 0;
const Gantt = (props) => { const Gantt = (props) => {
const versionGanttId = props.match.params ? props.match.params.id : 0; const versionGanttId = props.match.params ? props.match.params.id : 0;
const idProject = props.match.params.project ? props.match.params.project : 0; const idProject = props.match.params.project ? props.match.params.project : 0;
const timestamp = props.match.params.timestamp ? props.match.params.timestamp : 0; const timestamp = props.match.params.timestamp
? props.match.params.timestamp
: 0;
const [ro, setRo] = useState(1) const [ro, setRo] = useState(1);
const [listUserGant, setListUserGantt] = useState([]) const [listUserGant, setListUserGantt] = useState([]);
const [ready, setReady] = useState(false) const [ready, setReady] = useState(false);
let history = useHistory(); let history = useHistory();
useEffect(() => { useEffect(() => {
document.getElementsByClassName("breadcrumb-item active").innerHTML = "Gantt Project"; document.getElementsByClassName("breadcrumb-item active").innerHTML =
getDataUserGantt(); "Gantt Project";
}, []); getDataUserGantt();
}, []);
useEffect(() => { useEffect(() => {
cekPermission(); cekPermission();
}, [listUserGant]) }, [listUserGant]);
useEffect(() => { useEffect(() => {}, [ro]);
}, [ro])
const getDataUserGantt = async () => { const getDataUserGantt = async () => {
const payload = { const payload = {
"columns": [ columns: [
{ "name": "version_gantt_id", "logic_operator": "=", "value": versionGanttId, "operator": "AND" } {
] name: "version_gantt_id",
} logic_operator: "=",
const result = await axios value: versionGanttId,
.post(USER_VERSION_GANTT_SEARCH, payload, HEADER) operator: "AND",
.then(res => res) },
.catch((error) => error.response); ],
};
const result = await axios
.post(USER_VERSION_GANTT_SEARCH, payload, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.status == 200) { if (result && result.status == 200) {
setUserGantt(result.data.data); setUserGantt(result.data.data);
} else { } else {
cekPermission() cekPermission();
} }
} };
const setUserGantt = (data) => { const setUserGantt = (data) => {
let newTargetKeys = [] let newTargetKeys = [];
data.map((val, index) => { data.map((val, index) => {
newTargetKeys.push(val.user_id) newTargetKeys.push(val.user_id);
}); });
setListUserGantt(newTargetKeys) setListUserGantt(newTargetKeys);
} };
const handleRedirect = () => { const handleRedirect = () => {
history.push("/dashboard-project/"+idProject+"/"+versionGanttId); history.push("/dashboard-project/" + idProject + "/" + versionGanttId);
} };
const cekPermission = () => { const cekPermission = () => {
let check = listUserGant.includes(userId) let check = listUserGant.includes(userId);
if (check) { if (check) {
setRo(0) setRo(0);
} else { } else {
setRo(1) setRo(1);
} }
if (roCount >= 1) { if (roCount >= 1) {
setReady(true) setReady(true);
} }
roCount = roCount + 1; roCount = roCount + 1;
} };
const RenderGantt = () => ( const RenderGantt = () => (
<iframe <iframe
id="frame-gantt" id="frame-gantt"
src={`https://adw-gantt.ospro.id/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}`} src={`http://localhost:8444/adw-gantt/edit-mode/index.html?base_url=${BASE_SIMPRO_LUMEN}&gantt_id=${versionGanttId}&proyek_id=${idProject}&token=${token}&ro=${ro}&timestamp=${timestamp}`}
style={{ style={{
width: '100%', width: "100%",
height: '95vh', height: "95vh",
}} }}
scrolling="no" scrolling="no"
frameBorder="0" frameBorder="0"
allow="fullscreen" allow="fullscreen"
></iframe> ></iframe>
) );
return ( return (
<> <>
<div style={{ margin: "-15px", marginBottom: "-30px" }}> <div style={{ margin: "-15px", marginBottom: "-30px" }}>
{ready && <RenderGantt />} {ready && <RenderGantt />}
</div> </div>
</> </>
); );
} };
export default Gantt; export default Gantt;

Loading…
Cancel
Save