Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/guacamole-client/pull/309#discussion_r208810507
--- Diff:
guacamole/src/main/webapp/app/settings/directives/guacSettingsUserGroups.js ---
@@ -0,0 +1,270 @@
+/*
+ * 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 directive for managing all user groups in the system.
+ */
+angular.module('settings').directive('guacSettingsUserGroups',
['$injector',
+ function guacSettingsUserGroups($injector) {
+
+ // Required types
+ var ManageableUserGroup = $injector.get('ManageableUserGroup');
+ var PermissionSet = $injector.get('PermissionSet');
+ var SortOrder = $injector.get('SortOrder');
+
+ // Required services
+ var $location = $injector.get('$location');
+ var authenticationService = $injector.get('authenticationService');
+ var dataSourceService = $injector.get('dataSourceService');
+ var permissionService = $injector.get('permissionService');
+ var requestService = $injector.get('requestService');
+ var userGroupService = $injector.get('userGroupService');
+
+ var directive = {
+ restrict : 'E',
+ replace : true,
+ templateUrl : 'app/settings/templates/settingsUserGroups.html',
+ scope : {}
+ };
+
+ directive.controller = ['$scope', function
settingsUserGroupsController($scope) {
+
+ // Identifier of the current user
+ var currentUsername = authenticationService.getCurrentUsername();
+
+ /**
+ * The identifiers of all data sources accessible by the current
+ * user.
+ *
+ * @type String[]
+ */
+ var dataSources = authenticationService.getAvailableDataSources();
+
+ /**
+ * Map of data source identifiers to all permissions associated
+ * with the current user within that data source, or null if the
+ * user's permissions have not yet been loaded.
+ *
+ * @type Object.<String, PermissionSet>
+ */
+ var permissions = null;
+
+ /**
+ * All visible user groups, along with their corresponding data
+ * sources.
+ *
+ * @type ManageableUserGroup[]
+ */
+ $scope.manageableUserGroups = null;
+
+ /**
+ * Array of all user group properties that are filterable.
+ *
+ * @type String[]
+ */
+ $scope.filteredUserGroupProperties = [
+ 'userGroup.identifier'
+ ];
+
+ /**
+ * SortOrder instance which stores the sort order of the listed
+ * user groups.
+ *
+ * @type SortOrder
+ */
+ $scope.order = new SortOrder([
+ 'userGroup.identifier'
+ ]);
+
+ /**
+ * Returns whether critical data has completed being loaded.
+ *
+ * @returns {Boolean}
+ * true if enough data has been loaded for the user group
+ * interface to be useful, false otherwise.
+ */
+ $scope.isLoaded = function isLoaded() {
+ return $scope.manageableUserGroups !== null;
+ };
+
+ /**
+ * Returns the identifier of the data source that should be used by
+ * default when creating a new user group.
+ *
+ * @return {String}
+ * The identifier of the data source that should be used by
+ * default when creating a new user group, or null if user
group
+ * creation is not allowed.
+ */
+ $scope.getDefaultDataSource = function getDefaultDataSource() {
+
+ // Abort if permissions have not yet loaded
+ if (!permissions)
+ return null;
+
+ // For each data source
+ for (var dataSource in permissions) {
--- End diff --
Ick. Yeah, this is definitely non-detereministic. The user settings page
will have the same issue. I will try to make this reasonable.
---