Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ESIPFed/Geoweaver
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihengSun committed Oct 15, 2024
2 parents 01d55c7 + df5a56b commit a0a431d
Showing 1 changed file with 61 additions and 6 deletions.
67 changes: 61 additions & 6 deletions src/main/resources/static/js/gw.monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
*
*/

//get the process and workflow table
getTable = function (data, pw_indicator) {
var content = '<table class="table table-bordered">'
content+= '<tr><th>'+pw_indicator+'_ID</th><th>Execution_ID</th><th>Name</th><th>Begin time</th><th>Duration</th></tr>';
data.forEach(function (item) {
var running_time = GW.history.calculate_duration(item.begin_time, new Date(), 'Running');
content += '<tr><td>' + item.id + '</td><td>' + item.hid + '</td><td>' + item.name + '</td><td>' + item.begin_time + '</td><td>' + running_time + '</td></tr>';
});
content += '</table>';
return content;
};


GW.monitor = {
ws: null,

Expand Down Expand Up @@ -291,17 +304,31 @@ GW.monitor = {
method: "POST",

data: "type=process&isactive=true",
}).done(function (msg) {
}).then(function (msg) {
var process_msg=[];
if (!msg.length) {
$("#running_process_table").html("no running process found");

return;
} else {
msg = $.parseJSON(msg);

var content = GW.process.getTable(msg);
for (var i = 0; i < msg.length; i++) {
var pw_id = msg[i].id;
//get active processes id and name from execution_id
$.ajax({
url: "log",
method: "POST",
data: "type=process&id=" + pw_id,
}).done(function (detailMsg) {
var detailMsg = GW.general.parseResponse(detailMsg);
process_msg.push(detailMsg);
if (msg.length==process_msg.length){
var content = getTable(process_msg, 'Process');

$("#running_process_table").html(content);
}
});
}
}
});

Expand All @@ -313,19 +340,47 @@ GW.monitor = {
method: "POST",

data: "type=workflow&isactive=true",
}).done(function (msg) {
}).then(function (msg) {
if (!msg.length) {
$("#running_workflow_table").html("no running workflow found");

return;
}

msg = $.parseJSON(msg);

var content = GW.workflow.getTable(msg);
var workflow_msg=[]
for (var i = 0; i < msg.length; i++) {
var pw_id = msg[i].id;
$.ajax({
url: "log",
method: "POST",
data: "type=workflow&id=" + pw_id,
//get active workflows from execution_id
}).then(function (detailMsg) {
var detailMsg = $.parseJSON(detailMsg);
var workflow_id = detailMsg.process;
var begin_time = detailMsg.begin_time;
var hid = detailMsg.hid;
//get name of workflows from list
$.ajax({
url: "list",
method: "POST",
data: "type=workflow",
}).then(function (workflowList) {
workflowList = $.parseJSON(workflowList);
var workflowObj = workflowList.find(w => w.id === workflow_id);
workflow_msg.push({
id: workflow_id,
name: workflowObj.name,
hid: hid,
begin_time: begin_time
});
var content = getTable(workflow_msg, 'Workflow');

$("#running_workflow_table").html(content);
})
});
}});
},

showDialog: function () {
Expand Down

0 comments on commit a0a431d

Please sign in to comment.