Skip to content

Commit

Permalink
Print timing to console
Browse files Browse the repository at this point in the history
  • Loading branch information
knabar committed Mar 18, 2024
1 parent 4e90bca commit fb165ae
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
* or repeated before it is completed.
* @param promise When this promise resolves (successfully or otherwise) the overlay closes
* @param message The optional message to display (defaults to "Please wait")
* @param quiet Don't print timing to console
* @returns {*|jQuery} The jQuery element holding the dialog; no need to do anything with it
*/
OME.progress_overlay = function (promise, message) {
OME.progress_overlay = function (promise, message, quiet) {
'use strict';
const startTime = new Date().getTime();
const dialog = $('<div>' + (message || 'Please wait') + '</div>')
.appendTo(document.body)
.dialog({
Expand All @@ -22,7 +24,12 @@ OME.progress_overlay = function (promise, message) {
'ui-dialog': 'ome-modal-progress',
}
});
promise.finally(() => dialog.dialog('destroy').remove());
promise.finally(() => {
dialog.dialog('destroy').remove();
if (!quiet) {
window.console.log('UI blocked for ' + (new Date().getTime() - startTime).toString() + 'ms');
}
});
return dialog;
};

Expand Down

0 comments on commit fb165ae

Please sign in to comment.