GUACAMOLE-526: Update webapp to angular 1.6.9.

This commit is contained in:
James Muehlner
2018-04-25 22:25:02 -07:00
parent 03281667b4
commit b3eeb36b87
36 changed files with 301 additions and 159 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,7 +24,7 @@ angular.module('rest').factory('permissionService', ['$injector',
function permissionService($injector) {
// Required services
var $http = $injector.get('$http');
var requestService = $injector.get('requestService');
var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService');
@@ -103,7 +103,7 @@ angular.module('rest').factory('permissionService', ['$injector',
};
// Retrieve user permissions
return $http({
return requestService({
cache : cacheService.users,
method : 'GET',
url : getEffectivePermissionsResourceURL(dataSource, userID),
@@ -182,7 +182,7 @@ angular.module('rest').factory('permissionService', ['$injector',
};
// Retrieve user permissions
return $http({
return requestService({
cache : cacheService.users,
method : 'GET',
url : getPermissionsResourceURL(dataSource, identifier),
@@ -315,7 +315,7 @@ angular.module('rest').factory('permissionService', ['$injector',
addPatchOperations(permissionPatch, PermissionPatch.Operation.REMOVE, permissionsToRemove);
// Patch user permissions
return $http({
return requestService({
method : 'PATCH',
url : getPermissionsResourceURL(dataSource, identifier),
params : httpParameters,
@@ -323,7 +323,7 @@ angular.module('rest').factory('permissionService', ['$injector',
})
// Clear the cache
.success(function permissionsPatched(){
.then(function permissionsPatched(){
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) {
// Required services
var $http = $injector.get('$http');
var requestService = $injector.get('requestService');
var authenticationService = $injector.get('authenticationService');
var cacheService = $injector.get('cacheService');
@@ -55,7 +55,7 @@ angular.module('rest').factory('schemaService', ['$injector',
};
// Retrieve available user attributes
return $http({
return requestService({
cache : cacheService.schema,
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/userAttributes',
@@ -89,7 +89,7 @@ angular.module('rest').factory('schemaService', ['$injector',
};
// Retrieve available connection attributes
return $http({
return requestService({
cache : cacheService.schema,
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionAttributes',
@@ -123,7 +123,7 @@ angular.module('rest').factory('schemaService', ['$injector',
};
// Retrieve available sharing profile attributes
return $http({
return requestService({
cache : cacheService.schema,
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/sharingProfileAttributes',
@@ -157,7 +157,7 @@ angular.module('rest').factory('schemaService', ['$injector',
};
// Retrieve available connection group attributes
return $http({
return requestService({
cache : cacheService.schema,
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/connectionGroupAttributes',
@@ -188,7 +188,7 @@ angular.module('rest').factory('schemaService', ['$injector',
};
// Retrieve available protocols
return $http({
return requestService({
cache : cacheService.schema,
method : 'GET',
url : 'api/session/data/' + encodeURIComponent(dataSource) + '/schema/protocols',

View File

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

View File

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

View File

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