Hi,

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.

--
Endi S. Dewata
From dd2accf799f9e3c61ad640e7aea20445f3b8ee16 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Tue, 18 Jan 2011 20:21:14 +0700
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    |   17 ++++++++++++-----
 install/static/service.js |   39 +++++++++++++++++++++++++++++++++++----
 install/static/widget.js  |   37 +++++++++++++++++++++++++------------
 4 files changed, 91 insertions(+), 39 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 e3ed5e50a8801f75e0bdd94bc316e721a99f5de8..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();
@@ -322,8 +330,7 @@ function host_provisioning_status_widget(spec) {
 
         dialog.create = function() {
             dialog.container.append(
-                'Are you sure you want to unprovision this host?'
-            );
+                'Are you sure you want to unprovision this host?');
         };
 
         dialog.add_button('Unprovision', function() {
diff --git a/install/static/service.js b/install/static/service.js
index 50cd80784073032f6f054720e0fbcaa8e6638c6e..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;
     };
 
@@ -343,8 +375,7 @@ function service_provisioning_status_widget(spec) {
 
         dialog.create = function() {
             dialog.container.append(
-                'Are you sure you want to unprovision this service?'
-            );
+                'Are you sure you want to unprovision this service?');
         };
 
         dialog.add_button('Unprovision', function() {
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.6.6.1

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

Reply via email to