Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/guacamole-client/pull/282#discussion_r185388716
--- Diff:
guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js
---
@@ -157,205 +137,178 @@
angular.module('manage').controller('manageConnectionController', ['$scope', '$i
*/
$scope.isLoaded = function isLoaded() {
- return $scope.protocols !== null
- && $scope.rootGroup !== null
- && $scope.connection !== null
- && $scope.parameters !== null
- && $scope.historyDateFormat !== null
- && $scope.historyEntryWrappers !== null
- && $scope.permissions !== null
- && $scope.attributes !== null
- && $scope.canSaveConnection !== null
- && $scope.canDeleteConnection !== null
- && $scope.canCloneConnection !== null;
+ return $scope.protocols !== null
+ && $scope.rootGroup !== null
+ && $scope.connection !== null
+ && $scope.parameters !== null
+ && $scope.historyDateFormat !== null
+ && $scope.historyEntryWrappers !== null
+ && $scope.managementPermissions !== null
+ && $scope.attributes !== null;
};
- // Pull connection attribute schema
- schemaService.getConnectionAttributes($scope.selectedDataSource)
- .then(function attributesReceived(attributes) {
- $scope.attributes = attributes;
- }, requestService.WARN);
-
- // Pull connection group hierarchy
- connectionGroupService.getConnectionGroupTree(
- $scope.selectedDataSource,
- ConnectionGroup.ROOT_IDENTIFIER,
- [PermissionSet.ObjectPermissionType.ADMINISTER]
- )
- .then(function connectionGroupReceived(rootGroup) {
- $scope.rootGroup = rootGroup;
- }, requestService.WARN);
-
- // Query the user's permissions for the current connection
- permissionService.getEffectivePermissions($scope.selectedDataSource,
authenticationService.getCurrentUsername())
- .then(function permissionsReceived(permissions) {
-
- $scope.permissions = permissions;
-
- // Check if the connection is new or if the user has UPDATE
permission
- $scope.canSaveConnection =
- !identifier
- || PermissionSet.hasSystemPermission(permissions,
PermissionSet.SystemPermissionType.ADMINISTER)
- || PermissionSet.hasConnectionPermission(permissions,
PermissionSet.ObjectPermissionType.UPDATE, identifier);
-
- // Check if connection is not new and the user has DELETE
permission
- $scope.canDeleteConnection =
- !!identifier && (
- PermissionSet.hasSystemPermission(permissions,
PermissionSet.SystemPermissionType.ADMINISTER)
- || PermissionSet.hasConnectionPermission(permissions,
PermissionSet.ObjectPermissionType.DELETE, identifier)
- );
-
- // Check if the connection is not new and the user has UPDATE and
CREATE_CONNECTION permissions
- $scope.canCloneConnection =
- !!identifier && (
- PermissionSet.hasSystemPermission(permissions,
PermissionSet.SystemPermissionType.ADMINISTER) || (
- PermissionSet.hasConnectionPermission(permissions,
PermissionSet.ObjectPermissionType.UPDATE, identifier)
- && PermissionSet.hasSystemPermission(permissions,
PermissionSet.SystemPermissionType.CREATE_CONNECTION)
- )
- );
-
- }, 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) {
-
- // Pull data from existing connection
- connectionService.getConnection($scope.selectedDataSource,
identifier)
- .then(function connectionRetrieved(connection) {
- $scope.connection = connection;
- }, requestService.WARN);
+ /**
+ * Loads the data associated with the connection having the given
+ * identifier, preparing the interface for making modifications to that
+ * existing connection.
+ *
+ * @param {String} dataSource
+ * The unique identifier of the data source containing the
connection to
+ * load.
+ *
+ * @param {String} identifier
+ * The identifier of the connection to load.
+ *
+ * @returns {Promise}
+ * A promise which is resolved when the interface has been
prepared for
+ * editing the given connection.
+ */
+ var loadExistingConnection = function
loadExistingConnection(dataSource, identifier) {
+ return $q.all({
+ connection : connectionService.getConnection(dataSource,
identifier),
+ historyEntries :
connectionService.getConnectionHistory(dataSource, identifier),
+ parameters :
connectionService.getConnectionParameters(dataSource, identifier)
+ })
+ .then(function connectionDataRetrieved(values) {
- // Pull connection history
- connectionService.getConnectionHistory($scope.selectedDataSource,
identifier)
- .then(function historyReceived(historyEntries) {
+ $scope.connection = values.connection;
+ $scope.parameters = values.parameters;
// Wrap all history entries for sake of display
$scope.historyEntryWrappers = [];
- historyEntries.forEach(function wrapHistoryEntry(historyEntry)
{
- $scope.historyEntryWrappers.push(new
HistoryEntryWrapper(historyEntry));
+ angular.forEach(values.historyEntries, function
wrapHistoryEntry(historyEntry) {
--- End diff --
I can restore the original usage of built-in `forEach()` if you prefer.
---