From c0ff6de27bf3b63427af51cf84743475c5838a1b Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Sat, 10 Oct 2015 11:28:19 -0700 Subject: [PATCH] Added notification indicator --- .../dialog/res/templates/message.html | 5 +- .../res/templates/overlay-message-list.html | 8 +-- .../general/res/templates/message-banner.html | 2 +- platform/commonUI/notification/bundle.json | 16 +++++ .../res/notification-indicator.html | 7 +++ .../notification/src/NotificationIndicator.js | 50 ++++++++++++++++ .../src/NotificationIndicatorController.js | 59 +++++++++++++++++++ .../dialogTest/src/DialogLaunchController.js | 13 +--- .../src/NotificationLaunchController.js | 52 +++++++++++++++- 9 files changed, 188 insertions(+), 24 deletions(-) create mode 100644 platform/commonUI/notification/res/notification-indicator.html create mode 100644 platform/commonUI/notification/src/NotificationIndicator.js create mode 100644 platform/commonUI/notification/src/NotificationIndicatorController.js diff --git a/platform/commonUI/dialog/res/templates/message.html b/platform/commonUI/dialog/res/templates/message.html index 5ebdf7b757..78ae8be035 100644 --- a/platform/commonUI/dialog/res/templates/message.html +++ b/platform/commonUI/dialog/res/templates/message.html @@ -11,12 +11,9 @@
{{ngModel.hint}}
-
- {{ngModel.actionText}} -
+ ng-show="ngModel.progress !== undefined || ngModel.unknownProgress">
- - +
{{notifications.length}} Notifications + + {{notifications.length}} + \ No newline at end of file diff --git a/platform/commonUI/notification/src/NotificationIndicator.js b/platform/commonUI/notification/src/NotificationIndicator.js new file mode 100644 index 0000000000..b1d20e8264 --- /dev/null +++ b/platform/commonUI/notification/src/NotificationIndicator.js @@ -0,0 +1,50 @@ +/***************************************************************************** + * 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,window*/ + +define( + [], + function () { + "use strict"; + + 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 new file mode 100644 index 0000000000..ae417b1ba7 --- /dev/null +++ b/platform/commonUI/notification/src/NotificationIndicatorController.js @@ -0,0 +1,59 @@ +/***************************************************************************** + * 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( + ['./MessageSeverity'], + function (MessageSeverity) { + "use strict"; + + function NotificationIndicatorController($scope, notificationService, dialogService) { + $scope.notifications = notificationService.notifications; + $scope.showNotificationsList = function(){ + + var model = { + title: "Messages", + severity: MessageSeverity.INFO, + actions: [ + { + label: "Done", + action: function () { + dialogService.dismiss(); + } + } + ], + messages: [] + }; + + model.messages = notificationService.notifications; + dialogService.getDialogResponse('overlay-message-list', { + dialog: model, + cancel: function(){ + dialogService.dismiss(); + } + }); + + }; + } + return NotificationIndicatorController; + } +); diff --git a/testing/dialogTest/src/DialogLaunchController.js b/testing/dialogTest/src/DialogLaunchController.js index 11bba39da2..bc8cdcb419 100644 --- a/testing/dialogTest/src/DialogLaunchController.js +++ b/testing/dialogTest/src/DialogLaunchController.js @@ -108,7 +108,6 @@ define( { label: "Done", action: function () { - $log.debug("Done pressed"); dialogService.dismiss(); } } @@ -173,19 +172,13 @@ define( } function dismiss() { - scope.$destroy(); - element.remove(); + dialogService.dismiss(); } - - //for (var i = 0; i < 10; i++) { - // model.messages.push(createMessage(i)); - //} + model.messages = notificationService.notifications; dialogService.getDialogResponse('overlay-message-list', { dialog: model, - cancel: function(){ - dialogService.dismiss(); - } + cancel: dismiss }); }; } diff --git a/testing/dialogTest/src/NotificationLaunchController.js b/testing/dialogTest/src/NotificationLaunchController.js index 99caa8a71a..8150c2cfe5 100644 --- a/testing/dialogTest/src/NotificationLaunchController.js +++ b/testing/dialogTest/src/NotificationLaunchController.js @@ -35,17 +35,65 @@ define( }) }; + 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)]; + } + + 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)]; + } + $scope.newError = function(){ notificationService.notify({ title: "Error notification " + messageCounter++ + "!", + hint: "An error has occurred", severity: MessageSeverity.ERROR, primaryAction: { label: 'Retry', action: function() { console.log('Retry clicked'); } - }}); + }, + actions: getExampleActions}); }; $scope.newProgress = function(){ @@ -54,7 +102,7 @@ define( title: "Progress notification!", severity: MessageSeverity.INFO, progress: 0, - progressUnknown: true + unknownProgress: false };