Force flag for Hosts and Services.

The add dialogs for Hosts and Services have been updated to include
a checkbox to force adding hosts/services that are not in DNS.

The widgets has been updated to support tooltips.
This commit is contained in:
Endi S. Dewata 2011-01-18 12:12:47 -05:00
parent 17122d2705
commit 5c105a5ff4
4 changed files with 89 additions and 35 deletions

View File

@ -78,8 +78,7 @@ IPA.add_dialog = function (spec) {
state[that.entity_name + '-facet'] = 'details';
state[that.entity_name + '-pkey'] = pkey;
$.bbq.pushState(state);
},
function() { }
}
);
});
@ -90,28 +89,30 @@ IPA.add_dialog = function (spec) {
that.dialog_init();
};
function save_field(field, record, args, options){
var pkey_name = IPA.metadata[that.entity_name].primary_key;
var value = record[field.name];
if (!value) return;
if (field.name == pkey_name) {
args.push(value);
} else {
options[field.name] = value;
}
}
that.add = function(record, on_success, on_error) {
var args = [];
var options = {};
var pkey_name = IPA.metadata[that.entity_name].primary_key;
var command = IPA.command({
method: that.entity_name+'_add',
on_success: on_success,
on_error: on_error
});
for (var i=0; i<that.fields.length; i++) {
save_field(that.fields[i], record, args, options);
var field = that.fields[i];
var value = record[field.name];
if (!value) continue;
if (field.name == pkey_name) {
command.add_arg(value);
} else {
command.set_option(field.name, value);
}
}
IPA.cmd('add', args, options, on_success, on_error, that.entity_name);
command.execute();
};
that.add_dialog_init = that.init;

View File

@ -88,9 +88,17 @@ IPA.host_add_dialog = function (spec) {
that.init = function() {
that.add_field(IPA.text_widget({
'name': 'fqdn',
'size': 40,
'undo': false
name: 'fqdn',
size: 40,
undo: false
}));
// TODO: Replace with i18n label
that.add_field(IPA.checkbox_widget({
name: 'force',
label: 'Force',
tooltip: 'force host name even if not in DNS',
undo: false
}));
that.add_dialog_init();

View File

@ -100,6 +100,14 @@ IPA.service_add_dialog = function (spec) {
'undo': false
}));
// TODO: Replace with i18n label
that.add_field(IPA.checkbox_widget({
name: 'force',
label: 'Force',
tooltip: 'force principal name even if not in DNS',
undo: false
}));
that.add_dialog_init();
};
@ -112,7 +120,8 @@ IPA.service_add_dialog = function (spec) {
var tr = $('<tr/>').appendTo(table);
var td = $('<td/>', {
'style': 'vertical-align: top;'
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append(field.label+': ');
@ -128,7 +137,8 @@ IPA.service_add_dialog = function (spec) {
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
'style': 'vertical-align: top;'
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append(field.label+': ');
@ -138,6 +148,23 @@ IPA.service_add_dialog = function (spec) {
span = $('<span/>', { 'name': 'host' }).appendTo(td);
field.create(span);
field = that.get_field('force');
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append(field.label+': ');
td = $('<td/>', {
'style': 'vertical-align: top;'
}).appendTo(tr);
span = $('<span/>', { 'name': 'force' }).appendTo(td);
field.create(span);
};
that.get_record = function() {
@ -151,6 +178,11 @@ IPA.service_add_dialog = function (spec) {
record['krbprincipalname'] = service+'/'+host;
field = that.get_field('force');
var force = field.save()[0];
record['force'] = force;
return record;
};

View File

@ -30,6 +30,7 @@ IPA.widget = function(spec) {
that.id = spec.id;
that.name = spec.name;
that.label = spec.label;
that.tooltip = spec.tooltip;
that.read_only = spec.read_only;
that._entity_name = spec.entity_name;
@ -81,10 +82,18 @@ IPA.widget = function(spec) {
}
function init() {
if (that.entity_name && !that.label){
if (that.entity_name) {
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;
if (that.param_info) {
if (that.label === undefined) {
that.label = that.param_info.label;
}
if (that.tooltip === undefined) {
that.tooltip = that.param_info.doc;
}
}
}
}
@ -182,9 +191,10 @@ IPA.text_widget = function(spec) {
that.create = function(container) {
$('<input/>', {
'type': 'text',
'name': that.name,
'size': that.size
type: 'text',
name: that.name,
size: that.size,
title: that.tooltip
}).appendTo(container);
$('<span/>', {
@ -269,7 +279,8 @@ IPA.checkbox_widget = function (spec) {
$('<input/>', {
type: 'checkbox',
name: that.name,
checked : is_checked
checked : is_checked,
title: that.tooltip
}).appendTo(container);
if (that.undo) {
@ -404,9 +415,10 @@ IPA.textarea_widget = function (spec) {
that.create = function(container) {
$('<textarea/>', {
'rows': that.rows,
'cols': that.cols,
'name': that.name
rows: that.rows,
cols: that.cols,
name: that.name,
title: that.tooltip
}).appendTo(container);
if (that.undo) {
@ -904,12 +916,13 @@ IPA.dialog = function(spec) {
var tr = $('<tr/>').appendTo(table);
var td = $('<td/>', {
'style': 'vertical-align: top;'
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append(field.label+': ');
td = $('<td/>', {
'style': 'vertical-align: top;'
style: 'vertical-align: top;'
}).appendTo(tr);
var span = $('<span/>', { 'name': field.name }).appendTo(td);