From 389bbece051c739718905e2f0224b4383cb4f08a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 10 Feb 2022 11:41:05 -0800 Subject: [PATCH] GUACAMOLE-462: Store REST API history entry directly in ConnectionHistoryEntryWrapper, rather than duplicating properties. --- .../guacSettingsConnectionHistory.js | 16 +++--- .../templates/settingsConnectionHistory.html | 16 +++--- .../types/ConnectionHistoryEntryWrapper.js | 53 +++---------------- 3 files changed, 22 insertions(+), 63 deletions(-) diff --git a/guacamole/src/main/frontend/src/app/settings/directives/guacSettingsConnectionHistory.js b/guacamole/src/main/frontend/src/app/settings/directives/guacSettingsConnectionHistory.js index 796edcd5c..42cf10c1b 100644 --- a/guacamole/src/main/frontend/src/app/settings/directives/guacSettingsConnectionHistory.js +++ b/guacamole/src/main/frontend/src/app/settings/directives/guacSettingsConnectionHistory.js @@ -82,11 +82,11 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function * @type SortOrder */ $scope.order = new SortOrder([ - '-startDate', + '-entry.startDate', '-duration', - 'username', - 'connectionName', - 'remoteHost' + 'entry.username', + 'entry.connectionName', + 'entry.remoteHost' ]); // Get session date format @@ -216,11 +216,11 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function ), function pushRecord(historyEntryWrapper) { records.push([ - historyEntryWrapper.username, - $filter('date')(historyEntryWrapper.startDate, $scope.dateFormat), + historyEntryWrapper.entry.username, + $filter('date')(historyEntryWrapper.entry.startDate, $scope.dateFormat), historyEntryWrapper.duration / 1000, - historyEntryWrapper.connectionName, - historyEntryWrapper.remoteHost + historyEntryWrapper.entry.connectionName, + historyEntryWrapper.entry.remoteHost ]); } ); diff --git a/guacamole/src/main/frontend/src/app/settings/templates/settingsConnectionHistory.html b/guacamole/src/main/frontend/src/app/settings/templates/settingsConnectionHistory.html index 34f2fd3a6..41e0f65eb 100644 --- a/guacamole/src/main/frontend/src/app/settings/templates/settingsConnectionHistory.html +++ b/guacamole/src/main/frontend/src/app/settings/templates/settingsConnectionHistory.html @@ -17,31 +17,31 @@ - - - - - - + + - - + +
+ {{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_USERNAME' | translate}} + {{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_STARTDATE' | translate}} {{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_DURATION' | translate}} + {{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_CONNECTION_NAME' | translate}} + {{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_REMOTEHOST' | translate}}
{{historyEntryWrapper.startDate | date : dateFormat}}{{historyEntryWrapper.entry.startDate | date : dateFormat}} {{historyEntryWrapper.connectionName}}{{historyEntryWrapper.remoteHost}}{{historyEntryWrapper.entry.connectionName}}{{historyEntryWrapper.entry.remoteHost}}
diff --git a/guacamole/src/main/frontend/src/app/settings/types/ConnectionHistoryEntryWrapper.js b/guacamole/src/main/frontend/src/app/settings/types/ConnectionHistoryEntryWrapper.js index 87d691757..b9a3c5279 100644 --- a/guacamole/src/main/frontend/src/app/settings/types/ConnectionHistoryEntryWrapper.js +++ b/guacamole/src/main/frontend/src/app/settings/types/ConnectionHistoryEntryWrapper.js @@ -37,52 +37,11 @@ angular.module('settings').factory('ConnectionHistoryEntryWrapper', ['$injector' var ConnectionHistoryEntryWrapper = function ConnectionHistoryEntryWrapper(historyEntry) { /** - * The identifier of the connection associated with this history entry. + * The wrapped ConnectionHistoryEntry. * - * @type String + * @type ConnectionHistoryEntry */ - this.connectionIdentifier = historyEntry.connectionIdentifier; - - /** - * The name of the connection associated with this history entry. - * - * @type String - */ - this.connectionName = historyEntry.connectionName; - - /** - * The remote host associated with this history entry. - * - * @type String - */ - this.remoteHost = historyEntry.remoteHost; - - /** - * The username of the user associated with this particular usage of - * the connection. - * - * @type String - */ - this.username = historyEntry.username; - - /** - * The time that usage began, in seconds since 1970-01-01 00:00:00 UTC. - * - * @type Number - */ - this.startDate = historyEntry.startDate; - - /** - * The time that usage ended, in seconds since 1970-01-01 00:00:00 UTC. - * The absence of an endDate does NOT necessarily indicate that the - * connection is still in use, particularly if the server was shutdown - * or restarted before the history entry could be updated. To determine - * whether a connection is still active, check the active property of - * this history entry. - * - * @type Number - */ - this.endDate = historyEntry.endDate; + this.entry = historyEntry; /** * The total amount of time the connection associated with the wrapped @@ -90,7 +49,7 @@ angular.module('settings').factory('ConnectionHistoryEntryWrapper', ['$injector' * * @type Number */ - this.duration = this.endDate - this.startDate; + this.duration = historyEntry.endDate - historyEntry.startDate; /** * An object providing value and unit properties, denoting the duration @@ -101,7 +60,7 @@ angular.module('settings').factory('ConnectionHistoryEntryWrapper', ['$injector' this.readableDuration = null; // Set the duration if the necessary information is present - if (this.endDate && this.startDate) + if (historyEntry.endDate && historyEntry.startDate) this.readableDuration = new ConnectionHistoryEntry.Duration(this.duration); /** @@ -115,7 +74,7 @@ angular.module('settings').factory('ConnectionHistoryEntryWrapper', ['$injector' this.readableDurationText = 'SETTINGS_CONNECTION_HISTORY.TEXT_HISTORY_DURATION'; // Inform user if end date is not known - if (!this.endDate) + if (!historyEntry.endDate) this.readableDurationText = 'SETTINGS_CONNECTION_HISTORY.INFO_CONNECTION_DURATION_UNKNOWN'; };