From 013c815abfa4fd0391b79b2653d989588b170e86 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 13 Nov 2016 17:18:51 +0800 Subject: webui: Show a modal box indicating there are invalid configs --- fg21sim/webui/static/js/configs.js | 9 +++------ fg21sim/webui/static/js/websocket.js | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'fg21sim/webui/static') diff --git a/fg21sim/webui/static/js/configs.js b/fg21sim/webui/static/js/configs.js index 4e635ae..6ded8c4 100644 --- a/fg21sim/webui/static/js/configs.js +++ b/fg21sim/webui/static/js/configs.js @@ -136,7 +136,7 @@ var getFormConfigSingle = function (name) { value = target.filter(":checked").val(); } else if (target.is(":checkbox") && target.data("type") === "boolean") { // Convert the checkbox value into boolean - value = target.is(":checked") ? true : false; + value = target.prop("checked"); } else if (target.is(":checkbox")) { // Get values of checked checkboxes into array // Credit: https://stackoverflow.com/a/16171146/4856091 @@ -211,13 +211,10 @@ var setFormConfigSingle = function (name, value) { // Convert the checkbox value into boolean target.prop("checked", value); } else if (target.is(":checkbox")) { - // Convert value (key of a single option) to an Array - if (! Array.isArray(value)) { - value = [value]; - } + // The received value is already an Array target.val(value); } else if (target.is(":text") && target.data("type") == "array") { - // The received value is already an Array + // Convert array of values into a string value = value.join(", "); target.val(value); } else { diff --git a/fg21sim/webui/static/js/websocket.js b/fg21sim/webui/static/js/websocket.js index 26d7fce..0fcf98e 100644 --- a/fg21sim/webui/static/js/websocket.js +++ b/fg21sim/webui/static/js/websocket.js @@ -232,6 +232,7 @@ $(document).ready(function () { startServerTask(g_ws); getServerTaskStatus(g_ws); } else { + $("#console-invalid-configs").modal(); console.error("Exist invalid configuration values!"); } }); -- cgit v1.2.2