GUAC-1373: Modify connection history page to show duration instead of end date.

This commit is contained in:
James Muehlner
2015-11-24 23:29:01 -08:00
parent 622b7f5806
commit e2e8979654
10 changed files with 234 additions and 65 deletions

View File

@@ -68,7 +68,7 @@ angular.module('manage').factory('HistoryEntryWrapper', ['$injector',
if (historyEntry.active)
this.durationText = 'MANAGE_CONNECTION.INFO_CONNECTION_ACTIVE_NOW';
// If connection is not active, inform use if end date is not known
// If connection is not active, inform user if end date is not known
else if (!historyEntry.endDate)
this.durationText = 'MANAGE_CONNECTION.INFO_CONNECTION_DURATION_UNKNOWN';

View File

@@ -37,6 +37,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
controller: ['$scope', '$injector', function settingsConnectionHistoryController($scope, $injector) {
// Get required types
var ConnectionHistoryEntryWrapper = $injector.get('ConnectionHistoryEntryWrapper');
var FilterToken = $injector.get('FilterToken');
var SortOrder = $injector.get('SortOrder');
@@ -53,12 +54,12 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
$scope.dataSource = $routeParams.dataSource;
/**
* All matching connection history records, or null if these
* records have not yet been retrieved.
* All wrapped matching connection history entries, or null if these
* entries have not yet been retrieved.
*
* @type ConnectionHistoryEntry[]
* @type ConnectionHistoryEntryWrapper[]
*/
$scope.historyRecords = null;
$scope.historyEntryWrappers = null;
/**
* The search terms to use when filtering the history records.
@@ -82,7 +83,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
*/
$scope.order = new SortOrder([
'-startDate',
'-endDate',
'-duration',
'username',
'connectionName'
]);
@@ -107,7 +108,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
*
*/
$scope.isLoaded = function isLoaded() {
return $scope.historyRecords !== null
return $scope.historyEntryWrappers !== null
&& $scope.dateFormat !== null;
};
@@ -121,7 +122,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
* records are present, false otherwise.
*/
$scope.isHistoryEmpty = function isHistoryEmpty() {
return $scope.isLoaded() && $scope.historyRecords.length === 0;
return $scope.isLoaded() && $scope.historyEntryWrappers.length === 0;
};
/**
@@ -131,7 +132,7 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
$scope.search = function search() {
// Clear current results
$scope.historyRecords = null;
$scope.historyEntryWrappers = null;
// Tokenize search string
var tokens = FilterToken.tokenize($scope.searchString);
@@ -168,10 +169,13 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
return predicate === 'startDate' || predicate === '-startDate';
})
)
.success(function historyRetrieved(historyRecords) {
.success(function historyRetrieved(historyEntries) {
// Store retrieved permissions
$scope.historyRecords = historyRecords;
// Wrap all history entries for sake of display
$scope.historyEntryWrappers = [];
angular.forEach(historyEntries, function wrapHistoryEntry(historyEntry) {
$scope.historyEntryWrappers.push(new ConnectionHistoryEntryWrapper(historyEntry));
});
});

View File

@@ -43,8 +43,8 @@
<th guac-sort-order="order" guac-sort-property="'startDate'">
{{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_STARTDATE' | translate}}
</th>
<th guac-sort-order="order" guac-sort-property="'endDate'">
{{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_ENDDATE' | translate}}
<th guac-sort-order="order" guac-sort-property="'duration'">
{{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_DURATION' | translate}}
</th>
<th guac-sort-order="order" guac-sort-property="'connectionName'">
{{'SETTINGS_CONNECTION_HISTORY.TABLE_HEADER_SESSION_CONNECTION_NAME' | translate}}
@@ -52,11 +52,12 @@
</tr>
</thead>
<tbody ng-class="{loading: !isLoaded()}">
<tr ng-repeat="historyRecord in historyRecordPage" class="history">
<td>{{historyRecord.username}}</td>
<td>{{historyRecord.startDate | date : dateFormat}}</td>
<td>{{historyRecord.endDate | date : dateFormat}}</td>
<td>{{historyRecord.connectionName}}</td>
<tr ng-repeat="historyEntryWrapper in historyEntryWrapperPage" class="history">
<td>{{historyEntryWrapper.username}}</td>
<td>{{historyEntryWrapper.startDate | date : dateFormat}}</td>
<td translate="{{historyEntryWrapper.readableDurationText}}"
translate-values="{VALUE: historyEntryWrapper.readableDuration.value, UNIT: historyEntryWrapper.readableDuration.unit}"></td>
<td>{{historyEntryWrapper.connectionName}}</td>
</tr>
</tbody>
</table>
@@ -67,8 +68,8 @@
</p>
<!-- Pager for history list -->
<guac-pager page="historyRecordPage" page-size="25"
items="historyRecords | orderBy : order.predicate"></guac-pager>
<guac-pager page="historyEntryWrapperPage" page-size="25"
items="historyEntryWrappers | orderBy : order.predicate"></guac-pager>
</div>
</div>

View File

@@ -0,0 +1,121 @@
/*
* Copyright (C) 2015 Glyptodon LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* A service for defining the ConnectionHistoryEntryWrapper class.
*/
angular.module('settings').factory('ConnectionHistoryEntryWrapper', ['$injector',
function defineConnectionHistoryEntryWrapper($injector) {
// Required types
var ConnectionHistoryEntry = $injector.get('ConnectionHistoryEntry');
/**
* Wrapper for ConnectionHistoryEntry which adds display-specific
* properties, such as a duration.
*
* @constructor
* @param {ConnectionHistoryEntry} historyEntry
* The ConnectionHistoryEntry that should be wrapped.
*/
var ConnectionHistoryEntryWrapper = function ConnectionHistoryEntryWrapper(historyEntry) {
/**
* The identifier of the connection associated with this history entry.
*
* @type String
*/
this.connectionIdentifier = historyEntry.connectionIdentifier;
/**
* The name of the connection associated with this history entry.
*
* @type String
*/
this.connectionName = historyEntry.connectionName;
/**
* 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;
/**
* The total amount of time the connection associated with the wrapped
* history record was open, in seconds.
*
* @type Number
*/
this.duration = this.endDate - this.startDate;
/**
* An object providing value and unit properties, denoting the duration
* and its corresponding units.
*
* @type ConnectionHistoryEntry.Duration
*/
this.readableDuration = null;
// Set the duration if the necessary information is present
if (this.endDate && this.startDate)
this.readableDuration = new ConnectionHistoryEntry.Duration(this.duration);
/**
* The string to display as the duration of this history entry. If a
* duration is available, its value and unit will be exposed to any
* given translation string as the VALUE and UNIT substitution
* variables respectively.
*
* @type String
*/
this.readableDurationText = 'SETTINGS_CONNECTION_HISTORY.TEXT_HISTORY_DURATION';
// Inform user if end date is not known
if (!this.endDate)
this.readableDurationText = 'SETTINGS_CONNECTION_HISTORY.INFO_CONNECTION_DURATION_UNKNOWN';
};
return ConnectionHistoryEntryWrapper;
}]);

View File

@@ -38,7 +38,9 @@
"INFO_ACTIVE_USER_COUNT" : "In Benutzung durch {USERS} Benutzer.",
"NAME" : "Guacamole ${project.version}"
"NAME" : "Guacamole ${project.version}",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{Sekunde} other{Sekunden}}} minute{{VALUE, plural, one{Minute} other{Minuten}}} hour{{VALUE, plural, one{Stunde} other{Stunden}}} day{{VALUE, plural, one{Tag} other{Tage}}} other{}}"
},
@@ -202,7 +204,7 @@
"TABLE_HEADER_HISTORY_DURATION" : "Dauer",
"TEXT_CONFIRM_DELETE" : "Dieser Löschvorgang ist unumkehrbar. Soll diese Verbindung wirklich gelöscht werden?",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{Sekunde} other{Sekunden}}} minute{{VALUE, plural, one{Minute} other{Minuten}}} hour{{VALUE, plural, one{Stunde} other{Stunden}}} day{{VALUE, plural, one{Tag} other{Tage}}} other{}}"
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},
@@ -480,25 +482,6 @@
},
"SETTINGS_CONNECTION_HISTORY" : {
"ACTION_SEARCH" : "@:APP.ACTION_SEARCH",
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
"FORMAT_DATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
"HELP_CONNECTION_HISTORY" : "Die letzten Verbindungen werden hier historisch aufgelistet und können durch Klicken auf die Spaltenüberschriften sortiert werden. Zum Aufsuchen von bestimmten Datensätzen, geben Sie eine Filterzeichenfolge ein und klicken Sie auf \"Suchen\". Nur Datensätze, die die vorgesehenen Filterzeichenfolge entsprechen, werden aufgelistet.",
"INFO_NO_HISTORY" : "Keine passenden Datensätze",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Verbindungsname",
"TABLE_HEADER_SESSION_ENDDATE" : "Endzeit",
"TABLE_HEADER_SESSION_STARTDATE" : "Startzeit",
"TABLE_HEADER_SESSION_USERNAME" : "Benutzername"
},
"SETTINGS_CONNECTIONS" : {
"ACTION_ACKNOWLEDGE" : "@:APP.ACTION_ACKNOWLEDGE",
@@ -517,7 +500,23 @@
"SETTINGS_CONNECTION_HISTORY" : {
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER"
"ACTION_SEARCH" : "@:APP.ACTION_SEARCH",
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
"FORMAT_DATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
"HELP_CONNECTION_HISTORY" : "Die letzten Verbindungen werden hier historisch aufgelistet und können durch Klicken auf die Spaltenüberschriften sortiert werden. Zum Aufsuchen von bestimmten Datensätzen, geben Sie eine Filterzeichenfolge ein und klicken Sie auf \"Suchen\". Nur Datensätze, die die vorgesehenen Filterzeichenfolge entsprechen, werden aufgelistet.",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"INFO_NO_HISTORY" : "Keine passenden Datensätze",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Verbindungsname",
"TABLE_HEADER_SESSION_DURATION" : "Dauer",
"TABLE_HEADER_SESSION_STARTDATE" : "Startzeit",
"TABLE_HEADER_SESSION_USERNAME" : "Benutzername",
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},

View File

@@ -38,7 +38,9 @@
"INFO_ACTIVE_USER_COUNT" : "Currently in use by {USERS} {USERS, plural, one{user} other{users}}.",
"NAME" : "Guacamole ${project.version}"
"NAME" : "Guacamole ${project.version}",
"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{}}"
},
@@ -202,7 +204,7 @@
"TABLE_HEADER_HISTORY_DURATION" : "Duration",
"TEXT_CONFIRM_DELETE" : "Connections cannot be restored after they have been deleted. Are you sure you want to delete this connection?",
"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{}}"
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},
@@ -493,12 +495,15 @@
"HELP_CONNECTION_HISTORY" : "History records for past connections are listed here and can be sorted by clicking the column headers. To search for specific records, enter a filter string and click \"Search\". Only records which match the provided filter string will be listed.",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"INFO_NO_HISTORY" : "No matching records",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Connection name",
"TABLE_HEADER_SESSION_ENDDATE" : "End time",
"TABLE_HEADER_SESSION_DURATION" : "Duration",
"TABLE_HEADER_SESSION_STARTDATE" : "Start time",
"TABLE_HEADER_SESSION_USERNAME" : "Username"
"TABLE_HEADER_SESSION_USERNAME" : "Username",
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},

