summaryrefslogtreecommitdiffstats
path: root/install/static
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-01-13 10:00:38 +0700
committerEndi Sukma Dewata <edewata@redhat.com>2011-01-13 02:14:51 -0500
commitd92f5bf8bb476bd2c90262db9b44ac659b61ecf5 (patch)
tree63f5a461bd197aeef54a6b4a35c66fa003e6fd27 /install/static
parentb79bf4ab1757eb08f7209f158f1f3a386ace8c96 (diff)
downloadfreeipa-d92f5bf8bb476bd2c90262db9b44ac659b61ecf5.tar.gz
freeipa-d92f5bf8bb476bd2c90262db9b44ac659b61ecf5.tar.xz
freeipa-d92f5bf8bb476bd2c90262db9b44ac659b61ecf5.zip
Host details adjustments.
The labels for the following fields in Host details page have been changed: - fqdn: Fully Qualified Host Name - serverhostname: Host Name The ipa_details_field_create_input() and _ipa_create_text_input() has been converted into methods in ipa_details_field class. The code has been modified to display read-only fields as labels instead of disabled text fields. The attributelevelrights in host test data files have been updated.
Diffstat (limited to 'install/static')
-rw-r--r--install/static/details.js241
-rw-r--r--install/static/host.js13
-rw-r--r--install/static/test/data/host_show.json31
-rw-r--r--install/static/test/data/host_show_dev.example.com.json30
-rw-r--r--install/static/test/data/host_show_test.example.com.json31
-rw-r--r--install/static/test/details_tests.js8
-rwxr-xr-xinstall/static/widget.js23
7 files changed, 188 insertions, 189 deletions
diff --git a/install/static/details.js b/install/static/details.js
index f0756321d..b2dd26330 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -89,12 +89,12 @@ function ipa_details_field(spec) {
dd = ipa_create_first_dd(that.name);
- dd.append(ipa_details_field_create_input.call(that, that.values[0], hint_span, rights, 0));
+ dd.append(that.create_value(that.values[0], hint_span, rights, 0));
dd.appendTo(that.container);
for (var i = 1; i < that.values.length; ++i) {
dd = ipa_create_other_dd(that.name);
- dd.append(ipa_details_field_create_input.call(that, that.values[i], hint_span, rights, i));
+ dd.append(that.create_value(that.values[i], hint_span, rights, i));
dd.appendTo(that.container);
}
@@ -112,12 +112,113 @@ function ipa_details_field(spec) {
} else {
dd = ipa_create_first_dd(that.name);
- dd.append(ipa_details_field_create_input.call(that, '', hint_span, rights, 0));
+ dd.append(that.create_value('', hint_span, rights, 0));
dd.appendTo(that.container);
}
}
};
+ /* create an HTML element for displaying/editing an attribute
+ * arguments:
+ * attr - LDAP attribute name
+ * value - the attributes value */
+ that.create_value = function(value, hint, rights, index) {
+
+ // if field is primary key or non-writable, return a label
+
+ var label = $('<label/>', { html:value.toString() });
+
+ if (!IPA.is_field_writable(rights)) return label;
+
+ var param_info = ipa_get_param_info(that.entity_name, that.name);
+ if (param_info) {
+ if (param_info['primary_key']) return label;
+ if ('no_update' in param_info['flags']) return label;
+ }
+
+ // otherwise, create input field
+
+ var input = that.create_input(value, param_info, rights, index);
+ if (param_info) {
+ if (param_info['multivalue'] || param_info['class'] == 'List') {
+ input.append(_ipa_create_remove_link(that.name, param_info));
+ }
+ }
+
+ if (hint) input.after(hint);
+
+ return input;
+ };
+
+ /* creates a input box for editing a string attribute */
+ that.create_input = function(value, param_info, rights, index) {
+
+ index = index || 0;
+
+ function validate_input(text, param_info, error_link) {
+ if (param_info && param_info.pattern) {
+ var regex = new RegExp( param_info.pattern );
+ if (!text.match(regex)) {
+ error_link.style.display = "block";
+ if (param_info.pattern_errmsg) {
+ error_link.innerHTML = param_info.pattern_errmsg;
+ }
+ } else {
+ error_link.style.display = "none";
+ }
+ }
+ }
+
+ var doc = that.name;
+ if (param_info && param_info.doc) {
+ doc = param_info.doc;
+ }
+ var span = $("<Span />");
+ var input = $("<input/>", {
+ type: "text",
+ name: that.name,
+ value: value.toString(),
+ title: doc,
+ keyup: function(){
+ var undo_link = this.nextElementSibling;
+ undo_link.style.display = "inline";
+ var error_link = undo_link.nextElementSibling;
+
+ var text = $(this).val();
+ validate_input(text, param_info,error_link);
+ }
+ }).appendTo(span) ;
+
+ if (!IPA.is_field_writable(rights)) {
+ input.attr('disabled', 'disabled');
+ }
+
+ span.append($("<a/>", {
+ html:"undo",
+ "class":"ui-state-highlight ui-corner-all undo",
+ style:"display:none",
+ click: function(){
+ var previous_value = that.values || '';
+ if (index >= previous_value.length){
+ previous_value = '';
+ }else{
+ previous_value= previous_value[index];
+ }
+
+ this.previousElementSibling.value = previous_value;
+ this.style.display = "none";
+ var error_link = this.nextElementSibling;
+ validate_input(previous_value, param_info,error_link);
+ }
+ }));
+ span.append($("<span/>", {
+ html:"Does not match pattern",
+ "class":"ui-state-error ui-corner-all",
+ style:"display:none"
+ }));
+ return span;
+ };
+
function save() {
var values = [];
@@ -178,6 +279,10 @@ function ipa_details_section(spec){
};
that.create_field = function(spec) {
+
+ //TODO: replace ipa_details_field with class-specific implementation
+ //Valid field classes: Str, IA5Str, Int, Bool and List
+
var field = ipa_details_field(spec);
that.add_field(field);
return field;
@@ -332,11 +437,13 @@ function ipa_details_list_section(spec){
var field = fields[i];
var label = field.label;
- if (label !== ''){
+
+ // no need to get i18n label from metadata
+ // because it's already done by field.init()
+
+ if (label !== '') {
label += ':';
}
- var param_info = ipa_get_param_info(that.entity_name, field.name);
- if (param_info && param_info['label']) label = param_info['label'];
$('<dt/>', {
html: label
@@ -727,56 +834,6 @@ function ipa_insert_dd(jobj, content, dd_class){
-/* mapping of parameter types to handlers used to create inputs */
-var _ipa_param_type_2_handler_map = {
- 'Str': _ipa_create_text_input,
- 'IA5Str': _ipa_create_text_input,
- 'Int': _ipa_create_text_input,
- 'Bool': _ipa_create_text_input,
- 'List': _ipa_create_text_input
-};
-
-/* create an HTML element for displaying/editing an attribute
- * arguments:
- * attr - LDAP attribute name
- * value - the attributes value */
-function ipa_details_field_create_input(value,hint,rights, index)
-{
- var that = this;
-
- var input = $("<label>",{html:value.toString()});
- var param_info = ipa_get_param_info(that.entity_name, that.name);
- if (!param_info) {
- /* no information about the param is available, default to text input */
- input = _ipa_create_text_input.call(that, value, null, rights, index);
- if (hint){
- input.after(hint);
- }
- }else if (param_info['primary_key'] ||
- ('no_update' in param_info['flags'])){
- /* check if the param value can be modified */
- /* This is currently a no-op, as we use this logic for the
- default case as well */
- return input;
- }else{
- /* call handler by param class */
- var handler = _ipa_param_type_2_handler_map[param_info['class']];
- if (handler) {
- input = handler.call(that, value, param_info, rights, index);
- if ((param_info['multivalue'] ||
- param_info['class'] == 'List') &&
- IPA.is_field_writable(rights)){
- input.append( _ipa_create_remove_link(that.name, param_info));
- }
- if (hint){
- input.after(hint);
- }
- }
- }
- return input;
-}
-
-
/* creates a Remove link for deleting attribute values */
function _ipa_create_remove_link(attr, param_info)
{
@@ -797,76 +854,6 @@ function _ipa_create_remove_link(attr, param_info)
}
-/* creates a input box for editing a string attribute */
-function _ipa_create_text_input(value, param_info, rights, index)
-{
- var that = this;
- index = index || 0;
-
- function validate_input(text, param_info,error_link){
- if(param_info && param_info.pattern){
- var regex = new RegExp( param_info.pattern );
- if (!text.match(regex)) {
- error_link.style.display ="block";
- if ( param_info.pattern_errmsg){
- error_link.innerHTML = param_info.pattern_errmsg;
- }
- }else{
- error_link.style.display ="none";
- }
- }
- }
-
- var doc = that.name;
- if (param_info && param_info.doc){
- doc = param_info.doc;
- }
- var span = $("<Span />");
- var input = $("<input/>",{
- type: "text",
- name: that.name,
- value: value.toString(),
- title: doc,
- keyup: function(){
- var undo_link=this.nextElementSibling;
- undo_link.style.display ="inline";
- var error_link = undo_link.nextElementSibling;
-
- var text = $(this).val();
- validate_input(text, param_info,error_link);
- }
- }).appendTo(span) ;
-
- if (!IPA.is_field_writable(rights)){
- input.attr('disabled', 'disabled');
- }
-
- span.append($("<a/>",{
- html:"undo",
- "class":"ui-state-highlight ui-corner-all undo",
- style:"display:none",
- click: function(){
- var previous_value = that.values || '';
- if (index >= previous_value.length){
- previous_value = '';
- }else{
- previous_value= previous_value[index];
- }
-
- this.previousElementSibling.value = previous_value;
- this.style.display = "none";
- var error_link = this.nextElementSibling;
- validate_input(previous_value, param_info,error_link);
- }
- }));
- span.append($("<span/>",{
- html:"Does not match pattern",
- "class":"ui-state-error ui-corner-all",
- style:"display:none"
- }));
- return span;
-}
-
function ipa_details_field_create_add_link(title, rights, index) {
var that = this;
@@ -878,7 +865,7 @@ function ipa_details_field_create_add_link(title, rights, index) {
'click': function () {
var param_info = ipa_get_param_info(that.entity_name, '');
- var input = _ipa_create_text_input.call(that, '', param_info, rights, index);
+ var input = that.create_input('', param_info, rights, index);
link.replaceWith(input);
input.focus();
diff --git a/install/static/host.js b/install/static/host.js
index b6ca404af..708da8686 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -129,17 +129,24 @@ function ipa_host_details_facet(spec) {
});
that.add_section(section);
- section.create_field({'name': 'fqdn'});
+ //TODO: use i18n labels
+ section.create_field({
+ name: 'fqdn',
+ label: 'Fully Qualified Host Name'
+ });
+
section.create_field({'name': 'krbprincipalname'});
- //TODO add this to the host plugin
+ //TODO: add this to the host plugin
+ //TODO: use i18n labels
section.create_field({
'name': 'serverhostname',
- 'label': 'Server Host Name'
+ 'label': 'Host Name'
});
section.create_field({'name': 'description'});
+ //TODO: use i18n labels
section = ipa_details_list_section({
'name': 'enrollment',
'label': 'Enrollment'
diff --git a/install/static/test/data/host_show.json b/install/static/test/data/host_show.json
index b858970e4..b87802310 100644
--- a/install/static/test/data/host_show.json
+++ b/install/static/test/data/host_show.json
@@ -11,23 +11,26 @@
"fqdn": "rscwo",
"ipaclientversion": "rscwo",
"ipauniqueid": "rsc",
- "krbcanonicalname": "rscwo",
- "krbextradata": "rscwo",
- "krblastfailedauth": "rscwo",
+ "krbcanonicalname": "rsc",
+ "krbextradata": "rsc",
+ "krblastfailedauth": "rsc",
"krblastpwdchange": "rscwo",
- "krblastsuccessfulauth": "rscwo",
- "krbloginfailedcount": "rscwo",
+ "krblastsuccessfulauth": "rsc",
+ "krbloginfailedcount": "rsc",
+ "krbmaxrenewableage": "rscwo",
+ "krbmaxticketlife": "rscwo",
"krbobjectreferences": "rscwo",
- "krbpasswordexpiration": "rscwo",
- "krbprincipalaliases": "rscwo",
- "krbprincipalexpiration": "rscwo",
+ "krbpasswordexpiration": "rsc",
+ "krbprincipalaliases": "rsc",
+ "krbprincipalexpiration": "rsc",
"krbprincipalkey": "wo",
- "krbprincipalname": "rscwo",
- "krbprincipaltype": "rscwo",
- "krbpwdhistory": "rscwo",
- "krbpwdpolicyreference": "rscwo",
- "krbticketpolicyreference": "rscwo",
- "krbupenabled": "rscwo",
+ "krbprincipalname": "rsc",
+ "krbprincipaltype": "rsc",
+ "krbpwdhistory": "rsc",
+ "krbpwdpolicyreference": "rsc",
+ "krbticketflags": "rsc",
+ "krbticketpolicyreference": "rsc",
+ "krbupenabled": "rsc",
"l": "rscwo",
"managedby": "rscwo",
"memberof": "rsc",
diff --git a/install/static/test/data/host_show_dev.example.com.json b/install/static/test/data/host_show_dev.example.com.json
index d3e54fc84..1ee9f445f 100644
--- a/install/static/test/data/host_show_dev.example.com.json
+++ b/install/static/test/data/host_show_dev.example.com.json
@@ -11,26 +11,26 @@
"fqdn": "rscwo",
"ipaclientversion": "rscwo",
"ipauniqueid": "rsc",
- "krbcanonicalname": "rscwo",
- "krbextradata": "rscwo",
- "krblastfailedauth": "rscwo",
+ "krbcanonicalname": "rsc",
+ "krbextradata": "rsc",
+ "krblastfailedauth": "rsc",
"krblastpwdchange": "rscwo",
- "krblastsuccessfulauth": "rscwo",
- "krbloginfailedcount": "rscwo",
+ "krblastsuccessfulauth": "rsc",
+ "krbloginfailedcount": "rsc",
"krbmaxrenewableage": "rscwo",
"krbmaxticketlife": "rscwo",
"krbobjectreferences": "rscwo",
- "krbpasswordexpiration": "rscwo",
- "krbprincipalaliases": "rscwo",
- "krbprincipalexpiration": "rscwo",
+ "krbpasswordexpiration": "rsc",
+ "krbprincipalaliases": "rsc",
+ "krbprincipalexpiration": "rsc",
"krbprincipalkey": "wo",
- "krbprincipalname": "rscwo",
- "krbprincipaltype": "rscwo",
- "krbpwdhistory": "rscwo",
- "krbpwdpolicyreference": "rscwo",
- "krbticketflags": "rscwo",
- "krbticketpolicyreference": "rscwo",
- "krbupenabled": "rscwo",
+ "krbprincipalname": "rsc",
+ "krbprincipaltype": "rsc",
+ "krbpwdhistory": "rsc",
+ "krbpwdpolicyreference": "rsc",
+ "krbticketflags": "rsc",
+ "krbticketpolicyreference": "rsc",
+ "krbupenabled": "rsc",
"l": "rscwo",
"managedby": "rscwo",
"memberof": "rsc",
diff --git a/install/static/test/data/host_show_test.example.com.json b/install/static/test/data/host_show_test.example.com.json
index b858970e4..b87802310 100644
--- a/install/static/test/data/host_show_test.example.com.json
+++ b/install/static/test/data/host_show_test.example.com.json
@@ -11,23 +11,26 @@
"fqdn": "rscwo",
"ipaclientversion": "rscwo",
"ipauniqueid": "rsc",
- "krbcanonicalname": "rscwo",
- "krbextradata": "rscwo",
- "krblastfailedauth": "rscwo",
+ "krbcanonicalname": "rsc",
+ "krbextradata": "rsc",
+ "krblastfailedauth": "rsc",
"krblastpwdchange": "rscwo",
- "krblastsuccessfulauth": "rscwo",
- "krbloginfailedcount": "rscwo",
+ "krblastsuccessfulauth": "rsc",
+ "krbloginfailedcount": "rsc",
+ "krbmaxrenewableage": "rscwo",
+ "krbmaxticketlife": "rscwo",
"krbobjectreferences": "rscwo",
- "krbpasswordexpiration": "rscwo",
- "krbprincipalaliases": "rscwo",
- "krbprincipalexpiration": "rscwo",
+ "krbpasswordexpiration": "rsc",
+ "krbprincipalaliases": "rsc",
+ "krbprincipalexpiration": "rsc",
"krbprincipalkey": "wo",
- "krbprincipalname": "rscwo",
- "krbprincipaltype": "rscwo",
- "krbpwdhistory": "rscwo",
- "krbpwdpolicyreference": "rscwo",
- "krbticketpolicyreference": "rscwo",
- "krbupenabled": "rscwo",
+ "krbprincipalname": "rsc",
+ "krbprincipaltype": "rsc",
+ "krbpwdhistory": "rsc",
+ "krbpwdpolicyreference": "rsc",
+ "krbticketflags": "rsc",
+ "krbticketpolicyreference": "rsc",
+ "krbupenabled": "rsc",
"l": "rscwo",
"managedby": "rscwo",
"memberof": "rsc",
diff --git a/install/static/test/details_tests.js b/install/static/test/details_tests.js
index baed80ce5..1cb2036fd 100644
--- a/install/static/test/details_tests.js
+++ b/install/static/test/details_tests.js
@@ -225,7 +225,7 @@ test("Testing details lifecycle: create, setup, load.", function(){
});
-test("Testing _ipa_create_text_input().", function(){
+test("Testing create_input().", function() {
var field = ipa_details_field({
'name': "name"
@@ -234,7 +234,7 @@ test("Testing _ipa_create_text_input().", function(){
var name = "name";
var value="value";
var rights = 'rscwo'
- var input = _ipa_create_text_input.call(field, value, null,rights);
+ var input = field.create_input(value, null, rights);
ok(input,"input not null");
var text = input.find('input');
@@ -245,7 +245,7 @@ test("Testing _ipa_create_text_input().", function(){
same(text[0].type,"text" );
});
-test("Testing _ipa_create_text_input() read only .", function(){
+test("Testing create_input() read only .", function() {
var field = ipa_details_field({
'name': "name"
@@ -254,7 +254,7 @@ test("Testing _ipa_create_text_input() read only .", function(){
var name = "name";
var value="value";
var rights = 'rsc'
- var input = _ipa_create_text_input.call(field, value, null,rights);
+ var input = field.create_input(value, null, rights);
ok(input,"input not null");
var text = input.find('input');
diff --git a/install/static/widget.js b/install/static/widget.js
index 795cc42a2..d9661c3e8 100755
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -44,6 +44,7 @@ function ipa_widget(spec) {
that.save = spec.save || save;
that.update = spec.update || update;
that.validate_input = spec.validate_input || validate_input;
+ that.param_info = spec.param_info;
that.__defineGetter__("entity_name", function(){
return that._entity_name;
@@ -53,28 +54,26 @@ function ipa_widget(spec) {
that._entity_name = entity_name;
});
- var param_info;
-
/*returns true and clears the error message if the field value passes
the validation pattern. If the field value does not pass validation,
displays the error message and returns false. */
- function validate_input(text){
- if(!(param_info && param_info.pattern)){
+ function validate_input(text) {
+ if (!(that.param_info && that.param_info.pattern)) {
return true;
}
var error_link = that.get_error_link();
- if (!error_link){
+ if (!error_link) {
return true;
}
- var regex = new RegExp( param_info.pattern );
+ var regex = new RegExp( that.param_info.pattern );
//If the field is empty, don't validate
- if (!text || text.match(regex) ) {
+ if ( !text || text.match(regex) ) {
error_link.css('display', 'none');
return true;
}else{
error_link.css('display', 'block');
- if ( param_info.pattern_errmsg){
- error_link.html(param_info.pattern_errmsg);
+ if (that.param_info.pattern_errmsg) {
+ error_link.html(that.param_info.pattern_errmsg);
}
return false;
}
@@ -82,9 +81,9 @@ function ipa_widget(spec) {
function init() {
if (that.entity_name && !that.label){
- param_info = ipa_get_param_info(that.entity_name, spec.name);
- if ((param_info) && (that.label === undefined)){
- that.label = param_info.label;
+ that.param_info = ipa_get_param_info(that.entity_name, that.name);
+ if ((that.param_info) && (that.label === undefined)){
+ that.label = that.param_info.label;
}
}
}