GUACAMOLE-526: Merge changes updating AngularJS to the latest stable (1.6.9).

This commit is contained in:
Michael Jumper
2018-04-26 09:55:31 -07:00
36 changed files with 263 additions and 163 deletions

View File

@@ -324,19 +324,19 @@
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular</artifactId> <artifactId>angular</artifactId>
<version>1.3.16</version> <version>1.6.9</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular-route</artifactId> <artifactId>angular-route</artifactId>
<version>1.3.16</version> <version>1.6.9</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular-touch</artifactId> <artifactId>angular-touch</artifactId>
<version>1.3.16</version> <version>1.6.9</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@@ -358,13 +358,13 @@
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular-translate</artifactId> <artifactId>angular-translate</artifactId>
<version>2.8.0</version> <version>2.16.0</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular-translate-interpolation-messageformat</artifactId> <artifactId>angular-translate-interpolation-messageformat</artifactId>
<version>2.8.0</version> <version>2.16.0</version>
<scope>runtime</scope> <scope>runtime</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@@ -382,7 +382,7 @@
<dependency> <dependency>
<groupId>org.webjars.bower</groupId> <groupId>org.webjars.bower</groupId>
<artifactId>angular-translate-loader-static-files</artifactId> <artifactId>angular-translate-loader-static-files</artifactId>
<version>2.8.0</version> <version>2.16.0</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>

View File

