A custom adder dialog has been added for DNS zones to simplify creating
reverse zones from IP address. The dialog provides a checkbox which
indicates whether the content of the zone name field is an IP address.
The IP address will be used to generate the reverse zone name and email
address.

Ticket #1045

--
Endi S. Dewata
From 11af2ad4c93121dcd565f58e9e6e8fa4f6a969f1 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Tue, 19 Jul 2011 11:11:36 -0500
Subject: [PATCH] Creating reverse zones from IP address.

A custom adder dialog has been added for DNS zones to simplify creating
reverse zones from IP address. The dialog provides a checkbox which
indicates whether the content of the zone name field is an IP address.
The IP address will be used to generate the reverse zone name and email
address.

Ticket #1045
---
 install/ui/dns.js                  |  135 +++++++++++++++++++++++++++++++++++-
 install/ui/test/data/ipa_init.json |   55 +++++++++++----
 2 files changed, 174 insertions(+), 16 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 7401926532fb44e4b3c0dd7e9b2feda206b82fe8..86aacb51bd4dd24c6f456bdd6410ab937151c0da 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -80,15 +80,148 @@ IPA.entity_factories.dnszone = function() {
         }).
         standard_association_facets().
         adder_dialog({
+            factory: IPA.dnszone_adder_dialog,
+            width: 500,
+            height: 300,
             fields: [
                 'idnsname',
+                {
+                    factory: IPA.checkbox_widget,
+                    name: 'name_from_ip',
+                    undo: false
+                },
                 'idnssoamname',
                 'idnssoarname',
-                {factory:IPA.force_dnszone_add_checkbox_widget}]
+                {
+                    factory: IPA.force_dnszone_add_checkbox_widget
+                }
+            ]
         }).
         build();
 };
 