View File

@@ -36,7 +36,9 @@
"INFO_ACTIVE_USER_COUNT" : "Actuellement utilisé par {USERS} {USERS, plural, one{utilisateur} other{utilisateurs}}.",
"NAME" : "Guacamole ${project.version}"
"NAME" : "Guacamole ${project.version}",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{seconde} other{secondes}}} minute{{VALUE, plural, one{minute} other{minutes}}} hour{{VALUE, plural, one{heure} other{heures}}} day{{VALUE, plural, one{jour} other{jours}}} other{}}"
},
@@ -193,7 +195,7 @@
"TABLE_HEADER_HISTORY_DURATION" : "Durée",
"TEXT_CONFIRM_DELETE" : "Les connexions ne pourront être restaurées une fois supprimées. Êtes-vous certains de vouloir supprimer cette connexion ?",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{seconde} other{secondes}}} minute{{VALUE, plural, one{minute} other{minutes}}} hour{{VALUE, plural, one{heure} other{heures}}} day{{VALUE, plural, one{jour} other{jours}}} other{}}"
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},
@@ -461,7 +463,18 @@
"SETTINGS_CONNECTION_HISTORY" : {
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER"
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
"FORMAT_DATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Nom de connexion",
"TABLE_HEADER_SESSION_DURATION" : "Durée",
"TABLE_HEADER_SESSION_STARTDATE" : "Ouvert depuis",
"TABLE_HEADER_SESSION_USERNAME" : "Identifiant",
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},

