mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Merge pull request #115 from glyptodon/notification-service
GUAC-1120: Move notifications into own service.
This commit is contained in:
@@ -23,4 +23,13 @@
|
|||||||
/**
|
/**
|
||||||
* The module for code used to connect to a connection or balancing group.
|
* The module for code used to connect to a connection or balancing group.
|
||||||
*/
|
*/
|
||||||
angular.module('client', ['auth', 'element', 'history', 'osk', 'rest', 'textInput', 'touch']);
|
angular.module('client', [
|
||||||
|
'auth',
|
||||||
|
'element',
|
||||||
|
'history',
|
||||||
|
'notification',
|
||||||
|
'osk',
|
||||||
|
'rest',
|
||||||
|
'textInput',
|
||||||
|
'touch'
|
||||||
|
]);
|
||||||
|
@@ -33,6 +33,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
// Required services
|
// Required services
|
||||||
var $location = $injector.get('$location');
|
var $location = $injector.get('$location');
|
||||||
var guacClientManager = $injector.get('guacClientManager');
|
var guacClientManager = $injector.get('guacClientManager');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum number of pixels a drag gesture must move to result in the
|
* The minimum number of pixels a drag gesture must move to result in the
|
||||||
@@ -142,7 +143,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
name : "CLIENT.ACTION_RECONNECT",
|
name : "CLIENT.ACTION_RECONNECT",
|
||||||
callback : function reconnectCallback() {
|
callback : function reconnectCallback() {
|
||||||
$scope.client = guacClientManager.replaceManagedClient(uniqueId, $routeParams.params);
|
$scope.client = guacClientManager.replaceManagedClient(uniqueId, $routeParams.params);
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -407,7 +408,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
$scope.$watch('client.clientState.connectionState', function clientStateChanged(connectionState) {
|
$scope.$watch('client.clientState.connectionState', function clientStateChanged(connectionState) {
|
||||||
|
|
||||||
// Hide any existing status
|
// Hide any existing status
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
|
|
||||||
// Do not display status if status not known
|
// Do not display status if status not known
|
||||||
if (!connectionState)
|
if (!connectionState)
|
||||||
@@ -419,7 +420,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
// Connecting
|
// Connecting
|
||||||
if (connectionState === ManagedClientState.ConnectionState.CONNECTING
|
if (connectionState === ManagedClientState.ConnectionState.CONNECTING
|
||||||
|| connectionState === ManagedClientState.ConnectionState.WAITING) {
|
|| connectionState === ManagedClientState.ConnectionState.WAITING) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
title: "CLIENT.DIALOG_HEADER_CONNECTING",
|
title: "CLIENT.DIALOG_HEADER_CONNECTING",
|
||||||
text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase()
|
text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase()
|
||||||
});
|
});
|
||||||
@@ -435,7 +436,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
var countdown = (status in CLIENT_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null;
|
var countdown = (status in CLIENT_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null;
|
||||||
|
|
||||||
// Show error status
|
// Show error status
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
className: "error",
|
className: "error",
|
||||||
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
||||||
text: "CLIENT.ERROR_CLIENT_" + errorName,
|
text: "CLIENT.ERROR_CLIENT_" + errorName,
|
||||||
@@ -455,7 +456,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
var countdown = (status in TUNNEL_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null;
|
var countdown = (status in TUNNEL_AUTO_RECONNECT) ? RECONNECT_COUNTDOWN : null;
|
||||||
|
|
||||||
// Show error status
|
// Show error status
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
className: "error",
|
className: "error",
|
||||||
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
||||||
text: "CLIENT.ERROR_TUNNEL_" + errorName,
|
text: "CLIENT.ERROR_TUNNEL_" + errorName,
|
||||||
@@ -467,7 +468,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
|
|
||||||
// Disconnected
|
// Disconnected
|
||||||
else if (connectionState === ManagedClientState.ConnectionState.DISCONNECTED) {
|
else if (connectionState === ManagedClientState.ConnectionState.DISCONNECTED) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
title: "CLIENT.DIALOG_HEADER_DISCONNECTED",
|
title: "CLIENT.DIALOG_HEADER_DISCONNECTED",
|
||||||
text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(),
|
text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(),
|
||||||
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ]
|
actions: [ NAVIGATE_HOME_ACTION, RECONNECT_ACTION ]
|
||||||
@@ -476,7 +477,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
|||||||
|
|
||||||
// Hide status for all other states
|
// Hide status for all other states
|
||||||
else
|
else
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -27,23 +27,14 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
function indexController($scope, $injector) {
|
function indexController($scope, $injector) {
|
||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var $document = $injector.get("$document");
|
var $document = $injector.get('$document');
|
||||||
var $window = $injector.get("$window");
|
var $window = $injector.get('$window');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current status notification, or false if no status is currently
|
* The notification service.
|
||||||
* shown.
|
|
||||||
*
|
|
||||||
* @type Notification|Boolean
|
|
||||||
*/
|
*/
|
||||||
$scope.status = false;
|
$scope.guacNotification = guacNotification;
|
||||||
|
|
||||||
/**
|
|
||||||
* All currently-visible notifications.
|
|
||||||
*
|
|
||||||
* @type Notification[]
|
|
||||||
*/
|
|
||||||
$scope.notifications = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic page-level information.
|
* Basic page-level information.
|
||||||
@@ -66,91 +57,6 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The ID of the most recently shown notification, or 0 if no notifications
|
|
||||||
* have yet been shown.
|
|
||||||
*
|
|
||||||
* @type Number
|
|
||||||
*/
|
|
||||||
var notificationUniqueID = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows or hides the given notification as a modal status. If a status
|
|
||||||
* notification is currently shown, no further statuses will be shown
|
|
||||||
* until the current status is hidden.
|
|
||||||
*
|
|
||||||
* @param {Notification|Boolean|Object} status
|
|
||||||
* The status notification to show.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* // To show a status message with actions
|
|
||||||
* $scope.showStatus({
|
|
||||||
* 'title' : 'Disconnected',
|
|
||||||
* 'text' : 'You have been disconnected!',
|
|
||||||
* 'actions' : {
|
|
||||||
* 'name' : 'reconnect',
|
|
||||||
* 'callback' : function () {
|
|
||||||
* // Reconnection code goes here
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* // To hide the status message
|
|
||||||
* $scope.showStatus(false);
|
|
||||||
*/
|
|
||||||
$scope.showStatus = function showStatus(status) {
|
|
||||||
if (!$scope.status || !status)
|
|
||||||
$scope.status = status;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a notification to the the list of notifications shown.
|
|
||||||
*
|
|
||||||
* @param {Notification|Object} notification The notification to add.
|
|
||||||
*
|
|
||||||
* @returns {Number}
|
|
||||||
* A unique ID for the notification that's just been added.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var id = $scope.addNotification({
|
|
||||||
* 'title' : 'Download',
|
|
||||||
* 'text' : 'You have a file ready for download!',
|
|
||||||
* 'actions' : {
|
|
||||||
* 'name' : 'download',
|
|
||||||
* 'callback' : function () {
|
|
||||||
* // download the file and remove the notification here
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
$scope.addNotification = function addNotification(notification) {
|
|
||||||
var id = ++notificationUniqueID;
|
|
||||||
|
|
||||||
$scope.notifications.push({
|
|
||||||
notification : notification,
|
|
||||||
id : id
|
|
||||||
});
|
|
||||||
|
|
||||||
return id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a notification by unique ID.
|
|
||||||
*
|
|
||||||
* @param {type} id The unique ID of the notification to remove. This ID is
|
|
||||||
* retrieved from the initial call to addNotification.
|
|
||||||
*/
|
|
||||||
$scope.removeNotification = function removeNotification(id) {
|
|
||||||
for(var i = 0; i < $scope.notifications.length; i++) {
|
|
||||||
if($scope.notifications[i].id === id) {
|
|
||||||
$scope.notifications.splice(i, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create event listeners at the global level
|
// Create event listeners at the global level
|
||||||
var keyboard = new Guacamole.Keyboard($document[0]);
|
var keyboard = new Guacamole.Keyboard($document[0]);
|
||||||
|
|
||||||
@@ -197,9 +103,6 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
|||||||
// Set body CSS class
|
// Set body CSS class
|
||||||
$scope.page.bodyClassName = current.$$route.bodyClassName || '';
|
$scope.page.bodyClassName = current.$$route.bodyClassName || '';
|
||||||
|
|
||||||
// Hide any status dialog
|
|
||||||
$scope.showStatus(false);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@@ -23,5 +23,15 @@
|
|||||||
/**
|
/**
|
||||||
* The module for the root of the application.
|
* The module for the root of the application.
|
||||||
*/
|
*/
|
||||||
angular.module('index', ['ngRoute', 'ngTouch', 'pascalprecht.translate',
|
angular.module('index', [
|
||||||
'auth', 'home', 'manage', 'login', 'client', 'notification', 'rest']);
|
'auth',
|
||||||
|
'client',
|
||||||
|
'home',
|
||||||
|
'login',
|
||||||
|
'manage',
|
||||||
|
'ngRoute',
|
||||||
|
'ngTouch',
|
||||||
|
'notification',
|
||||||
|
'pascalprecht.translate',
|
||||||
|
'rest'
|
||||||
|
]);
|
||||||
|
@@ -36,6 +36,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
var $location = $injector.get('$location');
|
var $location = $injector.get('$location');
|
||||||
var $routeParams = $injector.get('$routeParams');
|
var $routeParams = $injector.get('$routeParams');
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var connectionService = $injector.get('connectionService');
|
var connectionService = $injector.get('connectionService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
var permissionService = $injector.get('permissionService');
|
var permissionService = $injector.get('permissionService');
|
||||||
@@ -50,7 +51,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE",
|
name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function acknowledgeCallback() {
|
callback : function acknowledgeCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -317,7 +318,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function connectionSaveFailed(error) {
|
.error(function connectionSaveFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -337,7 +338,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
// Handle action
|
// Handle action
|
||||||
callback : function deleteCallback() {
|
callback : function deleteCallback() {
|
||||||
deleteConnectionImmediately();
|
deleteConnectionImmediately();
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -349,7 +350,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
name : "MANAGE_CONNECTION.ACTION_CANCEL",
|
name : "MANAGE_CONNECTION.ACTION_CANCEL",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function cancelCallback() {
|
callback : function cancelCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -367,7 +368,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function connectionDeletionFailed(error) {
|
.error(function connectionDeletionFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -384,7 +385,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
$scope.deleteConnection = function deleteConnection() {
|
$scope.deleteConnection = function deleteConnection() {
|
||||||
|
|
||||||
// Confirm deletion request
|
// Confirm deletion request
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_CONFIRM_DELETE',
|
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_CONFIRM_DELETE',
|
||||||
'text' : 'MANAGE_CONNECTION.TEXT_CONFIRM_DELETE',
|
'text' : 'MANAGE_CONNECTION.TEXT_CONFIRM_DELETE',
|
||||||
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
||||||
|
@@ -35,6 +35,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
var $routeParams = $injector.get('$routeParams');
|
var $routeParams = $injector.get('$routeParams');
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var permissionService = $injector.get('permissionService');
|
var permissionService = $injector.get('permissionService');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +46,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
name : "MANAGE_CONNECTION_GROUP.ACTION_ACKNOWLEDGE",
|
name : "MANAGE_CONNECTION_GROUP.ACTION_ACKNOWLEDGE",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function acknowledgeCallback() {
|
callback : function acknowledgeCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function connectionGroupSaveFailed(error) {
|
.error(function connectionGroupSaveFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -207,7 +208,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
// Handle action
|
// Handle action
|
||||||
callback : function deleteCallback() {
|
callback : function deleteCallback() {
|
||||||
deleteConnectionGroupImmediately();
|
deleteConnectionGroupImmediately();
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,7 +220,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
name : "MANAGE_CONNECTION_GROUP.ACTION_CANCEL",
|
name : "MANAGE_CONNECTION_GROUP.ACTION_CANCEL",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function cancelCallback() {
|
callback : function cancelCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -237,7 +238,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function connectionGroupDeletionFailed(error) {
|
.error(function connectionGroupDeletionFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -254,7 +255,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
$scope.deleteConnectionGroup = function deleteConnectionGroup() {
|
$scope.deleteConnectionGroup = function deleteConnectionGroup() {
|
||||||
|
|
||||||
// Confirm deletion request
|
// Confirm deletion request
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_CONFIRM_DELETE',
|
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_CONFIRM_DELETE',
|
||||||
'text' : 'MANAGE_CONNECTION_GROUP.TEXT_CONFIRM_DELETE',
|
'text' : 'MANAGE_CONNECTION_GROUP.TEXT_CONFIRM_DELETE',
|
||||||
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
||||||
|
@@ -35,6 +35,7 @@ angular.module('manage').controller('manageController', ['$scope', '$injector',
|
|||||||
var $location = $injector.get('$location');
|
var $location = $injector.get('$location');
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var permissionService = $injector.get('permissionService');
|
var permissionService = $injector.get('permissionService');
|
||||||
var userService = $injector.get('userService');
|
var userService = $injector.get('userService');
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ angular.module('manage').controller('manageController', ['$scope', '$injector',
|
|||||||
name : "MANAGE.ACTION_ACKNOWLEDGE",
|
name : "MANAGE.ACTION_ACKNOWLEDGE",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function acknowledgeCallback() {
|
callback : function acknowledgeCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ angular.module('manage').controller('manageController', ['$scope', '$injector',
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function userCreationFailed(error) {
|
.error(function userCreationFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
|
@@ -36,6 +36,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
var $routeParams = $injector.get('$routeParams');
|
var $routeParams = $injector.get('$routeParams');
|
||||||
var authenticationService = $injector.get('authenticationService');
|
var authenticationService = $injector.get('authenticationService');
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var userService = $injector.get('userService');
|
var userService = $injector.get('userService');
|
||||||
var permissionService = $injector.get('permissionService');
|
var permissionService = $injector.get('permissionService');
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
name : "MANAGE_USER.ACTION_ACKNOWLEDGE",
|
name : "MANAGE_USER.ACTION_ACKNOWLEDGE",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function acknowledgeCallback() {
|
callback : function acknowledgeCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,7 +410,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
|
|
||||||
// Verify passwords match
|
// Verify passwords match
|
||||||
if ($scope.passwordMatch !== $scope.user.password) {
|
if ($scope.passwordMatch !== $scope.user.password) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||||
'text' : 'MANAGE_USER.ERROR_PASSWORD_MISMATCH',
|
'text' : 'MANAGE_USER.ERROR_PASSWORD_MISMATCH',
|
||||||
@@ -430,7 +431,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function userPermissionsPatchFailed(error) {
|
.error(function userPermissionsPatchFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -442,7 +443,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function userSaveFailed(error) {
|
.error(function userSaveFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -462,7 +463,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
// Handle action
|
// Handle action
|
||||||
callback : function deleteCallback() {
|
callback : function deleteCallback() {
|
||||||
deleteUserImmediately();
|
deleteUserImmediately();
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -474,7 +475,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
name : "MANAGE_USER.ACTION_CANCEL",
|
name : "MANAGE_USER.ACTION_CANCEL",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function cancelCallback() {
|
callback : function cancelCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -492,7 +493,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function userDeletionFailed(error) {
|
.error(function userDeletionFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'className' : 'error',
|
'className' : 'error',
|
||||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
@@ -509,7 +510,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
$scope.deleteUser = function deleteUser() {
|
$scope.deleteUser = function deleteUser() {
|
||||||
|
|
||||||
// Confirm deletion request
|
// Confirm deletion request
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
'title' : 'MANAGE_USER.DIALOG_HEADER_CONFIRM_DELETE',
|
'title' : 'MANAGE_USER.DIALOG_HEADER_CONFIRM_DELETE',
|
||||||
'text' : 'MANAGE_USER.TEXT_CONFIRM_DELETE',
|
'text' : 'MANAGE_USER.TEXT_CONFIRM_DELETE',
|
||||||
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
||||||
|
@@ -23,5 +23,11 @@
|
|||||||
/**
|
/**
|
||||||
* The module for the administration functionality.
|
* The module for the administration functionality.
|
||||||
*/
|
*/
|
||||||
angular.module('manage', ['groupList', 'locale', 'pager', 'rest', 'userMenu']);
|
angular.module('manage', [
|
||||||
|
'groupList',
|
||||||
|
'locale',
|
||||||
|
'notification',
|
||||||
|
'pager',
|
||||||
|
'rest',
|
||||||
|
'userMenu'
|
||||||
|
]);
|
||||||
|
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Glyptodon LLC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for displaying notifications and modal status dialogs.
|
||||||
|
*/
|
||||||
|
angular.module('notification').factory('guacNotification', ['$rootScope',
|
||||||
|
function guacNotification($rootScope) {
|
||||||
|
|
||||||
|
var service = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current status notification, or false if no status is currently
|
||||||
|
* shown.
|
||||||
|
*
|
||||||
|
* @type Notification|Boolean
|
||||||
|
*/
|
||||||
|
service.status = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All currently-visible notifications.
|
||||||
|
*
|
||||||
|
* @type Notification[]
|
||||||
|
*/
|
||||||
|
service.notifications = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID of the most recently shown notification, or 0 if no notifications
|
||||||
|
* have yet been shown.
|
||||||
|
*
|
||||||
|
* @type Number
|
||||||
|
*/
|
||||||
|
var notificationUniqueID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows or hides the given notification as a modal status. If a status
|
||||||
|
* notification is currently shown, no further statuses will be shown
|
||||||
|
* until the current status is hidden.
|
||||||
|
*
|
||||||
|
* @param {Notification|Boolean|Object} status
|
||||||
|
* The status notification to show.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* // To show a status message with actions
|
||||||
|
* guacNotification.showStatus({
|
||||||
|
* 'title' : 'Disconnected',
|
||||||
|
* 'text' : 'You have been disconnected!',
|
||||||
|
* 'actions' : {
|
||||||
|
* 'name' : 'reconnect',
|
||||||
|
* 'callback' : function () {
|
||||||
|
* // Reconnection code goes here
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* // To hide the status message
|
||||||
|
* guacNotification.showStatus(false);
|
||||||
|
*/
|
||||||
|
service.showStatus = function showStatus(status) {
|
||||||
|
if (!service.status || !status)
|
||||||
|
service.status = status;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a notification to the the list of notifications shown.
|
||||||
|
*
|
||||||
|
* @param {Notification|Object} notification
|
||||||
|
* The notification to add.
|
||||||
|
*
|
||||||
|
* @returns {Number}
|
||||||
|
* A unique ID for the notification that's just been added.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var id = guacNotification.addNotification({
|
||||||
|
* 'title' : 'Download',
|
||||||
|
* 'text' : 'You have a file ready for download!',
|
||||||
|
* 'actions' : {
|
||||||
|
* 'name' : 'download',
|
||||||
|
* 'callback' : function () {
|
||||||
|
* // download the file and remove the notification here
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
service.addNotification = function addNotification(notification) {
|
||||||
|
var id = ++notificationUniqueID;
|
||||||
|
|
||||||
|
service.notifications.push({
|
||||||
|
notification : notification,
|
||||||
|
id : id
|
||||||
|
});
|
||||||
|
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a notification by unique ID.
|
||||||
|
*
|
||||||
|
* @param {Number} id
|
||||||
|
* The unique ID of the notification to remove. This ID is retrieved
|
||||||
|
* from the initial call to addNotification.
|
||||||
|
*/
|
||||||
|
service.removeNotification = function removeNotification(id) {
|
||||||
|
for (var i = 0; i < service.notifications.length; i++) {
|
||||||
|
if (service.notifications[i].id === id) {
|
||||||
|
service.notifications.splice(i, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Hide status upon navigation
|
||||||
|
$rootScope.$on('$routeChangeSuccess', function() {
|
||||||
|
service.showStatus(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return service;
|
||||||
|
|
||||||
|
}]);
|
@@ -52,6 +52,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
var $document = $injector.get("$document");
|
var $document = $injector.get("$document");
|
||||||
var $location = $injector.get("$location");
|
var $location = $injector.get("$location");
|
||||||
var authenticationService = $injector.get("authenticationService");
|
var authenticationService = $injector.get("authenticationService");
|
||||||
|
var guacNotification = $injector.get('guacNotification');
|
||||||
var userService = $injector.get("userService");
|
var userService = $injector.get("userService");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +63,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
name : "USER_MENU.ACTION_ACKNOWLEDGE",
|
name : "USER_MENU.ACTION_ACKNOWLEDGE",
|
||||||
// Handle action
|
// Handle action
|
||||||
callback : function acknowledgeCallback() {
|
callback : function acknowledgeCallback() {
|
||||||
$scope.showStatus(false);
|
guacNotification.showStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
|
|
||||||
// Verify passwords match
|
// Verify passwords match
|
||||||
if ($scope.newPasswordMatch !== $scope.newPassword) {
|
if ($scope.newPasswordMatch !== $scope.newPassword) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
className : 'error',
|
className : 'error',
|
||||||
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
||||||
text : 'USER_MENU.ERROR_PASSWORD_MISMATCH',
|
text : 'USER_MENU.ERROR_PASSWORD_MISMATCH',
|
||||||
@@ -245,7 +246,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
|
|
||||||
// Verify that the new password is not blank
|
// Verify that the new password is not blank
|
||||||
if (!$scope.newPassword) {
|
if (!$scope.newPassword) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
className : 'error',
|
className : 'error',
|
||||||
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
||||||
text : 'USER_MENU.ERROR_PASSWORD_BLANK',
|
text : 'USER_MENU.ERROR_PASSWORD_BLANK',
|
||||||
@@ -262,7 +263,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
$scope.closePasswordUpdate();
|
$scope.closePasswordUpdate();
|
||||||
|
|
||||||
// Indicate that the password has been changed
|
// Indicate that the password has been changed
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
text : 'USER_MENU.PASSWORD_CHANGED',
|
text : 'USER_MENU.PASSWORD_CHANGED',
|
||||||
actions : [ ACKNOWLEDGE_ACTION ]
|
actions : [ ACKNOWLEDGE_ACTION ]
|
||||||
});
|
});
|
||||||
@@ -270,7 +271,7 @@ angular.module('userMenu').directive('guacUserMenu', [function guacUserMenu() {
|
|||||||
|
|
||||||
// Notify of any errors
|
// Notify of any errors
|
||||||
.error(function passwordUpdateFailed(error) {
|
.error(function passwordUpdateFailed(error) {
|
||||||
$scope.showStatus({
|
guacNotification.showStatus({
|
||||||
className : 'error',
|
className : 'error',
|
||||||
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
title : 'USER_MENU.DIALOG_HEADER_ERROR',
|
||||||
'text' : error.message,
|
'text' : error.message,
|
||||||
|
@@ -24,4 +24,4 @@
|
|||||||
* Module for displaying a user-oriented menu, containing the current username
|
* Module for displaying a user-oriented menu, containing the current username
|
||||||
* and options for navigation, changing the user's password, logging out, etc.
|
* and options for navigation, changing the user's password, logging out, etc.
|
||||||
*/
|
*/
|
||||||
angular.module('userMenu', []);
|
angular.module('userMenu', ['notification']);
|
||||||
|
@@ -35,9 +35,9 @@ THE SOFTWARE.
|
|||||||
<body ng-class="page.bodyClassName">
|
<body ng-class="page.bodyClassName">
|
||||||
|
|
||||||
<!-- Global status/error dialog -->
|
<!-- Global status/error dialog -->
|
||||||
<div ng-class="{shown: status}" class="status-outer">
|
<div ng-class="{shown: guacNotification.status}" class="status-outer">
|
||||||
<div class="status-middle">
|
<div class="status-middle">
|
||||||
<guac-notification notification="status"></guac-notification>
|
<guac-notification notification="guacNotification.status"></guac-notification>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
<!-- Notification area -->
|
<!-- Notification area -->
|
||||||
<div id="notificationArea">
|
<div id="notificationArea">
|
||||||
<div ng-repeat="wrapper in notifications">
|
<div ng-repeat="wrapper in guacNotification.notifications">
|
||||||
<guac-notification notification="wrapper.notification"></guac-notification>
|
<guac-notification notification="wrapper.notification"></guac-notification>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user