diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java b/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java index 2751e1403..990ad73c5 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/form/TextField.java @@ -19,6 +19,8 @@ package org.apache.guacamole.form; +import java.util.Collection; + /** * Represents a basic text field. The field may generally contain any data, but * may not contain multiple lines. @@ -35,6 +37,21 @@ public class TextField extends Field { super(name, Field.Type.TEXT); } + /** + * Creates a new TextField with the given name and possible values. As a + * text field may contain any data by definition, any provided options are + * simply known-good values. + * + * @param name + * The unique name to associate with this field. + * + * @param options + * A set of known legal options for this field. + */ + public TextField(String name, Collection options) { + super(name, Field.Type.TEXT, options); + } + /** * Parses the given string, interpreting empty strings as equivalent to * null. For all other cases, the given string is returned verbatim. diff --git a/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/ssh.json b/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/ssh.json index 45486c8a1..c7f3dc4c3 100644 --- a/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/ssh.json +++ b/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/ssh.json @@ -43,7 +43,8 @@ "fields" : [ { "name" : "color-scheme", - "type" : "TEXT" + "type" : "TEXT", + "options" : [ "", "black-white", "gray-black", "green-black", "white-black" ] }, { "name" : "font-name", diff --git a/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/telnet.json b/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/telnet.json index d8939910e..60064a791 100644 --- a/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/telnet.json +++ b/guacamole-ext/src/main/resources/org/apache/guacamole/protocols/telnet.json @@ -39,7 +39,8 @@ "fields" : [ { "name" : "color-scheme", - "type" : "TEXT" + "type" : "TEXT", + "options" : [ "", "black-white", "gray-black", "green-black", "white-black" ] }, { "name" : "font-name", diff --git a/guacamole/pom.xml b/guacamole/pom.xml index 0573c4c19..dc4f0824b 100644 --- a/guacamole/pom.xml +++ b/guacamole/pom.xml @@ -386,6 +386,14 @@ runtime + + + org.webjars.npm + datalist-polyfill + 1.14.0 + runtime + + org.eclipse.jetty diff --git a/guacamole/src/licenses/LICENSE b/guacamole/src/licenses/LICENSE index c2e6bf5be..447470769 100644 --- a/guacamole/src/licenses/LICENSE +++ b/guacamole/src/licenses/LICENSE @@ -390,6 +390,15 @@ Carlito (http://code.google.com/p/chromium/issues/detail?id=280557) SIL Open Font (bundled/carlito/LICENSE) +datalist-polyfill (https://github.com/mfranzke/datalist-polyfill) +----------------------------------------------------------------- + + Version: 1.14.0 + From: 'Maximilian Franzke' (https://github.com/mfranzke) + License(s): + MIT (bundled/datalist-polyfill-1.14.0/LICENSE) + + FileSaver.js (https://github.com/eligrey/FileSaver.js) ------------------------------------------------------ diff --git a/guacamole/src/licenses/bundled/datalist-polyfill-1.14.0/LICENSE b/guacamole/src/licenses/bundled/datalist-polyfill-1.14.0/LICENSE new file mode 100644 index 000000000..8864d4a39 --- /dev/null +++ b/guacamole/src/licenses/bundled/datalist-polyfill-1.14.0/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 + +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. diff --git a/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js b/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js index 7d5b8683c..e78037845 100644 --- a/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js +++ b/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js @@ -24,44 +24,10 @@ angular.module('form').controller('selectFieldController', ['$scope', '$injector', function selectFieldController($scope, $injector) { - // Required services - var translationStringService = $injector.get('translationStringService'); - // Interpret undefined/null as empty string $scope.$watch('model', function setModel(model) { if (!model && model !== '') $scope.model = ''; }); - /** - * Produces the translation string for the given field option - * value. The translation string will be of the form: - * - * NAMESPACE.FIELD_OPTION_NAME_VALUE - * - * where NAMESPACE is the namespace provided to the - * directive, NAME is the field name transformed - * via translationStringService.canonicalize(), and - * VALUE is the option value transformed via - * translationStringService.canonicalize() - * - * @param {String} value - * The name of the option value. - * - * @returns {String} - * The translation string which produces the translated name of the - * value specified. - */ - $scope.getFieldOption = function getFieldOption(value) { - - // If no field, or no value, then no corresponding translation string - if (!$scope.field || !$scope.field.name || !value) - return ''; - - return translationStringService.canonicalize($scope.namespace || 'MISSING_NAMESPACE') - + '.FIELD_OPTION_' + translationStringService.canonicalize($scope.field.name) - + '_' + translationStringService.canonicalize(value || 'EMPTY'); - - }; - }]); diff --git a/guacamole/src/main/webapp/app/form/controllers/textFieldController.js b/guacamole/src/main/webapp/app/form/controllers/textFieldController.js new file mode 100644 index 000000000..b5bc7538f --- /dev/null +++ b/guacamole/src/main/webapp/app/form/controllers/textFieldController.js @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +/** + * Controller for text fields. + */ +angular.module('form').controller('textFieldController', ['$scope', '$injector', + function textFieldController($scope, $injector) { + + /** + * The ID of the datalist element that should be associated with the text + * field, providing a set of known-good values. If no such values are + * defined, this will be null. + * + * @type String + */ + $scope.dataListId = null; + + // Generate unique ID for datalist, if applicable + if ($scope.field.options && $scope.field.options.length) + $scope.dataListId = $scope.field.name + '-datalist'; + +}]); diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js b/guacamole/src/main/webapp/app/form/directives/formField.js index 15bde947b..9cf785c3a 100644 --- a/guacamole/src/main/webapp/app/form/directives/formField.js +++ b/guacamole/src/main/webapp/app/form/directives/formField.js @@ -97,6 +97,37 @@ angular.module('form').directive('guacFormField', [function formField() { }; + /** + * Produces the translation string for the given field option + * value. The translation string will be of the form: + * + * NAMESPACE.FIELD_OPTION_NAME_VALUE + * + * where NAMESPACE is the namespace provided to the + * directive, NAME is the field name transformed + * via translationStringService.canonicalize(), and + * VALUE is the option value transformed via + * translationStringService.canonicalize() + * + * @param {String} value + * The name of the option value. + * + * @returns {String} + * The translation string which produces the translated name of the + * value specified. + */ + $scope.getFieldOption = function getFieldOption(value) { + + // If no field, or no value, then no corresponding translation string + if (!$scope.field || !$scope.field.name || !value) + return ''; + + return translationStringService.canonicalize($scope.namespace || 'MISSING_NAMESPACE') + + '.FIELD_OPTION_' + translationStringService.canonicalize($scope.field.name) + + '_' + translationStringService.canonicalize(value || 'EMPTY'); + + }; + /** * Returns whether the current field should be displayed. * diff --git a/guacamole/src/main/webapp/app/form/services/formService.js b/guacamole/src/main/webapp/app/form/services/formService.js index 64a171310..168a1efa7 100644 --- a/guacamole/src/main/webapp/app/form/services/formService.js +++ b/guacamole/src/main/webapp/app/form/services/formService.js @@ -44,6 +44,8 @@ angular.module('form').provider('formService', function formServiceProvider() { * @type FieldType */ 'TEXT' : { + module : 'form', + controller : 'textFieldController', templateUrl : 'app/form/templates/textField.html' }, diff --git a/guacamole/src/main/webapp/app/form/templates/textField.html b/guacamole/src/main/webapp/app/form/templates/textField.html index e213bc20e..a338db4cd 100644 --- a/guacamole/src/main/webapp/app/form/templates/textField.html +++ b/guacamole/src/main/webapp/app/form/templates/textField.html @@ -1 +1,7 @@ - \ No newline at end of file +
+ + + + +
\ No newline at end of file diff --git a/guacamole/src/main/webapp/index.html b/guacamole/src/main/webapp/index.html index fd5dba44e..5a53d8a23 100644 --- a/guacamole/src/main/webapp/index.html +++ b/guacamole/src/main/webapp/index.html @@ -71,8 +71,9 @@ - + + diff --git a/guacamole/src/main/webapp/translations/de.json b/guacamole/src/main/webapp/translations/de.json index a5f8517dc..90953e5c7 100644 --- a/guacamole/src/main/webapp/translations/de.json +++ b/guacamole/src/main/webapp/translations/de.json @@ -378,6 +378,12 @@ "FIELD_HEADER_PRIVATE_KEY" : "Privater Schlüssel:", "FIELD_HEADER_READ_ONLY" : "Nur-Lesen:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Schwarz auf Weiß", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grau auf Schwarz", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Grün auf Schwarz", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Weiß auf Schwarz", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -416,6 +422,12 @@ "FIELD_HEADER_PORT" : "Port:", "FIELD_HEADER_READ_ONLY" : "Nur-Lesen:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Schwarz auf Weiß", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grau auf Schwarz", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Grün auf Schwarz", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Weiß auf Schwarz", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", diff --git a/guacamole/src/main/webapp/translations/en.json b/guacamole/src/main/webapp/translations/en.json index 1b0377b46..56bf614e1 100644 --- a/guacamole/src/main/webapp/translations/en.json +++ b/guacamole/src/main/webapp/translations/en.json @@ -455,6 +455,12 @@ "FIELD_OPTION_BACKSPACE_8" : "Backspace (Ctrl-H)", "FIELD_OPTION_BACKSPACE_127" : "Delete (Ctrl-?)", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Black on white", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gray on black", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Green on black", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "White on black", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -519,6 +525,12 @@ "FIELD_OPTION_BACKSPACE_8" : "Backspace (Ctrl-H)", "FIELD_OPTION_BACKSPACE_127" : "Delete (Ctrl-?)", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Black on white", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gray on black", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Green on black", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "White on black", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", diff --git a/guacamole/src/main/webapp/translations/es.json b/guacamole/src/main/webapp/translations/es.json index 7bf1f9c49..283779a1f 100644 --- a/guacamole/src/main/webapp/translations/es.json +++ b/guacamole/src/main/webapp/translations/es.json @@ -435,6 +435,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Nombre script escritura:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Ruta script escritura:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Negro sobre blanco", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gris sobre negro", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Verde sobre negro", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Blanco sobre negro", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -481,6 +487,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Nombre script escritura:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Ruta script escritura:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Negro sobre blanco", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gris sobre negro", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Verde sobre negro", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Blanco sobre negro", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", diff --git a/guacamole/src/main/webapp/translations/fr.json b/guacamole/src/main/webapp/translations/fr.json index 3d692d5e8..8ebbd36cf 100644 --- a/guacamole/src/main/webapp/translations/fr.json +++ b/guacamole/src/main/webapp/translations/fr.json @@ -381,6 +381,12 @@ "FIELD_HEADER_PRIVATE_KEY" : "Clé privée:", "FIELD_HEADER_READ_ONLY" : "Lecture seule:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Noir sur blanc", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gris sur noir", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Vert sur noir", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Blanc sur noir", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -419,6 +425,12 @@ "FIELD_HEADER_PORT" : "Port:", "FIELD_HEADER_READ_ONLY" : "Lecture seule:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Noir sur blanc", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Gris sur noir", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Vert sur noir", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Blanc sur noir", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", diff --git a/guacamole/src/main/webapp/translations/nl.json b/guacamole/src/main/webapp/translations/nl.json index b45e01f61..69a789ac6 100644 --- a/guacamole/src/main/webapp/translations/nl.json +++ b/guacamole/src/main/webapp/translations/nl.json @@ -397,6 +397,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Typescript naam:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Typescript map:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Zwart op wit", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grijs op zwart", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Groen op zwart", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Wit op zwart", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -443,6 +449,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Typescript naam:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Typescript map:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Zwart op wit", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grijs op zwart", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Groen op zwart", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Wit op zwart", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", diff --git a/guacamole/src/main/webapp/translations/no.json b/guacamole/src/main/webapp/translations/no.json index 37f6cfd2a..30ea8719d 100644 --- a/guacamole/src/main/webapp/translations/no.json +++ b/guacamole/src/main/webapp/translations/no.json @@ -379,6 +379,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Typescript navn:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Typescript sti:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Svart på hvit", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grå på svart", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Grønn på svart", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Hvit på svart", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10", @@ -424,6 +430,12 @@ "FIELD_HEADER_TYPESCRIPT_NAME" : "Typescript navn:", "FIELD_HEADER_TYPESCRIPT_PATH" : "Typescript sti:", + "FIELD_OPTION_COLOR_SCHEME_BLACK_WHITE" : "Svart på hvit", + "FIELD_OPTION_COLOR_SCHEME_EMPTY" : "", + "FIELD_OPTION_COLOR_SCHEME_GRAY_BLACK" : "Grå på svart", + "FIELD_OPTION_COLOR_SCHEME_GREEN_BLACK" : "Grønn på svart", + "FIELD_OPTION_COLOR_SCHEME_WHITE_BLACK" : "Hvit på svart", + "FIELD_OPTION_FONT_SIZE_8" : "8", "FIELD_OPTION_FONT_SIZE_9" : "9", "FIELD_OPTION_FONT_SIZE_10" : "10",