View File

@@ -192,8 +192,7 @@
"TABLE_HEADER_HISTORY_START" : "Start Time",
"TABLE_HEADER_HISTORY_DURATION" : "Durata",
"TEXT_CONFIRM_DELETE" : "Le Connessioni non possono essere ripristinate dopo la loro eliminazione. Sei sicuro di volere eliminare questa connessione?",
"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{}}"
"TEXT_CONFIRM_DELETE" : "Le Connessioni non possono essere ripristinate dopo la loro eliminazione. Sei sicuro di volere eliminare questa connessione?"
},
@@ -461,7 +460,16 @@
"SETTINGS_CONNECTION_HISTORY" : {
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER"
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
"FORMAT_DATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Nome della connessione",
"TABLE_HEADER_SESSION_STARTDATE" : "Start Time",
"TABLE_HEADER_SESSION_DURATION" : "Durata",
"TABLE_HEADER_SESSION_USERNAME" : "Username"
},

View File

@@ -38,7 +38,9 @@
"INFO_ACTIVE_USER_COUNT" : "Op dit moment in gebruik door {USERS} {USERS, plural, one{gebruiker} other{gebruikers}}.",
"NAME" : "Guacamole ${project.version}"
"NAME" : "Guacamole ${project.version}",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{seconde} other{seconden}}} minute{{VALUE, plural, one{minuut} other{minuten}}} hour{{VALUE, plural, one{uur} other{uren}}} day{{VALUE, plural, one{dag} other{dagen}}} other{}}"
},
@@ -202,7 +204,7 @@
"TABLE_HEADER_HISTORY_DURATION" : "Tijdsduur",
"TEXT_CONFIRM_DELETE" : "Verbindingen kunnen niet worden hersteld nadat ze zijn verwijderd. Weet u zeker dat u deze verbinding wilt verwijderen?",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{seconde} other{seconden}}} minute{{VALUE, plural, one{minuut} other{minuten}}} hour{{VALUE, plural, one{uur} other{uren}}} day{{VALUE, plural, one{dag} other{dagen}}} other{}}"
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},
@@ -490,12 +492,15 @@
"HELP_CONNECTION_HISTORY" : "De gebruikgeschiedenis van verbindingen wordt hier onder getoond en kan gesorteerd worden door op de titel van de kolom te klikken. Voer een zoekterm in en klik op \"Zoeken\", om op specifieke resultaten te zoeken. Alleen de resultaten die voldoen aan de zoekterm zullen dan getoond worden.",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"INFO_NO_HISTORY" : "Geen resultaten gevonden",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Verbindingsnaam",
"TABLE_HEADER_SESSION_ENDDATE" : "Eindtijd",
"TABLE_HEADER_SESSION_DURATION" : "Tijdsduur",
"TABLE_HEADER_SESSION_STARTDATE" : "Starttijd",
"TABLE_HEADER_SESSION_USERNAME" : "Gebruikersnaam"
"TABLE_HEADER_SESSION_USERNAME" : "Gebruikersnaam",
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},

