Browse Source

perubahan api

pull/2/head
wahyuun 1 year ago
parent
commit
3f4f5ee201
  1. 7
      .env
  2. 1147
      src/const/ApiConst.js
  3. 2464
      src/views/Dashboard/DashboardProject.js
  4. 227
      src/views/SimproV2/Gantt/index.js

7
.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

1147
src/const/ApiConst.js

File diff suppressed because it is too large Load Diff

2464
src/views/Dashboard/DashboardProject.js

File diff suppressed because it is too large Load Diff

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

Loading…
Cancel
Save