GUAC-1176: Generalize form fields by removing the value property. Add type-specific convenience classes for each field.

This commit is contained in:
Michael Jumper
2015-06-08 10:14:10 -07:00
parent 0b8b67026a
commit a532e22926
16 changed files with 452 additions and 106 deletions

View File

@@ -37,6 +37,7 @@ import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermis
import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionGroupPermissionService; import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionGroupPermissionService;
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.Field; import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.form.Form; import org.glyptodon.guacamole.form.Form;
import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.User;
@@ -68,9 +69,9 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
* All attributes related to restricting user accounts, within a logical * All attributes related to restricting user accounts, within a logical
* form. * form.
*/ */
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList( public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.<Field>asList(
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"), new BooleanField(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"),
new Field(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true") new BooleanField(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true")
)); ));
/** /**

View File

@@ -39,6 +39,7 @@ import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionModel;
import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionMapper; import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionMapper;
import org.glyptodon.guacamole.auth.jdbc.security.PasswordEncryptionService; import org.glyptodon.guacamole.auth.jdbc.security.PasswordEncryptionService;
import org.glyptodon.guacamole.form.Field; import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.form.PasswordField;
import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.User;
import org.glyptodon.guacamole.net.auth.credentials.CredentialsInfo; import org.glyptodon.guacamole.net.auth.credentials.CredentialsInfo;
import org.glyptodon.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; import org.glyptodon.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException;
@@ -81,7 +82,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
* The password field to provide the user when their password is expired * The password field to provide the user when their password is expired
* and must be changed. * and must be changed.
*/ */
private static final Field NEW_PASSWORD = new Field(NEW_PASSWORD_PARAMETER, "New password", Field.Type.PASSWORD); private static final Field NEW_PASSWORD = new PasswordField(NEW_PASSWORD_PARAMETER, "New password");
/** /**
* The name of the HTTP password confirmation parameter to expect if the * The name of the HTTP password confirmation parameter to expect if the
@@ -93,7 +94,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
* The password confirmation field to provide the user when their password * The password confirmation field to provide the user when their password
* is expired and must be changed. * is expired and must be changed.
*/ */
private static final Field CONFIRM_NEW_PASSWORD = new Field(CONFIRM_NEW_PASSWORD_PARAMETER, "Confirm new password", Field.Type.PASSWORD); private static final Field CONFIRM_NEW_PASSWORD = new PasswordField(CONFIRM_NEW_PASSWORD_PARAMETER, "Confirm new password");
/** /**
* Information describing the expected credentials if a user's password is * Information describing the expected credentials if a user's password is

View File

@@ -0,0 +1,58 @@
/*
* 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;
import java.util.Collections;
/**
* Represents a field with strictly one possible value. It is assumed that the
* field may be blank, but that its sole non-blank value is the value provided.
* The provided value represents "true" while all other values, including
* having no associated value, represent "false".
*
* @author Michael Jumper
*/
public class BooleanField extends Field {
/**
* Creates a new BooleanField with the given name, title, and truth value.
* The truth value is the value that, when assigned to this field, means
* that this field is "true".
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*
* @param truthValue
* The value to consider "true" for this field. All other values will
* be considered "false".
*/
public BooleanField(String name, String title, String truthValue) {
super(name, title, Field.Type.BOOLEAN, Collections.singletonList(
new FieldOption(truthValue, truthValue)
));
}
}

View File

