diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java index 8ea650ae3..99bca4850 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java @@ -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.UserPermissionService; import org.glyptodon.guacamole.form.BooleanField; +import org.glyptodon.guacamole.form.DateField; import org.glyptodon.guacamole.form.Field; 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.net.auth.User; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; @@ -69,16 +70,6 @@ public class ModeledUser extends ModeledDirectoryObject implements Us */ 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 * disabled. @@ -128,10 +119,10 @@ public class ModeledUser extends ModeledDirectoryObject implements Us public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", Arrays.asList( new BooleanField(DISABLED_ATTRIBUTE_NAME, "true"), new BooleanField(EXPIRED_ATTRIBUTE_NAME, "true"), - new TextField(ACCESS_WINDOW_START_ATTRIBUTE_NAME), - new TextField(ACCESS_WINDOW_END_ATTRIBUTE_NAME), - new TextField(VALID_FROM_ATTRIBUTE_NAME), - new TextField(VALID_UNTIL_ATTRIBUTE_NAME), + new TimeField(ACCESS_WINDOW_START_ATTRIBUTE_NAME), + new TimeField(ACCESS_WINDOW_END_ATTRIBUTE_NAME), + new DateField(VALID_FROM_ATTRIBUTE_NAME), + new DateField(VALID_UNTIL_ATTRIBUTE_NAME), new TimeZoneField(TIMEZONE_ATTRIBUTE_NAME) )); @@ -288,7 +279,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us * The formatted date, or null if the provided time was null. */ private String formatDate(Date date) { - DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT); return date == null ? null : dateFormat.format(date); } @@ -303,7 +294,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us * The formatted time, or null if the provided time was null. */ private String formatTime(Time time) { - DateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT); + DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT); return time == null ? null : timeFormat.format(time); } @@ -331,7 +322,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us return null; // Parse date according to format - DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); + DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT); return new Date(dateFormat.parse(dateString).getTime()); } @@ -360,7 +351,7 @@ public class ModeledUser extends ModeledDirectoryObject implements Us return null; // Parse time according to format - DateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT); + DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT); return new Time(timeFormat.parse(timeString).getTime()); } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/DateField.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/DateField.java new file mode 100644 index 000000000..d27020bdb --- /dev/null +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/DateField.java @@ -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); + } + +} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/Field.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/Field.java index 6e8b48058..7e6f525ac 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/Field.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/Field.java @@ -90,6 +90,18 @@ public class Field { */ 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"; + } /** diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/TimeField.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/TimeField.java new file mode 100644 index 000000000..15891deb2 --- /dev/null +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/form/TimeField.java @@ -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); + } + +} diff --git a/guacamole/src/main/webapp/app/form/controllers/dateFieldController.js b/guacamole/src/main/webapp/app/form/controllers/dateFieldController.js new file mode 100644 index 000000000..cc73ac36e --- /dev/null +++ b/guacamole/src/main/webapp/app/form/controllers/dateFieldController.js @@ -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 */ + +}]); diff --git a/guacamole/src/main/webapp/app/form/controllers/timeFieldController.js b/guacamole/src/main/webapp/app/form/controllers/timeFieldController.js new file mode 100644 index 000000000..6cc4eb824 --- /dev/null +++ b/guacamole/src/main/webapp/app/form/controllers/timeFieldController.js @@ -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 */ + +}]); diff --git a/guacamole/src/main/webapp/app/form/services/formService.js b/guacamole/src/main/webapp/app/form/services/formService.js index ef42f864c..1f4721910 100644 --- a/guacamole/src/main/webapp/app/form/services/formService.js +++ b/guacamole/src/main/webapp/app/form/services/formService.js @@ -131,6 +131,30 @@ angular.module('form').provider('formService', function formServiceProvider() { module : 'form', controller : 'timeZoneFieldController', 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' } }; diff --git a/guacamole/src/main/webapp/app/form/templates/dateField.html b/guacamole/src/main/webapp/app/form/templates/dateField.html new file mode 100644 index 000000000..09d9267db --- /dev/null +++ b/guacamole/src/main/webapp/app/form/templates/dateField.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/guacamole/src/main/webapp/app/form/templates/timeField.html b/guacamole/src/main/webapp/app/form/templates/timeField.html new file mode 100644 index 000000000..0ecc1fbee --- /dev/null +++ b/guacamole/src/main/webapp/app/form/templates/timeField.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/guacamole/src/main/webapp/app/rest/types/Field.js b/guacamole/src/main/webapp/app/rest/types/Field.js index c5b913408..3474ef44a 100644 --- a/guacamole/src/main/webapp/app/rest/types/Field.js +++ b/guacamole/src/main/webapp/app/rest/types/Field.js @@ -138,7 +138,24 @@ angular.module('rest').factory('Field', [function defineField() { * * @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" };