From 3898a31047c218c43959593bbe738a1424882aa8 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 17 Nov 2016 10:37:22 +0800 Subject: webui: configs.js: Confirm before overwrite the configuration file Also improve the "showConfigsModal()" to support buttons. --- fg21sim/webui/static/js/configs.js | 92 ++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 18 deletions(-) (limited to 'fg21sim/webui/static/js') diff --git a/fg21sim/webui/static/js/configs.js b/fg21sim/webui/static/js/configs.js index bf7bcc5..80c218c 100644 --- a/fg21sim/webui/static/js/configs.js +++ b/fg21sim/webui/static/js/configs.js @@ -305,18 +305,19 @@ var updateFormConfigStatus = function () { * - `message` : Main summary message * - `code` : Error code if it is an error notification * - `reason` : Reason of the error + * - `buttons` : A list of buttons */ var showConfigsModal = function (data) { var modalBox = $("#modal-configs"); modalBox.html(""); - var p1 = $("

"); + var p = $("

"); if (data.icon) { - $("").addClass("fa fa-2x").addClass("fa-" + data.icon).appendTo(p1); + $("").addClass("fa fa-2x").addClass("fa-" + data.icon).appendTo(p); } if (data.message) { - $("").text(" " + data.message).appendTo(p1); + $("").text(" " + data.message).appendTo(p); } - modalBox.append(p1); + modalBox.append(p); if (data.code) { modalBox.append($("

Error Code:

") .append($("") @@ -329,6 +330,15 @@ var showConfigsModal = function (data) { .addClass("label label-warning") .text(data.reason))); } + if (data.buttons) { + p = $("

").addClass("button-group"); + data.buttons.forEach(function (btn) { + $("