Added notification indicator

This commit is contained in:
Andrew Henry 2015-10-10 11:28:19 -07:00 committed by Henry
parent 60dda8a7a4
commit c0ff6de27b
9 changed files with 188 additions and 24 deletions

View File

@ -11,12 +11,9 @@
<div class="hint" ng-hide="ngModel.hint === undefined">{{ngModel.hint}}</div>
</div>
<div class="message-body">
<div class="message-action">
{{ngModel.actionText}}
</div>
<mct-include key="'progress-bar'"
ng-model="ngModel"
ng-hide="ngModel.progress === undefined"></mct-include>
ng-show="ngModel.progress !== undefined || ngModel.unknownProgress"></mct-include>
</div>
<div class="bottom-bar">
<a ng-repeat="dialogAction in ngModel.actions"

View File

@ -6,13 +6,7 @@
</div>
</div>
<div class="abs message-body">
<mct-include ng-repeat="msg in ngModel.dialog.messages" key="'message'" ng-model="msg"></mct-include>
<!-- <ul>
<li ng-repeat="msg in ngModel.dialog.messages">
&lt;!&ndash;Message: {{msg.title}}&ndash;&gt;
</li>
</ul>-->
<mct-include ng-repeat="msg in ngModel.dialog.messages | orderBy: '-'" key="'message'" ng-model="msg"></mct-include>
</div>
<div class="abs bottom-bar">
<a ng-repeat="dialogAction in ngModel.dialog.actions"

View File

@ -3,7 +3,7 @@
<span class="banner-elem label">
{{active.notification.title}}
</span>
<span ng-hide="active.notification.progress === undefined">
<span ng-show="active.notification.progress !== undefined || active.notification.unknownProgress">
<mct-include key="'progress-bar'" class="banner-elem"
ng-model="active.notification">
</mct-include>

View File

@ -10,11 +10,27 @@
"value": 1000
}
],
"templates": [
{
"key":"notificationIndicatorTemplate",
"templateUrl": "notification-indicator.html"
}
],
"controllers": [
{
"key": "MessageController",
"implementation": "MessageController.js",
"depends": ["$scope"]
},
{
"key": "NotificationIndicatorController",
"implementation": "NotificationIndicatorController.js",
"depends": ["$scope", "notificationService", "dialogService"]
}
],
"indicators": [
{
"implementation": "NotificationIndicator.js"
}
],
"services": [

View File

@ -0,0 +1,7 @@
<span ng-show="notifications.length > 0" class="status block caution" ng-controller="NotificationIndicatorController">
<span class="ui-symbol status-indicator">&#x21;</span>
<span class="label">
<a ng-click="showNotificationsList()">{{notifications.length}} Notifications</a>
</span>
<span class="count">{{notifications.length}}</span>
</span>

View File

@ -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 NotificationIndicator() {
}
NotificationIndicator.template = 'notificationIndicatorTemplate';
NotificationIndicator.prototype.getGlyph = function () {
return "A";
};
NotificationIndicator.prototype.getGlyphClass = function () {
return 'caution';
};
NotificationIndicator.prototype.getText = function () {
return "Notifications";
};
NotificationIndicator.prototype.getDescription = function () {
return "Notifications";
};
return NotificationIndicator;
}
);

View File

@ -0,0 +1,59 @@
/*****************************************************************************
* 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 NotificationIndicatorController($scope, notificationService, dialogService) {
$scope.notifications = notificationService.notifications;
$scope.showNotificationsList = function(){
var model = {
title: "Messages",
severity: MessageSeverity.INFO,
actions: [
{
label: "Done",
action: function () {
dialogService.dismiss();
}
}
],
messages: []
};
model.messages = notificationService.notifications;
dialogService.getDialogResponse('overlay-message-list', {
dialog: model,
cancel: function(){
dialogService.dismiss();
}
});
};
}
return NotificationIndicatorController;
}
);

View File

@ -108,7 +108,6 @@ define(
{
label: "Done",
action: function () {
$log.debug("Done pressed");
dialogService.dismiss();
}
}
@ -173,19 +172,13 @@ define(
}
function dismiss() {
scope.$destroy();
element.remove();
dialogService.dismiss();
}
//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();
}
cancel: dismiss
});
};
}

View File

@ -35,17 +35,65 @@ define(
})
};
function getExampleActionText() {
var actionTexts = [
"Adipiscing turpis mauris in enim elementu hac, enim aliquam etiam.",
"Eros turpis, pulvinar turpis eros eu",
"Lundium nascetur a, lectus montes ac, parturient in natoque, duis risus risus pulvinar pid rhoncus, habitasse auctor natoque!"
];
return actionTexts[Math.floor(Math.random()*3)];
}
function getExampleActions() {
var actions = [
{
label: "Try Again",
action: function () {
$log.debug("Try Again pressed");
}
},
{
label: "Remove",
action: function () {
$log.debug("Remove pressed");
}
},
{
label: "Cancel",
action: function () {
$log.debug("Cancel pressed");
}
}
];
// Randomly remove some actions off the top; leave at least one
actions.splice(0,Math.floor(Math.random() * actions.length));
return actions;
}
function getExampleSeverity() {
var severities = [
MessageSeverity.INFO,
MessageSeverity.ALERT,
MessageSeverity.ERROR
];
return severities[Math.floor(Math.random() * severities.length)];
}
$scope.newError = function(){
notificationService.notify({
title: "Error notification " + messageCounter++ + "!",
hint: "An error has occurred",
severity: MessageSeverity.ERROR,
primaryAction: {
label: 'Retry',
action: function() {
console.log('Retry clicked');
}
}});
},
actions: getExampleActions});
};
$scope.newProgress = function(){
@ -54,7 +102,7 @@ define(
title: "Progress notification!",
severity: MessageSeverity.INFO,
progress: 0,
progressUnknown: true
unknownProgress: false
};