On 1/18/2011 10:42 PM, Endi Sukma Dewata wrote:
The attached patch addresses this bug:
https://fedorahosted.org/freeipa/ticket/639

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.

Rebased against the latest.

--
Endi S. Dewata
From 437f30f4d4e6b8914953a4e1a99e38f4244cbcee Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Tue, 18 Jan 2011 12:12:47 -0500
Subject: [PATCH] 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.
---
 install/static/add.js     |   37 +++++++++++++++++++------------------
 install/static/host.js    |   14 +++++++++++---
 install/static/service.js |   36 ++++++++++++++++++++++++++++++++++--
 install/static/widget.js  |   37 +++++++++++++++++++++++++------------
 4 files changed, 89 insertions(+), 35 deletions(-)

diff --git a/install/static/add.js b/install/static/add.js
index 69e0ad79b10449d96c6144c52faccb23acf7b7fd..69b1108c31a72b281129624630e0bfb6238f25fe 100644
--- a/install/static/add.js
+++ b/install/static/add.js
@@ -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;
diff --git a/install/static/host.js b/install/static/host.js
index dd435c56e298525a3e286b674684f2b4bfb4af1a..c3851ff75e7baf3c29389f1234d49943d3f3ef26 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -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();
diff --git a/install/static/service.js b/install/static/service.js
index 4154b22d4421132f5711e001d76ba75ee91f191b..81f00ec77599b5eb7462a4d0de9ff7b7629fb217 100644
--- a/install/static/service.js
+++ b/install/static/service.js
@@ -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;
     };
 
diff --git a/install/static/widget.js b/install/static/widget.js
index 9221e499cea5451f1e26c45cdf434d3629ea0b06..576eef77b4fed7a168925bd1fd7f4d7fbe4e7487 100644
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -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);
-- 
1.7.3.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to