Added some documentation to notification and dialog launchers

This commit is contained in:
Henry
2015-10-22 10:54:48 -07:00
parent f08725b6a2
commit dc5feb8b1a
5 changed files with 86 additions and 84 deletions

View File

@ -3,7 +3,8 @@
<span class="label"> <span class="label">
<a ng-click="launchProgress(true)">Known</a> | <a ng-click="launchProgress(true)">Known</a> |
<a ng-click="launchProgress(false)">Unknown</a> | <a ng-click="launchProgress(false)">Unknown</a> |
<a ng-click="launchError()">Error</a> <a ng-click="launchError()">Error</a> |
<a ng-click="launchInfo()">Info</a>
</span> </span>
<span class="count">Dialogs</span> <span class="count">Dialogs</span>
</span> </span>

View File

@ -1,7 +1,7 @@
<span class="status block ok" ng-controller="NotificationLaunchController"> <span class="status block ok" ng-controller="NotificationLaunchController">
<span class="ui-symbol status-indicator">&#xe600;</span> <span class="ui-symbol status-indicator">&#xe600;</span>
<span class="label"> <span class="label">
<a ng-click="newSuccess()">Success</a> | <a ng-click="newInfo()">Success</a> |
<a ng-click="newError()">Error</a> | <a ng-click="newError()">Error</a> |
<a ng-click="newAlert()">Alert</a> | <a ng-click="newAlert()">Alert</a> |
<a ng-click="newProgress()">Progress</a> <a ng-click="newProgress()">Progress</a>

View File

@ -26,7 +26,23 @@ define(
function (MessageSeverity) { function (MessageSeverity) {
"use strict"; "use strict";
/**
* A controller for the dialog launch view. This view allows manual
* launching of dialogs for demonstration and testing purposes. It
* also demonstrates the use of the DialogService.
* @param $scope
* @param $timeout
* @param $log
* @param dialogService
* @param notificationService
* @constructor
*/
function DialogLaunchController($scope, $timeout, $log, dialogService, notificationService) { function DialogLaunchController($scope, $timeout, $log, dialogService, notificationService) {
/*
Demonstrates launching a progress dialog and updating it
periodically with the progress of an ongoing process.
*/
$scope.launchProgress = function (knownProgress) { $scope.launchProgress = function (knownProgress) {
var model = { var model = {
title: "Progress Dialog Example", title: "Progress Dialog Example",
@ -72,6 +88,10 @@ define(
} }
}; };
/*
Demonstrates launching an error dialog
*/
$scope.launchError = function () { $scope.launchError = function () {
var model = { var model = {
title: "Error Dialog Example", title: "Error Dialog Example",
@ -100,87 +120,32 @@ define(
} }
}; };
$scope.launchMessages = function () { /*
Demonstrates launching an error dialog
*/
$scope.launchInfo = function () {
var model = { var model = {
title: "Messages", title: "Info Dialog Example",
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: MessageSeverity.INFO,
actions: [ actions: [
{ {
label: "Done", label: "OK",
action: function () { action: function () {
$log.debug("OK Pressed");
dialogService.dismiss(); dialogService.dismiss();
} }
} },
], ]
messages: []
}; };
function getExampleActionText() { if (!dialogService.showBlockingMessage(model)) {
var actionTexts = [ $log.error("Could not display modal dialog");
"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)];
}
function createMessage (messageNumber) {
var messageModel = {
title: "Message Title " + messageNumber,
actionText: getExampleActionText(),
severity: getExampleSeverity(),
actions: getExampleActions()
};
return messageModel;
}
function dismiss() {
dialogService.dismiss();
}
model.messages = notificationService.notifications;
dialogService.getDialogResponse('overlay-message-list', {
dialog: model,
cancel: dismiss
});
}; };
} }
return DialogLaunchController; return DialogLaunchController;
} }

View File

@ -26,6 +26,12 @@ define(
function () { function () {
"use strict"; "use strict";
/**
* A tool for manually invoking dialogs. When included this
* indicator will allow for dialogs of different types to be
* launched for demonstration and testing purposes.
* @constructor
*/
function DialogLaunchIndicator() { function DialogLaunchIndicator() {
} }

View File

@ -26,14 +26,21 @@ define(
function (MessageSeverity) { function (MessageSeverity) {
"use strict"; "use strict";
/**
* Allows launching of notification messages for the purposes of
* demonstration and testing. Also demonstrates use of
* the NotificationService. Notifications are non-blocking messages that
* appear at the bottom of the screen to inform the user of events
* in a non-intrusive way. For more information see the
* {@link NotificationService}
* @param $scope
* @param $timeout
* @param $log
* @param notificationService
* @constructor
*/
function NotificationLaunchController($scope, $timeout, $log, notificationService) { function NotificationLaunchController($scope, $timeout, $log, notificationService) {
var messageCounter = 1; var messageCounter = 1;
$scope.newSuccess = function(){
notificationService.info({
title: "Success notification!"
});
};
function getExampleActionText() { function getExampleActionText() {
var actionTexts = [ var actionTexts = [
@ -81,10 +88,13 @@ define(
return severities[Math.floor(Math.random() * severities.length)]; return severities[Math.floor(Math.random() * severities.length)];
} }
/**
* Launch a new notification with a severity level of 'Error'.
*/
$scope.newError = function(){ $scope.newError = function(){
notificationService.notify({ notificationService.notify({
title: "Error notification " + messageCounter++ + "!", title: "Example error notification " + messageCounter++,
hint: "An error has occurred", hint: "An error has occurred",
severity: MessageSeverity.ERROR, severity: MessageSeverity.ERROR,
primaryAction: { primaryAction: {
@ -95,11 +105,13 @@ define(
}, },
actions: getExampleActions()}); actions: getExampleActions()});
}; };
/**
* Launch a new notification with a severity of 'Alert'.
*/
$scope.newAlert = function(){ $scope.newAlert = function(){
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: MessageSeverity.ALERT,
primaryAction: { primaryAction: {
@ -111,17 +123,25 @@ define(
actions: getExampleActions()}); actions: getExampleActions()});
}; };
/**
* Launch a new notification with a progress bar that is updated
* periodically, tracking an ongoing process.
*/
$scope.newProgress = function(){ $scope.newProgress = function(){
var notification = { var notification = {
title: "Progress notification!", title: "Progress notification example",
severity: MessageSeverity.INFO, severity: MessageSeverity.INFO,
progress: 0, progress: 0,
actionText: getExampleActionText(), actionText: getExampleActionText(),
unknownProgress: false unknownProgress: false
}; };
/**
* Simulate an ongoing process and update the progress bar.
* @param notification
*/
function incrementProgress(notification) { function incrementProgress(notification) {
notification.progress = Math.min(100, Math.floor(notification.progress + Math.random() * 30)); notification.progress = Math.min(100, Math.floor(notification.progress + Math.random() * 30));
notification.progressText = ["Estimated time remaining:" + notification.progressText = ["Estimated time remaining:" +
@ -135,6 +155,16 @@ define(
incrementProgress(notification); incrementProgress(notification);
}; };
/**
* Launch a new notification with severity level of INFO.
*/
$scope.newInfo = function(){
notificationService.info({
title: "Example Info notification " + messageCounter++
});
};
} }
return NotificationLaunchController; return NotificationLaunchController;
} }