From 8830123c9b38fb838dff1701b005c311adaf77e4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 22 Feb 2017 01:04:27 -0800 Subject: [PATCH] GUACAMOLE-292: Add support for email fields. --- .../org/apache/guacamole/form/EmailField.java | 37 +++++++++++++++++++ .../java/org/apache/guacamole/form/Field.java | 6 +++ .../webapp/app/form/services/formService.js | 10 +++++ .../webapp/app/form/templates/emailField.html | 8 ++++ .../main/webapp/app/index/styles/input.css | 4 +- .../webapp/app/manage/styles/attributes.css | 1 + .../manage/styles/connection-parameter.css | 1 + .../src/main/webapp/app/rest/types/Field.js | 8 ++++ 8 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 guacamole-ext/src/main/java/org/apache/guacamole/form/EmailField.java create mode 100644 guacamole/src/main/webapp/app/form/templates/emailField.html diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/form/EmailField.java b/guacamole-ext/src/main/java/org/apache/guacamole/form/EmailField.java new file mode 100644 index 000000000..e56a75786 --- /dev/null +++ b/guacamole-ext/src/main/java/org/apache/guacamole/form/EmailField.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +package org.apache.guacamole.form; + +/** + * Represents a text field which may contain an email address. + */ +public class EmailField extends Field { + + /** + * Creates a new EmailField with the given name. + * + * @param name + * The unique name to associate with this field. + */ + public EmailField(String name) { + super(name, Field.Type.EMAIL); + } + +} diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java b/guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java index dba10654c..19f1ead09 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java @@ -47,6 +47,12 @@ public class Field { */ public static String TEXT = "TEXT"; + /** + * An email address field. This field type generally behaves + * identically to arbitrary text fields, but has semantic differences. + */ + public static String EMAIL = "EMAIL"; + /** * A username field. This field type generally behaves identically to * arbitrary text fields, but has semantic differences. diff --git a/guacamole/src/main/webapp/app/form/services/formService.js b/guacamole/src/main/webapp/app/form/services/formService.js index 0d12259ad..c117bbf7f 100644 --- a/guacamole/src/main/webapp/app/form/services/formService.js +++ b/guacamole/src/main/webapp/app/form/services/formService.js @@ -47,6 +47,16 @@ angular.module('form').provider('formService', function formServiceProvider() { templateUrl : 'app/form/templates/textField.html' }, + /** + * Email address field type. + * + * @see {@link Field.Type.EMAIL} + * @type FieldType + */ + 'EMAIL' : { + templateUrl : 'app/form/templates/emailField.html' + }, + /** * Numeric field type. * diff --git a/guacamole/src/main/webapp/app/form/templates/emailField.html b/guacamole/src/main/webapp/app/form/templates/emailField.html new file mode 100644 index 000000000..db6d3beda --- /dev/null +++ b/guacamole/src/main/webapp/app/form/templates/emailField.html @@ -0,0 +1,8 @@ +
+ + {{model}} +
\ No newline at end of file diff --git a/guacamole/src/main/webapp/app/index/styles/input.css b/guacamole/src/main/webapp/app/index/styles/input.css index 1eb8d9b71..4141c768c 100644 --- a/guacamole/src/main/webapp/app/index/styles/input.css +++ b/guacamole/src/main/webapp/app/index/styles/input.css @@ -17,11 +17,11 @@ * under the License. */ -input[type=checkbox], input[type=number], input[type=text], input[type=radio], label, textarea { +input[type=checkbox], input[type=number], input[type=text], input[type=email], input[type=radio], label, textarea { -webkit-tap-highlight-color: rgba(128,192,128,0.5); } -div.location, input[type=text], input[type=number], input[type=password], textarea { +div.location, input[type=text], input[type=email], input[type=number], input[type=password], textarea { border: 1px solid #777; -moz-border-radius: 0.2em; -webkit-border-radius: 0.2em; diff --git a/guacamole/src/main/webapp/app/manage/styles/attributes.css b/guacamole/src/main/webapp/app/manage/styles/attributes.css index 136ec5dee..2b5bc92fc 100644 --- a/guacamole/src/main/webapp/app/manage/styles/attributes.css +++ b/guacamole/src/main/webapp/app/manage/styles/attributes.css @@ -19,6 +19,7 @@ /* Do not stretch attributes to fit available area */ .attributes input[type=text], +.attributes input[type=email], .attributes input[type=password], .attributes input[type=number] { width: auto; diff --git a/guacamole/src/main/webapp/app/manage/styles/connection-parameter.css b/guacamole/src/main/webapp/app/manage/styles/connection-parameter.css index a005703a1..8fe19d691 100644 --- a/guacamole/src/main/webapp/app/manage/styles/connection-parameter.css +++ b/guacamole/src/main/webapp/app/manage/styles/connection-parameter.css @@ -19,6 +19,7 @@ /* Do not stretch connection parameters to fit available area */ .connection-parameters input[type=text], +.connection-parameters input[type=email], .connection-parameters input[type=password], .connection-parameters input[type=number] { width: auto; diff --git a/guacamole/src/main/webapp/app/rest/types/Field.js b/guacamole/src/main/webapp/app/rest/types/Field.js index 5204268d3..84dfe13b5 100644 --- a/guacamole/src/main/webapp/app/rest/types/Field.js +++ b/guacamole/src/main/webapp/app/rest/types/Field.js @@ -75,6 +75,14 @@ angular.module('rest').factory('Field', [function defineField() { */ TEXT : 'TEXT', + /** + * The type string associated with parameters that may contain an email + * address. + * + * @type String + */ + EMAIL : 'EMAIL', + /** * The type string associated with parameters that may contain an * arbitrary string, where that string represents the username of the