summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-07-19 13:46:09 -0500
committerAdam Young <ayoung@redhat.com>2011-07-20 13:51:20 -0400
commit6d14331a0561e98e4ce8a51bb418c1f6d25b5e88 (patch)
tree1195cc22de4ae7c5410f7d132023dc5fb7f85cc2 /install
parentbc4e97e191f68cdf16e0ef76b218c1f602835c2c (diff)
downloadfreeipa-6d14331a0561e98e4ce8a51bb418c1f6d25b5e88.tar.gz
freeipa-6d14331a0561e98e4ce8a51bb418c1f6d25b5e88.tar.xz
freeipa-6d14331a0561e98e4ce8a51bb418c1f6d25b5e88.zip
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
Diffstat (limited to 'install')
-rw-r--r--install/ui/dialog.js4
-rw-r--r--install/ui/entity.js7
-rw-r--r--install/ui/host.js41
-rw-r--r--install/ui/search.js127
4 files changed, 125 insertions, 54 deletions
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 9d22da7f1..5245ba92c 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -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;
};
diff --git a/install/ui/entity.js b/install/ui/entity.js
index ec0317897..0940c7d17 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -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;
diff --git a/install/ui/host.js b/install/ui/host.js
index 9994abf31..bbac4edd7 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -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 || {};
diff --git a/install/ui/search.js b/install/ui/search.js
index 1b07908b8..fec394dea 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -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;
}
- title = IPA.messages.dialogs.remove_title;
- 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 dialog = that.managed_entity.get_dialog('remove');
- 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();
+ if (!dialog) {
+ dialog = IPA.search_deleter_dialog();
+ }
- for (var i=0; i<values.length; i++) {
- var command = IPA.command({
- entity: entity.name,
- method: 'del'
- });
+ dialog.entity_name = entity.name;
+ dialog.entity = entity;
+ dialog.facet = that;
- 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);
- }
+ title = IPA.messages.dialogs.remove_title;
+ var label = entity.metadata.label;
+ dialog.title = title.replace('${entity}', label);
- 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. */