mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-09 14:41:21 +00:00
GUACAMOLE-526: Handle rejections for absolutely all promises.
This commit is contained in:
@@ -38,21 +38,10 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
var connectionService = $injector.get('connectionService');
|
||||
var connectionGroupService = $injector.get('connectionGroupService');
|
||||
var permissionService = $injector.get('permissionService');
|
||||
var requestService = $injector.get('requestService');
|
||||
var schemaService = $injector.get('schemaService');
|
||||
var translationStringService = $injector.get('translationStringService');
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to showStatus which
|
||||
* closes the currently-shown status dialog.
|
||||
*/
|
||||
var ACKNOWLEDGE_ACTION = {
|
||||
name : "MANAGE_CONNECTION.ACTION_ACKNOWLEDGE",
|
||||
// Handle action
|
||||
callback : function acknowledgeCallback() {
|
||||
guacNotification.showStatus(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The unique identifier of the data source containing the connection being
|
||||
* edited.
|
||||
@@ -186,7 +175,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
schemaService.getConnectionAttributes($scope.selectedDataSource)
|
||||
.then(function attributesReceived(attributes) {
|
||||
$scope.attributes = attributes;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull connection group hierarchy
|
||||
connectionGroupService.getConnectionGroupTree(
|
||||
@@ -196,7 +185,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
)
|
||||
.then(function connectionGroupReceived(rootGroup) {
|
||||
$scope.rootGroup = rootGroup;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Query the user's permissions for the current connection
|
||||
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
|
||||
@@ -226,18 +215,18 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Get protocol metadata
|
||||
schemaService.getProtocols($scope.selectedDataSource)
|
||||
.then(function protocolsReceived(protocols) {
|
||||
$scope.protocols = protocols;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Get history date format
|
||||
$translate('MANAGE_CONNECTION.FORMAT_HISTORY_START').then(function historyDateFormatReceived(historyDateFormat) {
|
||||
$scope.historyDateFormat = historyDateFormat;
|
||||
});
|
||||
}, angular.noop);
|
||||
|
||||
// If we are editing an existing connection, pull its data
|
||||
if (identifier) {
|
||||
@@ -246,7 +235,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
connectionService.getConnection($scope.selectedDataSource, identifier)
|
||||
.then(function connectionRetrieved(connection) {
|
||||
$scope.connection = connection;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull connection history
|
||||
connectionService.getConnectionHistory($scope.selectedDataSource, identifier)
|
||||
@@ -258,13 +247,13 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
$scope.historyEntryWrappers.push(new HistoryEntryWrapper(historyEntry));
|
||||
});
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull connection parameters
|
||||
connectionService.getConnectionParameters($scope.selectedDataSource, identifier)
|
||||
.then(function parametersReceived(parameters) {
|
||||
$scope.parameters = parameters;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
}
|
||||
|
||||
// If we are cloning an existing connection, pull its data instead
|
||||
@@ -277,7 +266,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
|
||||
// Clear the identifier field because this connection is new
|
||||
delete $scope.connection.identifier;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Do not pull connection history
|
||||
$scope.historyEntryWrappers = [];
|
||||
@@ -286,7 +275,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
connectionService.getConnectionParameters($scope.selectedDataSource, cloneSourceIdentifier)
|
||||
.then(function parametersReceived(parameters) {
|
||||
$scope.parameters = parameters;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
}
|
||||
|
||||
// If we are creating a new connection, populate skeleton connection data
|
||||
@@ -390,17 +379,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
connectionService.saveConnection($scope.selectedDataSource, $scope.connection)
|
||||
.then(function savedConnection() {
|
||||
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
.error(function connectionSaveFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
@@ -440,17 +419,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
connectionService.deleteConnection($scope.selectedDataSource, $scope.connection)
|
||||
.then(function deletedConnection() {
|
||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
.error(function connectionDeletionFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_CONNECTION.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -34,20 +34,9 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
var connectionGroupService = $injector.get('connectionGroupService');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var permissionService = $injector.get('permissionService');
|
||||
var requestService = $injector.get('requestService');
|
||||
var schemaService = $injector.get('schemaService');
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to showStatus which
|
||||
* closes the currently-shown status dialog.
|
||||
*/
|
||||
var ACKNOWLEDGE_ACTION = {
|
||||
name : "MANAGE_CONNECTION_GROUP.ACTION_ACKNOWLEDGE",
|
||||
// Handle action
|
||||
callback : function acknowledgeCallback() {
|
||||
guacNotification.showStatus(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The unique identifier of the data source containing the connection group
|
||||
* being edited.
|
||||
@@ -131,7 +120,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
schemaService.getConnectionGroupAttributes($scope.selectedDataSource)
|
||||
.then(function attributesReceived(attributes) {
|
||||
$scope.attributes = attributes;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Query the user's permissions for the current connection group
|
||||
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
|
||||
@@ -152,7 +141,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
|| PermissionSet.hasConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.DELETE, identifier)
|
||||
);
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
|
||||
// Pull connection group hierarchy
|
||||
@@ -163,14 +152,14 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
)
|
||||
.then(function connectionGroupReceived(rootGroup) {
|
||||
$scope.rootGroup = rootGroup;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// If we are editing an existing connection group, pull its data
|
||||
if (identifier) {
|
||||
connectionGroupService.getConnectionGroup($scope.selectedDataSource, identifier)
|
||||
.then(function connectionGroupReceived(connectionGroup) {
|
||||
$scope.connectionGroup = connectionGroup;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
}
|
||||
|
||||
// If we are creating a new connection group, populate skeleton connection group data
|
||||
@@ -232,17 +221,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
connectionGroupService.saveConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
||||
.then(function savedConnectionGroup() {
|
||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function connectionGroupSaveFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
@@ -282,17 +261,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
connectionGroupService.deleteConnectionGroup($scope.selectedDataSource, $scope.connectionGroup)
|
||||
.then(function deletedConnectionGroup() {
|
||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function connectionGroupDeletionFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_CONNECTION_GROUP.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -34,22 +34,11 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
var connectionService = $injector.get('connectionService');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var permissionService = $injector.get('permissionService');
|
||||
var requestService = $injector.get('requestService');
|
||||
var schemaService = $injector.get('schemaService');
|
||||
var sharingProfileService = $injector.get('sharingProfileService');
|
||||
var translationStringService = $injector.get('translationStringService');
|
||||
|
||||
/**
|
||||
* An action which can be provided along with the object sent to showStatus
|
||||
* to allow the user to acknowledge (and close) the currently-shown status
|
||||
* dialog.
|
||||
*/
|
||||
var ACKNOWLEDGE_ACTION = {
|
||||
name : "MANAGE_SHARING_PROFILE.ACTION_ACKNOWLEDGE",
|
||||
callback : function acknowledgeCallback() {
|
||||
guacNotification.showStatus(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to showStatus which
|
||||
* closes the currently-shown status dialog, effectively canceling the
|
||||
@@ -172,7 +161,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
schemaService.getSharingProfileAttributes($scope.selectedDataSource)
|
||||
.then(function attributesReceived(attributes) {
|
||||
$scope.attributes = attributes;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Query the user's permissions for the current sharing profile
|
||||
permissionService.getEffectivePermissions($scope.selectedDataSource, authenticationService.getCurrentUsername())
|
||||
@@ -208,13 +197,13 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
)
|
||||
);
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Get protocol metadata
|
||||
schemaService.getProtocols($scope.selectedDataSource)
|
||||
.then(function protocolsReceived(protocols) {
|
||||
$scope.protocols = protocols;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// If we are editing an existing sharing profile, pull its data
|
||||
if (identifier) {
|
||||
@@ -223,13 +212,13 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
sharingProfileService.getSharingProfile($scope.selectedDataSource, identifier)
|
||||
.then(function sharingProfileRetrieved(sharingProfile) {
|
||||
$scope.sharingProfile = sharingProfile;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull sharing profile parameters
|
||||
sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, identifier)
|
||||
.then(function parametersReceived(parameters) {
|
||||
$scope.parameters = parameters;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
}
|
||||
|
||||
@@ -246,13 +235,13 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
// Clear the identifier field because this sharing profile is new
|
||||
delete $scope.sharingProfile.identifier;
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull sharing profile parameters from cloned sharing profile
|
||||
sharingProfileService.getSharingProfileParameters($scope.selectedDataSource, cloneSourceIdentifier)
|
||||
.then(function parametersReceived(parameters) {
|
||||
$scope.parameters = parameters;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
}
|
||||
|
||||
@@ -276,7 +265,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
connectionService.getConnection($scope.selectedDataSource, identifier)
|
||||
.then(function connectionRetrieved(connection) {
|
||||
$scope.primaryConnection = connection;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
});
|
||||
|
||||
@@ -353,17 +342,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
sharingProfileService.saveSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
||||
.then(function savedSharingProfile() {
|
||||
$location.url('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function sharingProfileSaveFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
@@ -391,17 +370,7 @@ angular.module('manage').controller('manageSharingProfileController', ['$scope',
|
||||
sharingProfileService.deleteSharingProfile($scope.selectedDataSource, $scope.sharingProfile)
|
||||
.then(function deletedSharingProfile() {
|
||||
$location.path('/settings/' + encodeURIComponent($scope.selectedDataSource) + '/connections');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function sharingProfileDeletionFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_SHARING_PROFILE.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -39,6 +39,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
var dataSourceService = $injector.get('dataSourceService');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
var permissionService = $injector.get('permissionService');
|
||||
var requestService = $injector.get('requestService');
|
||||
var schemaService = $injector.get('schemaService');
|
||||
var translationStringService = $injector.get('translationStringService');
|
||||
var userService = $injector.get('userService');
|
||||
@@ -531,7 +532,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
// Pull user attribute schema
|
||||
schemaService.getUserAttributes(selectedDataSource).then(function attributesReceived(attributes) {
|
||||
$scope.attributes = attributes;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Pull user data and permissions if we are editing an existing user
|
||||
if (username) {
|
||||
@@ -550,7 +551,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
'username' : username
|
||||
});
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// The current user will be associated with username of the existing
|
||||
// user in the retrieved permission set
|
||||
@@ -562,9 +563,9 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
})
|
||||
|
||||
// If permissions cannot be retrieved, use empty permissions
|
||||
['catch'](function permissionRetrievalFailed() {
|
||||
['catch'](requestService.createErrorCallback(function permissionRetrievalFailed() {
|
||||
$scope.permissionFlags = new PermissionFlagSet();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// If we are cloning an existing user, pull his/her data instead
|
||||
@@ -577,7 +578,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
$scope.users = {};
|
||||
$scope.user = users[selectedDataSource];
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// The current user will be associated with cloneSourceUsername in the
|
||||
// retrieved permission set
|
||||
@@ -591,9 +592,9 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
})
|
||||
|
||||
// If permissions cannot be retrieved, use empty permissions
|
||||
['catch'](function permissionRetrievalFailed() {
|
||||
['catch'](requestService.createErrorCallback(function permissionRetrievalFailed() {
|
||||
$scope.permissionFlags = new PermissionFlagSet();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Use skeleton data if we are creating a new user
|
||||
@@ -676,7 +677,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
$scope.rootGroups[dataSource] = GroupListItem.fromConnectionGroup(dataSource, rootGroup);
|
||||
});
|
||||
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Query the user's permissions for the current user
|
||||
dataSourceService.apply(
|
||||
@@ -686,7 +687,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
)
|
||||
.then(function permissionsReceived(permissions) {
|
||||
$scope.permissions = permissions;
|
||||
});
|
||||
}, requestService.WARN);
|
||||
|
||||
// Update default expanded state whenever connection groups and associated
|
||||
// permissions change
|
||||
@@ -1140,30 +1141,9 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
permissionService.patchPermissions(selectedDataSource, $scope.user.username, permissionsAdded, permissionsRemoved)
|
||||
.then(function patchedUserPermissions() {
|
||||
$location.url('/settings/users');
|
||||
})
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function userPermissionsPatchFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'values' : error.translationValues,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
.error(function userSaveFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
@@ -1203,17 +1183,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
userService.deleteUser(selectedDataSource, $scope.user)
|
||||
.then(function deletedUser() {
|
||||
$location.path('/settings/users');
|
||||
})
|
||||
|
||||
// Notify of any errors
|
||||
['catch'](function userDeletionFailed(error) {
|
||||
guacNotification.showStatus({
|
||||
'className' : 'error',
|
||||
'title' : 'MANAGE_USER.DIALOG_HEADER_ERROR',
|
||||
'text' : error.translatableMessage,
|
||||
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||
});
|
||||
});
|
||||
}, requestService.SHOW_NOTIFICATION);
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user