mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUAC-1213: Add date and time fields, along with corresponding template/controller stubs.
This commit is contained in:
@@ -45,9 +45,10 @@ import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionGroupPermissionSer
|
|||||||
import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionPermissionService;
|
import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionPermissionService;
|
||||||
import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionService;
|
import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionService;
|
||||||
import org.glyptodon.guacamole.form.BooleanField;
|
import org.glyptodon.guacamole.form.BooleanField;
|
||||||
|
import org.glyptodon.guacamole.form.DateField;
|
||||||
import org.glyptodon.guacamole.form.Field;
|
import org.glyptodon.guacamole.form.Field;
|
||||||
import org.glyptodon.guacamole.form.Form;
|
import org.glyptodon.guacamole.form.Form;
|
||||||
import org.glyptodon.guacamole.form.TextField;
|
import org.glyptodon.guacamole.form.TimeField;
|
||||||
import org.glyptodon.guacamole.form.TimeZoneField;
|
import org.glyptodon.guacamole.form.TimeZoneField;
|
||||||
import org.glyptodon.guacamole.net.auth.User;
|
import org.glyptodon.guacamole.net.auth.User;
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
@@ -69,16 +70,6 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ModeledUser.class);
|
private static final Logger logger = LoggerFactory.getLogger(ModeledUser.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* The format to use for all date attributes associated with users.
|
|
||||||
*/
|
|
||||||
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The format to use for all time attributes associated with users.
|
|
||||||
*/
|
|
||||||
private static final String TIME_FORMAT = "HH:mm:ss";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the attribute which controls whether a user account is
|
* The name of the attribute which controls whether a user account is
|
||||||
* disabled.
|
* disabled.
|
||||||
@@ -128,10 +119,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", Arrays.<Field>asList(
|
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", Arrays.<Field>asList(
|
||||||
new BooleanField(DISABLED_ATTRIBUTE_NAME, "true"),
|
new BooleanField(DISABLED_ATTRIBUTE_NAME, "true"),
|
||||||
new BooleanField(EXPIRED_ATTRIBUTE_NAME, "true"),
|
new BooleanField(EXPIRED_ATTRIBUTE_NAME, "true"),
|
||||||
new TextField(ACCESS_WINDOW_START_ATTRIBUTE_NAME),
|
new TimeField(ACCESS_WINDOW_START_ATTRIBUTE_NAME),
|
||||||
new TextField(ACCESS_WINDOW_END_ATTRIBUTE_NAME),
|
new TimeField(ACCESS_WINDOW_END_ATTRIBUTE_NAME),
|
||||||
new TextField(VALID_FROM_ATTRIBUTE_NAME),
|
new DateField(VALID_FROM_ATTRIBUTE_NAME),
|
||||||
new TextField(VALID_UNTIL_ATTRIBUTE_NAME),
|
new DateField(VALID_UNTIL_ATTRIBUTE_NAME),
|
||||||
new TimeZoneField(TIMEZONE_ATTRIBUTE_NAME)
|
new TimeZoneField(TIMEZONE_ATTRIBUTE_NAME)
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -288,7 +279,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
* The formatted date, or null if the provided time was null.
|
* The formatted date, or null if the provided time was null.
|
||||||
*/
|
*/
|
||||||
private String formatDate(Date date) {
|
private String formatDate(Date date) {
|
||||||
DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT);
|
||||||
return date == null ? null : dateFormat.format(date);
|
return date == null ? null : dateFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +294,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
* The formatted time, or null if the provided time was null.
|
* The formatted time, or null if the provided time was null.
|
||||||
*/
|
*/
|
||||||
private String formatTime(Time time) {
|
private String formatTime(Time time) {
|
||||||
DateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT);
|
DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT);
|
||||||
return time == null ? null : timeFormat.format(time);
|
return time == null ? null : timeFormat.format(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +322,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Parse date according to format
|
// Parse date according to format
|
||||||
DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT);
|
||||||
return new Date(dateFormat.parse(dateString).getTime());
|
return new Date(dateFormat.parse(dateString).getTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -360,7 +351,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Parse time according to format
|
// Parse time according to format
|
||||||
DateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT);
|
DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT);
|
||||||
return new Time(timeFormat.parse(timeString).getTime());
|
return new Time(timeFormat.parse(timeString).getTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a date field. The field may contain only date values which
|
||||||
|
* conform to a standard pattern, defined by DateField.FORMAT.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class DateField extends Field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date format used by date fields, compatible with SimpleDateFormat.
|
||||||
|
*/
|
||||||
|
public static final String FORMAT = "yyyy-MM-dd";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new DateField with the given name.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* The unique name to associate with this field.
|
||||||
|
*/
|
||||||
|
public DateField(String name) {
|
||||||
|
super(name, Field.Type.DATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -90,6 +90,18 @@ public class Field {
|
|||||||
*/
|
*/
|
||||||
public static String TIMEZONE = "TIMEZONE";
|
public static String TIMEZONE = "TIMEZONE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A date field whose legal values conform to the pattern "YYYY-MM-DD",
|
||||||
|
* zero-padded.
|
||||||
|
*/
|
||||||
|
public static String DATE = "DATE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A time field whose legal values conform to the pattern "HH:MM:SS",
|
||||||
|
* zero-padded, 24-hour.
|
||||||
|
*/
|
||||||
|
public static String TIME = "TIME";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.glyptodon.guacamole.form;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a time field. The field may contain only time values which
|
||||||
|
* conform to a standard pattern, defined by TimeField.FORMAT.
|
||||||
|
*
|
||||||
|
* @author Michael Jumper
|
||||||
|
*/
|
||||||
|
public class TimeField extends Field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time format used by time fields, compatible with SimpleDateFormat.
|
||||||
|
*/
|
||||||
|
public static final String FORMAT = "HH:mm:ss";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new TimeField with the given name.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* The unique name to associate with this field.
|
||||||
|
*/
|
||||||
|
public TimeField(String name) {
|
||||||
|
super(name, Field.Type.TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for date fields.
|
||||||
|
*/
|
||||||
|
angular.module('form').controller('dateFieldController', ['$scope',
|
||||||
|
function dateFieldController($scope) {
|
||||||
|
|
||||||
|
/* STUB */
|
||||||
|
|
||||||
|
}]);
|
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for time fields.
|
||||||
|
*/
|
||||||
|
angular.module('form').controller('timeFieldController', ['$scope',
|
||||||
|
function timeFieldController($scope) {
|
||||||
|
|
||||||
|
/* STUB */
|
||||||
|
|
||||||
|
}]);
|
@@ -131,6 +131,30 @@ angular.module('form').provider('formService', function formServiceProvider() {
|
|||||||
module : 'form',
|
module : 'form',
|
||||||
controller : 'timeZoneFieldController',
|
controller : 'timeZoneFieldController',
|
||||||
templateUrl : 'app/form/templates/timeZoneField.html'
|
templateUrl : 'app/form/templates/timeZoneField.html'
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field type which allows selection of individual dates.
|
||||||
|
*
|
||||||
|
* @see {@link Field.Type.DATE}
|
||||||
|
* @type FieldType
|
||||||
|
*/
|
||||||
|
'DATE' : {
|
||||||
|
module : 'form',
|
||||||
|
controller : 'dateFieldController',
|
||||||
|
templateUrl : 'app/form/templates/dateField.html'
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field type which allows selection of times of day.
|
||||||
|
*
|
||||||
|
* @see {@link Field.Type.TIME}
|
||||||
|
* @type FieldType
|
||||||
|
*/
|
||||||
|
'TIME' : {
|
||||||
|
module : 'form',
|
||||||
|
controller : 'timeFieldController',
|
||||||
|
templateUrl : 'app/form/templates/timeField.html'
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="date-field">
|
||||||
|
<input type="text" ng-model="model" autocorrect="off" autocapitalize="off"/>
|
||||||
|
</div>
|
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="time-field">
|
||||||
|
<input type="text" ng-model="model" autocorrect="off" autocapitalize="off"/>
|
||||||
|
</div>
|
@@ -138,7 +138,24 @@ angular.module('rest').factory('Field', [function defineField() {
|
|||||||
*
|
*
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
TIMEZONE : "TIMEZONE"
|
TIMEZONE : "TIMEZONE",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type string associated with parameters that may contain dates.
|
||||||
|
* The format of the date is standardized as YYYY-MM-DD, zero-padded.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
DATE : "DATE",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type string associated with parameters that may contain times.
|
||||||
|
* The format of the time is stnadardized as HH:MM:DD, zero-padded,
|
||||||
|
* 24-hour.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
TIME : "TIME"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user