From 006df5cacc30a9a52d2e43dbb3798f247ae549e8 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 17 Nov 2016 14:43:00 +0800 Subject: webui: console.html: Remove extra modal "#console-invalid-configs" * Implement "showModalConsole()" based on "showModal()" * Move binding function from "websocket.js" to "console.js" --- fg21sim/webui/static/js/console.js | 59 +++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'fg21sim/webui/static/js/console.js') diff --git a/fg21sim/webui/static/js/console.js b/fg21sim/webui/static/js/console.js index 3dfd8b0..1ee323b 100644 --- a/fg21sim/webui/static/js/console.js +++ b/fg21sim/webui/static/js/console.js @@ -9,6 +9,15 @@ "use strict"; +/** + * Show notification contents in the "#modal-console" modal box. + */ +var showModalConsole = function (data) { + var modalBox = $("#modal-console"); + showModal(modalBox, data); +}; + + /** * Update the task status "#task-status" on the page. * @@ -68,7 +77,7 @@ var appendLogMessage = function (msg) { info: "", warning: "", error: "", - critical: "", + critical: "" }; var level = msg.levelname.toLowerCase(); var ele = $("

").addClass("code log log-" + level); @@ -180,3 +189,51 @@ var handleMsgConsole = function (msg) { // TODO: add error code support and handle each specific error ... } }; + + +$(document).ready(function () { + /** + * Start the simulation task on the server + */ + $("#task-start").on("click", function () { + if ($("#conf-status").data("validity")) { + updateTaskStatus({running: true, finished: false}); + startServerTask(g_ws); + getServerTaskStatus(g_ws); + } else { + $("#console-invalid-configs").modal(); + var modalData = {}; + modalData.icon = "times-circle"; + modalData.message = ("Exist invalid configuration values! " + + "Please correct the configurations " + + "before starting the task"); + showModalConsole(modalData); + console.error("Exist invalid configuration values!"); + } + }); + + /** + * Logging messages controls + */ + $("#log-toggle-debug").on("click", function () { + var status = toggleLogMessages("debug"); + $(this).fadeTo("fast", status ? 1.0 : 0.5); + }); + $("#log-toggle-info").on("click", function () { + var status = toggleLogMessages("info"); + $(this).fadeTo("fast", status ? 1.0 : 0.5); + }); + $("#log-toggle-warning").on("click", function () { + var status = toggleLogMessages("warning"); + $(this).fadeTo("fast", status ? 1.0 : 0.5); + }); + $("#log-toggle-error").on("click", function () { + var status = toggleLogMessages("error"); + toggleLogMessages("critical"); + $(this).fadeTo("fast", status ? 1.0 : 0.5); + }); + $("#log-delete").on("click", function () { + // TODO: add a confirmation dialog + deleteLogMessages(); + }); +}); -- cgit v1.2.2