@@ -214,14 +214,14 @@ terms and conditions of the following licenses.
AngularJS (https://angularjs.org/) AngularJS (https://angularjs.org/)
---------------------------------- ----------------------------------
Version: 1.3.16 Version: 1.6.9
From: 'Google Inc.' (http://www.google.com/) From: 'Google Inc.' (http://www.google.com/)
License(s): License(s):
MIT (bundled/angular-1.3.16/LICENSE) MIT (bundled/angular-1.6.9/LICENSE)
The MIT License The MIT License
Copyright (c) 2010-2016 Google, Inc. http://angularjs.org Copyright (c) 2010-2018 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -276,14 +276,14 @@ SOFTWARE.
angular-translate (https://angular-translate.github.io/) angular-translate (https://angular-translate.github.io/)
-------------------------------------------------------- --------------------------------------------------------
Version: 2.8.0 Version: 2.16.0
From: 'Pascal Precht' (https://github.com/PascalPrecht) From: 'Pascal Precht' (https://github.com/PascalPrecht)
License(s): License(s):
MIT (bundled/angular-translate-2.8.0/LICENSE) MIT (bundled/angular-translate-2.16.0/LICENSE)
The MIT License (MIT) The MIT License (MIT)
Copyright (c) <2014> <pascal.precht@gmail.com> Copyright (c) 2013-2017 The angular-translate team and Pascal Precht
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,6 +1,6 @@
The MIT License The MIT License
Copyright (c) 2014-2016 Google, Inc. http://angular.io Copyright (c) 2010-2018 Google, Inc. http://angularjs.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

View File

@@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) <2014> <pascal.precht@gmail.com> Copyright (c) 2013-2017 The angular-translate team and Pascal Precht
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

View File

@@ -185,7 +185,8 @@ angular.module('auth').factory('authenticationService', ['$injector',
}) })
// If authentication succeeds, handle received auth data // If authentication succeeds, handle received auth data
.success(function authenticationSuccessful(data) { .then(function authenticationSuccessful(response) {
var data = response.data;
var currentToken = service.getCurrentToken(); var currentToken = service.getCurrentToken();
@@ -217,11 +218,11 @@ angular.module('auth').factory('authenticationService', ['$injector',
}) })
// If authentication fails, propogate failure to returned promise // If authentication fails, propogate failure to returned promise
.error(function authenticationFailed(error) { ['catch'](function authenticationFailed(response) {
// Ensure error object exists, even if the error response is not // Ensure error object exists, even if the error response is not
// coming from the authentication REST endpoint // coming from the authentication REST endpoint
error = new Error(error); var error = new Error(response.data);
// Request credentials if provided credentials were invalid // Request credentials if provided credentials were invalid
if (error.type === Error.Type.INVALID_CREDENTIALS) if (error.type === Error.Type.INVALID_CREDENTIALS)

View File

@@ -464,7 +464,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
// Pull sharing profiles for the current connection // Pull sharing profiles for the current connection
tunnelService.getSharingProfiles(uuid) tunnelService.getSharingProfiles(uuid)
.success(function sharingProfilesRetrieved(sharingProfiles) { .then(function sharingProfilesRetrieved(sharingProfiles) {
$scope.sharingProfiles = sharingProfiles; $scope.sharingProfiles = sharingProfiles;
}); });

View File

@@ -512,7 +512,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
// If using a connection, pull connection name // If using a connection, pull connection name
if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) { if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION) {
connectionService.getConnection(clientIdentifier.dataSource, clientIdentifier.id) connectionService.getConnection(clientIdentifier.dataSource, clientIdentifier.id)
.success(function connectionRetrieved(connection) { .then(function connectionRetrieved(connection) {
managedClient.name = managedClient.title = connection.name; managedClient.name = managedClient.title = connection.name;
}); });
} }
@@ -520,7 +520,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
// If using a connection group, pull connection name // If using a connection group, pull connection name
else if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION_GROUP) { else if (clientIdentifier.type === ClientIdentifier.Types.CONNECTION_GROUP) {
connectionGroupService.getConnectionGroup(clientIdentifier.dataSource, clientIdentifier.id) connectionGroupService.getConnectionGroup(clientIdentifier.dataSource, clientIdentifier.id)
.success(function connectionGroupRetrieved(group) { .then(function connectionGroupRetrieved(group) {
managedClient.name = managedClient.title = group.name; managedClient.name = managedClient.title = group.name;
}); });
} }
@@ -631,7 +631,7 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
client.tunnel.uuid, sharingProfile.identifier); client.tunnel.uuid, sharingProfile.identifier);
// Add a new share link once the credentials are ready // Add a new share link once the credentials are ready
credentialRequest.success(function sharingCredentialsReceived(sharingCredentials) { credentialRequest.then(function sharingCredentialsReceived(sharingCredentials) {
client.shareLinks[sharingProfile.identifier] = client.shareLinks[sharingProfile.identifier] =
ManagedShareLink.getInstance(sharingProfile, sharingCredentials); ManagedShareLink.getInstance(sharingProfile, sharingCredentials);
}); });

View File

@@ -26,6 +26,9 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
// Disable HTML5 mode (use # for routing) // Disable HTML5 mode (use # for routing)
$locationProvider.html5Mode(false); $locationProvider.html5Mode(false);
// Clear hash prefix to keep /#/thing/bat URL style
$locationProvider.hashPrefix('');
/** /**
* Attempts to re-authenticate with the Guacamole server, sending any * Attempts to re-authenticate with the Guacamole server, sending any
* query parameters in the URL, along with the current auth token, and * query parameters in the URL, along with the current auth token, and

View File

@@ -337,7 +337,7 @@ angular.module('index').config(['$provide', function($provide) {
$delegate.apply(this, arguments).then(function patchTemplate(data) { $delegate.apply(this, arguments).then(function patchTemplate(data) {
// Retrieve and apply all patches // Retrieve and apply all patches
patchService.getPatches().success(function applyRetrievedPatches(patches) { patchService.getPatches().then(function applyRetrievedPatches(patches) {
// Parse HTML into DOM tree // Parse HTML into DOM tree
var root = $('<div></div>').html(data); var root = $('<div></div>').html(data);

View File

@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* A filter for transforming an object into an array of all non-inherited
* property values.
*/
angular.module('index').filter('toArray', [function toArrayFactory() {
return function toArrayFiter(input) {
console.log(input)
// If no object is available, just return an empty array
if (!input) {
return [];
}
return Object.keys(input).map(function fetchValueByKey(key) {
return input[key];
});
};
}]);

View File

@@ -74,7 +74,7 @@ angular.module('locale').factory('translationLoader', ['$injector', function tra
languageService.getLanguages() languageService.getLanguages()
// Attempt to retrieve translation if language is supported // Attempt to retrieve translation if language is supported
.success(function retrievedLanguages(languages) { .then(function retrievedLanguages(languages) {
// Skip retrieval if language is not supported // Skip retrieval if language is not supported
if (!(currentKey in languages)) { if (!(currentKey in languages)) {
@@ -90,18 +90,17 @@ angular.module('locale').factory('translationLoader', ['$injector', function tra
}) })
// Resolve promise if translation retrieved successfully // Resolve promise if translation retrieved successfully
.success(function translationFileRetrieved(translation) { .then(function translationFileRetrieved(request) {
deferred.resolve(translation); deferred.resolve(request.data);
}) },
// Retry with remaining languages if translation file could not be // Retry with remaining languages if translation file could not be
// retrieved // retrieved
.error(tryNextTranslation); tryNextTranslation);
},
})
// Retry with remaining languages if translation does not exist // Retry with remaining languages if translation does not exist
.error(tryNextTranslation); tryNextTranslation);
}; };

View File

@@ -184,7 +184,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Pull connection attribute schema // Pull connection attribute schema
schemaService.getConnectionAttributes($scope.selectedDataSource) schemaService.getConnectionAttributes($scope.selectedDataSource)
.success(function attributesReceived(attributes) { .then(function attributesReceived(attributes) {
$scope.attributes = attributes; $scope.attributes = attributes;
}); });
@@ -194,13 +194,13 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
ConnectionGroup.ROOT_IDENTIFIER, ConnectionGroup.ROOT_IDENTIFIER,
[PermissionSet.ObjectPermissionType.ADMINISTER] [PermissionSet.ObjectPermissionType.ADMINISTER]
) )
.success(function connectionGroupReceived(rootGroup) { .then(function connectionGroupReceived(rootGroup) {
$scope.rootGroup = rootGroup; $scope.rootGroup = rootGroup;
}); });
// Query the user's permissions for the current connection // Query the user's permissions for the current connection
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername()) permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
.success(function permissionsReceived(permissions) { .then(function permissionsReceived(permissions) {
$scope.permissions = permissions; $scope.permissions = permissions;
@@ -230,7 +230,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Get protocol metadata // Get protocol metadata
schemaService.getProtocols($scope.selectedDataSource) schemaService.getProtocols($scope.selectedDataSource)
.success(function protocolsReceived(protocols) { .then(function protocolsReceived(protocols) {
$scope.protocols = protocols; $scope.protocols = protocols;
}); });
@@ -244,13 +244,13 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Pull data from existing connection // Pull data from existing connection
connectionService.getConnection($scope.selectedDataSource, identifier) connectionService.getConnection($scope.selectedDataSource, identifier)
.success(function connectionRetrieved(connection) { .then(function connectionRetrieved(connection) {
$scope.connection = connection; $scope.connection = connection;
}); });
// Pull connection history // Pull connection history
connectionService.getConnectionHistory($scope.selectedDataSource, identifier) connectionService.getConnectionHistory($scope.selectedDataSource, identifier)
.success(function historyReceived(historyEntries) { .then(function historyReceived(historyEntries) {
// Wrap all history entries for sake of display // Wrap all history entries for sake of display
$scope.historyEntryWrappers = []; $scope.historyEntryWrappers = [];
@@ -262,7 +262,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Pull connection parameters // Pull connection parameters
connectionService.getConnectionParameters($scope.selectedDataSource, identifier) connectionService.getConnectionParameters($scope.selectedDataSource, identifier)
.success(function parametersReceived(parameters) { .then(function parametersReceived(parameters) {
$scope.parameters = parameters; $scope.parameters = parameters;
}); });
} }
@@ -272,7 +272,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Pull data from cloned connection // Pull data from cloned connection
connectionService.getConnection($scope.selectedDataSource, cloneSourceIdentifier) connectionService.getConnection($scope.selectedDataSource, cloneSourceIdentifier)
.success(function connectionRetrieved(connection) { .then(function connectionRetrieved(connection) {
$scope.connection = connection; $scope.connection = connection;
// Clear the identifier field because this connection is new // Clear the identifier field because this connection is new
@@ -284,7 +284,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Pull connection parameters from cloned connection // Pull connection parameters from cloned connection
connectionService.getConnectionParameters($scope.selectedDataSource, cloneSourceIdentifier) connectionService.getConnectionParameters($scope.selectedDataSource, cloneSourceIdentifier)
.success(function parametersReceived(parameters) { .then(function parametersReceived(parameters) {
$scope.parameters = parameters; $scope.parameters = parameters;
}); });
} }
@@ -388,7 +388,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Save the connection // Save the connection
connectionService.saveConnection($scope.selectedDataSource, $scope.connection) connectionService.saveConnection($scope.selectedDataSource, $scope.connection)
.success(function savedConnection() { .then(function savedConnection() {
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })
@@ -438,7 +438,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
// Delete the connection // Delete the connection
connectionService.deleteConnection($scope.selectedDataSource, $scope.connection) connectionService.deleteConnection($scope.selectedDataSource, $scope.connection)
.success(function deletedConnection() { .then(function deletedConnection() {
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })

View File

@@ -129,13 +129,13 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
// Pull connection group attribute schema // Pull connection group attribute schema
schemaService.getConnectionGroupAttributes($scope.selectedDataSource) schemaService.getConnectionGroupAttributes($scope.selectedDataSource)
.success(function attributesReceived(attributes) { .then(function attributesReceived(attributes) {
$scope.attributes = attributes; $scope.attributes = attributes;
}); });
// Query the user's permissions for the current connection group // Query the user's permissions for the current connection group
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername()) permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
.success(function permissionsReceived(permissions) { .then(function permissionsReceived(permissions) {
$scope.permissions = permissions; $scope.permissions = permissions;
@@ -161,14 +161,14 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
ConnectionGroup.ROOT_IDENTIFIER, ConnectionGroup.ROOT_IDENTIFIER,
[PermissionSet.ObjectPermissionType.ADMINISTER] [PermissionSet.ObjectPermissionType.ADMINISTER]
) )
.success(function connectionGroupReceived(rootGroup) { .then(function connectionGroupReceived(rootGroup) {
$scope.rootGroup = rootGroup; $scope.rootGroup = rootGroup;
}); });
// If we are editing an existing connection group, pull its data // If we are editing an existing connection group, pull its data
if (identifier) { if (identifier) {
connectionGroupService.getConnectionGroup($scope.selectedDataSource, identifier) connectionGroupService.getConnectionGroup($scope.selectedDataSource, identifier)
.success(function connectionGroupReceived(connectionGroup) { .then(function connectionGroupReceived(connectionGroup) {
$scope.connectionGroup = connectionGroup; $scope.connectionGroup = connectionGroup;
}); });
} }
@@ -230,12 +230,12 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
// Save the connection // Save the connection
connectionGroupService.saveConnectionGroup($scope.selectedDataSource, $scope.connectionGroup) connectionGroupService.saveConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
.success(function savedConnectionGroup() { .then(function savedConnectionGroup() {
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })
// Notify of any errors // Notify of any errors
.error(function connectionGroupSaveFailed(error) { ['catch'](function connectionGroupSaveFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
@@ -280,12 +280,12 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
// Delete the connection group // Delete the connection group
connectionGroupService.deleteConnectionGroup($scope.selectedDataSource, $scope.connectionGroup) connectionGroupService.deleteConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
.success(function deletedConnectionGroup() { .then(function deletedConnectionGroup() {
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })
// Notify of any errors // Notify of any errors
.error(function connectionGroupDeletionFailed(error) { ['catch'](function connectionGroupDeletionFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',

View File

@@ -170,13 +170,13 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Pull sharing profile attribute schema // Pull sharing profile attribute schema
schemaService.getSharingProfileAttributes($scope.selectedDataSource) schemaService.getSharingProfileAttributes($scope.selectedDataSource)
.success(function attributesReceived(attributes) { .then(function attributesReceived(attributes) {
$scope.attributes = attributes; $scope.attributes = attributes;
}); });
// Query the user's permissions for the current sharing profile // Query the user's permissions for the current sharing profile
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername()) permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
.success(function permissionsReceived(permissions) { .then(function permissionsReceived(permissions) {
$scope.permissions = permissions; $scope.permissions = permissions;
@@ -212,7 +212,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Get protocol metadata // Get protocol metadata
schemaService.getProtocols($scope.selectedDataSource) schemaService.getProtocols($scope.selectedDataSource)
.success(function protocolsReceived(protocols) { .then(function protocolsReceived(protocols) {
$scope.protocols = protocols; $scope.protocols = protocols;
}); });
@@ -221,13 +221,13 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Pull data from existing sharing profile // Pull data from existing sharing profile
sharingProfileService.getSharingProfile($scope.selectedDataSource, identifier) sharingProfileService.getSharingProfile($scope.selectedDataSource, identifier)
.success(function sharingProfileRetrieved(sharingProfile) { .then(function sharingProfileRetrieved(sharingProfile) {
$scope.sharingProfile = sharingProfile; $scope.sharingProfile = sharingProfile;
}); });
// Pull sharing profile parameters // Pull sharing profile parameters
sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, identifier) sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, identifier)
.success(function parametersReceived(parameters) { .then(function parametersReceived(parameters) {
$scope.parameters = parameters; $scope.parameters = parameters;
}); });
@@ -238,7 +238,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Pull data from cloned sharing profile // Pull data from cloned sharing profile
sharingProfileService.getSharingProfile($scope.selectedDataSource, cloneSourceIdentifier) sharingProfileService.getSharingProfile($scope.selectedDataSource, cloneSourceIdentifier)
.success(function sharingProfileRetrieved(sharingProfile) { .then(function sharingProfileRetrieved(sharingProfile) {
// Store data of sharing profile being cloned // Store data of sharing profile being cloned
$scope.sharingProfile = sharingProfile; $scope.sharingProfile = sharingProfile;
@@ -250,7 +250,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Pull sharing profile parameters from cloned sharing profile // Pull sharing profile parameters from cloned sharing profile
sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, cloneSourceIdentifier) sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, cloneSourceIdentifier)
.success(function parametersReceived(parameters) { .then(function parametersReceived(parameters) {
$scope.parameters = parameters; $scope.parameters = parameters;
}); });
@@ -274,7 +274,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Pull data from existing sharing profile // Pull data from existing sharing profile
connectionService.getConnection($scope.selectedDataSource, identifier) connectionService.getConnection($scope.selectedDataSource, identifier)
.success(function connectionRetrieved(connection) { .then(function connectionRetrieved(connection) {
$scope.primaryConnection = connection; $scope.primaryConnection = connection;
}); });
@@ -351,12 +351,12 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Save the sharing profile // Save the sharing profile
sharingProfileService.saveSharingProfile($scope.selectedDataSource, $scope.sharingProfile) sharingProfileService.saveSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
.success(function savedSharingProfile() { .then(function savedSharingProfile() {
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })
// Notify of any errors // Notify of any errors
.error(function sharingProfileSaveFailed(error) { ['catch'](function sharingProfileSaveFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR',
@@ -389,12 +389,12 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
// Delete the sharing profile // Delete the sharing profile
sharingProfileService.deleteSharingProfile($scope.selectedDataSource, $scope.sharingProfile) sharingProfileService.deleteSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
.success(function deletedSharingProfile() { .then(function deletedSharingProfile() {
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections'); $location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
}) })
// Notify of any errors // Notify of any errors
.error(function sharingProfileDeletionFailed(error) { ['catch'](function sharingProfileDeletionFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR',

View File

@@ -529,7 +529,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
}); });
// Pull user attribute schema // Pull user attribute schema
schemaService.getUserAttributes(selectedDataSource).success(function attributesReceived(attributes) { schemaService.getUserAttributes(selectedDataSource).then(function attributesReceived(attributes) {
$scope.attributes = attributes; $scope.attributes = attributes;
}); });
@@ -557,12 +557,12 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
$scope.selfUsername = username; $scope.selfUsername = username;
// Pull user permissions // Pull user permissions
permissionService.getPermissions(selectedDataSource, username).success(function gotPermissions(permissions) { permissionService.getPermissions(selectedDataSource, username).then(function gotPermissions(permissions) {
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions); $scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions);
}) })
// If permissions cannot be retrieved, use empty permissions // If permissions cannot be retrieved, use empty permissions
.error(function permissionRetrievalFailed() { ['catch'](function permissionRetrievalFailed() {
$scope.permissionFlags = new PermissionFlagSet(); $scope.permissionFlags = new PermissionFlagSet();
}); });
} }
@@ -585,13 +585,13 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
// Pull user permissions // Pull user permissions
permissionService.getPermissions(selectedDataSource, cloneSourceUsername) permissionService.getPermissions(selectedDataSource, cloneSourceUsername)
.success(function gotPermissions(permissions) { .then(function gotPermissions(permissions) {
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions); $scope.permissionFlags = PermissionFlagSet.fromPermissionSet(permissions);
permissionsAdded = permissions; permissionsAdded = permissions;
}) })
// If permissions cannot be retrieved, use empty permissions // If permissions cannot be retrieved, use empty permissions
.error(function permissionRetrievalFailed() { ['catch'](function permissionRetrievalFailed() {
$scope.permissionFlags = new PermissionFlagSet(); $scope.permissionFlags = new PermissionFlagSet();
}); });
} }
@@ -1117,7 +1117,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
else else
saveUserPromise = userService.createUser(selectedDataSource, $scope.user); saveUserPromise = userService.createUser(selectedDataSource, $scope.user);
saveUserPromise.success(function savedUser() { saveUserPromise.then(function savedUser() {
// Move permission flags if username differs from marker // Move permission flags if username differs from marker
if ($scope.selfUsername !== $scope.user.username) { if ($scope.selfUsername !== $scope.user.username) {
@@ -1138,12 +1138,12 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
// Upon success, save any changed permissions // Upon success, save any changed permissions
permissionService.patchPermissions(selectedDataSource, $scope.user.username, permissionsAdded, permissionsRemoved) permissionService.patchPermissions(selectedDataSource, $scope.user.username, permissionsAdded, permissionsRemoved)
.success(function patchedUserPermissions() { .then(function patchedUserPermissions() {
$location.url('/settings/users'); $location.url('/settings/users');
}) })
// Notify of any errors // Notify of any errors
.error(function userPermissionsPatchFailed(error) { ['catch'](function userPermissionsPatchFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
@@ -1201,12 +1201,12 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
// Delete the user // Delete the user
userService.deleteUser(selectedDataSource, $scope.user) userService.deleteUser(selectedDataSource, $scope.user)
.success(function deletedUser() { .then(function deletedUser() {
$location.path('/settings/users'); $location.path('/settings/users');
}) })
// Notify of any errors // Notify of any errors
.error(function userDeletionFailed(error) { ['catch'](function userDeletionFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
'className' : 'error', 'className' : 'error',
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR', 'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',

View File

@@ -32,7 +32,7 @@
<tr> <tr>
<th>{{'MANAGE_CONNECTION.FIELD_HEADER_PROTOCOL' | translate}}</th> <th>{{'MANAGE_CONNECTION.FIELD_HEADER_PROTOCOL' | translate}}</th>
<td> <td>
<select ng-model="connection.protocol" ng-options="name as getProtocolName(protocol.name) | translate for (name, protocol) in protocols | orderBy: name"></select> <select ng-model="connection.protocol" ng-options="protocol.name as getProtocolName(protocol.name) | translate for protocol in protocols | toArray | orderBy: name"></select>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -96,7 +96,7 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
// Pull user data // Pull user data
userService.getUser(authenticationService.getDataSource(), $scope.username) userService.getUser(authenticationService.getDataSource(), $scope.username)
.success(function userRetrieved(user) { .then(function userRetrieved(user) {
// Store retrieved user object // Store retrieved user object
$scope.user = user; $scope.user = user;

View File

@@ -88,7 +88,9 @@ angular.module('osk').directive('guacOsk', [function guacOsk() {
}) })
// Build OSK with retrieved layout // Build OSK with retrieved layout
.success(function layoutRetrieved(layout) { .then(function layoutRetrieved(request) {
var layout = request.data;
// Abort if the layout changed while we were waiting for a response // Abort if the layout changed while we were waiting for a response
if ($scope.layout !== url) if ($scope.layout !== url)

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
function activeConnectionService($injector) { function activeConnectionService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var $q = $injector.get('$q'); var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
@@ -58,7 +58,7 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve tunnels // Retrieve tunnels
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections',
params : httpParameters params : httpParameters
@@ -102,7 +102,7 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
angular.forEach(dataSources, function retrieveActiveConnections(dataSource) { angular.forEach(dataSources, function retrieveActiveConnections(dataSource) {
activeConnectionRequests.push( activeConnectionRequests.push(
service.getActiveConnections(dataSource, permissionTypes) service.getActiveConnections(dataSource, permissionTypes)
.success(function activeConnectionsRetrieved(activeConnections) { .then(function activeConnectionsRetrieved(activeConnections) {
activeConnectionMaps[dataSource] = activeConnections; activeConnectionMaps[dataSource] = activeConnections;
}) })
); );
@@ -157,7 +157,7 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
}); });
// Perform active connection deletion via PATCH // Perform active connection deletion via PATCH
return $http({ return requestService({
method : 'PATCH', method : 'PATCH',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/activeConnections',
params : httpParameters, params : httpParameters,
@@ -191,7 +191,7 @@ angular.module('rest').factory('activeConnectionService', ['$injector',
}; };
// Generate sharing credentials // Generate sharing credentials
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) url : 'api/session/data/' + encodeURIComponent(dataSource)
+ '/activeConnections/' + encodeURIComponent(id) + '/activeConnections/' + encodeURIComponent(id)

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
function connectionGroupService($injector) { function connectionGroupService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var $q = $injector.get('$q'); var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -70,7 +70,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve connection group // Retrieve connection group
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID) + '/tree', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID) + '/tree',
@@ -103,7 +103,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
}; };
// Retrieve connection group // Retrieve connection group
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroupID),
@@ -134,7 +134,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
// If connection group is new, add it and set the identifier automatically // If connection group is new, add it and set the identifier automatically
if (!connectionGroup.identifier) { if (!connectionGroup.identifier) {
return $http({ return requestService({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups',
params : httpParameters, params : httpParameters,
@@ -142,7 +142,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
}) })
// Set the identifier on the new connection group and clear the cache // Set the identifier on the new connection group and clear the cache
.success(function connectionGroupCreated(newConnectionGroup){ .then(function connectionGroupCreated(newConnectionGroup){
connectionGroup.identifier = newConnectionGroup.identifier; connectionGroup.identifier = newConnectionGroup.identifier;
cacheService.connections.removeAll(); cacheService.connections.removeAll();
@@ -154,7 +154,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
// Otherwise, update the existing connection group // Otherwise, update the existing connection group
else { else {
return $http({ return requestService({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier),
params : httpParameters, params : httpParameters,
@@ -162,7 +162,7 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function connectionGroupUpdated(){ .then(function connectionGroupUpdated(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
// Clear users cache to force reload of permissions for this // Clear users cache to force reload of permissions for this
@@ -191,14 +191,14 @@ angular.module('rest').factory('connectionGroupService', ['$injector',
}; };
// Delete connection group // Delete connection group
return $http({ return requestService({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connectionGroups/' + encodeURIComponent(connectionGroup.identifier),
params : httpParameters params : httpParameters
}) })
// Clear the cache // Clear the cache
.success(function connectionGroupDeleted(){ .then(function connectionGroupDeleted(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
}); });

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('connectionService', ['$injector',
function connectionService($injector) { function connectionService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -41,7 +41,7 @@ angular.module('rest').factory('connectionService', ['$injector',
* *
* @example * @example
* *
* connectionService.getConnection('myConnection').success(function(connection) { * connectionService.getConnection('myConnection').then(function(connection) {
* // Do something with the connection * // Do something with the connection
* }); * });
*/ */
@@ -53,7 +53,7 @@ angular.module('rest').factory('connectionService', ['$injector',
}; };
// Retrieve connection // Retrieve connection
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id),
@@ -82,7 +82,7 @@ angular.module('rest').factory('connectionService', ['$injector',
}; };
// Retrieve connection history // Retrieve connection history
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/history', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/history',
params : httpParameters params : httpParameters
@@ -110,7 +110,7 @@ angular.module('rest').factory('connectionService', ['$injector',
}; };
// Retrieve connection parameters // Retrieve connection parameters
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/parameters', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(id) + '/parameters',
@@ -141,7 +141,7 @@ angular.module('rest').factory('connectionService', ['$injector',
// If connection is new, add it and set the identifier automatically // If connection is new, add it and set the identifier automatically
if (!connection.identifier) { if (!connection.identifier) {
return $http({ return requestService({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections',
params : httpParameters, params : httpParameters,
@@ -149,7 +149,7 @@ angular.module('rest').factory('connectionService', ['$injector',
}) })
// Set the identifier on the new connection and clear the cache // Set the identifier on the new connection and clear the cache
.success(function connectionCreated(newConnection){ .then(function connectionCreated(newConnection){
connection.identifier = newConnection.identifier; connection.identifier = newConnection.identifier;
cacheService.connections.removeAll(); cacheService.connections.removeAll();
@@ -161,7 +161,7 @@ angular.module('rest').factory('connectionService', ['$injector',
// Otherwise, update the existing connection // Otherwise, update the existing connection
else { else {
return $http({ return requestService({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier),
params : httpParameters, params : httpParameters,
@@ -169,7 +169,7 @@ angular.module('rest').factory('connectionService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function connectionUpdated(){ .then(function connectionUpdated(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
// Clear users cache to force reload of permissions for this // Clear users cache to force reload of permissions for this
@@ -198,14 +198,14 @@ angular.module('rest').factory('connectionService', ['$injector',
}; };
// Delete connection // Delete connection
return $http({ return requestService({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections/' + encodeURIComponent(connection.identifier),
params : httpParameters params : httpParameters
}) })
// Clear the cache // Clear the cache
.success(function connectionDeleted(){ .then(function connectionDeleted(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
}); });

View File

@@ -23,6 +23,9 @@
angular.module('rest').factory('dataSourceService', ['$injector', angular.module('rest').factory('dataSourceService', ['$injector',
function dataSourceService($injector) { function dataSourceService($injector) {
// Required types
var Error = $injector.get('Error');
// Required services // Required services
var $q = $injector.get('$q'); var $q = $injector.get('$q');
@@ -83,21 +86,20 @@ angular.module('rest').factory('dataSourceService', ['$injector',
fn.apply(this, [dataSource].concat(args)) fn.apply(this, [dataSource].concat(args))
// Store result on success // Store result on success
.then(function immediateRequestSucceeded(response) { .then(function immediateRequestSucceeded(data) {
results[dataSource] = response.data; results[dataSource] = data;
deferredRequest.resolve(); deferredRequest.resolve();
}, },
// Fail on any errors (except "NOT FOUND") // Fail on any errors (except "NOT FOUND")
function immediateRequestFailed(response) { function immediateRequestFailed(error) {
// Ignore "NOT FOUND" errors if (error.type === Error.Type.NOT_FOUND)
if (response.status === 404)
deferredRequest.resolve(); deferredRequest.resolve();
// Explicitly abort for all other errors // Explicitly abort for all other errors
else else
deferredRequest.reject(response); deferredRequest.reject(error);
}); });

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('historyService', ['$injector',
function historyService($injector) { function historyService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var service = {}; var service = {};
@@ -74,7 +74,7 @@ angular.module('rest').factory('historyService', ['$injector',
httpParameters.order = sortPredicates; httpParameters.order = sortPredicates;
// Retrieve connection history // Retrieve connection history
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/history/connections', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/history/connections',
params : httpParameters params : httpParameters

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('languageService', ['$injector',
function languageService($injector) { function languageService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -47,7 +47,7 @@ angular.module('rest').factory('languageService', ['$injector',
}; };
// Retrieve available languages // Retrieve available languages
return $http({ return requestService({
cache : cacheService.languages, cache : cacheService.languages,
method : 'GET', method : 'GET',
url : 'api/languages', url : 'api/languages',

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('patchService', ['$injector',
function patchService($injector) { function patchService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -48,7 +48,7 @@ angular.module('rest').factory('patchService', ['$injector',
}; };
// Retrieve all applicable HTML patches // Retrieve all applicable HTML patches
return $http({ return requestService({
cache : cacheService.patches, cache : cacheService.patches,
method : 'GET', method : 'GET',
url : 'api/patches', url : 'api/patches',

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('permissionService', ['$injector',
function permissionService($injector) { function permissionService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var $q = $injector.get('$q'); var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -103,7 +103,7 @@ angular.module('rest').factory('permissionService', ['$injector',
}; };
// Retrieve user permissions // Retrieve user permissions
return $http({ return requestService({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : getEffectivePermissionsResourceURL(dataSource, userID), url : getEffectivePermissionsResourceURL(dataSource, userID),
@@ -182,7 +182,7 @@ angular.module('rest').factory('permissionService', ['$injector',
}; };
// Retrieve user permissions // Retrieve user permissions
return $http({ return requestService({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : getPermissionsResourceURL(dataSource, identifier), url : getPermissionsResourceURL(dataSource, identifier),
@@ -315,7 +315,7 @@ angular.module('rest').factory('permissionService', ['$injector',
addPatchOperations(permissionPatch, PermissionPatch.Operation.REMOVE, permissionsToRemove); addPatchOperations(permissionPatch, PermissionPatch.Operation.REMOVE, permissionsToRemove);
// Patch user permissions // Patch user permissions
return $http({ return requestService({
method : 'PATCH', method : 'PATCH',
url : getPermissionsResourceURL(dataSource, identifier), url : getPermissionsResourceURL(dataSource, identifier),
params : httpParameters, params : httpParameters,
@@ -323,7 +323,7 @@ angular.module('rest').factory('permissionService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function permissionsPatched(){ .then(function permissionsPatched(){
cacheService.users.removeAll(); cacheService.users.removeAll();
}); });
}; };

View File

@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* Service for converting $http promises that pass the entire response into
* promises that pass only the data from that response.
*/
angular.module('rest').factory('requestService', ['$q', '$http', 'Error',
function requestService($q, $http, Error) {
/**
* Given a configuration object formatted for the $http service, returns
* a promise that will resolve or reject with only the data from the $http
* response.
*
* @param {Object} object
* Configuration object for $http service call.
*
* @returns {Promise}
* A promise that will resolve or reject with the data from the response
* to the $http call.
*/
var wrappedHttpCall = function wrappedHttpCall(object) {
return $http(object).then(
function success(request) { return request.data; },
function failure(request) { throw new Error(request.data); }
);
}
return wrappedHttpCall;
}]);

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('schemaService', ['$injector',
function schemaService($injector) { function schemaService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -55,7 +55,7 @@ angular.module('rest').factory('schemaService', ['$injector',
}; };
// Retrieve available user attributes // Retrieve available user attributes
return $http({ return requestService({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userAttributes',
@@ -89,7 +89,7 @@ angular.module('rest').factory('schemaService', ['$injector',
}; };
// Retrieve available connection attributes // Retrieve available connection attributes
return $http({ return requestService({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionAttributes',
@@ -123,7 +123,7 @@ angular.module('rest').factory('schemaService', ['$injector',
}; };
// Retrieve available sharing profile attributes // Retrieve available sharing profile attributes
return $http({ return requestService({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes',
@@ -157,7 +157,7 @@ angular.module('rest').factory('schemaService', ['$injector',
}; };
// Retrieve available connection group attributes // Retrieve available connection group attributes
return $http({ return requestService({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionGroupAttributes', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionGroupAttributes',
@@ -188,7 +188,7 @@ angular.module('rest').factory('schemaService', ['$injector',
}; };
// Retrieve available protocols // Retrieve available protocols
return $http({ return requestService({
cache : cacheService.schema, cache : cacheService.schema,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/protocols', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/protocols',

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
function sharingProfileService($injector) { function sharingProfileService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -43,7 +43,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
* *
* @example * @example
* *
* sharingProfileService.getSharingProfile('mySharingProfile').success(function(sharingProfile) { * sharingProfileService.getSharingProfile('mySharingProfile').then(function(sharingProfile) {
* // Do something with the sharing profile * // Do something with the sharing profile
* }); * });
*/ */
@@ -55,7 +55,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
}; };
// Retrieve sharing profile // Retrieve sharing profile
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id),
@@ -84,7 +84,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
}; };
// Retrieve sharing profile parameters // Retrieve sharing profile parameters
return $http({ return requestService({
cache : cacheService.connections, cache : cacheService.connections,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id) + '/parameters', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(id) + '/parameters',
@@ -116,7 +116,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
// If sharing profile is new, add it and set the identifier automatically // If sharing profile is new, add it and set the identifier automatically
if (!sharingProfile.identifier) { if (!sharingProfile.identifier) {
return $http({ return requestService({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles',
params : httpParameters, params : httpParameters,
@@ -124,7 +124,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
}) })
// Set the identifier on the new sharing profile and clear the cache // Set the identifier on the new sharing profile and clear the cache
.success(function sharingProfileCreated(newSharingProfile){ .then(function sharingProfileCreated(newSharingProfile){
sharingProfile.identifier = newSharingProfile.identifier; sharingProfile.identifier = newSharingProfile.identifier;
cacheService.connections.removeAll(); cacheService.connections.removeAll();
@@ -136,7 +136,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
// Otherwise, update the existing sharing profile // Otherwise, update the existing sharing profile
else { else {
return $http({ return requestService({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier),
params : httpParameters, params : httpParameters,
@@ -144,7 +144,7 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function sharingProfileUpdated(){ .then(function sharingProfileUpdated(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
// Clear users cache to force reload of permissions for this // Clear users cache to force reload of permissions for this
@@ -174,14 +174,14 @@ angular.module('rest').factory('sharingProfileService', ['$injector',
}; };
// Delete sharing profile // Delete sharing profile
return $http({ return requestService({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/sharingProfiles/' + encodeURIComponent(sharingProfile.identifier),
params : httpParameters params : httpParameters
}) })
// Clear the cache // Clear the cache
.success(function sharingProfileDeleted(){ .then(function sharingProfileDeleted(){
cacheService.connections.removeAll(); cacheService.connections.removeAll();
}); });

View File

@@ -28,10 +28,10 @@ angular.module('rest').factory('tunnelService', ['$injector',
var Error = $injector.get('Error'); var Error = $injector.get('Error');
// Required services // Required services
var $http = $injector.get('$http');
var $q = $injector.get('$q'); var $q = $injector.get('$q');
var $window = $injector.get('$window'); var $window = $injector.get('$window');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var requestService = $injector.get('requestService');
var service = {}; var service = {};
@@ -71,7 +71,7 @@ angular.module('rest').factory('tunnelService', ['$injector',
}; };
// Retrieve tunnels // Retrieve tunnels
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/tunnels', url : 'api/session/tunnels',
params : httpParameters params : httpParameters
@@ -100,7 +100,7 @@ angular.module('rest').factory('tunnelService', ['$injector',
}; };
// Retrieve all associated sharing profiles // Retrieve all associated sharing profiles
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/tunnels/' + encodeURIComponent(tunnel) url : 'api/session/tunnels/' + encodeURIComponent(tunnel)
+ '/activeConnection/connection/sharingProfiles', + '/activeConnection/connection/sharingProfiles',
@@ -136,7 +136,7 @@ angular.module('rest').factory('tunnelService', ['$injector',
}; };
// Generate sharing credentials // Generate sharing credentials
return $http({ return requestService({
method : 'GET', method : 'GET',
url : 'api/session/tunnels/' + encodeURIComponent(tunnel) url : 'api/session/tunnels/' + encodeURIComponent(tunnel)
+ '/activeConnection/sharingCredentials/' + '/activeConnection/sharingCredentials/'

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('userService', ['$injector',
function userService($injector) { function userService($injector) {
// Required services // Required services
var $http = $injector.get('$http'); var requestService = $injector.get('requestService');
var $q = $injector.get('$q'); var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService'); var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService'); var cacheService = $injector.get('cacheService');
@@ -67,7 +67,7 @@ angular.module('rest').factory('userService', ['$injector',
httpParameters.permission = permissionTypes; httpParameters.permission = permissionTypes;
// Retrieve users // Retrieve users
return $http({ return requestService({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users',
@@ -100,7 +100,7 @@ angular.module('rest').factory('userService', ['$injector',
}; };
// Retrieve user // Retrieve user
return $http({ return requestService({
cache : cacheService.users, cache : cacheService.users,
method : 'GET', method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username),
@@ -133,14 +133,14 @@ angular.module('rest').factory('userService', ['$injector',
}; };
// Delete user // Delete user
return $http({ return requestService({
method : 'DELETE', method : 'DELETE',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username),
params : httpParameters params : httpParameters
}) })
// Clear the cache // Clear the cache
.success(function userDeleted(){ .then(function userDeleted(){
cacheService.users.removeAll(); cacheService.users.removeAll();
}); });
@@ -171,7 +171,7 @@ angular.module('rest').factory('userService', ['$injector',
}; };
// Create user // Create user
return $http({ return requestService({
method : 'POST', method : 'POST',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users',
params : httpParameters, params : httpParameters,
@@ -179,7 +179,7 @@ angular.module('rest').factory('userService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function userCreated(){ .then(function userCreated(){
cacheService.users.removeAll(); cacheService.users.removeAll();
}); });
@@ -209,7 +209,7 @@ angular.module('rest').factory('userService', ['$injector',
}; };
// Update user // Update user
return $http({ return requestService({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username),
params : httpParameters, params : httpParameters,
@@ -217,7 +217,7 @@ angular.module('rest').factory('userService', ['$injector',
}) })
// Clear the cache // Clear the cache
.success(function userUpdated(){ .then(function userUpdated(){
cacheService.users.removeAll(); cacheService.users.removeAll();
}); });
@@ -254,7 +254,7 @@ angular.module('rest').factory('userService', ['$injector',
}; };
// Update user password // Update user password
return $http({ return requestService({
method : 'PUT', method : 'PUT',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username) + '/password', url : 'api/session/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username) + '/password',
params : httpParameters, params : httpParameters,

View File

@@ -169,7 +169,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
return predicate === 'startDate' || predicate === '-startDate'; return predicate === 'startDate' || predicate === '-startDate';
}) })
) )
.success(function historyRetrieved(historyEntries) { .then(function historyRetrieved(historyEntries) {
// Wrap all history entries for sake of display // Wrap all history entries for sake of display
$scope.historyEntryWrappers = []; $scope.historyEntryWrappers = [];

View File

@@ -405,7 +405,7 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
// Retrieve current permissions // Retrieve current permissions
permissionService.getEffectivePermissions($scope.dataSource, currentUsername) permissionService.getEffectivePermissions($scope.dataSource, currentUsername)
.success(function permissionsRetrieved(permissions) { .then(function permissionsRetrieved(permissions) {
// Store retrieved permissions // Store retrieved permissions
$scope.permissions = permissions; $scope.permissions = permissions;

View File

@@ -150,7 +150,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
// Save the user with the new password // Save the user with the new password
userService.updateUserPassword(dataSource, username, $scope.oldPassword, $scope.newPassword) userService.updateUserPassword(dataSource, username, $scope.oldPassword, $scope.newPassword)
.success(function passwordUpdated() { .then(function passwordUpdated() {
// Clear the password fields // Clear the password fields
$scope.oldPassword = null; $scope.oldPassword = null;
@@ -167,7 +167,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
}) })
// Notify of any errors // Notify of any errors
.error(function passwordUpdateFailed(error) { ['catch'](function passwordUpdateFailed(error) {
guacNotification.showStatus({ guacNotification.showStatus({
className : 'error', className : 'error',
title : 'SETTINGS_PREFERENCES.DIALOG_HEADER_ERROR', title : 'SETTINGS_PREFERENCES.DIALOG_HEADER_ERROR',
@@ -180,20 +180,25 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
// Retrieve defined languages // Retrieve defined languages
languageService.getLanguages() languageService.getLanguages()
.success(function languagesRetrieved(languages) { .then(function languagesRetrieved(languages) {
$scope.languages = languages; $scope.languages = Object.keys(languages).map(function(key) {
return {
key: key,
value: languages[key]
};
})
}); });
// Retrieve current permissions // Retrieve current permissions
permissionService.getEffectivePermissions(dataSource, username) permissionService.getEffectivePermissions(dataSource, username)
.success(function permissionsRetrieved(permissions) { .then(function permissionsRetrieved(permissions) {
// Add action for changing password if permission is granted // Add action for changing password if permission is granted
$scope.canChangePassword = PermissionSet.hasUserPermission(permissions, $scope.canChangePassword = PermissionSet.hasUserPermission(permissions,
PermissionSet.ObjectPermissionType.UPDATE, username); PermissionSet.ObjectPermissionType.UPDATE, username);
}) })
.error(function permissionsFailed(error) { ['catch'](function permissionsFailed(error) {
$scope.canChangePassword = false; $scope.canChangePassword = false;
}); });

View File

@@ -9,7 +9,7 @@
<table class="fields"> <table class="fields">
<tr> <tr>
<th>{{'SETTINGS_PREFERENCES.FIELD_HEADER_LANGUAGE' | translate}}</th> <th>{{'SETTINGS_PREFERENCES.FIELD_HEADER_LANGUAGE' | translate}}</th>
<td><select ng-model="preferences.language" ng-change="changeLanguage()" ng-options="key as name for (key, name) in languages | orderBy: name"></select></td> <td><select ng-model="preferences.language" ng-change="changeLanguage()" ng-options="language.key as language.value for language in languages | orderBy: key"></select></td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@@ -61,15 +61,15 @@
<script type="text/javascript" src="webjars/lodash/2.4.1/dist/lodash.min.js"></script> <script type="text/javascript" src="webjars/lodash/2.4.1/dist/lodash.min.js"></script>
<!-- AngularJS --> <!-- AngularJS -->
<script type="text/javascript" src="webjars/angular/1.3.16/angular.min.js"></script> <script type="text/javascript" src="webjars/angular/1.6.9/angular.min.js"></script>
<script type="text/javascript" src="webjars/angular-route/1.3.16/angular-route.min.js"></script> <script type="text/javascript" src="webjars/angular-route/1.6.9/angular-route.min.js"></script>
<script type="text/javascript" src="webjars/angular-touch/1.3.16/angular-touch.min.js"></script> <script type="text/javascript" src="webjars/angular-touch/1.6.9/angular-touch.min.js"></script>
<!-- Internationalization --> <!-- Internationalization -->
<script type="text/javascript" src="webjars/messageformat/1.0.2/messageformat.min.js"></script> <script type="text/javascript" src="webjars/messageformat/1.0.2/messageformat.min.js"></script>
<script type="text/javascript" src="webjars/angular-translate/2.8.0/angular-translate.min.js"></script> <script type="text/javascript" src="webjars/angular-translate/2.16.0/angular-translate.min.js"></script>
<script type="text/javascript" src="webjars/angular-translate-interpolation-messageformat/2.8.0/angular-translate-interpolation-messageformat.min.js"></script> <script type="text/javascript" src="webjars/angular-translate-interpolation-messageformat/2.16.0/angular-translate-interpolation-messageformat.min.js"></script>
<script type="text/javascript" src="webjars/angular-translate-loader-static-files/2.8.0/angular-translate-loader-static-files.min.js"></script> <script type="text/javascript" src="webjars/angular-translate-loader-static-files/2.16.0/angular-translate-loader-static-files.min.js"></script>
<!-- Polyfills for Blob and the FileSaver API --> <!-- Polyfills for Blob and the FileSaver API -->
<script type="text/javascript" src="webjars/blob-polyfill/1.0.20150320/Blob.js"></script> <script type="text/javascript" src="webjars/blob-polyfill/1.0.20150320/Blob.js"></script>