1 | var hubber = $.connection.jobUpdaterHub;
|
---|
2 |
|
---|
3 | $(function () {
|
---|
4 | // $.connection.hub.logging = true;
|
---|
5 | var v = document.getElementById("userId").innerHTML;
|
---|
6 | $.connection.hub.qs = { 'userid': v };
|
---|
7 | $.connection.hub.start().done(function () {
|
---|
8 | hubber.server.initConnection();
|
---|
9 | redrawMain();
|
---|
10 | });
|
---|
11 | //processes updates task info for each individual task
|
---|
12 | hubber.client.processData = function (id, data, name) {
|
---|
13 | var obj = JSON.parse(data);
|
---|
14 | editTaskData(id, obj);
|
---|
15 |
|
---|
16 | saveData(id, obj.StateLog, name);
|
---|
17 | console.log("#UPDATED " + id);
|
---|
18 | }
|
---|
19 | //processes updated job info
|
---|
20 | hubber.client.processJobData = function (calc, fin) {
|
---|
21 | editJobData(calc, fin);
|
---|
22 | }
|
---|
23 | //Called when server is done with request
|
---|
24 | hubber.client.requestDone = function () {
|
---|
25 | if (document.getElementById("refreshtogg").checked) {
|
---|
26 | setTimeout(function () {
|
---|
27 | hubber.server.updateAll();
|
---|
28 | console.log("#REFRESH ALL");
|
---|
29 |
|
---|
30 | }, 5000);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | })
|
---|
34 |
|
---|
35 | //Toggles the refresh button. ON is refresh every 5 sec, OFF is no refresh
|
---|
36 | function autoRefresh() {
|
---|
37 | if (document.getElementById("refreshtogg").checked)
|
---|
38 | hubber.server.updateAll();
|
---|
39 |
|
---|
40 | }
|
---|
41 | //Restarts an aborted, paused or failed task
|
---|
42 | function restart(id) {
|
---|
43 | document.getElementById("restarterbtn" + id).disabled = true;
|
---|
44 | document.getElementById("restarterbtn" + id).value = "Sending restart request...";
|
---|
45 | hubber.server.restartTask(id);
|
---|
46 | }
|
---|
47 | //Writes the new job info to the page
|
---|
48 | function editJobData(c, f) {
|
---|
49 | $("#jobcalculating").html("Calculating: " + c);
|
---|
50 | $("#jobfinished").html("Finished: " + f);
|
---|
51 | }
|
---|
52 | //Writes updated task info to the page
|
---|
53 | function editTaskData(id, task) {
|
---|
54 | //lastupdate
|
---|
55 | if (task.LastHeartbeat != null) {
|
---|
56 | var dat = new Date(task.LastHeartbeat);
|
---|
57 | $("#lastupdpar" + id).html("Last update: " + dat.toUTCString());
|
---|
58 | }
|
---|
59 | else
|
---|
60 | $("#lastupdpar" + id).html("No updates yet");
|
---|
61 | //task restarter
|
---|
62 | document.getElementById("restarter" + id).style.display = "none";
|
---|
63 | //state
|
---|
64 | if (task.State == "0") {//OFFLINE
|
---|
65 | $("#statepar" + id).css({
|
---|
66 | 'color': 'gray',
|
---|
67 | 'font-weight': 'normal'
|
---|
68 | });
|
---|
69 | $("#statepar" + id).html("State: Offline");
|
---|
70 | }
|
---|
71 | else if (task.State == "1") {//WAITING
|
---|
72 | $("#statepar" + id).css({
|
---|
73 | 'color': 'white',
|
---|
74 | 'font-weight': 'normal'
|
---|
75 | });
|
---|
76 | $("#statepar" + id).html("State: Waiting");
|
---|
77 | }
|
---|
78 | else if (task.State == "2") {//TRANSFERRING
|
---|
79 | $("#statepar" + id).css({
|
---|
80 | 'color': 'white',
|
---|
81 | 'font-weight': 'normal',
|
---|
82 | 'text-shadow': '2px 2px black'
|
---|
83 | });
|
---|
84 | $("#statepar" + id).html("State: Transferring");
|
---|
85 | }
|
---|
86 | else if (task.State == "3") {//CALCULATING
|
---|
87 | $("#statepar" + id).css({
|
---|
88 | 'color': 'white',
|
---|
89 | 'font-weight': 'normal'
|
---|
90 | });
|
---|
91 | $("#statepar" + id).html("State: Calculating");
|
---|
92 | }
|
---|
93 | else if (task.State == "4") {//PAUSED
|
---|
94 | $("#statepar" + id).css({
|
---|
95 | 'color': 'white',
|
---|
96 | 'font-weight': 'normal'
|
---|
97 | });
|
---|
98 | $("#statepar" + id).html("State: Paused");
|
---|
99 | //Able to restart
|
---|
100 | document.getElementById("restarter" + id).style.display = "";
|
---|
101 | document.getElementById("restarterbtn" + id).disabled = false;
|
---|
102 | document.getElementById("restarterbtn" + id).value = "Restart task";
|
---|
103 | }
|
---|
104 | else if (task.State == "5") {//FINISHED
|
---|
105 | $("#statepar" + id).css({
|
---|
106 | 'color': '#009900',
|
---|
107 | 'font-weight': '900',
|
---|
108 | 'text-shadow': '1px 1px black'
|
---|
109 | });
|
---|
110 | $("#statepar" + id).html("State: Finished");
|
---|
111 | var datf = new Date(task.StateLog[task.StateLog.length - 1].DateTime);
|
---|
112 | $("#lastupdpar" + id).html("Finished: " + datf.toUTCString());
|
---|
113 | }
|
---|
114 | else if (task.State == "6") {//ABORTED
|
---|
115 | $("#statepar" + id).css({
|
---|
116 | 'color': '#e60000',
|
---|
117 | 'font-weight': '900',
|
---|
118 | 'text-shadow': '1px 1px black'
|
---|
119 | });
|
---|
120 | $("#statepar" + id).html("State: Aborted");
|
---|
121 | //Able to restart
|
---|
122 | document.getElementById("restarter" + id).style.display = "";
|
---|
123 | document.getElementById("restarterbtn" + id).disabled = false;
|
---|
124 | document.getElementById("restarterbtn" + id).value = "Restart task";
|
---|
125 | }
|
---|
126 | else if (task.State == "7") {//FAILED
|
---|
127 | $("#statepar" + id).css({
|
---|
128 | 'color': '#e60000',
|
---|
129 | 'font-weight': '900',
|
---|
130 | 'text-shadow': '1px 1px black'
|
---|
131 | });
|
---|
132 | $("#statepar" + id).html("State: Failed");
|
---|
133 | //Able to restart
|
---|
134 | document.getElementById("restarter" + id).style.display = "";
|
---|
135 | document.getElementById("restarterbtn" + id).disabled = false;
|
---|
136 | document.getElementById("restarterbtn" + id).value = "Restart task";
|
---|
137 | }
|
---|
138 |
|
---|
139 | //execution time
|
---|
140 | $("#executionpar" + id).html(task.ExecutionTime + " executed");
|
---|
141 | //exception
|
---|
142 | if (task.StateLog[task.StateLog.length - 1].Exception != null)
|
---|
143 | if (task.StateLog[task.StateLog.length - 1].Exception != "") {
|
---|
144 | $("#exceptionpar" + id).html("Exception: " + task.StateLog[task.StateLog.length - 1].Exception)
|
---|
145 | $("#exceptionpar" + id).css({
|
---|
146 | 'color': '#e60000',
|
---|
147 | 'font-weight': '700',
|
---|
148 | 'text-shadow': '1px 1px black'
|
---|
149 | });
|
---|
150 | }
|
---|
151 | else if (task.State == "6") {
|
---|
152 | $("#exceptionpar" + id).html("Task is aborted.")
|
---|
153 | $("#exceptionpar" + id).css({
|
---|
154 | 'color': '#e65c00',
|
---|
155 | 'font-weight': '700',
|
---|
156 | 'text-shadow': '1px 1px black'
|
---|
157 | });
|
---|
158 | }
|
---|
159 | else {
|
---|
160 | $("#exceptionpar" + id).html("No exceptions");
|
---|
161 | $("#exceptionpar" + id).css({
|
---|
162 | 'color': 'white',
|
---|
163 | 'text-shadow': '2px 2px black'
|
---|
164 | });
|
---|
165 | }
|
---|
166 | else {
|
---|
167 | $("#exceptionpar" + id).html("No exceptions");
|
---|
168 | $("#exceptionpar" + id).css({
|
---|
169 | 'color': 'white',
|
---|
170 | 'text-shadow': '2px 2px black'
|
---|
171 | });
|
---|
172 | }
|
---|
173 | //state changes
|
---|
174 | $("#statechangespar" + id).html("Statelogs: " + task.StateLog.length);
|
---|
175 | //graph title
|
---|
176 | var dat1 = new Date(task.StateLog[0].DateTime);
|
---|
177 | var dat2 = new Date(task.StateLog[task.StateLog.length - 1].DateTime);
|
---|
178 | $("#graphtitle" + id).html(
|
---|
179 | "From " + dat1.toUTCString() +
|
---|
180 | "<br/> to " + dat2.toUTCString()
|
---|
181 | );
|
---|
182 | } |
---|