diff --git a/guacamole/src/main/webapp/app/index/controllers/indexController.js b/guacamole/src/main/webapp/app/index/controllers/indexController.js index 4a5b26ce3..5854cf7ff 100644 --- a/guacamole/src/main/webapp/app/index/controllers/indexController.js +++ b/guacamole/src/main/webapp/app/index/controllers/indexController.js @@ -50,6 +50,21 @@ angular.module('index').controller('indexController', ['$scope', '$injector', } }; + /** + * The current status notification, or false if no status is currently + * shown. + * + * @type Notification|Boolean + */ + $scope.status = false; + + /** + * All currently-visible notifications. + * + * @type Notification[] + */ + $scope.notifications = []; + // Put some useful variables in the top level scope $scope.page = { title: '', @@ -59,7 +74,6 @@ angular.module('index').controller('indexController', ['$scope', '$injector', $scope.currentUserIsAdmin = false; $scope.currentUserHasUpdate = false; $scope.currentUserPermissions = null; - $scope.notifications = []; var notificationUniqueID = 0; // A promise to be fulfilled when all basic user permissions are loaded. @@ -77,41 +91,8 @@ angular.module('index').controller('indexController', ['$scope', '$injector', * notification is currently shown, no further statuses will be shown * until the current status is hidden. * - * @param {Object} status The status notification to show. - * @param {String} [status.title] The title of the notification. - * @param {String} [status.text] The body text of the notification. - * @param {String} [status.className] The CSS class name to apply. - * - * @param {String} [status.countdown.text] - * In the case that a countdown applies to the notification, the text to - * display while the countdown is active. - * - * @param {Function} [status.countdown.callback] - * The callback to call when the countdown expires. - * - * @param {String} [status.countdown.remaining] - * The number of seconds remaining before the countdown callback is - * called. - * - * @param {String} [status.progress.text] - * If this notification has associated progress, the text to display - * while the operation is occurring. - * - * @param {String} [status.progress.value] - * The current state of operation progress, as an arbitrary number - * which increases as the operation continues. - * - * @param {String} [status.progress.unit] - * The unit of the arbitrary status.progress.value, if that value has - * an associated unit. - * - * @param {String} [status.progress.ratio] - * If known, the current status of the operation as a value between - * 0 and 1 inclusive, where 0 is not yet started, and 1 is complete. - * - * @param {Object[]} [status.actions] - * Array of action objects which contain an action name and callback to - * be executed when that action is invoked. + * @param {Notification|Boolean|Object} status + * The status notification to show. * * @example * @@ -138,43 +119,10 @@ angular.module('index').controller('indexController', ['$scope', '$injector', /** * Adds a notification to the the list of notifications shown. * - * @param {Object} notification The notification to add. - * @param {String} [notification.title] The title of the notification. - * @param {String} [notification.text] The body text of the notification. - * @param {String} [notification.className] The CSS class name to apply. + * @param {Notification|Object} notification The notification to add. * - * @param {String} [notification.countdown.text] - * In the case that a countdown applies to the notification, the text to - * display while the countdown is active. - * - * @param {Function} [notification.countdown.callback] - * The callback to call when the countdown expires. - * - * @param {String} [notification.countdown.remaining] - * The number of seconds remaining before the countdown callback is - * called. - * - * @param {String} [notification.progress.text] - * If this notification has associated progress, the text to display - * while the operation is occurring. - * - * @param {String} [notification.progress.value] - * The current state of operation progress, as an arbitrary number - * which increases as the operation continues. - * - * @param {String} [notification.progress.unit] - * The unit of the arbitrary notification.progress.value, if that value - * has an associated unit. - * - * @param {String} [notification.progress.ratio] - * If known, the current status of the operation as a value between - * 0 and 1 inclusive, where 0 is not yet started, and 1 is complete. - * - * @param {Object[]} [notification.actions] - * Array of action objects which contain an action name and callback to - * be executed when that action is invoked. - * - * @returns {Number} A unique ID for the notification that's just been added. + * @returns {Number} + * A unique ID for the notification that's just been added. * * @example * diff --git a/guacamole/src/main/webapp/app/notification/directives/guacNotification.js b/guacamole/src/main/webapp/app/notification/directives/guacNotification.js index f8fb8334b..e6c36ef58 100644 --- a/guacamole/src/main/webapp/app/notification/directives/guacNotification.js +++ b/guacamole/src/main/webapp/app/notification/directives/guacNotification.js @@ -31,110 +31,11 @@ angular.module('notification').directive('guacNotification', [function guacNotif scope: { /** - * The CSS class to apply to the notification. + * The notification to display. * - * @type String + * @type Notification|Object */ - className : '=', - - /** - * The title of the notification. - * - * @type String - */ - title : '=', - - /** - * The body text of the notification. - * - * @type String - */ - text : '=', - - /** - * The text to use for displaying the countdown. For the sake of - * i18n, the variable REMAINING will be applied within the - * translation string for formatting plurals, etc. - * - * @type String - * @example - * "Only {REMAINING} {REMAINING, plural, one{second} other{seconds}} remain." - */ - countdownText : '=', - - /** - * The number of seconds to wait before automatically calling the - * default callback. - * - * @type Number - */ - countdown : '=', - - /** - * The function to call when timeRemaining expires. If timeRemaining - * is not set, this does not apply. - * - * @type Function - */ - defaultCallback : '=', - - /** - * The text to use for displaying the progress. For the sake of - * i18n, the variable PROGRESS will be applied within the - * translation string for formatting plurals, etc., while the - * variable UNIT will be applied, if needed, for whatever units - * are applicable to the progress display. - * - * @type String - * @example - * "{PROGRESS} {UNIT, select, b{B} kb{KB}} uploaded." - */ - progressText : '=', - - /** - * The unit which applies to the progress indicator, if any. This - * will be substituted in the progressText string with the UNIT - * variable. - * - * @type String - */ - progressUnit : '=', - - /** - * Arbitrary value denoting how much progress has been made - * in some ongoing task that this notification represents. - * - * @type Number - */ - progress : '=', - - /** - * Value between 0 and 1 denoting what proportion of the operation - * has completed. If known, this value should be 0 if the operation - * has not started, and 1 if the operation is complete. - * - * @type Number - */ - progressRatio : '=', - - /** - * Array of name/callback pairs for each action the user is allowed - * to take once the notification is shown. - * - * @type Array - * @example - * [ - * { - * name : "Action 1 name", - * callback : actionCallback1 - * }, - * { - * name : "Action 2 text", - * callback : actionCallback2 - * } - * ] - */ - actions : '=' + notification : '=' }, @@ -142,21 +43,22 @@ angular.module('notification').directive('guacNotification', [function guacNotif controller: ['$scope', '$interval', function guacNotificationController($scope, $interval) { // Update progress bar if end known - $scope.$watch("progressRatio", function updateProgress(ratio) { + $scope.$watch("notification.progress.ratio", function updateProgress(ratio) { $scope.progressPercent = ratio * 100; }); - // Set countdown interval when associated property is set - $scope.$watch("countdown", function resetTimeRemaining(countdown) { + $scope.$watch("notification", function resetTimeRemaining(notification) { - $scope.timeRemaining = countdown; + var countdown = notification.countdown; // Clean up any existing interval if ($scope.interval) $interval.cancel($scope.interval); // Update and handle countdown, if provided - if ($scope.timeRemaining) { + if (countdown) { + + $scope.timeRemaining = countdown.remaining; $scope.interval = $interval(function updateTimeRemaining() { @@ -164,8 +66,8 @@ angular.module('notification').directive('guacNotification', [function guacNotif $scope.timeRemaining--; // Call countdown callback when time remaining expires - if ($scope.timeRemaining === 0 && $scope.defaultCallback) - $scope.defaultCallback(); + if ($scope.timeRemaining === 0) + countdown.performAction(); }, 1000, $scope.timeRemaining); @@ -184,4 +86,4 @@ angular.module('notification').directive('guacNotification', [function guacNotif }] }; -}]); \ No newline at end of file +}]); diff --git a/guacamole/src/main/webapp/app/notification/templates/guacNotification.html b/guacamole/src/main/webapp/app/notification/templates/guacNotification.html index 0691f663e..50d484fb2 100644 --- a/guacamole/src/main/webapp/app/notification/templates/guacNotification.html +++ b/guacamole/src/main/webapp/app/notification/templates/guacNotification.html @@ -1,4 +1,4 @@ -