|
|
@ -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') { |
|
|
|
|
|
|
|
const parentUrl = event.data.url; |
|
|
|
|
|
|
|
|
|
|
|
// Send a message to the parent window requesting the URL
|
|
|
|
// Remove the base URL and hash
|
|
|
|
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
|
|
|
|
|
|
|
|
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() { |
|
|
@ -118,28 +118,30 @@ function getProgressLine(){ |
|
|
|
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates}; |
|
|
|
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getScalePaddings(){ |
|
|
|
function getScalePaddings(values){ |
|
|
|
var scale = gantt.getScale(); |
|
|
|
var scale = gantt.getScale(); |
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
let minDate = new Date(); |
|
|
|
// let minDate = new Date();
|
|
|
|
let maxDate = new Date(); |
|
|
|
// let maxDate = new Date();
|
|
|
|
|
|
|
|
let minValueDate = new Date(values.dates[0]); |
|
|
|
|
|
|
|
let maxValueDate = new Date(values.dates[values.dates.length -1]); |
|
|
|
|
|
|
|
|
|
|
|
gantt.eachTask(function(task){ |
|
|
|
// gantt.eachTask(function(task){
|
|
|
|
let plannedEarlier = task.planned_start < task.start_date; |
|
|
|
// let plannedEarlier = task.planned_start < task.start_date;
|
|
|
|
let plannedLater = task.planned_end > task.end_date; |
|
|
|
// let plannedLater = task.planned_end > task.end_date;
|
|
|
|
|
|
|
|
|
|
|
|
if (plannedEarlier) { |
|
|
|
// if (plannedEarlier) {
|
|
|
|
minDate = new Date(Math.min(minDate.getTime(), task.planned_start.getTime())); |
|
|
|
// minDate = new Date(Math.min(minDate.getTime(), task.planned_start.getTime()));
|
|
|
|
} else { |
|
|
|
// } else {
|
|
|
|
minDate = new Date(Math.min(minDate.getTime(), task.start_date.getTime())); |
|
|
|
// minDate = new Date(Math.min(minDate.getTime(), task.start_date.getTime()));
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (plannedLater) { |
|
|
|
// if (plannedLater) {
|
|
|
|
maxDate = new Date(Math.max(maxDate.getTime(), task.planned_end.getTime())); |
|
|
|
// maxDate = new Date(Math.max(maxDate.getTime(), task.planned_end.getTime()));
|
|
|
|
} else { |
|
|
|
// } else {
|
|
|
|
maxDate = new Date(Math.max(maxDate.getTime(), task.end_date.getTime())); |
|
|
|
// maxDate = new Date(Math.max(maxDate.getTime(), task.end_date.getTime()));
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
var padding = { |
|
|
|
var padding = { |
|
|
|
left:0, |
|
|
|
left:0, |
|
|
@ -149,8 +151,8 @@ function getScalePaddings(){ |
|
|
|
if(dataRange.start_date){ |
|
|
|
if(dataRange.start_date){ |
|
|
|
var yScaleLabelsWidth = 48; |
|
|
|
var yScaleLabelsWidth = 48; |
|
|
|
// fine tune values in order to align chart with the scale range
|
|
|
|
// fine tune values in order to align chart with the scale range
|
|
|
|
padding.left = gantt.posFromDate(minDate) - yScaleLabelsWidth; |
|
|
|
padding.left = gantt.posFromDate(minValueDate); |
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxDate) - yScaleLabelsWidth; |
|
|
|
padding.right = scale.full_width - gantt.posFromDate(maxValueDate); |
|
|
|
padding.top = gantt.config.row_height - 12; |
|
|
|
padding.top = gantt.config.row_height - 12; |
|
|
|
padding.bottom = gantt.config.row_height - 12; |
|
|
|
padding.bottom = gantt.config.row_height - 12; |
|
|
|
} |
|
|
|
} |
|
|
@ -213,13 +215,13 @@ var lineOverlay = overlayControl.addOverlay(function(container) { |
|
|
|
responsive: true, |
|
|
|
responsive: true, |
|
|
|
maintainAspectRatio: false, |
|
|
|
maintainAspectRatio: false, |
|
|
|
layout: { |
|
|
|
layout: { |
|
|
|
padding: getScalePaddings() |
|
|
|
padding: getScalePaddings(values) |
|
|
|
}, |
|
|
|
}, |
|
|
|
onResize: function(chart, newSize) { |
|
|
|
onResize: function(chart, newSize) { |
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
var dataRange = gantt.getSubtaskDates(); |
|
|
|
if(dataRange.start_date){ |
|
|
|
if(dataRange.start_date){ |
|
|
|
// align chart with the scale range
|
|
|
|
// align chart with the scale range
|
|
|
|
chart.options.layout.padding = getScalePaddings(); |
|
|
|
chart.options.layout.padding = getScalePaddings(values); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
legend: { |
|
|
|
legend: { |
|
|
|