Integrated notifications list

This commit is contained in:
Henry 2015-10-09 14:17:55 -07:00
parent 85300d3743
commit 82ae9e72c1
8 changed files with 66 additions and 41 deletions

View File

@ -1,16 +1,5 @@
{ {
"extensions": { "extensions": {
"constants": [
{
"key": "messageSeverity",
"value": {
"ALERT": "alert",
"ERROR": "error",
"INFO": "info",
"SUCCESS": "success"
}
}
],
"services": [ "services": [
{ {
"key": "dialogService", "key": "dialogService",

View File

@ -1,4 +1,9 @@
<div class="l-message message-severity-{{ngModel.severity}}"> <div ng-controller="MessageController"
class="l-message"
title="{{MessageSeverity}}"
ng-class="{'message-severity-info': ngModel.severity===MessageSeverity.INFO,
'message-severity-error': ngModel.severity===MessageSeverity.ERROR,
'message-severity-alert': ngModel.severity===MessageSeverity.ALERT}">
<div class="ui-symbol type-icon message-type"></div> <div class="ui-symbol type-icon message-type"></div>
<div class="message-contents"> <div class="message-contents">
<div class="top-bar"> <div class="top-bar">

View File

@ -6,6 +6,13 @@
"value": 3000 "value": 3000
} }
], ],
"controllers": [
{
"key": "MessageController",
"implementation": "MessageController.js",
"depends": ["$scope"]
}
],
"services": [ "services": [
{ {
"key": "notificationService", "key": "notificationService",

View File

@ -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;
}
);

View File

@ -4,8 +4,8 @@
/*global define*/ /*global define*/
define(function(){ define(function(){
return { return {
SUCCESS: 0, INFO: 0,
INFO: 1, ALERT: 1,
ERROR: 2 ERROR: 2
}; };
}); });

View File

@ -112,7 +112,7 @@ define(
*/ */
NotificationService.prototype.success = function (notification) { NotificationService.prototype.success = function (notification) {
notification.autoDismiss = notification.autoDismiss || true; notification.autoDismiss = notification.autoDismiss || true;
notification.severity = MessageSeverity.SUCCESS; notification.severity = MessageSeverity.INFO;
this.notify(notification); this.notify(notification);
}; };
@ -260,7 +260,7 @@ define(
* @param notification * @param notification
*/ */
NotificationService.prototype.dismissOrMinimize = function (notification){ NotificationService.prototype.dismissOrMinimize = function (notification){
if (notification.severity > MessageSeverity.SUCCESS){ if (notification.severity > MessageSeverity.INFO){
this.minimize(notification); this.minimize(notification);
} else { } else {
this.dismiss(notification); this.dismiss(notification);

View File

@ -16,10 +16,10 @@
"implementation": "DialogLaunchController.js", "implementation": "DialogLaunchController.js",
"depends": [ "depends": [
"$scope", "$scope",
"dialogService",
"$timeout", "$timeout",
"$log", "$log",
"messageSeverity" "dialogService",
"notificationService"
] ]
}, },
{ {

View File

@ -22,11 +22,11 @@
/*global define*/ /*global define*/
define( define(
[], ['../../../platform/commonUI/notification/src/MessageSeverity'],
function () { function (MessageSeverity) {
"use strict"; "use strict";
function DialogLaunchController($scope, dialogService, $timeout, $log, messageSeverity) { function DialogLaunchController($scope, $timeout, $log, dialogService, notificationService) {
$scope.launchProgress = function (knownProgress) { $scope.launchProgress = function (knownProgress) {
var model = { var model = {
title: "Progress Dialog Example", title: "Progress Dialog Example",
@ -35,7 +35,7 @@ define(
actionText: "Calculating...", actionText: "Calculating...",
unknownProgress: !knownProgress, unknownProgress: !knownProgress,
unknownDuration: false, unknownDuration: false,
severity: messageSeverity.INFO, severity: MessageSeverity.INFO,
actions: [ actions: [
{ {
label: "Cancel Operation", label: "Cancel Operation",
@ -76,7 +76,7 @@ define(
var model = { var model = {
title: "Error Dialog Example", title: "Error Dialog Example",
actionText: "Something happened, and it was not good.", actionText: "Something happened, and it was not good.",
severity: messageSeverity.ERROR, severity: MessageSeverity.ERROR,
actions: [ actions: [
{ {
label: "Try Again", label: "Try Again",
@ -103,7 +103,7 @@ define(
$scope.launchMessages = function () { $scope.launchMessages = function () {
var model = { var model = {
title: "Messages", title: "Messages",
severity: messageSeverity.MESSAGES, severity: MessageSeverity.INFO,
actions: [ actions: [
{ {
label: "Done", label: "Done",
@ -155,9 +155,9 @@ define(
function getExampleSeverity() { function getExampleSeverity() {
var severities = [ var severities = [
messageSeverity.INFO, MessageSeverity.INFO,
messageSeverity.ALERT, MessageSeverity.ALERT,
messageSeverity.ERROR MessageSeverity.ERROR
]; ];
return severities[Math.floor(Math.random() * severities.length)]; return severities[Math.floor(Math.random() * severities.length)];
} }
@ -177,26 +177,16 @@ define(
element.remove(); element.remove();
} }
for (var i = 0; i < 10; i++) { //for (var i = 0; i < 10; i++) {
model.messages.push(createMessage(i)); // model.messages.push(createMessage(i));
} //}
model.messages = notificationService.notifications;
dialogService.getDialogResponse('overlay-message-list', { dialogService.getDialogResponse('overlay-message-list', {
dialog: model, dialog: model,
cancel: function(){ cancel: function(){
dialogService.dismiss(); 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; return DialogLaunchController;