GUAC-1373: Define sorting only by start date.

This commit is contained in:
Michael Jumper
2015-11-15 20:19:31 -08:00
committed by James Muehlner
parent 4e4ba9ac45
commit 77804b2a9d
6 changed files with 14 additions and 90 deletions

View File

@@ -86,8 +86,8 @@
guacamole_connection_history.start_date, guacamole_connection_history.start_date,
guacamole_connection_history.end_date guacamole_connection_history.end_date
FROM guacamole_connection_history FROM guacamole_connection_history
JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id LEFT JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id LEFT JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
<!-- Search terms --> <!-- Search terms -->
<foreach collection="terms" item="term" <foreach collection="terms" item="term"
@@ -117,19 +117,13 @@
</foreach> </foreach>
<!-- Bind sort property enum values for sake of readability --> <!-- Bind sort property enum values for sake of readability -->
<bind name="CONNECTION_NAME" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@CONNECTION_NAME"/>
<bind name="USER_IDENTIFIER" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@USER_IDENTIFIER"/>
<bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/> <bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/>
<bind name="END_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@END_DATE"/>
<!-- Sort predicates --> <!-- Sort predicates -->
<foreach collection="sortPredicates" item="sortPredicate" <foreach collection="sortPredicates" item="sortPredicate"
open="ORDER BY " separator=", "> open="ORDER BY " separator=", ">
<choose> <choose>
<when test="sortPredicate.property == CONNECTION_NAME">guacamole_connection.connection_name</when>
<when test="sortPredicate.property == USER_IDENTIFIER">guacamole_user.username</when>
<when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when> <when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when>
<when test="sortPredicate.property == END_DATE">guacamole_connection_history.end_date</when>
<otherwise>1</otherwise> <otherwise>1</otherwise>
</choose> </choose>
<if test="sortPredicate.descending">DESC</if> <if test="sortPredicate.descending">DESC</if>
@@ -150,8 +144,8 @@
guacamole_connection_history.start_date, guacamole_connection_history.start_date,
guacamole_connection_history.end_date guacamole_connection_history.end_date
FROM guacamole_connection_history FROM guacamole_connection_history
JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id LEFT JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id LEFT JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
<!-- Restrict to readable connections --> <!-- Restrict to readable connections -->
JOIN guacamole_connection_permission ON JOIN guacamole_connection_permission ON
@@ -193,19 +187,13 @@
</foreach> </foreach>
<!-- Bind sort property enum values for sake of readability --> <!-- Bind sort property enum values for sake of readability -->
<bind name="CONNECTION_NAME" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@CONNECTION_NAME"/>
<bind name="USER_IDENTIFIER" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@USER_IDENTIFIER"/>
<bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/> <bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/>
<bind name="END_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@END_DATE"/>
<!-- Sort predicates --> <!-- Sort predicates -->
<foreach collection="sortPredicates" item="sortPredicate" <foreach collection="sortPredicates" item="sortPredicate"
open="ORDER BY " separator=", "> open="ORDER BY " separator=", ">
<choose> <choose>
<when test="sortPredicate.property == CONNECTION_NAME">guacamole_connection.connection_name</when>
<when test="sortPredicate.property == USER_IDENTIFIER">guacamole_user.username</when>
<when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when> <when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when>
<when test="sortPredicate.property == END_DATE">guacamole_connection_history.end_date</when>
<otherwise>1</otherwise> <otherwise>1</otherwise>
</choose> </choose>
<if test="sortPredicate.descending">DESC</if> <if test="sortPredicate.descending">DESC</if>

View File

