mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
Removed MessageSeverity enum and MessageController
This commit is contained in:
parent
109ae3323d
commit
83276d70d3
@ -22,8 +22,8 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../platform/commonUI/notification/src/MessageSeverity'],
|
[],
|
||||||
function (MessageSeverity) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +51,7 @@ define(
|
|||||||
actionText: "Calculating...",
|
actionText: "Calculating...",
|
||||||
unknownProgress: !knownProgress,
|
unknownProgress: !knownProgress,
|
||||||
unknownDuration: false,
|
unknownDuration: false,
|
||||||
severity: MessageSeverity.INFO,
|
severity: "info",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: "Cancel Operation",
|
label: "Cancel Operation",
|
||||||
@ -96,7 +96,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: "error",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: "Try Again",
|
label: "Try Again",
|
||||||
@ -129,7 +129,7 @@ define(
|
|||||||
actionText: "This is an example of a blocking info" +
|
actionText: "This is an example of a blocking info" +
|
||||||
" dialog. This dialog can be used to draw the user's" +
|
" dialog. This dialog can be used to draw the user's" +
|
||||||
" attention to an event.",
|
" attention to an event.",
|
||||||
severity: MessageSeverity.INFO,
|
severity: "info",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: "OK",
|
label: "OK",
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../platform/commonUI/notification/src/MessageSeverity'],
|
[],
|
||||||
function (MessageSeverity) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,9 +81,9 @@ define(
|
|||||||
|
|
||||||
function getExampleSeverity() {
|
function getExampleSeverity() {
|
||||||
var severities = [
|
var severities = [
|
||||||
MessageSeverity.INFO,
|
"info",
|
||||||
MessageSeverity.ALERT,
|
"alert",
|
||||||
MessageSeverity.ERROR
|
"error"
|
||||||
];
|
];
|
||||||
return severities[Math.floor(Math.random() * severities.length)];
|
return severities[Math.floor(Math.random() * severities.length)];
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ define(
|
|||||||
notificationService.notify({
|
notificationService.notify({
|
||||||
title: "Example error notification " + messageCounter++,
|
title: "Example error notification " + messageCounter++,
|
||||||
hint: "An error has occurred",
|
hint: "An error has occurred",
|
||||||
severity: MessageSeverity.ERROR,
|
severity: "error",
|
||||||
primaryOption: {
|
primaryOption: {
|
||||||
label: 'Retry',
|
label: 'Retry',
|
||||||
callback: function() {
|
callback: function() {
|
||||||
@ -113,7 +113,7 @@ define(
|
|||||||
notificationService.notify({
|
notificationService.notify({
|
||||||
title: "Alert notification " + (messageCounter++),
|
title: "Alert notification " + (messageCounter++),
|
||||||
hint: "This is an alert message",
|
hint: "This is an alert message",
|
||||||
severity: MessageSeverity.ALERT,
|
severity: "alert",
|
||||||
primaryOption: {
|
primaryOption: {
|
||||||
label: 'Retry',
|
label: 'Retry',
|
||||||
callback: function() {
|
callback: function() {
|
||||||
@ -132,7 +132,7 @@ define(
|
|||||||
|
|
||||||
var notification = {
|
var notification = {
|
||||||
title: "Progress notification example",
|
title: "Progress notification example",
|
||||||
severity: MessageSeverity.INFO,
|
severity: "info",
|
||||||
progress: 0,
|
progress: 0,
|
||||||
actionText: getExampleActionText(),
|
actionText: getExampleActionText(),
|
||||||
unknownProgress: false
|
unknownProgress: false
|
||||||
|
@ -43,13 +43,6 @@
|
|||||||
"key": "overlay",
|
"key": "overlay",
|
||||||
"templateUrl": "templates/overlay.html"
|
"templateUrl": "templates/overlay.html"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"controllers": [
|
|
||||||
{
|
|
||||||
"key": "MessageController",
|
|
||||||
"implementation": "MessageController.js",
|
|
||||||
"depends": ["$scope"]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,5 @@
|
|||||||
<div ng-controller="MessageController"
|
<div class="l-message"
|
||||||
class="l-message"
|
ng-class="'message-severity-' + ngModel.severity">
|
||||||
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">
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
);
|
|
@ -1,8 +1,5 @@
|
|||||||
<div ng-controller="BannerController" ng-show="active.notification"
|
<div ng-controller="BannerController" ng-show="active.notification"
|
||||||
class="l-message-banner s-message-banner" ng-class="{
|
class="l-message-banner s-message-banner {{active.notification.severity}}" ng-class="{
|
||||||
'info': active.notification.severity===MessageSeverity.INFO,
|
|
||||||
'alert': active.notification.severity===MessageSeverity.ALERT,
|
|
||||||
'error': active.notification.severity===MessageSeverity.ERROR,
|
|
||||||
'minimized': active.notification.minimized,
|
'minimized': active.notification.minimized,
|
||||||
'new': !active.notification.minimized}"
|
'new': !active.notification.minimized}"
|
||||||
ng-click="maximize(active.notification)">
|
ng-click="maximize(active.notification)">
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../../../notification/src/MessageSeverity'],
|
[],
|
||||||
function (MessageSeverity) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,6 @@ define(
|
|||||||
*/
|
*/
|
||||||
function BannerController($scope, notificationService, dialogService) {
|
function BannerController($scope, notificationService, dialogService) {
|
||||||
$scope.active = notificationService.active;
|
$scope.active = notificationService.active;
|
||||||
$scope.MessageSeverity = MessageSeverity;
|
|
||||||
|
|
||||||
$scope.action = function (action, $event){
|
$scope.action = function (action, $event){
|
||||||
/*
|
/*
|
||||||
@ -56,7 +55,7 @@ define(
|
|||||||
notificationService.dismissOrMinimize(notification);
|
notificationService.dismissOrMinimize(notification);
|
||||||
};
|
};
|
||||||
$scope.maximize = function(notification) {
|
$scope.maximize = function(notification) {
|
||||||
if (notification.severity > MessageSeverity.INFO){
|
if (notification.severity != "info"){
|
||||||
notification.cancel = function(){
|
notification.cancel = function(){
|
||||||
dialogService.dismiss();
|
dialogService.dismiss();
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<span ng-show="notifications.length > 0" class="status block"
|
<span ng-show="notifications.length > 0" class="status block"
|
||||||
ng-class="{
|
ng-class="highest.severity"
|
||||||
'info': highest.severity===MessageSeverity.INFO,
|
|
||||||
'error': highest.severity===MessageSeverity.ERROR,
|
|
||||||
'alert': highest.severity===MessageSeverity.ALERT }"
|
|
||||||
ng-controller="NotificationIndicatorController">
|
ng-controller="NotificationIndicatorController">
|
||||||
<span class="ui-symbol status-indicator"></span>
|
<span class="ui-symbol status-indicator"></span>
|
||||||
<span class="label">
|
<span class="label">
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* Created by akhenry on 10/7/15.
|
|
||||||
*/
|
|
||||||
/*global define*/
|
|
||||||
define(function(){
|
|
||||||
return {
|
|
||||||
INFO: 0,
|
|
||||||
ALERT: 1,
|
|
||||||
ERROR: 2
|
|
||||||
};
|
|
||||||
});
|
|
@ -22,8 +22,8 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['./MessageSeverity'],
|
[],
|
||||||
function (MessageSeverity) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +40,6 @@ define(
|
|||||||
function NotificationIndicatorController($scope, notificationService, dialogService) {
|
function NotificationIndicatorController($scope, notificationService, dialogService) {
|
||||||
$scope.notifications = notificationService.notifications;
|
$scope.notifications = notificationService.notifications;
|
||||||
$scope.highest = notificationService.highest;
|
$scope.highest = notificationService.highest;
|
||||||
$scope.MessageSeverity = MessageSeverity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch a dialog showing a list of current notifications.
|
* Launch a dialog showing a list of current notifications.
|
||||||
@ -48,8 +47,7 @@ define(
|
|||||||
$scope.showNotificationsList = function(){
|
$scope.showNotificationsList = function(){
|
||||||
|
|
||||||
var model = {
|
var model = {
|
||||||
title: "Messages",
|
title: "Messages"
|
||||||
severity: MessageSeverity.INFO
|
|
||||||
};
|
};
|
||||||
|
|
||||||
model.messages = notificationService.notifications;
|
model.messages = notificationService.notifications;
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
* @namespace platform/commonUI/dialog
|
* @namespace platform/commonUI/dialog
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
["./MessageSeverity"],
|
[],
|
||||||
function (MessageSeverity) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,8 +56,9 @@ define(
|
|||||||
*
|
*
|
||||||
* @typedef {object} Notification
|
* @typedef {object} Notification
|
||||||
* @property {string} title The title of the message
|
* @property {string} title The title of the message
|
||||||
* @property {MessageSeverity} severity The importance of the
|
* @property {string} severity The importance of the
|
||||||
* message (eg. error, info)
|
* message (one of 'info', 'alert', or 'error' where info < alert <
|
||||||
|
* error)
|
||||||
* @property {number} progress The completion status of a task
|
* @property {number} progress The completion status of a task
|
||||||
* represented numerically
|
* represented numerically
|
||||||
* @property {boolean} unknownProgress a boolean indicating that the
|
* @property {boolean} unknownProgress a boolean indicating that the
|
||||||
@ -91,7 +92,7 @@ define(
|
|||||||
function NotificationService($timeout, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) {
|
function NotificationService($timeout, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) {
|
||||||
this.notifications = [];
|
this.notifications = [];
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
this.highest ={ severity: MessageSeverity.INFO };
|
this.highest ={ severity: "info" };
|
||||||
this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS;
|
this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS;
|
||||||
this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT;
|
this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT;
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
NotificationService.prototype.info = function (notification) {
|
NotificationService.prototype.info = function (notification) {
|
||||||
notification.autoDismiss = notification.autoDismiss || true;
|
notification.autoDismiss = notification.autoDismiss || true;
|
||||||
notification.severity = MessageSeverity.INFO;
|
notification.severity = "info";
|
||||||
this.notify(notification);
|
this.notify(notification);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -130,13 +131,18 @@ define(
|
|||||||
* @param {Notification} notification The notification to display
|
* @param {Notification} notification The notification to display
|
||||||
*/
|
*/
|
||||||
NotificationService.prototype.notify = function (notification) {
|
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){
|
if (notification.autoDismiss === true){
|
||||||
notification.autoDismiss = this.DEFAULT_AUTO_DISMISS;
|
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;
|
this.highest.severity = notification.severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,11 +277,6 @@ define(
|
|||||||
//For now minimize everything, and have discussion around which
|
//For now minimize everything, and have discussion around which
|
||||||
//kind of messages should or should not be in the minimized
|
//kind of messages should or should not be in the minimized
|
||||||
//notifications list
|
//notifications list
|
||||||
/*if (notification.severity > MessageSeverity.INFO){
|
|
||||||
this.minimize(notification);
|
|
||||||
} else {
|
|
||||||
this.dismiss(notification);
|
|
||||||
}*/
|
|
||||||
this.minimize(notification);
|
this.minimize(notification);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */
|
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine */
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['../src/NotificationService','../src/MessageSeverity'],
|
['../src/NotificationService'],
|
||||||
function (NotificationService, MessageSeverity) {
|
function (NotificationService) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
describe("The notification service ", function () {
|
describe("The notification service ", function () {
|
||||||
@ -34,46 +34,6 @@ define(
|
|||||||
successModel,
|
successModel,
|
||||||
errorModel;
|
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(){
|
beforeEach(function(){
|
||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockAutoDismiss = mockMinimizeTimeout = 1000;
|
mockAutoDismiss = mockMinimizeTimeout = 1000;
|
||||||
@ -81,11 +41,11 @@ define(
|
|||||||
mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
|
mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
|
||||||
successModel = {
|
successModel = {
|
||||||
title: "Mock Success Notification",
|
title: "Mock Success Notification",
|
||||||
severity: MessageSeverity.INFO
|
severity: "info"
|
||||||
};
|
};
|
||||||
errorModel = {
|
errorModel = {
|
||||||
title: "Mock Error Notification",
|
title: "Mock Error Notification",
|
||||||
severity: MessageSeverity.ERROR
|
severity: "error"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -147,23 +107,6 @@ define(
|
|||||||
activeNotification = notificationService.getActiveNotification();
|
activeNotification = notificationService.getActiveNotification();
|
||||||
expect(activeNotification).toBe(errorModel);
|
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() {
|
it("auto-minimizes an active error notification", function() {
|
||||||
var activeNotification;
|
var activeNotification;
|
||||||
//First pre-load with an error message
|
//First pre-load with an error message
|
||||||
@ -190,11 +133,11 @@ define(
|
|||||||
var activeNotification,
|
var activeNotification,
|
||||||
error2 = {
|
error2 = {
|
||||||
title: "Second Mock Error Notification",
|
title: "Second Mock Error Notification",
|
||||||
severity: MessageSeverity.ERROR
|
severity: "error"
|
||||||
},
|
},
|
||||||
error3 = {
|
error3 = {
|
||||||
title: "Third Mock Error Notification",
|
title: "Third Mock Error Notification",
|
||||||
severity: MessageSeverity.ERROR
|
severity: "error"
|
||||||
};
|
};
|
||||||
|
|
||||||
//First pre-load with a info message
|
//First pre-load with a info message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user