From 82ae9e72c19588d21fc40f1927d92fdda850b2df Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 9 Oct 2015 14:17:55 -0700 Subject: [PATCH] Integrated notifications list --- platform/commonUI/dialog/bundle.json | 11 ------ .../dialog/res/templates/message.html | 7 +++- platform/commonUI/notification/bundle.json | 7 ++++ .../notification/src/MessageController.js | 34 ++++++++++++++++++ .../notification/src/MessageSeverity.js | 4 +-- .../notification/src/NotificationService.js | 4 +-- testing/dialogTest/bundle.json | 4 +-- .../dialogTest/src/DialogLaunchController.js | 36 +++++++------------ 8 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 platform/commonUI/notification/src/MessageController.js diff --git a/platform/commonUI/dialog/bundle.json b/platform/commonUI/dialog/bundle.json index 8b53971d4a..80cd456c20 100644 --- a/platform/commonUI/dialog/bundle.json +++ b/platform/commonUI/dialog/bundle.json @@ -1,16 +1,5 @@ { "extensions": { - "constants": [ - { - "key": "messageSeverity", - "value": { - "ALERT": "alert", - "ERROR": "error", - "INFO": "info", - "SUCCESS": "success" - } - } - ], "services": [ { "key": "dialogService", diff --git a/platform/commonUI/dialog/res/templates/message.html b/platform/commonUI/dialog/res/templates/message.html index 5d78e408d8..876a2d956a 100644 --- a/platform/commonUI/dialog/res/templates/message.html +++ b/platform/commonUI/dialog/res/templates/message.html @@ -1,4 +1,9 @@ -
+
diff --git a/platform/commonUI/notification/bundle.json b/platform/commonUI/notification/bundle.json index 6f793e7ee4..92301a72d6 100644 --- a/platform/commonUI/notification/bundle.json +++ b/platform/commonUI/notification/bundle.json @@ -6,6 +6,13 @@ "value": 3000 } ], + "controllers": [ + { + "key": "MessageController", + "implementation": "MessageController.js", + "depends": ["$scope"] + } + ], "services": [ { "key": "notificationService", diff --git a/platform/commonUI/notification/src/MessageController.js b/platform/commonUI/notification/src/MessageController.js new file mode 100644 index 0000000000..390f4463d3 --- /dev/null +++ b/platform/commonUI/notification/src/MessageController.js @@ -0,0 +1,34 @@ +/***************************************************************************** + * 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 MessageController($scope) { + $scope.MessageSeverity = MessageSeverity; + } + return MessageController; + } +); diff --git a/platform/commonUI/notification/src/MessageSeverity.js b/platform/commonUI/notification/src/MessageSeverity.js index 5708dd9554..44064bf92f 100644 --- a/platform/commonUI/notification/src/MessageSeverity.js +++ b/platform/commonUI/notification/src/MessageSeverity.js @@ -4,8 +4,8 @@ /*global define*/ define(function(){ return { - SUCCESS: 0, - INFO: 1, + INFO: 0, + ALERT: 1, ERROR: 2 }; }); \ No newline at end of file diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index d2aa34d029..b4aabf2de6 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -112,7 +112,7 @@ define( */ NotificationService.prototype.success = function (notification) { notification.autoDismiss = notification.autoDismiss || true; - notification.severity = MessageSeverity.SUCCESS; + notification.severity = MessageSeverity.INFO; this.notify(notification); }; @@ -260,7 +260,7 @@ define( * @param notification */ NotificationService.prototype.dismissOrMinimize = function (notification){ - if (notification.severity > MessageSeverity.SUCCESS){ + if (notification.severity > MessageSeverity.INFO){ this.minimize(notification); } else { this.dismiss(notification); diff --git a/testing/dialogTest/bundle.json b/testing/dialogTest/bundle.json index 095f668c0f..fe4883ed7d 100644 --- a/testing/dialogTest/bundle.json +++ b/testing/dialogTest/bundle.json @@ -16,10 +16,10 @@ "implementation": "DialogLaunchController.js", "depends": [ "$scope", - "dialogService", "$timeout", "$log", - "messageSeverity" + "dialogService", + "notificationService" ] }, { diff --git a/testing/dialogTest/src/DialogLaunchController.js b/testing/dialogTest/src/DialogLaunchController.js index 17fd736861..11bba39da2 100644 --- a/testing/dialogTest/src/DialogLaunchController.js +++ b/testing/dialogTest/src/DialogLaunchController.js @@ -22,11 +22,11 @@ /*global define*/ define( - [], - function () { + ['../../../platform/commonUI/notification/src/MessageSeverity'], + function (MessageSeverity) { "use strict"; - function DialogLaunchController($scope, dialogService, $timeout, $log, messageSeverity) { + function DialogLaunchController($scope, $timeout, $log, dialogService, notificationService) { $scope.launchProgress = function (knownProgress) { var model = { title: "Progress Dialog Example", @@ -35,7 +35,7 @@ define( actionText: "Calculating...", unknownProgress: !knownProgress, unknownDuration: false, - severity: messageSeverity.INFO, + severity: MessageSeverity.INFO, actions: [ { label: "Cancel Operation", @@ -76,7 +76,7 @@ define( var model = { title: "Error Dialog Example", actionText: "Something happened, and it was not good.", - severity: messageSeverity.ERROR, + severity: MessageSeverity.ERROR, actions: [ { label: "Try Again", @@ -103,7 +103,7 @@ define( $scope.launchMessages = function () { var model = { title: "Messages", - severity: messageSeverity.MESSAGES, + severity: MessageSeverity.INFO, actions: [ { label: "Done", @@ -155,9 +155,9 @@ define( function getExampleSeverity() { var severities = [ - messageSeverity.INFO, - messageSeverity.ALERT, - messageSeverity.ERROR + MessageSeverity.INFO, + MessageSeverity.ALERT, + MessageSeverity.ERROR ]; return severities[Math.floor(Math.random() * severities.length)]; } @@ -177,26 +177,16 @@ define( element.remove(); } - for (var i = 0; i < 10; i++) { - model.messages.push(createMessage(i)); - } + //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(); } }); - -/* - if (dialogService.showMessageList(model)) { - //Do processing here - for (var i = 0; i < 10; i++) { - model.messages.push(createMessage(i)); - } - } else { - $log.error("Could not display modal dialog"); - } -*/ }; } return DialogLaunchController;