From 82670584875a38f639a815abf9345a17f6222790 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 8 Oct 2015 15:08:26 -0700 Subject: [PATCH] Begun integration of Notifications framework with Charles' code --- .../general/res/templates/message-banner.html | 28 +++++++---- .../src/controllers/BannerController.js | 2 +- platform/commonUI/notification/bundle.json | 2 +- .../notification/src/NotificationService.js | 27 ++++++---- testing/dialogTest/bundle.json | 15 ++++++ .../dialogTest/res/notification-launch.html | 9 ++++ .../src/NotificationLaunchController.js | 44 ++++++++++++++++ .../src/NotificationLaunchIndicator.js | 50 +++++++++++++++++++ 8 files changed, 155 insertions(+), 22 deletions(-) create mode 100644 testing/dialogTest/res/notification-launch.html create mode 100644 testing/dialogTest/src/NotificationLaunchController.js create mode 100644 testing/dialogTest/src/NotificationLaunchIndicator.js diff --git a/platform/commonUI/general/res/templates/message-banner.html b/platform/commonUI/general/res/templates/message-banner.html index 5091f81548..2e53c2c94b 100644 --- a/platform/commonUI/general/res/templates/message-banner.html +++ b/platform/commonUI/general/res/templates/message-banner.html @@ -1,12 +1,18 @@ -
- +
+
+ + + +
\ No newline at end of file diff --git a/platform/commonUI/general/src/controllers/BannerController.js b/platform/commonUI/general/src/controllers/BannerController.js index 8f1128df1e..b1f26eddce 100644 --- a/platform/commonUI/general/src/controllers/BannerController.js +++ b/platform/commonUI/general/src/controllers/BannerController.js @@ -26,7 +26,7 @@ define( function () { "use strict"; function BannerController($scope, notificationService){ - $scope.activeNotification = notificationService.active.Notification; + $scope.active = notificationService.active; } return BannerController; }); \ No newline at end of file diff --git a/platform/commonUI/notification/bundle.json b/platform/commonUI/notification/bundle.json index 6c1ac21d88..6f793e7ee4 100644 --- a/platform/commonUI/notification/bundle.json +++ b/platform/commonUI/notification/bundle.json @@ -3,7 +3,7 @@ "constants": [ { "key": "DEFAULT_AUTO_DISMISS", - "value": 2000 + "value": 3000 } ], "services": [ diff --git a/platform/commonUI/notification/src/NotificationService.js b/platform/commonUI/notification/src/NotificationService.js index 1a521ad4da..8ecf2ad0b4 100644 --- a/platform/commonUI/notification/src/NotificationService.js +++ b/platform/commonUI/notification/src/NotificationService.js @@ -93,8 +93,7 @@ define( * A context in which to hold the active notification and a * handle to its timeout. */ - this.active = { - }; + this.active = {}; } /** @@ -113,7 +112,7 @@ define( */ NotificationService.prototype.success = function (notification) { notification.autoDismiss = notification.autoDismiss || true; - NotificationService.prototype.notify(notification); + this.notify(notification); }; /** @@ -126,7 +125,12 @@ define( NotificationService.prototype.notify = function (notification) { /*var notification = new Notification(model), that=this; */ - var that = this; + var that = this, + timeout; + + if (notification.autoDismiss === true){ + notification.autoDismiss = this.DEFAULT_AUTO_DISMISS; + } this.notifications.push(notification); /* @@ -145,9 +149,12 @@ define( This notifcation has been added to queue and will be serviced as soon as possible. */ + timeout = notification.autoDismiss ? + notification.autoDismiss : + this.DEFAULT_AUTO_DISMISS; this.active.timeout = this.$timeout(function () { that.dismissOrMinimize(that.active.notification); - }); + }, timeout); } }; @@ -171,9 +178,9 @@ define( */ if (notification && (notification.autoDismiss || this.selectNextNotification())) { - timeout = isNaN(notification.autoDismiss) ? - this.DEFAULT_AUTO_DISMISS : - notification.autoDismiss; + timeout = notification.autoDismiss ? + notification.autoDismiss : + this.DEFAULT_AUTO_DISMISS; this.active.timeout = this.$timeout(function () { that.dismissOrMinimize(notification); @@ -258,5 +265,7 @@ define( this.dismiss(notification); } }; + return NotificationService; - }); \ No newline at end of file + } +); \ No newline at end of file diff --git a/testing/dialogTest/bundle.json b/testing/dialogTest/bundle.json index 36ec16e048..095f668c0f 100644 --- a/testing/dialogTest/bundle.json +++ b/testing/dialogTest/bundle.json @@ -4,6 +4,10 @@ { "key": "dialogLaunchTemplate", "templateUrl": "dialog-launch.html" + }, + { + "key": "notificationLaunchTemplate", + "templateUrl": "notification-launch.html" } ], "controllers": [ @@ -17,11 +21,22 @@ "$log", "messageSeverity" ] + }, + { + "key": "NotificationLaunchController", + "implementation": "NotificationLaunchController.js", + "depends": [ + "$scope", + "notificationService" + ] } ], "indicators": [ { "implementation": "DialogLaunchIndicator.js" + }, + { + "implementation": "NotificationLaunchIndicator.js" } ] } diff --git a/testing/dialogTest/res/notification-launch.html b/testing/dialogTest/res/notification-launch.html new file mode 100644 index 0000000000..73bc7c524f --- /dev/null +++ b/testing/dialogTest/res/notification-launch.html @@ -0,0 +1,9 @@ + + + + Success | + Error | + Progress + + Notifications + \ No newline at end of file diff --git a/testing/dialogTest/src/NotificationLaunchController.js b/testing/dialogTest/src/NotificationLaunchController.js new file mode 100644 index 0000000000..d475df08cb --- /dev/null +++ b/testing/dialogTest/src/NotificationLaunchController.js @@ -0,0 +1,44 @@ +/***************************************************************************** + * 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( + [], + function () { + "use strict"; + + function NotificationLaunchController($scope, notificationService) { + /** + * Success | + Error | + Progress + */ + $scope.newSuccess = function(){ + + notificationService.success({ + title: "Success notification!" + }) + }; + } + return NotificationLaunchController; + } +); diff --git a/testing/dialogTest/src/NotificationLaunchIndicator.js b/testing/dialogTest/src/NotificationLaunchIndicator.js new file mode 100644 index 0000000000..174810d721 --- /dev/null +++ b/testing/dialogTest/src/NotificationLaunchIndicator.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 NotificationLaunchIndicator() { + + } + + NotificationLaunchIndicator.template = 'notificationLaunchTemplate'; + + NotificationLaunchIndicator.prototype.getGlyph = function () { + return "i"; + }; + NotificationLaunchIndicator.prototype.getGlyphClass = function () { + return 'caution'; + }; + NotificationLaunchIndicator.prototype.getText = function () { + return "Launch notification"; + }; + NotificationLaunchIndicator.prototype.getDescription = function () { + return "Launch notification"; + }; + + return NotificationLaunchIndicator; + } +);