Commit a85d892f authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: /viewLog correctly displays the actual status of last slapgrid run

parent 16aae696
...@@ -534,7 +534,7 @@ padding: 10px;height: 80px;padding-bottom:15px;} ...@@ -534,7 +534,7 @@ padding: 10px;height: 80px;padding-bottom:15px;}
.log_info_box div.state_terminated span{ .log_info_box div.state_terminated span{
background: #00C800; background: #00C800;
} }
.log_info_box div.state_waiting span, .log_info_box div.state_stopped span{ .log_info_box div.state_waiting span, .log_info_box div.state_stopped span, .log_info_box div.state_failed span{
background: #FF3131; background: #FF3131;
} }
......
...@@ -49,29 +49,18 @@ function removeFirstLog() { ...@@ -49,29 +49,18 @@ function removeFirstLog() {
$("#salpgridLog p:first-child").remove(); $("#salpgridLog p:first-child").remove();
} }
function getRunningState() { function writeLogs(data) {
"use strict"; "use strict";
var size = 0, var log_info = "",
log_info = "",
param = {
position: logReadingPosition,
log: (openedlogpage !== "") ? processType.toLowerCase() : ""
},
jqxhr = $.post(url, param, function (data) {
running = data.result;
if (data.instance.state) {
processType = "Instance";
} else if (data.software.state) {
processType = "Software";
}
setRunningState(data);
size = data.content.position - logReadingPosition; size = data.content.position - logReadingPosition;
if (size < 0) { if (size < 0) {
clearAll(); clearAll();
} }
if (logReadingPosition !== 0 && data.content.truncated) { if (logReadingPosition !== 0 && data.content.truncated) {
log_info = "<p class='info' rel='0'>SLAPRUNNER INFO: SLAPGRID-LOG HAS BEEN TRUNCATED HERE. To see full log reload your log page</p>"; log_info = "<p class='info' rel='0'>SLAPRUNNER INFO: SLAPGRID-LOG HAS BEEN TRUNCATED HERE. To see full log reload your log page</p>";
} }
logReadingPosition = data.content.position; logReadingPosition = data.content.position;
if (data.content.content !== "") { if (data.content.content !== "") {
if (data.content.content !== "") { if (data.content.content !== "") {
...@@ -94,6 +83,33 @@ function getRunningState() { ...@@ -94,6 +83,33 @@ function getRunningState() {
removeFirstLog(); //in cas of previous <p/> size is 0 removeFirstLog(); //in cas of previous <p/> size is 0
} }
} }
}
function getRunningState() {
"use strict";
var build_success = 0,
run_success = 0,
param = {
position: logReadingPosition,
log: (openedlogpage !== "") ? processType.toLowerCase() : ""
},
jqxhr = $.post(url, param, function (data) {
running = data.result;
if (data.instance.state) {
processType = "Instance";
} else if (data.software.state) {
processType = "Software";
}
writeLogs(data);
setRunningState(data);
if(data.result) {
updateStatus(processType.toLowerCase(), "running");
} else {
build_success = (data.software.success === 0)? "terminated":"failed";
run_success = (data.instance.success === 0)? "terminated":"failed";
updateStatus("software", build_success);
updateStatus("instance", run_success);
}
}).error(function () { }).error(function () {
clearAll(false); clearAll(false);
}); });
...@@ -169,8 +185,9 @@ function updateStatus(elt, val) { ...@@ -169,8 +185,9 @@ function updateStatus(elt, val) {
break; break;
case "running": case "running":
$(src).children('p').text("Processing"); $(src).children('p').text("Processing");
processType = elt; break;
getRunningState() case "failed":
$(src).children('p').text("Failed");
break; break;
} }
// in case of failure // in case of failure
...@@ -203,13 +220,6 @@ function setRunningState(data) { ...@@ -203,13 +220,6 @@ function setRunningState(data) {
$("#softrun").addClass('slapos_stop'); $("#softrun").addClass('slapos_stop');
$("#running img").before('<p id="running_info" class="instance">Running instance...</p>'); $("#running img").before('<p id="running_info" class="instance">Running instance...</p>');
} }
if (processType === "Software") {
running = false;
$("#running_info").remove();
$("#softrun").addClass('slapos_run');
$("#softrun").removeClass('slapos_stop');
$("#instrun").click();
}
} }
} }
} else { } else {
...@@ -228,7 +238,6 @@ function setRunningState(data) { ...@@ -228,7 +238,6 @@ function setRunningState(data) {
} }
$("#running").hide(); $("#running").hide();
$("#running_info").remove(); $("#running_info").remove();
running = false; //nothing is currently running
$("#softrun").removeClass('slapos_stop'); $("#softrun").removeClass('slapos_stop');
$("#softrun").addClass('slapos_run'); $("#softrun").addClass('slapos_run');
if ( $("#running").children('span').length > 0 ) { if ( $("#running").children('span').length > 0 ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment