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