You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/08/14 01:27:10 UTC
[7/8] incubator-guacamole-client git commit: GUACAMOLE-78: Render the
usernames of anonymous users differently.
GUACAMOLE-78: Render the usernames of anonymous users differently.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/21f184f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/21f184f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/21f184f4
Branch: refs/heads/master
Commit: 21f184f42e63c5a338354d17fbcd06db7602c310
Parents: 42cd4dc
Author: Michael Jumper <mj...@apache.org>
Authored: Fri Aug 12 20:05:33 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Aug 12 20:05:33 2016 -0700
----------------------------------------------------------------------
.../webapp/app/list/directives/guacUserItem.js | 92 ++++++++++++++++++++
.../src/main/webapp/app/list/listModule.js | 4 +-
.../main/webapp/app/list/styles/user-item.css | 23 +++++
.../webapp/app/list/templates/guacUserItem.html | 3 +
.../app/manage/templates/manageConnection.html | 2 +-
.../templates/settingsConnectionHistory.html | 2 +-
.../settings/templates/settingsSessions.html | 2 +-
guacamole/src/main/webapp/translations/en.json | 7 ++
8 files changed, 131 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/list/directives/guacUserItem.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/list/directives/guacUserItem.js b/guacamole/src/main/webapp/app/list/directives/guacUserItem.js
new file mode 100644
index 0000000..5c5d26d
--- /dev/null
+++ b/guacamole/src/main/webapp/app/list/directives/guacUserItem.js
@@ -0,0 +1,92 @@
+/*
+ * 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 which graphically represents an individual user.
+ */
+angular.module('list').directive('guacUserItem', [function guacUserItem() {
+
+ return {
+ restrict: 'E',
+ replace: true,
+ scope: {
+
+ /**
+ * The username of the user represented by this guacUserItem.
+ *
+ * @type String
+ */
+ username : '='
+
+ },
+
+ templateUrl: 'app/list/templates/guacUserItem.html',
+ controller: ['$scope', '$injector',
+ function guacUserItemController($scope, $injector) {
+
+ // Required types
+ var AuthenticationResult = $injector.get('AuthenticationResult');
+
+ // Required services
+ var $translate = $injector.get('$translate');
+
+ /**
+ * The string to display when listing the user having the provided
+ * username. Generally, this will be the username itself, but can
+ * also be an arbitrary human-readable representation of the user,
+ * or null if the display name is not yet determined.
+ *
+ * @type String
+ */
+ $scope.displayName = null;
+
+ /**
+ * Returns whether the username provided to this directive denotes
+ * a user that authenticated anonymously.
+ *
+ * @returns {Boolean}
+ * true if the username provided represents an anonymous user,
+ * false otherwise.
+ */
+ $scope.isAnonymous = function isAnonymous() {
+ return $scope.username === AuthenticationResult.ANONYMOUS_USERNAME;
+ };
+
+ // Update display name whenever provided username changes
+ $scope.$watch('username', function updateDisplayName(username) {
+
+ // If the user is anonymous, pull the display name for anonymous
+ // users from the translation service
+ if ($scope.isAnonymous()) {
+ $translate('LIST.TEXT_ANONYMOUS_USER')
+ .then(function retrieveAnonymousDisplayName(anonymousDisplayName) {
+ $scope.displayName = anonymousDisplayName;
+ });
+ }
+
+ // For all other users, use the username verbatim
+ else
+ $scope.displayName = username;
+
+ });
+
+ }] // end controller
+
+ };
+}]);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/list/listModule.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/list/listModule.js b/guacamole/src/main/webapp/app/list/listModule.js
index b3e6581..845c8c9 100644
--- a/guacamole/src/main/webapp/app/list/listModule.js
+++ b/guacamole/src/main/webapp/app/list/listModule.js
@@ -21,4 +21,6 @@
* Module for displaying, sorting, and filtering the contents of a list, split
* into multiple pages.
*/
-angular.module('list', []);
+angular.module('list', [
+ 'auth'
+]);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/list/styles/user-item.css
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/list/styles/user-item.css b/guacamole/src/main/webapp/app/list/styles/user-item.css
new file mode 100644
index 0000000..ffedd39
--- /dev/null
+++ b/guacamole/src/main/webapp/app/list/styles/user-item.css
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+.user-item.anonymous {
+ font-style: italic;
+ opacity: 0.5;
+}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/list/templates/guacUserItem.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/list/templates/guacUserItem.html b/guacamole/src/main/webapp/app/list/templates/guacUserItem.html
new file mode 100644
index 0000000..e6ea670
--- /dev/null
+++ b/guacamole/src/main/webapp/app/list/templates/guacUserItem.html
@@ -0,0 +1,3 @@
+<div class="user-item" ng-class="{'anonymous' : isAnonymous() }">
+ <span class="username">{{displayName}}</span>
+</div>
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
index 336530d..9df51a0 100644
--- a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
+++ b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html
@@ -75,7 +75,7 @@
</thead>
<tbody>
<tr ng-repeat="wrapper in wrapperPage">
- <td class="username">{{wrapper.entry.username}}</td>
+ <td class="username"><guac-user-item username="wrapper.entry.username"></guac-user-item></td>
<td class="start">{{wrapper.entry.startDate | date:historyDateFormat}}</td>
<td class="duration"
translate="{{wrapper.durationText}}"
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/settings/templates/settingsConnectionHistory.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/settings/templates/settingsConnectionHistory.html b/guacamole/src/main/webapp/app/settings/templates/settingsConnectionHistory.html
index b03ea3e..d0de134 100644
--- a/guacamole/src/main/webapp/app/settings/templates/settingsConnectionHistory.html
+++ b/guacamole/src/main/webapp/app/settings/templates/settingsConnectionHistory.html
@@ -32,7 +32,7 @@
</thead>
<tbody ng-class="{loading: !isLoaded()}">
<tr ng-repeat="historyEntryWrapper in historyEntryWrapperPage" class="history">
- <td>{{historyEntryWrapper.username}}</td>
+ <td><guac-user-item username="historyEntryWrapper.username"></guac-user-item></td>
<td>{{historyEntryWrapper.startDate | date : dateFormat}}</td>
<td translate="{{historyEntryWrapper.readableDurationText}}"
translate-values="{VALUE: historyEntryWrapper.readableDuration.value, UNIT: historyEntryWrapper.readableDuration.unit}"></td>
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/app/settings/templates/settingsSessions.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/settings/templates/settingsSessions.html b/guacamole/src/main/webapp/app/settings/templates/settingsSessions.html
index 917c7db..184ff0b 100644
--- a/guacamole/src/main/webapp/app/settings/templates/settingsSessions.html
+++ b/guacamole/src/main/webapp/app/settings/templates/settingsSessions.html
@@ -37,7 +37,7 @@
<td class="select-session">
<input ng-change="wrapperSelectionChange(wrapper)" type="checkbox" ng-model="wrapper.checked" />
</td>
- <td>{{wrapper.activeConnection.username}}</td>
+ <td><guac-user-item username="wrapper.activeConnection.username"></guac-user-item></td>
<td>{{wrapper.startDate}}</td>
<td>{{wrapper.activeConnection.remoteHost}}</td>
<td>{{wrapper.name}}</td>
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/21f184f4/guacamole/src/main/webapp/translations/en.json
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/translations/en.json b/guacamole/src/main/webapp/translations/en.json
index af3d8c5..48dbeab 100644
--- a/guacamole/src/main/webapp/translations/en.json
+++ b/guacamole/src/main/webapp/translations/en.json
@@ -42,6 +42,7 @@
"INFO_ACTIVE_USER_COUNT" : "Currently in use by {USERS} {USERS, plural, one{user} other{users}}.",
+ "TEXT_ANONYMOUS_USER" : "Anonymous",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{second} other{seconds}}} minute{{VALUE, plural, one{minute} other{minutes}}} hour{{VALUE, plural, one{hour} other{hours}}} day{{VALUE, plural, one{day} other{days}}} other{}}"
},
@@ -166,6 +167,12 @@
},
+ "LIST" : {
+
+ "TEXT_ANONYMOUS_USER" : "Anonymous"
+
+ },
+
"LOGIN": {
"ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE",