From 42d92be0cb42456649a1dfc5dd560892a80bdf12 Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Mon, 17 Sep 2018 07:12:13 -0600 Subject: [PATCH] Better handling of the case where idlegraph info contains no info cause there are no nodes allocated (transient situation). --- www/aptui/js/adminextend.js | 18 ++++++++++++------ www/aptui/js/idlegraphs.js | 15 +++++++++++++-- www/aptui/js/status.js | 2 +- www/aptui/template/adminextend.html | 3 +++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/www/aptui/js/adminextend.js b/www/aptui/js/adminextend.js index 85dc4b486..abc5e6baf 100644 --- a/www/aptui/js/adminextend.js +++ b/www/aptui/js/adminextend.js @@ -765,12 +765,18 @@ $(function () var callback = function (status, json) { console.info("LoadIdleData callback"); - if (status < 0) { - // Error, show something that indicates we could not get - // the idle data. - $('#idledata-error').html("Could not get graph data: " + - json.value); - $('#idledata-error').removeClass("hidden"); + if (status <= 0) { + if (status == 0) { + // No data. + $('#idledata-nodata').removeClass("hidden"); + } + else { + // Error, show something that indicates we could not get + // the idle data. + $('#idledata-error').html("Could not get graph data: " + + json.value); + $('#idledata-error').removeClass("hidden"); + } } if (continuation !== undefined) { continuation(); diff --git a/www/aptui/js/idlegraphs.js b/www/aptui/js/idlegraphs.js index b7fc60fe8..777048623 100644 --- a/www/aptui/js/idlegraphs.js +++ b/www/aptui/js/idlegraphs.js @@ -385,10 +385,21 @@ window.ShowIdleGraphs = (function () return; } _.each(json.value, function(data, name) { - var idledata = JSON.parse(data); - rawData[name] = idledata; + // No data, skip + if (data == "") { + return; + } + rawData[name] = JSON.parse(data); }); console.info("raw", rawData); + + // No data, tell caller and done. + if (Object.keys(rawData).length == 0) { + if (C_callback) { + C_callback(0, json); + } + return; + } var load = ProcessData("load", "avg"); var ctrl = ProcessData("ctrl", "avg"); var expt = ProcessData("expt", "avg"); diff --git a/www/aptui/js/status.js b/www/aptui/js/status.js index 4c7e35482..28885ffd9 100644 --- a/www/aptui/js/status.js +++ b/www/aptui/js/status.js @@ -3313,7 +3313,7 @@ $(function () * This callback is to let us know if there is any actual data. */ var callback = function (gotdata, ignored) { - if (!gotdata) { + if (gotdata <= 0) { $('#Idlegraphs #nodata').removeClass("hidden"); } }; diff --git a/www/aptui/template/adminextend.html b/www/aptui/template/adminextend.html index 2a7a5f8b4..a3bb3fbbe 100644 --- a/www/aptui/template/adminextend.html +++ b/www/aptui/template/adminextend.html @@ -209,6 +209,9 @@ pre {
+