Browse Source

Fix cumulative request

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
6e6606ec59
  1. 98
      view-mode/function/overlaySCurve.js

98
view-mode/function/overlaySCurve.js

@ -13,59 +13,59 @@ function callback(response) {
return_first = response; return_first = response;
} }
function getSCurveData(){ function messageListener(event) {
if (event.data && event.data.action === 'sendUrl') {
// Send a message to the parent window requesting the URL const parentUrl = event.data.url;
window.parent.postMessage({ action: 'getUrl' }, '*');
// Listen for messages from the parent window
window.addEventListener('message', function(event) {
if (event.data && event.data.action === 'sendUrl') {
const parentUrl = event.data.url;
// Remove the base URL and hash // Remove the base URL and hash
const path = parentUrl.replace("https://adw.ospro.id/#/dashboard-project/", ""); const path = parentUrl.replace("https://adw.ospro.id/#/dashboard-project/", "");
// Split the remaining path by "/" // Split the remaining path by "/"
parts = path.split("/"); parts = path.split("/");
if (parts[2] && parts[2] == "1") { if (parts[2] && parts[2] == "1") {
$.ajax({ $.ajax({
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": `Bearer ${token}` "Authorization": `Bearer ${token}`
}, },
url: `${base_url}project/calculate-s-curve`, url: `${base_url}project/calculate-s-curve`,
type: "POST", type: "POST",
data:JSON.stringify(sCurvePayload), data: JSON.stringify(sCurvePayload),
success: function (data) { success: function (data) {
callback(data) callback(data)
} window.removeEventListener('message', messageListener);
}); }
$.ajax({ });
headers: { $.ajax({
"Content-Type": "application/json", headers: {
"Authorization": `Bearer ${token}` "Content-Type": "application/json",
}, "Authorization": `Bearer ${token}`
url: `${base_url}project/s-curve-command`, },
type: "POST", url: `${base_url}project/s-curve-command`,
data:JSON.stringify(sCurvePayload), type: "POST",
}); data: JSON.stringify(sCurvePayload),
} else { });
$.ajax({ } else {
headers: { $.ajax({
"Content-Type": "application/json", headers: {
"Authorization": `Bearer ${token}` "Content-Type": "application/json",
}, "Authorization": `Bearer ${token}`
url: `${base_url}project/get-s-curve`, },
type: "POST", url: `${base_url}project/get-s-curve`,
data:JSON.stringify(sCurvePayload), type: "POST",
success: function (data) { data: JSON.stringify(sCurvePayload),
callback(data) success: function (data) {
} callback(data)
}); window.removeEventListener('message', messageListener);
} }
} });
}); }
}
}
function getSCurveData() {
window.parent.postMessage({ action: 'getUrl' }, '*');
window.addEventListener('message', messageListener);
}; };
function toggleOverlay() { function toggleOverlay() {

Loading…
Cancel
Save