Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id E8B0CE00C3E; Mon, 25 Jul 2016 00:57:54 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [23.83.223.161 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from seahorse.cherry.relay.mailchannels.net (seahorse.cherry.relay.mailchannels.net [23.83.223.161]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 2C3D1E00972 for ; Mon, 25 Jul 2016 00:57:33 -0700 (PDT) X-Sender-Id: wwwh|x-authuser|elliot@townx.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 54A4C203E2; Mon, 25 Jul 2016 07:57:21 +0000 (UTC) Received: from uscentral428.accountservergroup.com (ip-10-27-139-41.us-west-2.compute.internal [10.27.139.41]) by relay.mailchannels.net (Postfix) with ESMTPA id 7E4BE2060C; Mon, 25 Jul 2016 07:57:20 +0000 (UTC) X-Sender-Id: wwwh|x-authuser|elliot@townx.org Received: from uscentral428.accountservergroup.com (uscentral428.accountservergroup.com [10.91.5.35]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.3); Mon, 25 Jul 2016 07:57:21 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|elliot@townx.org X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1469433440977:2626804875 X-MC-Ingress-Time: 1469433440977 Received: from [176.249.240.35] (port=40256 helo=localhost.localdomain) by uscentral428.accountservergroup.com with esmtpa (Exim 4.87) (envelope-from ) id 1bRalD-00017N-6o; Mon, 25 Jul 2016 03:57:11 -0400 From: Elliot Smith To: toaster@yoctoproject.org Date: Mon, 25 Jul 2016 08:57:02 +0100 Message-Id: <1469433422-11318-1-git-send-email-elliot.smith@intel.com> X-Mailer: git-send-email 2.7.4 X-AuthUser: elliot@townx.org Subject: [PATCH] toaster: show loading spinner after creating custom image X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2016 07:57:55 -0000 Creating a custom image through the "New custom image" dialog can sometimes result in a long pause between pressing the button to create the image, and being transferred to the page showing details of its content. This can make it appear as though pressing the button had no effect. To prevent this from happening, disable the button and text box in the new custom image dialog after the "Create image" button is pressed. Also show a loading spinner and "loading..." text on the button to make it clear that the application is still responding. [YOCTO #9475] Signed-off-by: Elliot Smith --- .../lib/toaster/toastergui/static/css/default.css | 12 ++++++++ .../lib/toaster/toastergui/static/js/libtoaster.js | 20 +++++++++++-- .../toastergui/static/js/newcustomimage_modal.js | 33 ++++++++++++++++++++-- .../toastergui/templates/newcustomimage_modal.html | 7 ++++- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/static/css/default.css b/bitbake/lib/toaster/toastergui/static/css/default.css index 0d3570a..96eedfc 100644 --- a/bitbake/lib/toaster/toastergui/static/css/default.css +++ b/bitbake/lib/toaster/toastergui/static/css/default.css @@ -249,6 +249,18 @@ code { color: #333; background-color: transparent; } /* Style the special no results message in the custom image details page */ [id^="no-results-special-"] > .alert-warning > ol { margin-top: 10px; } +/* style the loading spinner in the new custom image dialog */ +#create-new-custom-image-btn [data-role="loading-state"] { + padding-left: 16px; +} + +/* icon has to be absolutely positioned, otherwise the spin animation doesn't work */ +#create-new-custom-image-btn [data-role="loading-state"] .icon-spinner { + position: absolute; + left: 26px; + bottom: 26px; +} + /* Style the content of modal dialogs */ .modal-footer { text-align: left; } .date-filter-controls { margin-top: 10px; } diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index eafe70d..b8bf1a2 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js @@ -421,8 +421,23 @@ var libtoaster = (function () { }); } + // if true, the loading spinner for Ajax requests will be displayed + // if requests take more than 1200ms + var ajaxLoadingTimerEnabled = true; + + // turn on the page-level loading spinner for Ajax requests + function _enableAjaxLoadingTimer() { + ajaxLoadingTimerEnabled = true; + } + + // turn off the page-level loading spinner for Ajax requests + function _disableAjaxLoadingTimer() { + ajaxLoadingTimerEnabled = false; + } return { + enableAjaxLoadingTimer: _enableAjaxLoadingTimer, + disableAjaxLoadingTimer: _disableAjaxLoadingTimer, reload_params : reload_params, startABuild : _startABuild, cancelABuild : _cancelABuild, @@ -469,7 +484,6 @@ function reload_params(params) { window.location.href = url+"?"+callparams.join('&'); } - /* Things that happen for all pages */ $(document).ready(function() { @@ -628,7 +642,9 @@ $(document).ready(function() { window.clearTimeout(ajaxLoadingTimer); ajaxLoadingTimer = window.setTimeout(function() { - $("#loading-notification").fadeIn(); + if (libtoaster.ajaxLoadingTimerEnabled) { + $("#loading-notification").fadeIn(); + } }, 1200); }); diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js index 8356c02..dace8e3 100644 --- a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js +++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js @@ -25,7 +25,11 @@ function newCustomImageModalInit(){ var duplicateNameMsg = "An image with this name already exists. Image names must be unique."; var duplicateImageInProjectMsg = "An image with this name already exists in this project." var invalidBaseRecipeIdMsg = "Please select an image to customise."; - + + // set button to "submit" state and enable text entry so user can + // enter the custom recipe name + showSubmitState(); + /* capture clicks on radio buttons inside the modal; when one is selected, * set the recipe on the modal */ @@ -40,6 +44,9 @@ function newCustomImageModalInit(){ }); newCustomImgBtn.click(function(e){ + // disable the button and text entry + showLoadingState(); + e.preventDefault(); var baseRecipeId = imgCustomModal.data('recipe'); @@ -69,12 +76,33 @@ function newCustomImageModalInit(){ } } else { imgCustomModal.modal('hide'); + imgCustomModal.one('hidden.bs.modal', showSubmitState); window.location.replace(ret.url + '?notify=new'); } }); } }); + // enable text entry, show "Create image" button text + function showSubmitState() { + libtoaster.enableAjaxLoadingTimer(); + newCustomImgBtn.find('[data-role="loading-state"]').hide(); + newCustomImgBtn.find('[data-role="submit-state"]').show(); + newCustomImgBtn.removeAttr('disabled'); + nameInput.removeAttr('disabled'); + } + + // disable text entry, show "Creating image..." button text; + // we also disabled the page-level ajax loading spinner while this spinner + // is active + function showLoadingState() { + libtoaster.disableAjaxLoadingTimer(); + newCustomImgBtn.find('[data-role="submit-state"]').hide(); + newCustomImgBtn.find('[data-role="loading-state"]').show(); + newCustomImgBtn.attr('disabled', 'disabled'); + nameInput.attr('disabled', 'disabled'); + } + function showNameError(text){ invalidNameHelp.text(text); invalidNameHelp.show(); @@ -167,6 +195,5 @@ function newCustomImageModalSetRecipes(baseRecipes) { // show the radio button container imageSelector.show(); - - } + } } diff --git a/bitbake/lib/toaster/toastergui/templates/newcustomimage_modal.html b/bitbake/lib/toaster/toastergui/templates/newcustomimage_modal.html index 5caa683..d448d3a 100644 --- a/bitbake/lib/toaster/toastergui/templates/newcustomimage_modal.html +++ b/bitbake/lib/toaster/toastergui/templates/newcustomimage_modal.html @@ -48,7 +48,12 @@ -- 2.7.4