@@ -86,8 +86,8 @@
guacamole_connection_history.start_date, guacamole_connection_history.start_date,
guacamole_connection_history.end_date guacamole_connection_history.end_date
FROM guacamole_connection_history FROM guacamole_connection_history
JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id LEFT JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id LEFT JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
<!-- Search terms --> <!-- Search terms -->
<foreach collection="terms" item="term" <foreach collection="terms" item="term"
@@ -117,19 +117,13 @@
</foreach> </foreach>
<!-- Bind sort property enum values for sake of readability --> <!-- Bind sort property enum values for sake of readability -->
<bind name="CONNECTION_NAME" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@CONNECTION_NAME"/>
<bind name="USER_IDENTIFIER" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@USER_IDENTIFIER"/>
<bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/> <bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/>
<bind name="END_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@END_DATE"/>
<!-- Sort predicates --> <!-- Sort predicates -->
<foreach collection="sortPredicates" item="sortPredicate" <foreach collection="sortPredicates" item="sortPredicate"
open="ORDER BY " separator=", "> open="ORDER BY " separator=", ">
<choose> <choose>
<when test="sortPredicate.property == CONNECTION_NAME">guacamole_connection.connection_name</when>
<when test="sortPredicate.property == USER_IDENTIFIER">guacamole_user.username</when>
<when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when> <when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when>
<when test="sortPredicate.property == END_DATE">guacamole_connection_history.end_date</when>
<otherwise>1</otherwise> <otherwise>1</otherwise>
</choose> </choose>
<if test="sortPredicate.descending">DESC</if> <if test="sortPredicate.descending">DESC</if>
@@ -150,8 +144,8 @@
guacamole_connection_history.start_date, guacamole_connection_history.start_date,
guacamole_connection_history.end_date guacamole_connection_history.end_date
FROM guacamole_connection_history FROM guacamole_connection_history
JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id LEFT JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id LEFT JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
<!-- Restrict to readable connections --> <!-- Restrict to readable connections -->
JOIN guacamole_connection_permission ON JOIN guacamole_connection_permission ON
@@ -193,19 +187,13 @@
</foreach> </foreach>
<!-- Bind sort property enum values for sake of readability --> <!-- Bind sort property enum values for sake of readability -->
<bind name="CONNECTION_NAME" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@CONNECTION_NAME"/>
<bind name="USER_IDENTIFIER" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@USER_IDENTIFIER"/>
<bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/> <bind name="START_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@START_DATE"/>
<bind name="END_DATE" value="@org.glyptodon.guacamole.net.auth.ConnectionRecordSet$SortableProperty@END_DATE"/>
<!-- Sort predicates --> <!-- Sort predicates -->
<foreach collection="sortPredicates" item="sortPredicate" <foreach collection="sortPredicates" item="sortPredicate"
open="ORDER BY " separator=", "> open="ORDER BY " separator=", ">
<choose> <choose>
<when test="sortPredicate.property == CONNECTION_NAME">guacamole_connection.connection_name</when>
<when test="sortPredicate.property == USER_IDENTIFIER">guacamole_user.username</when>
<when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when> <when test="sortPredicate.property == START_DATE">guacamole_connection_history.start_date</when>
<when test="sortPredicate.property == END_DATE">guacamole_connection_history.end_date</when>
<otherwise>1</otherwise> <otherwise>1</otherwise>
</choose> </choose>
<if test="sortPredicate.descending">DESC</if> <if test="sortPredicate.descending">DESC</if>

View File

@@ -39,29 +39,11 @@ public interface ConnectionRecordSet {
*/ */
enum SortableProperty { enum SortableProperty {
/**
* The name (not identifier) of the connection associated with the
* connection record.
*/
CONNECTION_NAME,
/**
* The identifier (username) of the user that used the connection
* associated with the connection record.
*/
USER_IDENTIFIER,
/** /**
* The date and time when the connection associated with the * The date and time when the connection associated with the
* connection record began. * connection record began.
*/ */
START_DATE, START_DATE
/**
* The date and time when the connection associated with the
* connection record ended.
*/
END_DATE
}; };

View File

@@ -46,29 +46,11 @@ public class APIConnectionRecordSortPredicate {
*/ */
public enum SortableProperty { public enum SortableProperty {
/**
* The name (not identifier) of the connection associated with the
* connection record.
*/
connectionName(ConnectionRecordSet.SortableProperty.CONNECTION_NAME),
/**
* The username (identifier) of the user associated with the connection
* record.
*/
username(ConnectionRecordSet.SortableProperty.USER_IDENTIFIER),
/** /**
* The date that the connection associated with the connection record * The date that the connection associated with the connection record
* began (connected). * began (connected).
*/ */
startDate(ConnectionRecordSet.SortableProperty.START_DATE), startDate(ConnectionRecordSet.SortableProperty.START_DATE);
/**
* The date that the connection associated with the connection record
* ended (disconnected).
*/
endDate(ConnectionRecordSet.SortableProperty.END_DATE);
/** /**
* The ConnectionRecordSet.SortableProperty that this property name * The ConnectionRecordSet.SortableProperty that this property name

View File

@@ -110,29 +110,11 @@ angular.module('rest').factory('ConnectionHistoryEntry', [function defineConnect
*/ */
ConnectionHistoryEntry.SortPredicate = { ConnectionHistoryEntry.SortPredicate = {
/**
* The name of the connection associated with the history entry (not
* the connection identifier).
*/
CONNECTION_NAME : 'connectionName',
/**
* The username of the user associated with the history entry (the user
* identifier).
*/
USER_IDENTIFIER : 'username',
/** /**
* The date and time that the connection associated with the history * The date and time that the connection associated with the history
* entry began (connected). * entry began (connected).
*/ */
START_DATE : 'startDate', START_DATE : 'startDate'
/**
* The date and time that the connection associated with the history
* entry ended (disconnected).
*/
END_DATE : 'endDate'
}; };

View File

@@ -164,7 +164,9 @@ angular.module('settings').directive('guacSettingsConnectionHistory', [function
historyService.getConnectionHistory( historyService.getConnectionHistory(
$scope.dataSource, $scope.dataSource,
requiredContents, requiredContents,
$scope.order.predicate $scope.order.predicate.filter(function isSupportedPredicate(predicate) {
return predicate === 'startDate' || predicate === '-startDate';
})
) )
.success(function historyRetrieved(historyRecords) { .success(function historyRetrieved(historyRecords) {