From dc5feb8b1a816f1f74d15db0a7d7277bc6d32cd5 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 10:54:48 -0700 Subject: [PATCH 01/13] Added some documentation to notification and dialog launchers --- testing/dialogTest/res/dialog-launch.html | 3 +- .../dialogTest/res/notification-launch.html | 2 +- .../dialogTest/src/DialogLaunchController.js | 105 ++++++------------ .../dialogTest/src/DialogLaunchIndicator.js | 6 + .../src/NotificationLaunchController.js | 54 +++++++-- 5 files changed, 86 insertions(+), 84 deletions(-) diff --git a/testing/dialogTest/res/dialog-launch.html b/testing/dialogTest/res/dialog-launch.html index 1b117c2ebf..bc56e6b4f2 100644 --- a/testing/dialogTest/res/dialog-launch.html +++ b/testing/dialogTest/res/dialog-launch.html @@ -3,7 +3,8 @@ Known | Unknown | - Error + Error | + Info Dialogs \ No newline at end of file diff --git a/testing/dialogTest/res/notification-launch.html b/testing/dialogTest/res/notification-launch.html index e9b7e8f84e..1e077bf3be 100644 --- a/testing/dialogTest/res/notification-launch.html +++ b/testing/dialogTest/res/notification-launch.html @@ -1,7 +1,7 @@ - Success | + Success | Error | Alert | Progress diff --git a/testing/dialogTest/src/DialogLaunchController.js b/testing/dialogTest/src/DialogLaunchController.js index bc8cdcb419..42882a0dfe 100644 --- a/testing/dialogTest/src/DialogLaunchController.js +++ b/testing/dialogTest/src/DialogLaunchController.js @@ -26,7 +26,23 @@ define( function (MessageSeverity) { "use strict"; + /** + * A controller for the dialog launch view. This view allows manual + * launching of dialogs for demonstration and testing purposes. It + * also demonstrates the use of the DialogService. + * @param $scope + * @param $timeout + * @param $log + * @param dialogService + * @param notificationService + * @constructor + */ function DialogLaunchController($scope, $timeout, $log, dialogService, notificationService) { + + /* + Demonstrates launching a progress dialog and updating it + periodically with the progress of an ongoing process. + */ $scope.launchProgress = function (knownProgress) { var model = { title: "Progress Dialog Example", @@ -72,6 +88,10 @@ define( } }; + + /* + Demonstrates launching an error dialog + */ $scope.launchError = function () { var model = { title: "Error Dialog Example", @@ -100,87 +120,32 @@ define( } }; - $scope.launchMessages = function () { + /* + Demonstrates launching an error dialog + */ + $scope.launchInfo = function () { var model = { - title: "Messages", + title: "Info Dialog Example", + actionText: "This is an example of a blocking info" + + " dialog. This dialog can be used to draw the user's" + + " attention to an event.", severity: MessageSeverity.INFO, actions: [ { - label: "Done", + label: "OK", action: function () { + $log.debug("OK Pressed"); dialogService.dismiss(); } - } - ], - messages: [] + }, + ] }; - function getExampleActionText() { - var actionTexts = [ - "Adipiscing turpis mauris in enim elementu hac, enim aliquam etiam.", - "Eros turpis, pulvinar turpis eros eu", - "Lundium nascetur a, lectus montes ac, parturient in natoque, duis risus risus pulvinar pid rhoncus, habitasse auctor natoque!" - ]; - return actionTexts[Math.floor(Math.random()*3)]; + if (!dialogService.showBlockingMessage(model)) { + $log.error("Could not display modal dialog"); } - - function getExampleActions() { - var actions = [ - { - label: "Try Again", - action: function () { - $log.debug("Try Again pressed"); - } - }, - { - label: "Remove", - action: function () { - $log.debug("Remove pressed"); - } - }, - { - label: "Cancel", - action: function () { - $log.debug("Cancel pressed"); - } - } - ]; - - // Randomly remove some actions off the top; leave at least one - actions.splice(0,Math.floor(Math.random() * actions.length)); - - return actions; - } - - function getExampleSeverity() { - var severities = [ - MessageSeverity.INFO, - MessageSeverity.ALERT, - MessageSeverity.ERROR - ]; - return severities[Math.floor(Math.random() * severities.length)]; - } - - function createMessage (messageNumber) { - var messageModel = { - title: "Message Title " + messageNumber, - actionText: getExampleActionText(), - severity: getExampleSeverity(), - actions: getExampleActions() - }; - return messageModel; - } - - function dismiss() { - dialogService.dismiss(); - } - - model.messages = notificationService.notifications; - dialogService.getDialogResponse('overlay-message-list', { - dialog: model, - cancel: dismiss - }); }; + } return DialogLaunchController; } diff --git a/testing/dialogTest/src/DialogLaunchIndicator.js b/testing/dialogTest/src/DialogLaunchIndicator.js index 47c516fc70..9330ce2194 100644 --- a/testing/dialogTest/src/DialogLaunchIndicator.js +++ b/testing/dialogTest/src/DialogLaunchIndicator.js @@ -26,6 +26,12 @@ define( function () { "use strict"; + /** + * A tool for manually invoking dialogs. When included this + * indicator will allow for dialogs of different types to be + * launched for demonstration and testing purposes. + * @constructor + */ function DialogLaunchIndicator() { } diff --git a/testing/dialogTest/src/NotificationLaunchController.js b/testing/dialogTest/src/NotificationLaunchController.js index 63b436a894..b45bbfc094 100644 --- a/testing/dialogTest/src/NotificationLaunchController.js +++ b/testing/dialogTest/src/NotificationLaunchController.js @@ -26,14 +26,21 @@ define( function (MessageSeverity) { "use strict"; + /** + * Allows launching of notification messages for the purposes of + * demonstration and testing. Also demonstrates use of + * the NotificationService. Notifications are non-blocking messages that + * appear at the bottom of the screen to inform the user of events + * in a non-intrusive way. For more information see the + * {@link NotificationService} + * @param $scope + * @param $timeout + * @param $log + * @param notificationService + * @constructor + */ function NotificationLaunchController($scope, $timeout, $log, notificationService) { var messageCounter = 1; - $scope.newSuccess = function(){ - - notificationService.info({ - title: "Success notification!" - }); - }; function getExampleActionText() { var actionTexts = [ @@ -80,11 +87,14 @@ define( ]; return severities[Math.floor(Math.random() * severities.length)]; } - + + /** + * Launch a new notification with a severity level of 'Error'. + */ $scope.newError = function(){ notificationService.notify({ - title: "Error notification " + messageCounter++ + "!", + title: "Example error notification " + messageCounter++, hint: "An error has occurred", severity: MessageSeverity.ERROR, primaryAction: { @@ -95,11 +105,13 @@ define( }, actions: getExampleActions()}); }; - + /** + * Launch a new notification with a severity of 'Alert'. + */ $scope.newAlert = function(){ notificationService.notify({ - title: "Alert notification " + (messageCounter++) + "!", + title: "Alert notification " + (messageCounter++), hint: "This is an alert message", severity: MessageSeverity.ALERT, primaryAction: { @@ -111,17 +123,25 @@ define( actions: getExampleActions()}); }; + + /** + * Launch a new notification with a progress bar that is updated + * periodically, tracking an ongoing process. + */ $scope.newProgress = function(){ var notification = { - title: "Progress notification!", + title: "Progress notification example", severity: MessageSeverity.INFO, progress: 0, actionText: getExampleActionText(), unknownProgress: false - }; + /** + * Simulate an ongoing process and update the progress bar. + * @param notification + */ function incrementProgress(notification) { notification.progress = Math.min(100, Math.floor(notification.progress + Math.random() * 30)); notification.progressText = ["Estimated time remaining:" + @@ -135,6 +155,16 @@ define( incrementProgress(notification); }; + /** + * Launch a new notification with severity level of INFO. + */ + $scope.newInfo = function(){ + + notificationService.info({ + title: "Example Info notification " + messageCounter++ + }); + }; + } return NotificationLaunchController; } From 0628398b01ba4ac9c97eb05488d64ee4ead4891e Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 13:30:34 -0700 Subject: [PATCH 02/13] Moved notifications examples from 'testing' to examples --- bundles.json | 3 +-- {testing/dialogTest => example/notifications}/bundle.json | 0 .../notifications}/res/dialog-launch.html | 0 .../notifications}/res/notification-launch.html | 0 .../notifications}/src/DialogLaunchController.js | 0 .../notifications}/src/DialogLaunchIndicator.js | 0 .../notifications}/src/NotificationLaunchController.js | 0 .../notifications}/src/NotificationLaunchIndicator.js | 0 8 files changed, 1 insertion(+), 2 deletions(-) rename {testing/dialogTest => example/notifications}/bundle.json (100%) rename {testing/dialogTest => example/notifications}/res/dialog-launch.html (100%) rename {testing/dialogTest => example/notifications}/res/notification-launch.html (100%) rename {testing/dialogTest => example/notifications}/src/DialogLaunchController.js (100%) rename {testing/dialogTest => example/notifications}/src/DialogLaunchIndicator.js (100%) rename {testing/dialogTest => example/notifications}/src/NotificationLaunchController.js (100%) rename {testing/dialogTest => example/notifications}/src/NotificationLaunchIndicator.js (100%) diff --git a/bundles.json b/bundles.json index c85b681bf5..7119dc690a 100644 --- a/bundles.json +++ b/bundles.json @@ -31,6 +31,5 @@ "example/imagery", "example/eventGenerator", "example/generator", - - "testing/dialogTest" + "example/notifications" ] diff --git a/testing/dialogTest/bundle.json b/example/notifications/bundle.json similarity index 100% rename from testing/dialogTest/bundle.json rename to example/notifications/bundle.json diff --git a/testing/dialogTest/res/dialog-launch.html b/example/notifications/res/dialog-launch.html similarity index 100% rename from testing/dialogTest/res/dialog-launch.html rename to example/notifications/res/dialog-launch.html diff --git a/testing/dialogTest/res/notification-launch.html b/example/notifications/res/notification-launch.html similarity index 100% rename from testing/dialogTest/res/notification-launch.html rename to example/notifications/res/notification-launch.html diff --git a/testing/dialogTest/src/DialogLaunchController.js b/example/notifications/src/DialogLaunchController.js similarity index 100% rename from testing/dialogTest/src/DialogLaunchController.js rename to example/notifications/src/DialogLaunchController.js diff --git a/testing/dialogTest/src/DialogLaunchIndicator.js b/example/notifications/src/DialogLaunchIndicator.js similarity index 100% rename from testing/dialogTest/src/DialogLaunchIndicator.js rename to example/notifications/src/DialogLaunchIndicator.js diff --git a/testing/dialogTest/src/NotificationLaunchController.js b/example/notifications/src/NotificationLaunchController.js similarity index 100% rename from testing/dialogTest/src/NotificationLaunchController.js rename to example/notifications/src/NotificationLaunchController.js diff --git a/testing/dialogTest/src/NotificationLaunchIndicator.js b/example/notifications/src/NotificationLaunchIndicator.js similarity index 100% rename from testing/dialogTest/src/NotificationLaunchIndicator.js rename to example/notifications/src/NotificationLaunchIndicator.js From 0053989de893b4ef9feee891e8e940a0a4825104 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 14:14:21 -0700 Subject: [PATCH 03/13] renamed dialog and notification 'actions' to 'options' --- .../src/DialogLaunchController.js | 16 ++++++++-------- .../src/NotificationLaunchController.js | 18 +++++++++--------- .../commonUI/dialog/res/templates/message.html | 12 ++++++------ platform/commonUI/dialog/src/DialogService.js | 6 +++--- .../general/res/templates/message-banner.html | 6 +++--- .../notification/src/NotificationService.js | 10 +++++----- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/example/notifications/src/DialogLaunchController.js b/example/notifications/src/DialogLaunchController.js index 42882a0dfe..5679f990a0 100644 --- a/example/notifications/src/DialogLaunchController.js +++ b/example/notifications/src/DialogLaunchController.js @@ -52,17 +52,17 @@ define( unknownProgress: !knownProgress, unknownDuration: false, severity: MessageSeverity.INFO, - actions: [ + options: [ { label: "Cancel Operation", - action: function () { + callback: function () { $log.debug("Operation cancelled"); dialogService.dismiss(); } }, { label: "Do something else...", - action: function () { + callback: function () { $log.debug("Something else pressed"); } } @@ -97,17 +97,17 @@ define( title: "Error Dialog Example", actionText: "Something happened, and it was not good.", severity: MessageSeverity.ERROR, - actions: [ + options: [ { label: "Try Again", - action: function () { + callback: function () { $log.debug("Try Again Pressed"); dialogService.dismiss(); } }, { label: "Cancel", - action: function () { + callback: function () { $log.debug("Cancel Pressed"); dialogService.dismiss(); } @@ -130,10 +130,10 @@ define( " dialog. This dialog can be used to draw the user's" + " attention to an event.", severity: MessageSeverity.INFO, - actions: [ + options: [ { label: "OK", - action: function () { + callback: function () { $log.debug("OK Pressed"); dialogService.dismiss(); } diff --git a/example/notifications/src/NotificationLaunchController.js b/example/notifications/src/NotificationLaunchController.js index b45bbfc094..e59c009422 100644 --- a/example/notifications/src/NotificationLaunchController.js +++ b/example/notifications/src/NotificationLaunchController.js @@ -55,19 +55,19 @@ define( var actions = [ { label: "Try Again", - action: function () { + callback: function () { $log.debug("Try Again pressed"); } }, { label: "Remove", - action: function () { + callback: function () { $log.debug("Remove pressed"); } }, { label: "Cancel", - action: function () { + callback: function () { $log.debug("Cancel pressed"); } } @@ -97,13 +97,13 @@ define( title: "Example error notification " + messageCounter++, hint: "An error has occurred", severity: MessageSeverity.ERROR, - primaryAction: { + primaryOption: { label: 'Retry', - action: function() { + callback: function() { $log.info('Retry clicked'); } }, - actions: getExampleActions()}); + options: getExampleActions()}); }; /** * Launch a new notification with a severity of 'Alert'. @@ -114,13 +114,13 @@ define( title: "Alert notification " + (messageCounter++), hint: "This is an alert message", severity: MessageSeverity.ALERT, - primaryAction: { + primaryOption: { label: 'Retry', - action: function() { + callback: function() { $log.info('Retry clicked'); } }, - actions: getExampleActions()}); + options: getExampleActions()}); }; diff --git a/platform/commonUI/dialog/res/templates/message.html b/platform/commonUI/dialog/res/templates/message.html index ecf598daf4..6b8c5c99cc 100644 --- a/platform/commonUI/dialog/res/templates/message.html +++ b/platform/commonUI/dialog/res/templates/message.html @@ -19,15 +19,15 @@ ng-show="ngModel.progress !== undefined || ngModel.unknownProgress"> diff --git a/platform/commonUI/dialog/src/DialogService.js b/platform/commonUI/dialog/src/DialogService.js index 215d64fead..27ffa9ae8b 100644 --- a/platform/commonUI/dialog/src/DialogService.js +++ b/platform/commonUI/dialog/src/DialogService.js @@ -178,7 +178,7 @@ define( * A user action that can be performed from a blocking dialog. These * actions will be rendered as buttons within a blocking dialog. * - * @typedef DialogAction + * @typedef DialogOption * @property {string} label a label to be displayed as the button * text for this action * @property {function} action a function to be called when the @@ -207,12 +207,12 @@ define( * impossible to provide an estimate for. Providing a true value for * this attribute will indicate to the user that the progress and * duration cannot be estimated. - * @property {DialogAction} primaryAction an action that will + * @property {DialogOption} primaryOption an action that will * be added to the dialog as a button. The primary action can be * used as the suggested course of action for the user. Making it * distinct from other actions allows it to be styled differently, * and treated preferentially in banner mode. - * @property {DialogAction[]} actions a list of actions that will + * @property {DialogOption[]} options a list of actions that will * be added to the dialog as buttons. */ diff --git a/platform/commonUI/general/res/templates/message-banner.html b/platform/commonUI/general/res/templates/message-banner.html index 629fc1080d..0af92aeba5 100644 --- a/platform/commonUI/general/res/templates/message-banner.html +++ b/platform/commonUI/general/res/templates/message-banner.html @@ -14,10 +14,10 @@ ng-model="active.notification"> - diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index 411e3727cb..c11b92c651 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -37,13 +37,13 @@ define( "use strict"; /** - * A representation of a user action. Actions are provided to + * A representation of a user action. Options are provided to * dialogs and notifications and are shown as buttons. * - * @typedef {object} NotificationAction + * @typedef {object} NotificationOption * @property {string} label the label to appear on the button for * this action - * @property {function} action a callback function to be invoked + * @property {function} callback a callback function to be invoked * when the button is clicked */ @@ -67,12 +67,12 @@ define( * be automatically minimized or dismissed (depending on severity). * Additionally, if the provided value is a number, it will be used * as the delay period before being dismissed. - * @property {NotificationAction} primaryAction the default user + * @property {NotificationOption} primaryOption the default user * response to * this message. Will be represented as a button with the provided * label and action. May be used by banner notifications to display * only the most important option to users. - * @property {NotificationAction[]} actions any additional + * @property {NotificationOption[]} options any additional * actions the user can take. Will be represented as additional buttons * that may or may not be available from a banner. */ From 109ae3323d89192ad636e95825260f3e807d2c0d Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 15:10:53 -0700 Subject: [PATCH 04/13] Added jsdoc and moved MessageController to dialogs from notifications --- platform/commonUI/dialog/bundle.json | 7 ++++++ .../src/MessageController.js | 15 ++++++++++- .../src/controllers/BannerController.js | 19 ++++++++++++++ platform/commonUI/notification/bundle.json | 5 ---- .../src/NotificationIndicatorController.js | 25 +++++++++++-------- 5 files changed, 55 insertions(+), 16 deletions(-) rename platform/commonUI/{notification => dialog}/src/MessageController.js (68%) diff --git a/platform/commonUI/dialog/bundle.json b/platform/commonUI/dialog/bundle.json index 80cd456c20..fb94f14b61 100644 --- a/platform/commonUI/dialog/bundle.json +++ b/platform/commonUI/dialog/bundle.json @@ -43,6 +43,13 @@ "key": "overlay", "templateUrl": "templates/overlay.html" } + ], + "controllers": [ + { + "key": "MessageController", + "implementation": "MessageController.js", + "depends": ["$scope"] + } ] } } \ No newline at end of file diff --git a/platform/commonUI/notification/src/MessageController.js b/platform/commonUI/dialog/src/MessageController.js similarity index 68% rename from platform/commonUI/notification/src/MessageController.js rename to platform/commonUI/dialog/src/MessageController.js index 390f4463d3..595f429f9e 100644 --- a/platform/commonUI/notification/src/MessageController.js +++ b/platform/commonUI/dialog/src/MessageController.js @@ -22,10 +22,23 @@ /*global define*/ define( - ['./MessageSeverity'], + ['../../notification/src/MessageSeverity'], function (MessageSeverity) { "use strict"; + /** + * A controller for the message view which used to represent a + * message to the user in the dialogs and notifications systems. The + * message view (../res/templates/message.html) is included + * from the blocking message dialog + * (../res/templates/overlay-blocking-message.html), + * and the message list (../res/templates/overlay-message-list.html) + * shown from the notifications indicator + * @param $scope + * @constructor + * @see DialogService#showBlockingMessage + * @see NotificationService + */ function MessageController($scope) { $scope.MessageSeverity = MessageSeverity; } diff --git a/platform/commonUI/general/src/controllers/BannerController.js b/platform/commonUI/general/src/controllers/BannerController.js index a59860f884..c3f698fc38 100644 --- a/platform/commonUI/general/src/controllers/BannerController.js +++ b/platform/commonUI/general/src/controllers/BannerController.js @@ -25,10 +25,29 @@ define( ['../../../notification/src/MessageSeverity'], function (MessageSeverity) { "use strict"; + + /** + * A controller for banner notifications. Banner notifications are a + * non-blocking way of drawing the user's attention to an event such + * as system errors, or the progress or successful completion of an + * ongoing task. This controller provides scoped functions for + * dismissing and 'maximizing' notifications. See {@link NotificationService} + * for more details on Notifications. + * + * @param $scope + * @param notificationService + * @param dialogService + * @constructor + */ function BannerController($scope, notificationService, dialogService) { $scope.active = notificationService.active; $scope.MessageSeverity = MessageSeverity; + $scope.action = function (action, $event){ + /* + Prevents default 'maximize' behaviour when clicking on + notification button + */ $event.stopPropagation(); return action(); }; diff --git a/platform/commonUI/notification/bundle.json b/platform/commonUI/notification/bundle.json index d729e42673..f4dbd5c71a 100644 --- a/platform/commonUI/notification/bundle.json +++ b/platform/commonUI/notification/bundle.json @@ -21,11 +21,6 @@ } ], "controllers": [ - { - "key": "MessageController", - "implementation": "MessageController.js", - "depends": ["$scope"] - }, { "key": "NotificationIndicatorController", "implementation": "NotificationIndicatorController.js", diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index 9571b0f6a4..e225fd41bf 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -26,25 +26,30 @@ define( function (MessageSeverity) { "use strict"; + /** + * Provides an indicator that is visible when there are + * banner notifications that have been minimized. Will also indicate + * the number of notifications. Notifications can be viewed by + * clicking on the indicator to launch a dialog showing a list of + * notifications. + * @param $scope + * @param notificationService + * @param dialogService + * @constructor + */ function NotificationIndicatorController($scope, notificationService, dialogService) { $scope.notifications = notificationService.notifications; $scope.highest = notificationService.highest; $scope.MessageSeverity = MessageSeverity; + /** + * Launch a dialog showing a list of current notifications. + */ $scope.showNotificationsList = function(){ var model = { title: "Messages", - severity: MessageSeverity.INFO, - actions: [ - { - label: "Done", - action: function () { - dialogService.dismiss(); - } - } - ], - messages: [] + severity: MessageSeverity.INFO }; model.messages = notificationService.notifications; From 83276d70d3942a9b46d9a176e4398841e725e51b Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 16:29:10 -0700 Subject: [PATCH 05/13] Removed MessageSeverity enum and MessageController --- .../src/DialogLaunchController.js | 10 +-- .../src/NotificationLaunchController.js | 16 ++--- platform/commonUI/dialog/bundle.json | 7 -- .../dialog/res/templates/message.html | 8 +-- .../commonUI/dialog/src/MessageController.js | 47 ------------- .../general/res/templates/message-banner.html | 5 +- .../src/controllers/BannerController.js | 7 +- .../res/notification-indicator.html | 5 +- .../notification/src/MessageSeverity.js | 11 --- .../src/NotificationIndicatorController.js | 8 +-- .../notification/src/NotificationService.js | 29 ++++---- .../test/NotificationServiceSpec.js | 69 ++----------------- 12 files changed, 44 insertions(+), 178 deletions(-) delete mode 100644 platform/commonUI/dialog/src/MessageController.js delete mode 100644 platform/commonUI/notification/src/MessageSeverity.js diff --git a/example/notifications/src/DialogLaunchController.js b/example/notifications/src/DialogLaunchController.js index 5679f990a0..e6a8b4e132 100644 --- a/example/notifications/src/DialogLaunchController.js +++ b/example/notifications/src/DialogLaunchController.js @@ -22,8 +22,8 @@ /*global define*/ define( - ['../../../platform/commonUI/notification/src/MessageSeverity'], - function (MessageSeverity) { + [], + function () { "use strict"; /** @@ -51,7 +51,7 @@ define( actionText: "Calculating...", unknownProgress: !knownProgress, unknownDuration: false, - severity: MessageSeverity.INFO, + severity: "info", options: [ { label: "Cancel Operation", @@ -96,7 +96,7 @@ define( var model = { title: "Error Dialog Example", actionText: "Something happened, and it was not good.", - severity: MessageSeverity.ERROR, + severity: "error", options: [ { label: "Try Again", @@ -129,7 +129,7 @@ define( actionText: "This is an example of a blocking info" + " dialog. This dialog can be used to draw the user's" + " attention to an event.", - severity: MessageSeverity.INFO, + severity: "info", options: [ { label: "OK", diff --git a/example/notifications/src/NotificationLaunchController.js b/example/notifications/src/NotificationLaunchController.js index e59c009422..7d0618ada4 100644 --- a/example/notifications/src/NotificationLaunchController.js +++ b/example/notifications/src/NotificationLaunchController.js @@ -22,8 +22,8 @@ /*global define*/ define( - ['../../../platform/commonUI/notification/src/MessageSeverity'], - function (MessageSeverity) { + [], + function () { "use strict"; /** @@ -81,9 +81,9 @@ define( function getExampleSeverity() { var severities = [ - MessageSeverity.INFO, - MessageSeverity.ALERT, - MessageSeverity.ERROR + "info", + "alert", + "error" ]; return severities[Math.floor(Math.random() * severities.length)]; } @@ -96,7 +96,7 @@ define( notificationService.notify({ title: "Example error notification " + messageCounter++, hint: "An error has occurred", - severity: MessageSeverity.ERROR, + severity: "error", primaryOption: { label: 'Retry', callback: function() { @@ -113,7 +113,7 @@ define( notificationService.notify({ title: "Alert notification " + (messageCounter++), hint: "This is an alert message", - severity: MessageSeverity.ALERT, + severity: "alert", primaryOption: { label: 'Retry', callback: function() { @@ -132,7 +132,7 @@ define( var notification = { title: "Progress notification example", - severity: MessageSeverity.INFO, + severity: "info", progress: 0, actionText: getExampleActionText(), unknownProgress: false diff --git a/platform/commonUI/dialog/bundle.json b/platform/commonUI/dialog/bundle.json index fb94f14b61..80cd456c20 100644 --- a/platform/commonUI/dialog/bundle.json +++ b/platform/commonUI/dialog/bundle.json @@ -43,13 +43,6 @@ "key": "overlay", "templateUrl": "templates/overlay.html" } - ], - "controllers": [ - { - "key": "MessageController", - "implementation": "MessageController.js", - "depends": ["$scope"] - } ] } } \ No newline at end of file diff --git a/platform/commonUI/dialog/res/templates/message.html b/platform/commonUI/dialog/res/templates/message.html index 6b8c5c99cc..8568fe5fb1 100644 --- a/platform/commonUI/dialog/res/templates/message.html +++ b/platform/commonUI/dialog/res/templates/message.html @@ -1,9 +1,5 @@ -
+
diff --git a/platform/commonUI/dialog/src/MessageController.js b/platform/commonUI/dialog/src/MessageController.js deleted file mode 100644 index 595f429f9e..0000000000 --- a/platform/commonUI/dialog/src/MessageController.js +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************************** - * Open MCT Web, Copyright (c) 2014-2015, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT Web is licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * Open MCT Web includes source code licensed under additional open source - * licenses. See the Open Source Licenses file (LICENSES.md) included with - * this source code distribution or the Licensing information page available - * at runtime from the About dialog for additional information. - *****************************************************************************/ -/*global define*/ - -define( - ['../../notification/src/MessageSeverity'], - function (MessageSeverity) { - "use strict"; - - /** - * A controller for the message view which used to represent a - * message to the user in the dialogs and notifications systems. The - * message view (../res/templates/message.html) is included - * from the blocking message dialog - * (../res/templates/overlay-blocking-message.html), - * and the message list (../res/templates/overlay-message-list.html) - * shown from the notifications indicator - * @param $scope - * @constructor - * @see DialogService#showBlockingMessage - * @see NotificationService - */ - function MessageController($scope) { - $scope.MessageSeverity = MessageSeverity; - } - return MessageController; - } -); diff --git a/platform/commonUI/general/res/templates/message-banner.html b/platform/commonUI/general/res/templates/message-banner.html index 0af92aeba5..29b107126e 100644 --- a/platform/commonUI/general/res/templates/message-banner.html +++ b/platform/commonUI/general/res/templates/message-banner.html @@ -1,8 +1,5 @@
diff --git a/platform/commonUI/general/src/controllers/BannerController.js b/platform/commonUI/general/src/controllers/BannerController.js index c3f698fc38..511bf23b38 100644 --- a/platform/commonUI/general/src/controllers/BannerController.js +++ b/platform/commonUI/general/src/controllers/BannerController.js @@ -22,8 +22,8 @@ /*global define*/ define( - ['../../../notification/src/MessageSeverity'], - function (MessageSeverity) { + [], + function () { "use strict"; /** @@ -41,7 +41,6 @@ define( */ function BannerController($scope, notificationService, dialogService) { $scope.active = notificationService.active; - $scope.MessageSeverity = MessageSeverity; $scope.action = function (action, $event){ /* @@ -56,7 +55,7 @@ define( notificationService.dismissOrMinimize(notification); }; $scope.maximize = function(notification) { - if (notification.severity > MessageSeverity.INFO){ + if (notification.severity != "info"){ notification.cancel = function(){ dialogService.dismiss(); }; diff --git a/platform/commonUI/notification/res/notification-indicator.html b/platform/commonUI/notification/res/notification-indicator.html index 1d2bf90960..9c7e80a639 100644 --- a/platform/commonUI/notification/res/notification-indicator.html +++ b/platform/commonUI/notification/res/notification-indicator.html @@ -1,8 +1,5 @@ diff --git a/platform/commonUI/notification/src/MessageSeverity.js b/platform/commonUI/notification/src/MessageSeverity.js deleted file mode 100644 index 44064bf92f..0000000000 --- a/platform/commonUI/notification/src/MessageSeverity.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Created by akhenry on 10/7/15. - */ -/*global define*/ -define(function(){ - return { - INFO: 0, - ALERT: 1, - ERROR: 2 - }; -}); \ No newline at end of file diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index e225fd41bf..21da649a8f 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -22,8 +22,8 @@ /*global define*/ define( - ['./MessageSeverity'], - function (MessageSeverity) { + [], + function () { "use strict"; /** @@ -40,7 +40,6 @@ define( function NotificationIndicatorController($scope, notificationService, dialogService) { $scope.notifications = notificationService.notifications; $scope.highest = notificationService.highest; - $scope.MessageSeverity = MessageSeverity; /** * Launch a dialog showing a list of current notifications. @@ -48,8 +47,7 @@ define( $scope.showNotificationsList = function(){ var model = { - title: "Messages", - severity: MessageSeverity.INFO + title: "Messages" }; model.messages = notificationService.notifications; diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index c11b92c651..2e1a44a1a8 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -32,8 +32,8 @@ * @namespace platform/commonUI/dialog */ define( - ["./MessageSeverity"], - function (MessageSeverity) { + [], + function () { "use strict"; /** @@ -56,8 +56,9 @@ define( * * @typedef {object} Notification * @property {string} title The title of the message - * @property {MessageSeverity} severity The importance of the - * message (eg. error, info) + * @property {string} severity The importance of the + * message (one of 'info', 'alert', or 'error' where info < alert < + * error) * @property {number} progress The completion status of a task * represented numerically * @property {boolean} unknownProgress a boolean indicating that the @@ -91,7 +92,7 @@ define( function NotificationService($timeout, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) { this.notifications = []; this.$timeout = $timeout; - this.highest ={ severity: MessageSeverity.INFO }; + this.highest ={ severity: "info" }; this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS; this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT; @@ -118,7 +119,7 @@ define( */ NotificationService.prototype.info = function (notification) { notification.autoDismiss = notification.autoDismiss || true; - notification.severity = MessageSeverity.INFO; + notification.severity = "info"; this.notify(notification); }; @@ -130,13 +131,18 @@ define( * @param {Notification} notification The notification to display */ NotificationService.prototype.notify = function (notification) { - var self = this; - + var self = this, + ordinality = { + "info": 1, + "alert": 2, + "error": 3 + }; + notification.severity = notification.severity || "info" if (notification.autoDismiss === true){ notification.autoDismiss = this.DEFAULT_AUTO_DISMISS; } - if (notification.severity > this.highest.severity){ + if (ordinality[notification.severity.toLowerCase()] > ordinality[this.highest.severity.toLowerCase()]){ this.highest.severity = notification.severity; } @@ -271,11 +277,6 @@ define( //For now minimize everything, and have discussion around which //kind of messages should or should not be in the minimized //notifications list - /*if (notification.severity > MessageSeverity.INFO){ - this.minimize(notification); - } else { - this.dismiss(notification); - }*/ this.minimize(notification); }; diff --git a/platform/commonUI/notification/test/NotificationServiceSpec.js b/platform/commonUI/notification/test/NotificationServiceSpec.js index 3957fe622e..dca76652ce 100644 --- a/platform/commonUI/notification/test/NotificationServiceSpec.js +++ b/platform/commonUI/notification/test/NotificationServiceSpec.js @@ -22,8 +22,8 @@ /*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ define( - ['../src/NotificationService','../src/MessageSeverity'], - function (NotificationService, MessageSeverity) { + ['../src/NotificationService'], + function (NotificationService) { "use strict"; describe("The notification service ", function () { @@ -34,46 +34,6 @@ define( successModel, errorModel; - /** - * 1) Calling .notify results in a new notification being created - * with the provided model and set to the active notification. DONE - * - * 2) Calling .notify with autoDismiss results in a SUCCESS notification - * becoming dismissed after timeout has elapsed DONE - * - * 3) Calling .notify with autoDismiss results in an ERROR notification - * being MINIMIZED after a timeout has elapsed DONE - * - * 4) Calling .notify with an active info notification results in that - * notification being auto-dismissed, and the new notification becoming - * active. DONE - * - * 5) Calling .notify with an active error notification results in that - * notification being auto-minimized and the new notification becoming - * active. DONE - * - * 6) Calling .notify with an active error notification, AND a - * queued error notification results in the active notification - * being auto-dismissed, the next message in the queue becoming - * active, then auto-dismissed, and then the provided notification - * becoming active. - */ - - /** - var model = { - title: string, - progress: number, - severity: MessageSeverity, - unknownProgress: boolean, - minimized: boolean, - autoDismiss: boolean | number, - actions: { - label: string, - action: function - } - } - */ - beforeEach(function(){ mockTimeout = jasmine.createSpy("$timeout"); mockAutoDismiss = mockMinimizeTimeout = 1000; @@ -81,11 +41,11 @@ define( mockTimeout, mockAutoDismiss, mockMinimizeTimeout); successModel = { title: "Mock Success Notification", - severity: MessageSeverity.INFO + severity: "info" }; errorModel = { title: "Mock Error Notification", - severity: MessageSeverity.ERROR + severity: "error" }; }); @@ -147,23 +107,6 @@ define( activeNotification = notificationService.getActiveNotification(); expect(activeNotification).toBe(errorModel); }); - /* Test is temporarily invalid as info messages are being - minimized - it("auto-dismisses an active success notification, removing" + - " it completely", function() { - //First pre-load with a info message - notificationService.notify(successModel); - //Then notify of an error - notificationService.notify(errorModel); - expect(notificationService.notifications.length).toEqual(2); - mockTimeout.mostRecentCall.args[0](); - //Two timeouts, one is to force minimization after - // displaying the message for a minimum period, the - // second is to allow minimization animation to take place. - mockTimeout.mostRecentCall.args[0](); - //Previous info message should be completely dismissed - expect(notificationService.notifications.length).toEqual(1); - });*/ it("auto-minimizes an active error notification", function() { var activeNotification; //First pre-load with an error message @@ -190,11 +133,11 @@ define( var activeNotification, error2 = { title: "Second Mock Error Notification", - severity: MessageSeverity.ERROR + severity: "error" }, error3 = { title: "Third Mock Error Notification", - severity: MessageSeverity.ERROR + severity: "error" }; //First pre-load with a info message From e3ef68bc6f711a30973b274e6a58a55d9299755e Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 16:41:09 -0700 Subject: [PATCH 06/13] Fixed jslint errors --- example/notifications/src/DialogLaunchController.js | 6 ++---- .../commonUI/general/src/controllers/BannerController.js | 2 +- platform/commonUI/notification/src/NotificationService.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/example/notifications/src/DialogLaunchController.js b/example/notifications/src/DialogLaunchController.js index e6a8b4e132..f35d008cd0 100644 --- a/example/notifications/src/DialogLaunchController.js +++ b/example/notifications/src/DialogLaunchController.js @@ -130,15 +130,13 @@ define( " dialog. This dialog can be used to draw the user's" + " attention to an event.", severity: "info", - options: [ - { + primaryOption: { label: "OK", callback: function () { $log.debug("OK Pressed"); dialogService.dismiss(); } - }, - ] + } }; if (!dialogService.showBlockingMessage(model)) { diff --git a/platform/commonUI/general/src/controllers/BannerController.js b/platform/commonUI/general/src/controllers/BannerController.js index 511bf23b38..068b5cda81 100644 --- a/platform/commonUI/general/src/controllers/BannerController.js +++ b/platform/commonUI/general/src/controllers/BannerController.js @@ -55,7 +55,7 @@ define( notificationService.dismissOrMinimize(notification); }; $scope.maximize = function(notification) { - if (notification.severity != "info"){ + if (notification.severity !== "info"){ notification.cancel = function(){ dialogService.dismiss(); }; diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index 2e1a44a1a8..8887e7cb9a 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -137,7 +137,7 @@ define( "alert": 2, "error": 3 }; - notification.severity = notification.severity || "info" + notification.severity = notification.severity || "info"; if (notification.autoDismiss === true){ notification.autoDismiss = this.DEFAULT_AUTO_DISMISS; } From 78b528b4a575f606f2c481f8f7707a7fd2f23232 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2015 11:48:25 -0700 Subject: [PATCH 07/13] Added additional test cases, and some tidying --- .../notification/src/NotificationIndicator.js | 17 +--- .../src/NotificationIndicatorController.js | 11 +-- .../NotificationIndicatorControllerSpec.js | 80 +++++++++++++++++++ .../commonUI/notification/test/suite.json | 3 +- 4 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js diff --git a/platform/commonUI/notification/src/NotificationIndicator.js b/platform/commonUI/notification/src/NotificationIndicator.js index b1d20e8264..29a831d251 100644 --- a/platform/commonUI/notification/src/NotificationIndicator.js +++ b/platform/commonUI/notification/src/NotificationIndicator.js @@ -26,25 +26,10 @@ define( function () { "use strict"; - function NotificationIndicator() { - - } + function NotificationIndicator() {} NotificationIndicator.template = 'notificationIndicatorTemplate'; - NotificationIndicator.prototype.getGlyph = function () { - return "A"; - }; - NotificationIndicator.prototype.getGlyphClass = function () { - return 'caution'; - }; - NotificationIndicator.prototype.getText = function () { - return "Notifications"; - }; - NotificationIndicator.prototype.getDescription = function () { - return "Notifications"; - }; - return NotificationIndicator; } ); diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index 21da649a8f..685152de9c 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -45,14 +45,11 @@ define( * Launch a dialog showing a list of current notifications. */ $scope.showNotificationsList = function(){ - - var model = { - title: "Messages" - }; - - model.messages = notificationService.notifications; dialogService.getDialogResponse('overlay-message-list', { - dialog: model, + dialog: { + title: "Messages", + messages: notificationService.notifications + }, cancel: function(){ dialogService.dismiss(); } diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js new file mode 100644 index 0000000000..fa906012ae --- /dev/null +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -0,0 +1,80 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */ + +define( + ['../src/NotificationIndicatorController'], + function (NotificationIndicatorController) { + "use strict"; + + describe("The notification indicator controller ", function () { + var mockNotificationService, + mockScope, + mockDialogService; + + beforeEach(function(){ + mockNotificationService = jasmine.createSpy("notificationService"); + mockScope = jasmine.createSpy("$scope"); + mockDialogService = { + getDialogResponse: function(template, model){}, + dismiss: function(){} + } + + spyOn(mockDialogService, 'getDialogResponse'); + spyOn(mockDialogService, 'dismiss'); + }); + + it("exposes the highest notification severity to the template", function() { + mockNotificationService.highest = { + severity: "error" + }; + var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + expect(mockScope.highest).toBeTruthy(); + expect(mockScope.highest.severity).toBe("error"); + }); + + it("invokes the dialog service to show list of messages", function() { + var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + expect(mockScope.showNotificationsList).toBeDefined(); + mockScope.showNotificationsList(); + expect(mockDialogService.getDialogResponse).toHaveBeenCalled(); + expect(mockDialogService.getDialogResponse.mostRecentCall.args[0]).toBe('overlay-message-list'); + expect(mockDialogService.getDialogResponse.mostRecentCall.args[1].dialog).toBeDefined(); + expect(mockDialogService.getDialogResponse.mostRecentCall.args[1].cancel).toBeDefined(); + //Invoke the cancel callback + mockDialogService.getDialogResponse.mostRecentCall.args[1].cancel(); + expect(mockDialogService.dismiss).toHaveBeenCalled(); + }); + + it("provides a means of dismissing the message list", function() { + var controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService); + expect(mockScope.showNotificationsList).toBeDefined(); + mockScope.showNotificationsList(); + expect(mockDialogService.getDialogResponse).toHaveBeenCalled(); + expect(mockDialogService.getDialogResponse.mostRecentCall.args[1].cancel).toBeDefined(); + //Invoke the cancel callback + mockDialogService.getDialogResponse.mostRecentCall.args[1].cancel(); + expect(mockDialogService.dismiss).toHaveBeenCalled(); + }) + + }); + }); \ No newline at end of file diff --git a/platform/commonUI/notification/test/suite.json b/platform/commonUI/notification/test/suite.json index 08238b16c0..2b52722303 100644 --- a/platform/commonUI/notification/test/suite.json +++ b/platform/commonUI/notification/test/suite.json @@ -1,3 +1,4 @@ [ - "NotificationService" + "NotificationService", + "NotificationIndicatorController" ] \ No newline at end of file From fa7431d68bb8070710c3e072661595b67e9ad23d Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2015 12:01:48 -0700 Subject: [PATCH 08/13] Added test case to DialogServiceSpec --- platform/commonUI/dialog/test/DialogServiceSpec.js | 11 +++++++++++ .../test/NotificationIndicatorControllerSpec.js | 11 ++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/platform/commonUI/dialog/test/DialogServiceSpec.js b/platform/commonUI/dialog/test/DialogServiceSpec.js index 949c1102a8..ddd826ef39 100644 --- a/platform/commonUI/dialog/test/DialogServiceSpec.js +++ b/platform/commonUI/dialog/test/DialogServiceSpec.js @@ -121,6 +121,17 @@ define( ); }); + it("invokes the overlay service with the correct parameters when" + + " a blocking dialog is requested", function() { + var dialogModel = {}; + expect(dialogService.showBlockingMessage(dialogModel)).toBe(true); + expect(mockOverlayService.createOverlay).toHaveBeenCalledWith( + "overlay-blocking-message", + dialogModel, + "t-dialog-sm" + ); + }); + }); } ); \ No newline at end of file diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js index fa906012ae..f20e3dd357 100644 --- a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -34,13 +34,10 @@ define( beforeEach(function(){ mockNotificationService = jasmine.createSpy("notificationService"); mockScope = jasmine.createSpy("$scope"); - mockDialogService = { - getDialogResponse: function(template, model){}, - dismiss: function(){} - } - - spyOn(mockDialogService, 'getDialogResponse'); - spyOn(mockDialogService, 'dismiss'); + mockDialogService = jasmine.createSpyObj( + "dialogService", + ["getDialogResponse","dismiss"] + ); }); it("exposes the highest notification severity to the template", function() { From 89046ecad563319d06d4972329ca5c6b30ed85f7 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2015 12:03:56 -0700 Subject: [PATCH 09/13] fixed jslint error --- .../notification/test/NotificationIndicatorControllerSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js index f20e3dd357..1c85704fc4 100644 --- a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -71,7 +71,7 @@ define( //Invoke the cancel callback mockDialogService.getDialogResponse.mostRecentCall.args[1].cancel(); expect(mockDialogService.dismiss).toHaveBeenCalled(); - }) + }); }); }); \ No newline at end of file From e05858e26bc82d00ee4d15109dbff9e40b876f92 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2015 12:11:37 -0700 Subject: [PATCH 10/13] Added newline to end of source files --- platform/commonUI/dialog/test/DialogServiceSpec.js | 2 +- platform/commonUI/notification/bundle.json | 2 +- .../notification/src/NotificationIndicatorController.js | 1 + platform/commonUI/notification/src/NotificationService.js | 2 +- .../notification/test/NotificationIndicatorControllerSpec.js | 3 ++- platform/commonUI/notification/test/NotificationServiceSpec.js | 3 ++- platform/commonUI/notification/test/suite.json | 2 +- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/commonUI/dialog/test/DialogServiceSpec.js b/platform/commonUI/dialog/test/DialogServiceSpec.js index ddd826ef39..2dc109ac44 100644 --- a/platform/commonUI/dialog/test/DialogServiceSpec.js +++ b/platform/commonUI/dialog/test/DialogServiceSpec.js @@ -134,4 +134,4 @@ define( }); } -); \ No newline at end of file +); diff --git a/platform/commonUI/notification/bundle.json b/platform/commonUI/notification/bundle.json index f4dbd5c71a..4851dd28b6 100644 --- a/platform/commonUI/notification/bundle.json +++ b/platform/commonUI/notification/bundle.json @@ -42,4 +42,4 @@ } ] } -} \ No newline at end of file +} diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index 685152de9c..66ad825a32 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -60,3 +60,4 @@ define( return NotificationIndicatorController; } ); + diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index 8887e7cb9a..140c4537c8 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -282,4 +282,4 @@ define( return NotificationService; } -); \ No newline at end of file +); diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js index 1c85704fc4..59450fd060 100644 --- a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -74,4 +74,5 @@ define( }); }); - }); \ No newline at end of file + } +); diff --git a/platform/commonUI/notification/test/NotificationServiceSpec.js b/platform/commonUI/notification/test/NotificationServiceSpec.js index dca76652ce..695275bc70 100644 --- a/platform/commonUI/notification/test/NotificationServiceSpec.js +++ b/platform/commonUI/notification/test/NotificationServiceSpec.js @@ -174,4 +174,5 @@ define( }); }); }); - }); \ No newline at end of file + } +); diff --git a/platform/commonUI/notification/test/suite.json b/platform/commonUI/notification/test/suite.json index 2b52722303..75e88599fd 100644 --- a/platform/commonUI/notification/test/suite.json +++ b/platform/commonUI/notification/test/suite.json @@ -1,4 +1,4 @@ [ "NotificationService", "NotificationIndicatorController" -] \ No newline at end of file +] From 789b640b9bb8979c9620d46c678573a510b9a52e Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Oct 2015 16:28:42 -0700 Subject: [PATCH 11/13] Refactored dismiss and minimize out of NotificationService and on to returned Notification type --- .../src/NotificationLaunchController.js | 19 +- .../general/res/templates/message-banner.html | 18 +- .../src/controllers/BannerController.js | 9 +- .../src/NotificationIndicatorController.js | 6 +- .../notification/src/NotificationService.js | 233 +++++++++++------- .../test/NotificationServiceSpec.js | 47 +++- 6 files changed, 218 insertions(+), 114 deletions(-) diff --git a/example/notifications/src/NotificationLaunchController.js b/example/notifications/src/NotificationLaunchController.js index 7d0618ada4..851e0575f5 100644 --- a/example/notifications/src/NotificationLaunchController.js +++ b/example/notifications/src/NotificationLaunchController.js @@ -130,7 +130,7 @@ define( */ $scope.newProgress = function(){ - var notification = { + var notificationModel = { title: "Progress notification example", severity: "info", progress: 0, @@ -142,17 +142,18 @@ define( * Simulate an ongoing process and update the progress bar. * @param notification */ - function incrementProgress(notification) { - notification.progress = Math.min(100, Math.floor(notification.progress + Math.random() * 30)); - notification.progressText = ["Estimated time remaining:" + - " about ", 60 - Math.floor((notification.progress / 100) * 60), " seconds"].join(" "); - if (notification.progress < 100) { - $timeout(function(){incrementProgress(notification);}, 1000); + function incrementProgress(notificationModel) { + notificationModel.progress = Math.min(100, Math.floor(notificationModel.progress + Math.random() * 30)); + notificationModel.progressText = ["Estimated time" + + " remaining:" + + " about ", 60 - Math.floor((notificationModel.progress / 100) * 60), " seconds"].join(" "); + if (notificationModel.progress < 100) { + $timeout(function(){incrementProgress(notificationModel);}, 1000); } } - notificationService.notify(notification); - incrementProgress(notification); + notificationService.notify(notificationModel); + incrementProgress(notificationModel); }; /** diff --git a/platform/commonUI/general/res/templates/message-banner.html b/platform/commonUI/general/res/templates/message-banner.html index 29b107126e..44c7f915b6 100644 --- a/platform/commonUI/general/res/templates/message-banner.html +++ b/platform/commonUI/general/res/templates/message-banner.html @@ -1,20 +1,20 @@
- + - diff --git a/platform/commonUI/general/src/controllers/BannerController.js b/platform/commonUI/general/src/controllers/BannerController.js index 068b5cda81..4be9304cc6 100644 --- a/platform/commonUI/general/src/controllers/BannerController.js +++ b/platform/commonUI/general/src/controllers/BannerController.js @@ -52,14 +52,15 @@ define( }; $scope.dismiss = function(notification, $event) { $event.stopPropagation(); - notificationService.dismissOrMinimize(notification); + notification.dismissOrMinimize(); }; $scope.maximize = function(notification) { - if (notification.severity !== "info"){ - notification.cancel = function(){ + if (notification.model.severity !== "info"){ + + notification.model.cancel = function(){ dialogService.dismiss(); }; - dialogService.showBlockingMessage(notification); + dialogService.showBlockingMessage(notification.model); } }; } diff --git a/platform/commonUI/notification/src/NotificationIndicatorController.js b/platform/commonUI/notification/src/NotificationIndicatorController.js index 66ad825a32..e58b0a606b 100644 --- a/platform/commonUI/notification/src/NotificationIndicatorController.js +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -48,7 +48,11 @@ define( dialogService.getDialogResponse('overlay-message-list', { dialog: { title: "Messages", - messages: notificationService.notifications + //Launch the message list dialog with the models + // from the notifications + messages: notificationService.notifications && notificationService.notifications.map(function(notification){ + return notification.model; + }) }, cancel: function(){ dialogService.dismiss(); diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index 140c4537c8..cff2d57d7a 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -29,7 +29,7 @@ * dialogs so that the same information can be provided in a dialog * and then minimized to a banner notification if needed. * - * @namespace platform/commonUI/dialog + * @namespace platform/commonUI/notification */ define( [], @@ -54,11 +54,10 @@ define( * dialogs so that the same information can be provided in a dialog * and then minimized to a banner notification if needed. * - * @typedef {object} Notification + * @typedef {object} NotificationModel * @property {string} title The title of the message - * @property {string} severity The importance of the - * message (one of 'info', 'alert', or 'error' where info < alert < - * error) + * @property {string} severity The importance of the message (one of + * 'info', 'alert', or 'error' where info < alert