From 80f1594a1795093d01302670297d4bdab245b222 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 26 Sep 2014 14:12:30 -0700 Subject: [PATCH] add a restart modal to settings page --- domain-server/resources/web/js/settings.js | 29 +++++++++++++++++-- .../resources/web/settings/index.shtml | 13 +++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 8f97da1ff4..b2d37c96cb 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -143,12 +143,11 @@ $('body').on('click', '.save-button', function(e){ type: 'POST' }).done(function(data){ if (data.status == "success") { - showAlertMessage("Domain settings saved.", true); + showRestartModal(); } else { showAlertMessage(SETTINGS_ERROR_MESSAGE, false); + reloadSettings(); } - - reloadSettings(); }).fail(function(){ showAlertMessage(SETTINGS_ERROR_MESSAGE, false); reloadSettings(); @@ -181,6 +180,30 @@ function badgeSidebarForDifferences(changedInput) { $("a[href='#" + panelParentID + "'] .badge").html(badgeValue); } +function showRestartModal() { + $('#restart-modal').modal({ + backdrop: 'static', + keyboard: false + }); + + var secondsElapsed = 0; + var numberOfSecondsToWait = 3; + + var refreshSpan = $('span#refresh-time') + refreshSpan.html(numberOfSecondsToWait + " seconds"); + + // call ourselves every 1 second to countdown + window.setInterval(function(){ + secondsElapsed++; + secondsLeft = numberOfSecondsToWait - secondsElapsed + refreshSpan.html(secondsLeft + (secondsLeft == 1 ? " second" : " seconds")) + + if (secondsElapsed == numberOfSecondsToWait) { + location.reload(true); + } + }, 1000); +} + function cleanupFormValues(node) { if (node.type && node.type === 'checkbox') { return { name: node.id, value: node.checked ? true : false }; diff --git a/domain-server/resources/web/settings/index.shtml b/domain-server/resources/web/settings/index.shtml index b6318e9a4d..54fbb02eca 100644 --- a/domain-server/resources/web/settings/index.shtml +++ b/domain-server/resources/web/settings/index.shtml @@ -58,6 +58,19 @@ + +