View File

@@ -35,7 +35,9 @@
"INFO_ACTIVE_USER_COUNT" : "Подключено пользователей {USERS}.",
"NAME" : "Guacamole ${project.version}"
"NAME" : "Guacamole ${project.version}",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{секунда} other{сек}}} minute{{VALUE, plural, one{минута} other{мин}}} hour{{VALUE, plural, one{час} other{ч}}} day{{VALUE, plural, one{день} other{дн}}} other{}}"
},
@@ -190,7 +192,7 @@
"TABLE_HEADER_HISTORY_DURATION" : "Продолжительность",
"TEXT_CONFIRM_DELETE" : "Подключения не могут быть восстановлены после удаления. Вы уверены, что хотите удалить подключение?",
"TEXT_HISTORY_DURATION" : "{VALUE} {UNIT, select, second{{VALUE, plural, one{секунда} other{сек}}} minute{{VALUE, plural, one{минута} other{мин}}} hour{{VALUE, plural, one{час} other{ч}}} day{{VALUE, plural, one{день} other{дн}}} other{}}"
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},
@@ -429,7 +431,18 @@
"SETTINGS_CONNECTION_HISTORY" : {
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER"
"FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
"FORMAT_DATE" : "@:APP.FORMAT_DATE_TIME_PRECISE",
"INFO_CONNECTION_DURATION_UNKNOWN" : "--",
"TABLE_HEADER_SESSION_CONNECTION_NAME" : "Название подключения",
"TABLE_HEADER_SESSION_DURATION" : "Продолжительность",
"TABLE_HEADER_SESSION_STARTDATE" : "Время начала",
"TABLE_HEADER_SESSION_USERNAME" : "Имя пользователя",
"TEXT_HISTORY_DURATION" : "@:APP.TEXT_HISTORY_DURATION"
},