Browse Source

optimize load time

pull/1/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
b56037d61d
  1. 18
      src/function/ganttConfig.js
  2. 30
      src/function/restActivityLink.js

18
src/function/ganttConfig.js

@ -639,6 +639,24 @@ for (var i = 0; i < radios.length; i++) {
};
}
// end Zoom Scale function
//
//
// GANTT PERFORMANCE CONFIG RECOMMENDATION
gantt.config.scales = [
{unit: "month", step: 1, format: "%F, %Y"},
{unit: "week", step: 1, format: function (date) {
return "Week #" + gantt.date.getWeek(date);
}},
{unit: "day", step: 1, format: "%D", css: function(date) {
if(!gantt.isWorkTime({ date: date, unit: "day"})){
return "weekend"
}
}}
];
gantt.config.show_task_cells = false;
gantt.config.static_background = true;
gantt.config.branch_loading = true;
gantt.config.smart_scales = true;
// gantt initialization
$(document).ready(function () {

30
src/function/restActivityLink.js

@ -23,7 +23,9 @@ gantt.ajax.get({
isBaselineSet = false;
}
}
gantt.parse(data);
gantt.silent(function () {
gantt.parse(data);
});
});
function refresData(id){
@ -34,18 +36,20 @@ function refresData(id){
"Authorization": `Bearer ${token}`
}
}).then(function (xhr) {
gantt.clearAll();
gantt.clearAll();
let data = {};
let response = xhr.responseText;
let obj = JSON.parse(response);
data['data'] = obj.data.data;
data['links'] = obj.data.links;
// console.log("data parse wrong", data);
gantt.parse(data);
gantt.silent(function () {
gantt.parse(data);
});
if(id){
if(gantt.isTaskExists(id)){
expandTask();
}
}
}
});
}
@ -54,10 +58,10 @@ function refresData(id){
// action - "create"|"update"|"delete"
// data - an object with task or link data
// id – the id of a processed object (task or link)
var dp = gantt.createDataProcessor(function(entity, action, data, id) {
var dp = gantt.createDataProcessor(function(entity, action, data, id) {
switch(action) {
case "create":
if(entity=="task"){
data['proyek_id'] = proyekId;
data['start_date'] = `${data.start_date}+07`;
@ -71,7 +75,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
}
data['version_gantt_id'] = ganttId;
return gantt.ajax.post({
headers: {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
@ -95,7 +99,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
data['end_date'] = moment(data.end_date).format("YYYY-MM-DD HH:mm:ss+07");
// data['planned_start'] = moment(data.planned_start).format("YYYY-MM-DD HH:mm:ss+07");
// data['planned_end'] = moment(data.planned_end).format("YYYY-MM-DD HH:mm:ss+07");
if(data && data.parent){
data['parent_id'] = data.parent;
}
@ -110,7 +114,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
// let dataProgress = parseInt(data.progress)
// dataProgress = dataProgress/100
return gantt.ajax.put({
headers: {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
@ -136,7 +140,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
// if(data.rencana_biaya != resData.rencana_biaya){
// // gantt.getTask(id).bobot_planning = resData.bobot_planning;
// // gantt.updateTask(id);
// }else{
// if(parent && parent > 0){
// updateActivity(parent);
@ -150,7 +154,7 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
case "delete":
// console.log("cek data", data)
return gantt.ajax.del({
headers: {
headers: {
"Authorization": `Bearer ${token}`
},
url: base_url + entity + "/" + id
@ -174,9 +178,9 @@ var dp = gantt.createDataProcessor(function(entity, action, data, id) {
// let res = response.responseText
// res = JSON.parse(res)
// console.log("cek response", res)
// refresData();
});
break;
}
});
});

Loading…
Cancel
Save