Changeset 13733 for branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts
- Timestamp:
- 03/24/16 17:19:13 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/Graphs/GraphDataCollector.js
r13719 r13733 1 1 var dataCollection = []; 2 3 function initSaveData(id, coll) {//initial data save 4 var temp = dataConversion(coll); 2 var taskStatus = { 3 "Offline": "bar-off", 4 "Waiting": "bar-wait", 5 "Transferring": "bar-trans", 6 "Calculating": "bar-calc", 7 "Paused": "bar-paus", 8 "Finished": "bar-fin", 9 "Aborted": "bar-abo", 10 "Failed": "bar-fail" 11 } 12 13 function initSaveData(id, coll, name) {//initial data save 14 var temp = dataConversion(coll, name); 5 15 temp.unshift(id); //add ID in front of array 6 16 dataCollection.push(temp);// [id,timearr, piearr] 7 console.log("#CREATION: " + id); 8 } 9 function saveData(id, coll) { 10 var temp = dataConversion(coll); 11 for (var i = 0; i < dataCollection.length; i++) { 12 if (dataCollection[i][0] == id) { 13 dataCollection[i][1] = temp[0]; 14 dataCollection[i][2] = temp[1]; 17 // console.log("#CREATION: " + id); 18 } 19 function saveData(id, coll, name) { 20 var temp = dataConversion(coll, name); 21 for (var i = 0; i < dataCollection.length; i++) { 22 if (dataCollection[i][0] == id) { 23 dataCollection[i][1] = temp[0]; // [data,layout] 24 dataCollection[i][2] = temp[1]; // data 25 dataCollection[i][3] = temp[2]; // [tasks, name] 15 26 } 16 27 } … … 31 42 } 32 43 } 33 34 } 35 function dataConversion(coll) { 36 37 38 return [dataConversionLine(coll),dataConversionPie(coll)]; 39 } 40 function dataConversionLine(coll) { 44 } 45 function getDataGantt(id) { 46 for (var i = 0; i < dataCollection.length; i++) { 47 if (dataCollection[i][0] == id) { 48 return dataCollection[i][3]; 49 } 50 } 51 } 52 function dataConversion(coll, name) { 53 var line = dataConversionLine(coll, name); 54 var pie = dataConversionPie(coll); 55 var gantt = dataConversionGantt(coll, name); 56 return [line, pie, gantt]; 57 } 58 function dataConversionGantt(coll, nam) { 59 var tasks = []; 60 for (var v = 0; v < coll.length; v++) { 61 62 var temp = {}; 63 temp.startDate = Date.parse(coll[v].DateTime); 64 if (v < coll.length - 1) 65 temp.endDate = Date.parse(coll[v + 1].DateTime); 66 else { 67 68 var dat = Date.parse(coll[v].DateTime); 69 //console.log(dat); 70 temp.endDate = dat + 600000; 71 temp.last = true; 72 } 73 temp.taskName = nam; 74 75 if (coll[v].State == 0) 76 temp.status = "Offline"; 77 else if (coll[v].State == 1) 78 temp.status = "Waiting"; 79 else if (coll[v].State == 2) 80 temp.status = "Transferring"; 81 else if (coll[v].State == 3) 82 temp.status = "Calculating"; 83 else if (coll[v].State == 4) 84 temp.status = "Paused"; 85 else if (coll[v].State == 5) 86 temp.status = "Finished"; 87 else if (coll[v].State == 6) 88 temp.status = "Aborted"; 89 else if (coll[v].State == 7) 90 temp.status = "Failed"; 91 tasks.push(temp); 92 } 93 return [tasks, nam]; 94 } 95 function dataConversionLine(coll, nam) { 41 96 var xarr = []; 42 97 var yarr = []; 98 43 99 for (var v = 0; v < coll.length; v++) { 100 44 101 xarr.push(Date.parse(coll[v].DateTime)); 102 // console.log(xarr[v]); 103 // xarr[v] = xarr[v] - 3600000; 45 104 if (coll[v].State == 1) 46 105 yarr.push("Waiting"); 47 else if (coll[v].State == 2) 106 else if (coll[v].State == 2) 48 107 yarr.push("Transferring"); 49 else if (coll[v].State == 3) 108 else if (coll[v].State == 3) 50 109 yarr.push("Calculating"); 51 110 else if (coll[v].State == 5) … … 54 113 yarr.push("Failed"); 55 114 } 115 116 56 117 var data = [{//Time graph 57 118 x: xarr, … … 59 120 type: 'scatter', 60 121 mode: 'lines', 61 name: 'Task ',62 connectgaps: true,63 line: {shape:'hv'}122 name: nam, 123 connectgaps: true, 124 line: { shape: 'hvh' } 64 125 }]; 65 layout = {126 layout = { 66 127 "showlegend": true, 67 128 "width": "100%", 68 129 "xaxis": { 69 "autorange": true, 130 "autorange": true, 70 131 "range": [ 71 Date.parse(coll[0].DateTime), 72 Date.parse(coll[coll.length - 1].DateTime)73 ], 74 "title": "Time", 132 Date.parse(coll[0].DateTime), 133 Date.parse(coll[coll.length - 1].DateTime) 134 ], 135 "title": "Time", 75 136 "type": "date" 76 137 } 77 138 78 139 } 79 80 return [data,layout]; 81 } 82 function dataConversionHBar(coll) { 83 var xarr = []; 84 var yarr = []; 85 for (var v = 0; v < coll.length; v++) { 86 xarr.push(coll[v].DateTime.substr(11, 8)); 87 if (coll[v].State == 1) 88 yarr.push("Waiting"); 89 else if (coll[v].State == 2) 90 yarr.push("Transferring"); 91 else if (coll[v].State == 3) 92 yarr.push("Calculating"); 93 else if (coll[v].State == 5) 94 yarr.push("Finished"); 95 else if (coll[v].State == 7) 96 yarr.push("Failed"); 97 } 98 var data = [{//Time graph 99 x: xarr, 100 y: yarr, 101 type: 'scatter' 102 }]; 103 104 return data; 105 } 140 141 return [data, layout]; 142 } 143 106 144 function dataConversionPie(coll) { 107 145 var waiting = 0; 108 146 var transfer = 0; 109 147 var calc = 0; 110 for (var v = 0; v < coll.length -1; v++) {111 if (coll[v].State == 1)148 for (var v = 0; v < coll.length - 1; v++) { 149 if (coll[v].State == 1) 112 150 waiting += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime); 113 else if (coll[v].State == 2) 151 else if (coll[v].State == 2) 114 152 transfer += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime); 115 else if (coll[v].State == 3) 153 else if (coll[v].State == 3) 116 154 calc += Date.parse(coll[v + 1].DateTime) - Date.parse(coll[v].DateTime); 117 155 } … … 133 171 document.getElementById("graph" + val).style.width = "100%"; 134 172 document.getElementById("graph" + val).style.height = "400px"; 173 document.getElementById("graph" + val).innerHTML = ""; 174 document.getElementById("graph" + val).style.marginLeft = "0px"; 135 175 if (document.getElementById("graphtoggle" + val).checked) { 136 176 setTimeout(function () { 177 178 var temp = getDataGantt(val); 179 var w = $("#graph" + val).parent().width() - 30; 180 document.getElementById("graph" + val).style.height = "200px"; 181 var gantt = d3.gantt().selector('#graph' + val).height('200').width(w).margin({ 182 top: 20, 183 right: 40, 184 bottom: 20, 185 left: 20 186 }).drawytitles(false).taskTypes([temp[1]]).taskStatus(taskStatus); 187 // document.getElementById("graph" + val).style.marginLeft = "-40px"; 188 gantt(temp[0]); 189 }, 100); 190 191 192 /* setTimeout(function () { 137 193 Plotly.newPlot('graph' + val, getData(val)[0], getData(val)[1]); 138 }, 100); 139 console.log("#REDRAWN LINE: " + val);194 }, 100);*/ 195 // console.log("#REDRAWN LINE: " + val); 140 196 } else { 141 197 setTimeout(function () { … … 144 200 //console.log("#REDRAWN PIE: " + val); 145 201 } 146 202 147 203 148 204 } 149 205 function redrawMain() { 206 document.getElementById("graphMain").innerHTML = ""; 207 208 var tempdata = []; 209 var tempnames = []; 210 for (var i = 0; i < dataCollection.length; i++) { 211 var t = dataCollection[i][3][0].slice(); 212 var name = t[0].taskName.substring(0, 5) + " | " + i + ":"; 213 214 for (var v = 0; v < t.length; v++) { 215 t[v].taskName = name; 216 } 217 tempdata = tempdata.concat(t); 218 tempnames = tempnames.concat(name) 219 } 220 var h = (tempnames.length * 20) + 100; 221 document.getElementById("graphMain").style.height = h + "px"; 222 223 var w = $("#graphMain").parent().width() - 100; 224 225 var gantt = d3.gantt().selector("#graphMain").height(h - 50).width(w).taskTypes(tempnames).taskStatus(taskStatus); 226 document.getElementById("graphMain").style.marginLeft = "20px"; 227 gantt(tempdata); 228 /* LINE VERSION 150 229 var temp = []; 151 230 var min = dataCollection[0][1][0][0].x[0]; … … 173 252 } 174 253 Plotly.newPlot('graphMain', temp, layout); 175 176 177 } 254 */ 255 256 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/Graphs/GraphHubber.js
r13719 r13733 5 5 $.connection.hub.start().done(function () { 6 6 hubber.server.initConnection(); 7 hubber.server.updateAll();7 // hubber.server.updateAll(); 8 8 redrawMain(); 9 9 }); 10 hubber.client.processData = function (id, data ) {10 hubber.client.processData = function (id, data, name) { 11 11 var obj = JSON.parse(data); 12 12 13 editTaskData(id, obj); 13 saveData(id, obj.StateLog); 14 //console.log(name); 15 saveData(id, obj.StateLog, name); 16 console.log("#UPDATED " + id); 17 } 18 hubber.client.processJobData = function (calc, fin) { 19 editJobData(calc, fin); 14 20 } 15 21 hubber.client.requestDone = function () { 16 17 setTimeout(function () { 18 hubber.server.updateAll(); 19 console.log("#REFRESH ALL"); 20 21 }, 5000); 22 if (document.getElementById("refreshtogg").checked) { 23 setTimeout(function () { 24 hubber.server.updateAll(); 25 console.log("#REFRESH ALL"); 26 27 }, 5000); 28 } 22 29 } 23 30 //hubber.c 24 31 }) 25 32 33 function autoRefresh() { 34 if (document.getElementById("refreshtogg").checked) 35 hubber.server.updateAll(); 36 37 } 38 function restart(id) { 39 document.getElementById("restarterbtn" + id).disabled = true; 40 document.getElementById("restarterbtn" + id).value = "Sending restart request..."; 41 hubber.server.restartTask(id); 42 } 43 function editJobData(c, f) { 44 $("#jobcalculating").html("Calculating: " + c); 45 $("#jobfinished").html("Finished: " + f); 46 } 47 26 48 function editTaskData(id, task) { 27 49 //lastupdate 28 var dat = new Date(task.LastHeartbeat); 29 $("#lastupdpar" + id).html("Last update: " + dat.toUTCString()); 50 if (task.LastHeartbeat != null) { 51 var dat = new Date(task.LastHeartbeat); 52 $("#lastupdpar" + id).html("Last update: " + dat.toUTCString()); 53 } 54 else 55 $("#lastupdpar" + id).html("No updates yet"); 56 //task restarter 57 document.getElementById("restarter" + id).style.display = "none"; 30 58 //state 31 if (task.State == "1") { 59 if (task.State == "0") { 60 $("#statepar" + id).css({ 61 'color': 'gray', 62 'font-weight': 'normal' 63 }); 64 $("#statepar" + id).html("State: Offline"); 65 } 66 else if (task.State == "1") { 32 67 $("#statepar" + id).css({ 33 68 'color': 'white', … … 39 74 $("#statepar" + id).css({ 40 75 'color': 'white', 41 'font-weight': 'normal' 76 'font-weight': 'normal', 77 'text-shadow': '2px 2px black' 42 78 }); 43 79 $("#statepar" + id).html("State: Transferring"); … … 50 86 $("#statepar" + id).html("State: Calculating"); 51 87 } 88 else if (task.State == "4") { 89 $("#statepar" + id).css({ 90 'color': 'white', 91 'font-weight': 'normal' 92 }); 93 $("#statepar" + id).html("State: Paused"); 94 document.getElementById("restarter" + id).style.display = ""; 95 document.getElementById("restarterbtn" + id).disabled = false; 96 document.getElementById("restarterbtn" + id).value = "Restart task"; 97 } 52 98 else if (task.State == "5") { 53 99 $("#statepar" + id).css({ 54 100 'color': '#009900', 55 'font-weight': '900' 101 'font-weight': '900', 102 'text-shadow': '1px 1px black' 56 103 }); 57 104 $("#statepar" + id).html("State: Finished"); 58 var datf = new Date(task.StateLog[task.StateLog.length - 1].DateTime);105 var datf = new Date(task.StateLog[task.StateLog.length - 1].DateTime); 59 106 $("#lastupdpar" + id).html("Finished: " + datf.toUTCString()); 107 } 108 else if (task.State == "6") { 109 $("#statepar" + id).css({ 110 'color': '#e60000', 111 'font-weight': '900', 112 'text-shadow': '1px 1px black' 113 }); 114 $("#statepar" + id).html("State: Aborted"); 115 116 document.getElementById("restarter" + id).style.display = ""; 117 document.getElementById("restarterbtn" + id).disabled = false; 118 document.getElementById("restarterbtn" + id).value = "Restart task"; 60 119 } 61 120 else if (task.State == "7") { 62 121 $("#statepar" + id).css({ 63 'color': '#df2020', 64 'font-weight': '900' 122 'color': '#e60000', 123 'font-weight': '900', 124 'text-shadow': '1px 1px black' 65 125 }); 66 126 $("#statepar" + id).html("State: Failed"); 127 128 document.getElementById("restarter" + id).style.display = ""; 129 document.getElementById("restarterbtn" + id).disabled = false; 130 document.getElementById("restarterbtn" + id).value = "Restart task"; 67 131 } 68 132 69 133 //execution time 70 134 $("#executionpar" + id).html(task.ExecutionTime + " executed"); 135 //exception 136 if (task.StateLog[task.StateLog.length - 1].Exception != null) 137 if (task.StateLog[task.StateLog.length - 1].Exception != "") { 138 $("#exceptionpar" + id).html("Exception: " + task.StateLog[task.StateLog.length - 1].Exception) 139 $("#exceptionpar" + id).css({ 140 'color': '#e60000', 141 'font-weight': '700', 142 'text-shadow': '1px 1px black' 143 }); 144 } 145 else if (task.State == "6") { 146 $("#exceptionpar" + id).html("Task is aborted.") 147 $("#exceptionpar" + id).css({ 148 'color': '#e65c00', 149 'font-weight': '700', 150 'text-shadow': '1px 1px black' 151 }); 152 } 153 else { 154 $("#exceptionpar" + id).html("No exceptions"); 155 $("#exceptionpar" + id).css({ 156 'color': 'white', 157 'text-shadow': '2px 2px black' 158 }); 159 } 160 else { 161 $("#exceptionpar" + id).html("No exceptions"); 162 $("#exceptionpar" + id).css({ 163 'color': 'white', 164 'text-shadow': '2px 2px black' 165 }); 166 } 71 167 //state changes 72 $("#statechangespar" + id).html("Statelogs: " +task.StateLog.length);168 $("#statechangespar" + id).html("Statelogs: " + task.StateLog.length); 73 169 //graph title 74 170 var dat1 = new Date(task.StateLog[0].DateTime); -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/Scripts/hubber.js
r13714 r13733 22 22 function addtoHive() { 23 23 24 var jobname = prompt("Please enter a job name", "Job");24 var jobname = document.getElementById("jname").value; 25 25 if (jobname && jobname != "" && jobname != null) { 26 26 hubber.server.changeName(jobname); … … 29 29 document.getElementById("result").style.display = ""; 30 30 document.getElementById("realhiveadd").click(); 31 } else { 32 alert("Job name not set!"); 31 33 } 32 34 }
Note: See TracChangeset
for help on using the changeset viewer.