From ecea5c3b2408dc88b2508dd5ef80454b0573624a Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Mon, 31 Mar 2014 08:36:00 -0600 Subject: [PATCH] Lots of UI changes. --- www/aptui/js/status.js | 111 ++++++++++++++++++++++++++++------- www/aptui/manage_profile.php | 5 +- www/aptui/status.php | 29 +++++---- 3 files changed, 114 insertions(+), 31 deletions(-) diff --git a/www/aptui/js/status.js b/www/aptui/js/status.js index 9e83ee6ef..dce1d6b8a 100644 --- a/www/aptui/js/status.js +++ b/www/aptui/js/status.js @@ -1,10 +1,11 @@ window.APT_OPTIONS.config(); -require(['jquery', 'js/quickvm_sup', +require(['jquery', 'js/quickvm_sup', 'tablesorter', 'tablesorterwidgets', 'bootstrap'], function ($, sup) { 'use strict'; + var CurrentTopo = null; function initialize() { @@ -62,6 +63,7 @@ function ($, sup) // This is considered the home page, for now. window.location.replace('instantiate.php'); } + sup.ShowModal("#waitwait"); var $xmlthing = sup.CallMethod("terminate", null, window.APT_OPTIONS.uuid, null); @@ -118,6 +120,7 @@ function ($, sup) $("#terminate_button").prop("disabled", false); $("#extend_button").prop("disabled", false); ShowTopo(uuid); + StartResizeWatchdog() } else if (status == 'failed') { bgtype = "bg-danger"; @@ -134,9 +137,11 @@ function ($, sup) } else if (status == 'terminating' || status == 'terminated') { status_html = "" + status + ""; + bgtype = "bg-danger"; + statustext = "Your experiment has been terminated!"; $("#terminate_button").prop("disabled", true); $("#extend_button").prop("disabled", true); - StartCountdownClock.stop = 0; + StartCountdownClock.stop = 1; } $("#statusmessage").html(statustext); $("#statusmessage-container") @@ -153,7 +158,7 @@ function ($, sup) // // Install a window resize handler to redraw the topomap. // - function StartResizeWatchdog(uuid) + function StartResizeWatchdog() { var resizeTimer; @@ -165,7 +170,7 @@ function ($, sup) // Must clear the div for the D3 library. $("#showtopo_statuspage").html("
"); $("#showtopo_statuspage").removeClass("invisible"); - ShowTopo(uuid); + ReDrawTopoMap(); } // @@ -208,6 +213,9 @@ function ($, sup) // variables for time units var days, hours, minutes, seconds; + + // text color. + var color = ""; // update the tag with id "countdown" every 1 second var updater = setInterval(function () { @@ -244,7 +252,7 @@ function ($, sup) clearInterval(updater); return; } - + // do some time calculations days = parseInt(seconds_left / 86400); seconds_left = seconds_left % 86400; @@ -265,9 +273,40 @@ function ($, sup) seconds = "0" + seconds; var countdown = - days + ":" + hours + ":" + minutes + ":" + seconds; + days + ":" + hours + ":" + minutes + ":" + seconds; + var newcolor = ""; + var statusbg = ""; + var statustext = "Your experiment is ready"; $("#quickvm_countdown").html(countdown); + + seconds_left = (target_date - current_date) / 1000; + if (seconds_left < 3600) { + newcolor = "text-danger"; + statusbg = "bg-danger"; + statustext = "Extend your experiment before it expires!"; + } + else if (seconds_left < 2 * 3600) { + newcolor = "text-warning"; + statusbg = "bg-warning"; + statustext = "Your experiment is going to expire soon!"; + } + else { + newcolor = ""; + statusbg = "hidden"; + } + if (newcolor != color) { + $("#quickvm_countdown") + .removeClass("text-warning text-danger") + .addClass(newcolor); + + $("#statusmessage").html(statustext); + $("#statusmessage-container") + .removeClass('bg-success bg-danger hidden') + .addClass(statusbg); + + color = newcolor; + } }, 1000); } @@ -284,16 +323,20 @@ function ($, sup) return; } var callback = function(json) { + sup.HideModal("#waitwait"); + console.info(json.value); + var message; if (json.code) { if (json.code < 0) { - alert("Could not extend experiment. " + - "Please try again later"); + message = "Could not extend experiment. " + + "Please try again later"; } else { - alert("Could not extend experiment: " + json.value); + message = "Could not extend experiment: " + json.value; } + sup.SpitOops("oops", message); return; } $("#quickvm_expires").html(json.value); @@ -301,8 +344,9 @@ function ($, sup) // Reset the countdown clock. StartCountdownClock.reset = json.value; } - var $xmlthing = sup.CallMethod("request_extension", null, uuid, reason); sup.HideModal('#extend_modal'); + sup.ShowModal("#waitwait"); + var $xmlthing = sup.CallMethod("request_extension", null, uuid, reason); $xmlthing.done(callback); } @@ -321,7 +365,7 @@ function ($, sup) var url = jsonauth.baseurl + ':' + port + '/' + '#' + encodeURIComponent(document.location.href) + ',' + session; console.info(url); - var iwidth = $('#' + id).width(); + var iwidth = "100%"; var iheight = 400; $('#' + id).html('