mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 14:11:21 +00:00
GUAC-1160: Create "guacForm" directive which allows the editing of an arbitrary set of fields.
This commit is contained in:
82
guacamole/src/main/webapp/app/form/directives/form.js
Normal file
82
guacamole/src/main/webapp/app/form/directives/form.js
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A directive that allows editing of a collection of fields.
|
||||||
|
*/
|
||||||
|
angular.module('form').directive('guacForm', [function form() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
// Element only
|
||||||
|
restrict: 'E',
|
||||||
|
replace: true,
|
||||||
|
scope: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fields to display.
|
||||||
|
*
|
||||||
|
* @type Field[]
|
||||||
|
*/
|
||||||
|
fields : '=',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object which will receive all field values. Each field value
|
||||||
|
* will be assigned to the property of this object having the same
|
||||||
|
* name.
|
||||||
|
*
|
||||||
|
* @type Object.<String, String>
|
||||||
|
*/
|
||||||
|
model : '='
|
||||||
|
|
||||||
|
},
|
||||||
|
templateUrl: 'app/form/templates/form.html',
|
||||||
|
controller: ['$scope', function formController($scope) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object which will receive all field values. Normally, this
|
||||||
|
* will be the object provided within the "model" attribute. If
|
||||||
|
* no such object has been provided, a blank model will be used
|
||||||
|
* instead as a placeholder, such that the fields of this form
|
||||||
|
* will have something to bind to.
|
||||||
|
*
|
||||||
|
* @type Object.<String, String>
|
||||||
|
*/
|
||||||
|
$scope.values = {};
|
||||||
|
|
||||||
|
// Update string value and re-assign to model when field is changed
|
||||||
|
$scope.$watch('model', function setModel(model) {
|
||||||
|
|
||||||
|
// Assign new model only if provided
|
||||||
|
if (model)
|
||||||
|
$scope.values = model;
|
||||||
|
|
||||||
|
// Otherwise, use blank model
|
||||||
|
else
|
||||||
|
$scope.values = {};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}] // end controller
|
||||||
|
};
|
||||||
|
|
||||||
|
}]);
|
50
guacamole/src/main/webapp/app/form/styles/form-field.css
Normal file
50
guacamole/src/main/webapp/app/form/styles/form-field.css
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Keep toggle-password icon on same line */
|
||||||
|
.form-field .password-field {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generic 1x1em icon/button */
|
||||||
|
.form-field .password-field .icon.toggle-password {
|
||||||
|
|
||||||
|
display: inline-block;
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: default;
|
||||||
|
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 1em;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Icon for unmasking passwords */
|
||||||
|
.form-field .password-field input[type=password] ~ .icon.toggle-password {
|
||||||
|
background-image: url('images/action-icons/guac-show-pass.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Icon for masking passwords */
|
||||||
|
.form-field .password-field input[type=text] ~ .icon.toggle-password {
|
||||||
|
background-image: url('images/action-icons/guac-hide-pass.png');
|
||||||
|
}
|
@@ -20,31 +20,8 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Keep toggle-password icon on same line */
|
table.form th {
|
||||||
.form-field .password-field {
|
text-align: left;
|
||||||
white-space: nowrap;
|
font-weight: normal;
|
||||||
}
|
padding-right: 1em;
|
||||||
|
|
||||||
/* Generic 1x1em icon/button */
|
|
||||||
.form-field .password-field .icon.toggle-password {
|
|
||||||
|
|
||||||
display: inline-block;
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: default;
|
|
||||||
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-size: 1em;
|
|
||||||
width: 1em;
|
|
||||||
height: 1em;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Icon for unmasking passwords */
|
|
||||||
.form-field .password-field input[type=password] ~ .icon.toggle-password {
|
|
||||||
background-image: url('images/action-icons/guac-show-pass.png');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Icon for masking passwords */
|
|
||||||
.form-field .password-field input[type=text] ~ .icon.toggle-password {
|
|
||||||
background-image: url('images/action-icons/guac-hide-pass.png');
|
|
||||||
}
|
}
|
||||||
|
32
guacamole/src/main/webapp/app/form/templates/form.html
Normal file
32
guacamole/src/main/webapp/app/form/templates/form.html
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<table class="form">
|
||||||
|
<!--
|
||||||
|
Copyright 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- All fields in form -->
|
||||||
|
<tr ng-repeat="field in fields">
|
||||||
|
<th>{{field.title | translate}}</th>
|
||||||
|
<td>
|
||||||
|
<guac-form-field field="field" model="values[field.name]"></guac-form-field>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
@@ -59,17 +59,8 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
<!-- Connection parameters -->
|
<!-- Connection parameters -->
|
||||||
<h2 class="header">{{'MANAGE_CONNECTION.SECTION_HEADER_PARAMETERS' | translate}}</h2>
|
<h2 class="header">{{'MANAGE_CONNECTION.SECTION_HEADER_PARAMETERS' | translate}}</h2>
|
||||||
<div class="section" ng-class="{loading: !parameters}">
|
<div class="section connection-parameters" ng-class="{loading: !parameters}">
|
||||||
<table class="properties connection-parameters">
|
<guac-form fields="protocols[connection.protocol].parameters" model="parameters"></guac-form>
|
||||||
|
|
||||||
<!-- All the different possible editable field types -->
|
|
||||||
<tr ng-repeat="parameter in protocols[connection.protocol].parameters">
|
|
||||||
<th>{{parameter.title | translate}}</th>
|
|
||||||
<td>
|
|
||||||
<guac-form-field field="parameter" model="parameters[parameter.name]"></guac-form-field>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Form action buttons -->
|
<!-- Form action buttons -->
|
||||||
|
Reference in New Issue
Block a user