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