From e361bd13bd4b24eb9ba7713716e8041564d5415d Mon Sep 17 00:00:00 2001 From: Rob Hoelz Date: Thu, 30 Oct 2014 09:13:20 -0500 Subject: [PATCH] Display HTML5 notifications when a task is no longer running Sometimes bringing up a set of machines can take a while, and the user would like to know when the process is complete. Currently, the user has to check back with Asgard every so often. This commit introduces the use of HTML5 notifications (which are not used if unsupported by the user's browser) to inform the user when the task has completed or failed. --- web-app/js/custom.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web-app/js/custom.js b/web-app/js/custom.js index 1851e88e..cf1928ab 100644 --- a/web-app/js/custom.js +++ b/web-app/js/custom.js @@ -968,6 +968,11 @@ jQuery(document).ready(function() { if (taskData.status !== 'running') { poller.stop = true; jCancellationForm.slideUp(); + if('Notification' in window) { + var notification = new Notification("Job's Done", { + 'body': taskData.status + }); + } } }, contentType: 'application/json' @@ -1721,4 +1726,15 @@ jQuery(document).ready(function() { }; setUpTableSortability(); + var setUpNotifications = function() { + if('Notification' in window && Notification.permission !== 'granted') { + Notification.requestPermission(function(permission) { + if(Notification.permission !== permission) { + Notification.permission = permission; + } + }); + } + }; + setUpNotifications(); + });