Browse Source

Adjusting s curve

pull/1/head
Wahyu Ramadhan 2 years ago
parent
commit
accb333552
  1. 19
      view-mode/function/overlaySCurve.js
  2. 18
      view-mode/function/restActivityLink.js

19
view-mode/function/overlaySCurve.js

@ -1,6 +1,7 @@
var overlayControl = gantt.ext.overlay; var overlayControl = gantt.ext.overlay;
var today = new Date(); var today = new Date();
var return_first; var return_first;
var parts = [];
var sCurvePayload = { var sCurvePayload = {
period: 'week', period: 'week',
@ -26,7 +27,7 @@ function getSCurveData(){
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 "/"
const parts = path.split("/"); parts = path.split("/");
if (parts[2] && parts[2] == "1") { if (parts[2] && parts[2] == "1") {
$.ajax({ $.ajax({
headers: { headers: {
@ -92,7 +93,8 @@ function getProgressLine(){
getSCurveData(); getSCurveData();
var cumulativePlannedDurations = return_first.data[0].data.percentagePlan; var cumulativePlannedDurations = return_first.data[0].data.percentagePlan;
var cumulativeRealDurations = return_first.data[0].data.percentageReal; var cumulativeRealDurations = return_first.data[0].data.percentageReal;
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations}; var dates = return_first.data[0].data.dates;
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates};
} }
function getScalePaddings(){ function getScalePaddings(){
@ -119,16 +121,21 @@ function getScalePaddings(){
var myChart; var myChart;
var lineOverlay = overlayControl.addOverlay(function(container) { var lineOverlay = overlayControl.addOverlay(function(container) {
var values = getProgressLine();
var scaleLabels = []; var scaleLabels = [];
if(parts[2] && parts[2] == '1'){
values.dates.forEach(function(date){
var dateScale = new Date(date);
scaleLabels.push(dateToStr(dateScale));
})
} else {
var chartScale = getChartScaleRange(); var chartScale = getChartScaleRange();
chartScale.forEach(function(date){ chartScale.forEach(function(date){
scaleLabels.push(dateToStr(date)); scaleLabels.push(dateToStr(date));
}); });
}
var values = getProgressLine();
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");
container.appendChild(canvas); container.appendChild(canvas);
@ -220,7 +227,7 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
ticks: { ticks: {
display: true, display: true,
min: 0, min: 0,
stepSize: 100, stepSize: 10,
} }
}, },
] ]

18
view-mode/function/restActivityLink.js

@ -1,3 +1,16 @@
var parts = [];
window.parent.postMessage({ action: 'getUrl' }, '*');
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/", "");
// Split the remaining path by "/"
parts = path.split("/");
}
});
gantt.ajax.get({ gantt.ajax.get({
url: `${base_url}activity/${ganttId}/${proyekId}/get`, url: `${base_url}activity/${ganttId}/${proyekId}/get`,
headers: { headers: {
@ -23,9 +36,12 @@ gantt.ajax.get({
isBaselineSet = false; isBaselineSet = false;
} }
} }
if(!parts[2]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
}); });
}
}); });
function refresData(id){ function refresData(id){
@ -43,9 +59,11 @@ function refresData(id){
data['data'] = obj.data.data; data['data'] = obj.data.data;
data['links'] = obj.data.links; data['links'] = obj.data.links;
// console.log("data parse wrong", data); // console.log("data parse wrong", data);
if(!parts[2]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
}); });
}
if(id){ if(id){
if(gantt.isTaskExists(id)){ if(gantt.isTaskExists(id)){
expandTask(); expandTask();

Loading…
Cancel
Save