+IPA.dnszone_adder_dialog = function(spec) {
+
+    spec = spec || {};
+
+    var that = IPA.add_dialog(spec);
+
+    that.create = function() {
+
+        var table = $('<table/>').appendTo(that.container);
+
+        var field = that.fields.get('idnsname');
+        var tr = $('<tr/>').appendTo(table);
+
+        var td = $('<td/>', {
+            style: 'vertical-align: top;',
+            title: field.label
+        }).appendTo(tr);
+
+        td.append($('<label/>', {
+            text: field.label+':'
+        }));
+
+        td = $('<td/>', {
+            style: 'vertical-align: top;'
+        }).appendTo(tr);
+
+        var span = $('<span/>', {
+            name: field.name
+        }).appendTo(td);
+
+        field.create(span);
+        field.field_span = span;
+
+        field = that.fields.get('name_from_ip');
+        tr = $('<tr/>').appendTo(table);
+
+        td = $('<td/>', {
+            style: 'vertical-align: top;',
+            title: field.label
+        }).appendTo(tr);
+
+        td = $('<td/>', {
+            style: 'vertical-align: top;'
+        }).appendTo(tr);
+
+        span = $('<span/>', {
+            name: field.name
+        }).appendTo(td);
+
+        td.append($('<label/>', {
+            text: field.label
+        }));
+
+        field.create(span);
+        field.field_span = span;
+
+        var fields = that.fields.values;
+        for (var i=0; i<fields.length; i++) {
+            field = fields[i];
+            if (field.name == 'idnsname' || field.name == 'name_from_ip') continue;
+            if (field.hidden) continue;
+
+            tr = $('<tr/>').appendTo(table);
+
+            td = $('<td/>', {
+                style: 'vertical-align: top;',
+                title: field.label
+            }).appendTo(tr);
+
+            td.append($('<label/>', {
+                text: field.label+':'
+            }));
+
+            td = $('<td/>', {
+                style: 'vertical-align: top;'
+            }).appendTo(tr);
+
+            span = $('<span/>', {
+                name: field.name
+            }).appendTo(td);
+
+            field.create(span);
+            field.field_span = span;
+        }
+    };
+
+    that.save = function(record) {
+
+        var idnsname;
+        var name_from_ip;
+
+        var fields = that.fields.values;
+        for (var i=0; i<fields.length; i++) {
+            var field = fields[i];
+
+            if (field.name == 'idnsname') {
+
+                idnsname = field.save()[0];
+
+            } else if (field.name == 'name_from_ip') {
+
+                name_from_ip = field.save()[0];
+                if (name_from_ip) {
+                    record.name_from_ip = idnsname;
+                } else {
+                    record.idnsname = idnsname;
+                }
+
+            } else if (field.name == 'idnssoarname') {
+
+                field.optional = name_from_ip;
+
+            } else {
+                var values = field.save();
+                record[field.name] = values.join(',');
+            }
+        }
+    };
+
+    return that;
+};
+
 IPA.dns_record_search_load = function (result) {
     this.table.empty();
     var normalized_record;
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 6277e39c41826f293e23dfaaaef9728b005a8c6f..7d9d234e98686889601c8f5cc8316dcd847baa4b 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -2549,7 +2549,7 @@
                                 "cli_name": "ipaentitlementid",
                                 "cli_short_name": null,
                                 "default": null,
-                                "doc": "Enrollment UUID",
+                                "doc": "Enrollment UUID (not implemented)",
                                 "exclude": null,
                                 "flags": [
                                     "no_update",
@@ -10350,6 +10350,33 @@
                                 "attribute": false,
                                 "autofill": false,
                                 "class": "Str",
+                                "cli_name": "name_from_ip",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "IP network to create reverse zone name from",
+                                "exclude": null,
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "Reverse zone IP network",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": false,
+                                "name": "name_from_ip",
+                                "noextrawhitespace": true,
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
                                 "cli_name": "name_server",
                                 "cli_short_name": null,
                                 "default": null,
@@ -11047,12 +11074,12 @@
                             {
                                 "alwaysask": false,
                                 "attribute": false,
-                                "autofill": false,
+                                "autofill": true,
                                 "class": "StrEnum",
                                 "cli_name": "type",
                                 "cli_short_name": null,
-                                "default": null,
-                                "doc": "Rule type (allow or deny)",
+                                "default": "allow",
+                                "doc": "Rule type (allow)",
                                 "exclude": null,
                                 "flags": [],
                                 "hint": null,
@@ -14456,12 +14483,12 @@
                                 "cli_name": "runasusercat",
                                 "cli_short_name": null,
                                 "default": null,
-                                "doc": "Run As User category the rule applies to",
+                                "doc": "RunAs User category the rule applies to",
                                 "exclude": null,
                                 "flags": [],
                                 "hint": null,
                                 "include": null,
-                                "label": "Run As User category",
+                                "label": "RunAs User category",
                                 "multivalue": false,
                                 "name": "ipasudorunasusercategory",
                                 "primary_key": false,
@@ -14480,12 +14507,12 @@
                                 "cli_name": "runasgroupcat",
                                 "cli_short_name": null,
                                 "default": null,
-                                "doc": "Run As Group category the rule applies to",
+                                "doc": "RunAs Group category the rule applies to",
                                 "exclude": null,
                                 "flags": [],
                                 "hint": null,
                                 "include": null,
-                                "label": "Run As Group category",
+                                "label": "RunAs Group category",
                                 "multivalue": false,
                                 "name": "ipasudorunasgroupcategory",
                                 "primary_key": false,
@@ -14752,7 +14779,7 @@
                                 "cli_name": "ipasudorunas_user",
                                 "cli_short_name": null,
                                 "default": null,
-                                "doc": "Run As User",
+                                "doc": "RunAs User",
                                 "exclude": null,
                                 "flags": [
                                     "no_update",
@@ -14761,7 +14788,7 @@
                                 ],
                                 "hint": null,
                                 "include": null,
-                                "label": "Run As User",
+                                "label": "RunAs User",
                                 "length": null,
                                 "maxlength": null,
                                 "minlength": null,
@@ -14783,7 +14810,7 @@
                                 "cli_name": "ipasudorunas_group",
                                 "cli_short_name": null,
                                 "default": null,
-                                "doc": "Run As Group",
+                                "doc": "RunAs Group",
                                 "exclude": null,
                                 "flags": [
                                     "no_update",
@@ -14792,7 +14819,7 @@
                                 ],
                                 "hint": null,
                                 "include": null,
-                                "label": "Run As Group",
+                                "label": "RunAs Group",
                                 "length": null,
                                 "maxlength": null,
                                 "minlength": null,
@@ -16167,9 +16194,7 @@
                         "memberof_group": [
                             "admins"
                         ],
-                        "nsaccountlock": [
-                            "False"
-                        ],
+                        "nsaccountlock": false,
                         "objectclass": [
                             "top",
                             "person",
-- 
1.7.5.1

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

Reply via email to