mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Added checkbox to remove hosts from DNS.
A custom deleter dialog for hosts has been added to provide an option whether to remove the hosts from DNS. Ticket #1470
This commit is contained in:
committed by
Adam Young
parent
bc4e97e191
commit
6d14331a05
@@ -631,7 +631,7 @@ IPA.deleter_dialog = function (spec) {
|
||||
};
|
||||
|
||||
that.set_values = function(values) {
|
||||
that.values = that.values.concat(values);
|
||||
that.values = values;
|
||||
};
|
||||
|
||||
that.create = function() {
|
||||
@@ -678,5 +678,7 @@ IPA.deleter_dialog = function (spec) {
|
||||
that.dialog_open(container);
|
||||
};
|
||||
|
||||
that.deleter_dialog_create = that.create;
|
||||
|
||||
return that;
|
||||
};
|
||||
|
@@ -974,6 +974,13 @@ IPA.entity_builder = function(){
|
||||
return that.dialog(spec);
|
||||
};
|
||||
|
||||
that.deleter_dialog = function(spec) {
|
||||
spec.factory = spec.factory || IPA.search_deleter_dialog;
|
||||
spec.name = spec.name || 'remove';
|
||||
|
||||
return that.dialog(spec);
|
||||
};
|
||||
|
||||
that.build = function(){
|
||||
var item = entity;
|
||||
entity = null;
|
||||
|
@@ -122,9 +122,50 @@ IPA.entity_factories.host = function () {
|
||||
}
|
||||
]
|
||||
}).
|
||||
deleter_dialog({
|
||||
factory: IPA.host_deleter_dialog
|
||||
}).
|
||||
build();
|
||||
};
|
||||
|
||||
IPA.host_deleter_dialog = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = IPA.search_deleter_dialog(spec);
|
||||
|
||||
that.create = function() {
|
||||
|
||||
that.deleter_dialog_create();
|
||||
|
||||
var metadata = IPA.get_method_option('host_del', 'updatedns');
|
||||
|
||||
that.updatedns = $('<input/>', {
|
||||
type: 'checkbox',
|
||||
name: 'updatedns',
|
||||
title: metadata.doc
|
||||
}).appendTo(that.container);
|
||||
|
||||
that.container.append(' ');
|
||||
|
||||
that.container.append(metadata.doc);
|
||||
};
|
||||
|
||||
that.create_command = function() {
|
||||
var batch = that.search_deleter_dialog_create_command();
|
||||
var updatedns = that.updatedns.is(':checked');
|
||||
|
||||
for (var i=0; i<batch.commands.length; i++) {
|
||||
var command = batch.commands[i];
|
||||
command.set_option('updatedns', updatedns);
|
||||
}
|
||||
|
||||
return batch;
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.dnszone_select_widget = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
@@ -182,16 +182,13 @@ IPA.search_facet = function(spec) {
|
||||
dialog.open(that.container);
|
||||
};
|
||||
|
||||
|
||||
that.remove = function() {
|
||||
that.remove_instances(that.managed_entity);
|
||||
};
|
||||
|
||||
|
||||
that.remove_instances = function(entity) {
|
||||
|
||||
var values = that.get_values();
|
||||
var label = entity.metadata.label;
|
||||
|
||||
var title;
|
||||
if (!values.length) {
|
||||
@@ -200,60 +197,21 @@ IPA.search_facet = function(spec) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = that.managed_entity.get_dialog('remove');
|
||||
|
||||
if (!dialog) {
|
||||
dialog = IPA.search_deleter_dialog();
|
||||
}
|
||||
|
||||
dialog.entity_name = entity.name;
|
||||
dialog.entity = entity;
|
||||
dialog.facet = that;
|
||||
|
||||
title = IPA.messages.dialogs.remove_title;
|
||||
title = title.replace('${entity}', label);
|
||||
var label = entity.metadata.label;
|
||||
dialog.title = title.replace('${entity}', label);
|
||||
|
||||
var dialog = IPA.deleter_dialog({
|
||||
'title': title,
|
||||
'parent': that.container,
|
||||
'values': values,
|
||||
entity_name: entity.name
|
||||
});
|
||||
|
||||
dialog.execute = function() {
|
||||
|
||||
var batch = IPA.batch_command({
|
||||
'on_success': function() {
|
||||
that.refresh();
|
||||
dialog.close();
|
||||
},
|
||||
'on_error': function() {
|
||||
that.refresh();
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
var pkeys =
|
||||
entity.get_primary_key_prefix();
|
||||
|
||||
for (var i=0; i<values.length; i++) {
|
||||
var command = IPA.command({
|
||||
entity: entity.name,
|
||||
method: 'del'
|
||||
});
|
||||
|
||||
for (var k=0; k<pkeys.length; k++) {
|
||||
command.add_arg(pkeys[k]);
|
||||
}
|
||||
var value = values[i];
|
||||
if (value instanceof Object){
|
||||
for (var key in value){
|
||||
if (value.hasOwnProperty(key)){
|
||||
if (key === 'pkey'){
|
||||
command.add_arg(value[key]);
|
||||
}else{
|
||||
command.set_option(key, value[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
command.add_arg(value);
|
||||
}
|
||||
batch.add_command(command);
|
||||
}
|
||||
|
||||
batch.execute();
|
||||
};
|
||||
dialog.set_values(values);
|
||||
|
||||
dialog.init();
|
||||
|
||||
@@ -339,6 +297,69 @@ IPA.search_facet = function(spec) {
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.search_deleter_dialog = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = IPA.deleter_dialog(spec);
|
||||
|
||||
that.create_command = function() {
|
||||
var batch = IPA.batch_command();
|
||||
|
||||
var pkeys = that.entity.get_primary_key_prefix();
|
||||
|
||||
for (var i=0; i<that.values.length; i++) {
|
||||
var command = IPA.command({
|
||||
entity: that.entity.name,
|
||||
method: 'del'
|
||||
});
|
||||
|
||||
for (var j=0; j<pkeys.length; j++) {
|
||||
command.add_arg(pkeys[j]);
|
||||
}
|
||||
|
||||
var value = that.values[i];
|
||||
if (value instanceof Object) {
|
||||
for (var key in value) {
|
||||
if (value.hasOwnProperty(key)) {
|
||||
if (key === 'pkey'){
|
||||
command.add_arg(value[key]);
|
||||
} else {
|
||||
command.set_option(key, value[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command.add_arg(value);
|
||||
}
|
||||
|
||||
batch.add_command(command);
|
||||
}
|
||||
|
||||
return batch;
|
||||
};
|
||||
|
||||
that.execute = function() {
|
||||
|
||||
var batch = that.create_command();
|
||||
|
||||
batch.on_success = function() {
|
||||
that.facet.refresh();
|
||||
that.close();
|
||||
};
|
||||
|
||||
batch.on_error = function() {
|
||||
that.facet.refresh();
|
||||
that.close();
|
||||
};
|
||||
|
||||
batch.execute();
|
||||
};
|
||||
|
||||
that.search_deleter_dialog_create_command = that.create_command;
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
/*TODO. this has much copied code from above. Refactor the search_facet
|
||||
To either be nested or not nested. */
|
||||
|
Reference in New Issue
Block a user