@@ -0,0 +1,51 @@
/*
* 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;
import java.util.Collection;
/**
* Represents an arbitrary field with a finite, enumerated set of possible
* values.
*
* @author Michael Jumper
*/
public class EnumField extends Field {
/**
* Creates a new EnumField with the given name, title, and possible values.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*
* @param options
* All possible legal options for this field.
*/
public EnumField(String name, String title, Collection<FieldOption> options) {
super(name, title, Field.Type.ENUM, options);
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2013 Glyptodon LLC * Copyright (C) 2015 Glyptodon LLC
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,11 @@ import org.codehaus.jackson.map.annotate.JsonSerialize;
/** /**
* Represents an arbitrary field, such as an HTTP parameter, the parameter of a * Represents an arbitrary field, such as an HTTP parameter, the parameter of a
* remote desktop protocol, or an input field within a form. * remote desktop protocol, or an input field within a form. Fields are generic
* and typed dynamically through a type string, with the semantics of the field
* defined by the type string. The behavior of each field type is defined
* either through the web application itself (see FormService.js) or through
* extensions.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
@@ -94,13 +98,7 @@ public class Field {
private String type; private String type;
/** /**
* The value of this field, when checked. This is only applicable to * A collection of all legal values of this field.
* BOOLEAN fields.
*/
private String value;
/**
* A collection of all associated field options.
*/ */
private Collection<FieldOption> options; private Collection<FieldOption> options;
@@ -111,7 +109,7 @@ public class Field {
} }
/** /**
* Creates a new Parameter with the given name, title, and type. * Creates a new Field with the given name, title, and type.
* *
* @param name * @param name
* The unique name to associate with this field. * The unique name to associate with this field.
@@ -123,13 +121,14 @@ public class Field {
* The type of this field. * The type of this field.
*/ */
public Field(String name, String title, String type) { public Field(String name, String title, String type) {
this.name = name; this.name = name;
this.title = title; this.title = title;
this.type = type; this.type = type;
} }
/** /**
* Creates a new ENUM Parameter with the given name, title, and options. * Creates a new Field with the given name, title, type, and possible
* values.
* *
* @param name * @param name
* The unique name to associate with this field. * The unique name to associate with this field.
@@ -137,13 +136,17 @@ public class Field {
* @param title * @param title
* The human-readable title to associate with this field. * The human-readable title to associate with this field.
* *
* @param type
* The type of this field.
*
* @param options * @param options
* A collection of all possible valid options for this field. * A collection of all possible valid options for this field.
*/ */
public Field(String name, String title, Collection<FieldOption> options) { public Field(String name, String title, String type,
Collection<FieldOption> options) {
this.name = name; this.name = name;
this.title = title; this.title = title;
this.type = Type.ENUM; this.type = type;
this.options = options; this.options = options;
} }
@@ -188,28 +191,6 @@ public class Field {
this.title = title; this.title = title;
} }
/**
* Returns the value that should be assigned to this field if enabled. This
* is only applicable to BOOLEAN fields.
*
* @return
* The value that should be assigned to this field if enabled.
*/
public String getValue() {
return value;
}
/**
* Sets the value that should be assigned to this field if enabled. This is
* only applicable to BOOLEAN fields.
*
* @param value
* The value that should be assigned to this field if enabled.
*/
public void setValue(String value) {
this.value = value;
}
/** /**
* Returns the type of this field. * Returns the type of this field.
* *
@@ -232,8 +213,7 @@ public class Field {
/** /**
* Returns a mutable collection of field options. Changes to this * Returns a mutable collection of field options. Changes to this
* collection directly affect the available options. This is only * collection directly affect the available options.
* applicable to ENUM fields.
* *
* @return * @return
* A mutable collection of field options, or null if the field has no * A mutable collection of field options, or null if the field has no
@@ -244,8 +224,7 @@ public class Field {
} }
/** /**
* Sets the options available as possible values of this field. This is * Sets the options available as possible values of this field.
* only applicable to ENUM fields.
* *
* @param options * @param options
* The options to associate with this field. * The options to associate with this field.

View File

@@ -0,0 +1,45 @@
/*
* 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 field which can contain multiple lines of text.
*
* @author Michael Jumper
*/
public class MultilineField extends Field {
/**
* Creates a new MultilineField with the given name and title.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*/
public MultilineField(String name, String title) {
super(name, title, Field.Type.MULTILINE);
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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 field which may contain only integer values.
*
* @author Michael Jumper
*/
public class NumericField extends Field {
/**
* Creates a new NumericField with the given name and title.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*/
public NumericField(String name, String title) {
super(name, title, Field.Type.NUMERIC);
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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 field which contains sensitive text information related to
* authenticating a user.
*
* @author Michael Jumper
*/
public class PasswordField extends Field {
/**
* Creates a new PasswordField with the given name and title.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*/
public PasswordField(String name, String title) {
super(name, title, Field.Type.PASSWORD);
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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 basic text field. The field may generally contain any data, but
* may not contain multiple lines.
*
* @author Michael Jumper
*/
public class TextField extends Field {
/**
* Creates a new TextField with the given name and title.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*/
public TextField(String name, String title) {
super(name, title, Field.Type.TEXT);
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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 text field which will contain the uniquely-identifying name of
* a user.
*
* @author Michael Jumper
*/
public class UsernameField extends Field {
/**
* Creates a new UsernameField with the given name and title.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*/
public UsernameField(String name, String title) {
super(name, title, Field.Type.USERNAME);
}
}

View File

@@ -26,6 +26,8 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import org.glyptodon.guacamole.form.Field; import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.form.PasswordField;
import org.glyptodon.guacamole.form.UsernameField;
/** /**
* Information which describes a set of valid credentials. * Information which describes a set of valid credentials.
@@ -71,13 +73,13 @@ public class CredentialsInfo {
* A field describing the username HTTP parameter expected by Guacamole * A field describing the username HTTP parameter expected by Guacamole
* during login, if usernames are being used. * during login, if usernames are being used.
*/ */
public static final Field USERNAME = new Field("username", "username", Field.Type.USERNAME); public static final Field USERNAME = new UsernameField("username", "username");
/** /**
* A field describing the password HTTP parameter expected by Guacamole * A field describing the password HTTP parameter expected by Guacamole
* during login, if passwords are being used. * during login, if passwords are being used.
*/ */
public static final Field PASSWORD = new Field("password", "password", Field.Type.PASSWORD); public static final Field PASSWORD = new PasswordField("password", "password");
/** /**
* CredentialsInfo object which describes standard username/password * CredentialsInfo object which describes standard username/password

View File

@@ -67,16 +67,22 @@
] ]
}, },
{ {
"name" : "disable-auth", "name" : "disable-auth",
"title" : "Disable authentication", "title" : "Disable authentication",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "ignore-cert", "name" : "ignore-cert",
"title" : "Ignore server certificate", "title" : "Ignore server certificate",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
} }
] ]
}, },
@@ -131,10 +137,13 @@
] ]
}, },
{ {
"name" : "console", "name" : "console",
"title" : "Administrator console", "title" : "Administrator console",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
} }
] ]
}, },
@@ -193,28 +202,40 @@
"name" : "device-redirection", "name" : "device-redirection",
"fields" : [ "fields" : [
{ {
"name" : "console-audio", "name" : "console-audio",
"title" : "Support audio in console", "title" : "Support audio in console",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "disable-audio", "name" : "disable-audio",
"title" : "Disable audio", "title" : "Disable audio",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "enable-printing", "name" : "enable-printing",
"title" : "Enable printing", "title" : "Enable printing",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "enable-drive", "name" : "enable-drive",
"title" : "Enable drive", "title" : "Enable drive",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "drive-path", "name" : "drive-path",

View File

@@ -131,10 +131,13 @@
"name" : "sftp", "name" : "sftp",
"fields" : [ "fields" : [
{ {
"name" : "enable-sftp", "name" : "enable-sftp",
"title" : "Enable SFTP", "title" : "Enable SFTP",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
} }
] ]
} }

View File

@@ -37,16 +37,22 @@
"name" : "display", "name" : "display",
"fields" : [ "fields" : [
{ {
"name" : "read-only", "name" : "read-only",
"title" : "Read-only", "title" : "Read-only",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "swap-red-blue", "name" : "swap-red-blue",
"title" : "Swap red/blue components", "title" : "Swap red/blue components",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "cursor", "name" : "cursor",
@@ -119,10 +125,13 @@
"name" : "audio", "name" : "audio",
"fields" : [ "fields" : [
{ {
"name" : "enable-audio", "name" : "enable-audio",
"title" : "Enable audio", "title" : "Enable audio",
"type" : "BOOLEAN", "type" : "BOOLEAN",
"value" : "true" "options" : [{
"value" : "true",
"title" : "true"
}]
}, },
{ {
"name" : "audio-servername", "name" : "audio-servername",

View File

@@ -29,12 +29,12 @@ angular.module('form').controller('checkboxFieldController', ['$scope',
// Update typed value when model is changed // Update typed value when model is changed
$scope.$watch('model', function modelChanged(model) { $scope.$watch('model', function modelChanged(model) {
$scope.typedValue = (model === $scope.field.value); $scope.typedValue = (model === $scope.field.options[0].value);
}); });
// Update string value in model when typed value is changed // Update string value in model when typed value is changed
$scope.$watch('typedValue', function typedValueChanged(typedValue) { $scope.$watch('typedValue', function typedValueChanged(typedValue) {
$scope.model = (typedValue ? $scope.field.value : ''); $scope.model = (typedValue ? $scope.field.options[0].value : '');
}); });
}]); }]);

View File

@@ -64,16 +64,7 @@ angular.module('rest').factory('Field', [function defineField() {
this.type = template.type || Field.Type.TEXT; this.type = template.type || Field.Type.TEXT;
/** /**
* The value to set the parameter to, in the case of a BOOLEAN * All possible legal values for this parameter.
* parameter, to enable that parameter's effect.
*
* @type String
*/
this.value = template.value;
/**
* All possible legal values for this parameter. This property is only
* applicable to ENUM type parameters.
* *
* @type FieldOption[] * @type FieldOption[]
*/ */
@@ -123,7 +114,9 @@ angular.module('rest').factory('Field', [function defineField() {
/** /**
* The type string associated with parameters that may contain only a * The type string associated with parameters that may contain only a
* single possible value, where that value enables the parameter's * single possible value, where that value enables the parameter's
* effect. * effect. It is assumed that each BOOLEAN field will provide exactly
* one possible value (option), which will be the value if that field
* is true.
* *
* @type String * @type String
*/ */