On 06/09/2016 10:15 AM, Pavel Vomacka wrote:


On 06/08/2016 04:40 PM, Petr Vobornik wrote:
On 06/07/2016 10:07 AM, Pavel Vomacka wrote:

On 06/06/2016 07:51 PM, Martin Basti wrote:


On 05.06.2016 18:34, Pavel Vomacka wrote:
Hello,

please review attached patches which add WebUI part of DNS Locations feature.

--
Pavel^3 Vomacka


NACK

1)
When I edit location description and click on revert button, then that nice
location table just disappear :)
It's the same situation as with using 'Save' button - reported here:
https://fedorahosted.org/freeipa/ticket/5776 . I'll write there a comment that
revert button hides values in association tables.
2)
Can we put a placeholder "100" (gray font or something) to Location weight in server detail view? Because when weight is not specified then default is 100
Placeholder added.


1. please add "disable_facet_tabs: true," to location details page.
There is no point to display single facet tab.
Fixed.
2. can we extend location_association_table the same witth as rule
tables are extended in sudo and hbac rules? IIRC it needs to use
specific section type of 'servers' section.
Fixed.

3. the placeholder 100 should be also added to adder dialog in
location_association_table_widget
I think that it can be confusing when user tries to move a server from one location to another, because server might have set a weight already and it can differ from 100. In this case user would see placeholder 100 but in reality the weight of server would be different (value set in previous location).
4. Description could be textarea - to be consistent with hbac, sudo rules.
Fixed.

5. "Information" section is called "General" or "$Entity Settings" on
other parts of Web UI. It should be consistent.
Fixed.

Patches attached.

--
Pavel^3 Vomacka





Another revision of patch 40, removed useless comma from ipa_init.json. Both patches attached.
From 67867ac7389aa9856ad1bd0bbc413519d85bf594 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Sun, 5 Jun 2016 18:03:17 +0200
Subject: [PATCH 1/2] Add adapter attribute for choosing record

The new attribute of the adapter contains the name of record which will be
extracted from API call result.

Part of: https://fedorahosted.org/freeipa/ticket/5905
---
 install/ui/src/freeipa/field.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js
index fdf925e3d7adc62622e0c9e5e1440eefbdac807b..12ef7f45585802c4099e469c9fb5188b3a3587ab 100644
--- a/install/ui/src/freeipa/field.js
+++ b/install/ui/src/freeipa/field.js
@@ -802,6 +802,13 @@ field.Adapter = declare(null, {
     result_index: 0,
 
     /**
+     * Name of the record which we want to extract from the result.
+     * Used in dnslocations.
+     * @type {String}
+     */
+    result_name: 'result',
+
+    /**
      * Extract record from RPC call response
      *
      * Tries to detect if supplied data is RPC call response if so, it
@@ -821,10 +828,10 @@ field.Adapter = declare(null, {
         var dr = data.result;
         var record = null;
         if (dr) {
-            if (IPA.defined(dr.result)) record = dr.result;
+            if (IPA.defined(dr[this.result_name])) record = dr[this.result_name];
             else if (dr.results) {
                 var result = dr.results[this.result_index];
-                if (result) record = result.result;
+                if (result) record = result[this.result_name];
             }
         }
         return record;
-- 
2.5.5

From 3d26dd326c76533c20e219b3a36c24e52145c566 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Sun, 5 Jun 2016 18:07:29 +0200
Subject: [PATCH 2/2] DNS Locations: WebUI part

WebUI part of DNS Location feature.

https://fedorahosted.org/freeipa/ticket/5905
---
 install/ui/src/freeipa/navigation/menu_spec.js |   5 +
 install/ui/src/freeipa/topology.js             | 258 ++++++++++++++++++++++++-
 2 files changed, 260 insertions(+), 3 deletions(-)

diff --git a/install/ui/src/freeipa/navigation/menu_spec.js b/install/ui/src/freeipa/navigation/menu_spec.js
index fb64ccaea56cabdb6addb28543d3f968a746018b..0afc7daceb725cee5677982c68c09d1666d42885 100644
--- a/install/ui/src/freeipa/navigation/menu_spec.js
+++ b/install/ui/src/freeipa/navigation/menu_spec.js
@@ -226,6 +226,11 @@ var nav = {};
                             hidden: true
                         },
                         {
+                            entity: 'location',
+                            facet: 'search',
+                            hidden: true
+                        },
+                        {
                             facet: 'topology-graph',
                             hidden: true
                         }
diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
index c26dc685328904ed893c960b6b4b0981cd9d28ce..5e9e6013e883e982d54ee86f8b5c3eb3ac4b2ceb 100644
--- a/install/ui/src/freeipa/topology.js
+++ b/install/ui/src/freeipa/topology.js
@@ -51,7 +51,8 @@ var topology = IPA.topology = {
             suffix_search: 'topologysuffix_search',
             server_search: 'server_search',
             domainlevel: 'domainlevel_details',
-            topologygraph: 'topology-graph'
+            topologygraph: 'topology-graph',
+            location_search: 'location_search'
         }
     }
 };
@@ -193,6 +194,14 @@ return {
 var make_server_spec = function() {
 return {
     name: 'server',
+    policies: [
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'location',
+            dest_facet: 'details'
+        }
+    ],
     facets: [
            {
             $type: 'search',
@@ -212,7 +221,6 @@ return {
         },
         {
             $type: 'details',
-            no_update: true,
             disable_facet_tabs: true,
             sections: [
                 {
@@ -221,7 +229,18 @@ return {
                         { name: 'cn', read_only: true },
                         { name: 'ipamindomainlevel', read_only: true },
                         { name: 'ipamaxdomainlevel', read_only: true },
-                        { $type: 'multivalued', name: 'iparepltopomanagedsuffix_topologysuffix', read_only: true }
+                        { $type: 'multivalued', name: 'iparepltopomanagedsuffix_topologysuffix', read_only: true },
+                        {
+                            $type: 'entity_select',
+                            name: 'ipalocation_location',
+                            other_entity: 'location',
+                            other_field: 'idnsname',
+                            flags: ['w_if_no_aci']
+                        },
+                        {
+                            name: 'ipalocationweight',
+                            placeholder: '100'
+                        }
                     ]
                 }
             ]
@@ -272,6 +291,235 @@ topology.domainlevel_adapter = declare([mod_field.Adapter], {
 });
 
 
+var make_location_spec = function() {
+return {
+    name: 'location',
+    policies: [
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'server',
+            dest_facet: 'details'
+        },
+        {
+            $factory: IPA.facet_update_policy,
+            source_facet: 'details',
+            dest_entity: 'location',
+            dest_facet: 'search'
+        }
+    ],
+    facets: [
+        {
+            $type: 'search',
+            disable_facet_tabs: false,
+            tabs_in_sidebar: true,
+            tab_label: '@mo:location.label',
+            facet_groups: [topology.search_facet_group],
+            facet_group: 'search',
+            columns: [
+                'idnsname',
+                'description'
+            ]
+        },
+        {
+            $type: 'details',
+            disable_facet_tabs: true,
+            section_layout_class: 'col-sm-12',
+            sections: [
+                {
+                    name: 'general',
+                    label: '@i18n:details.general',
+                    fields: [
+                        'idnsname',
+                        {
+                            $type: 'textarea',
+                            name: 'description'
+                        }
+                    ]
+                },
+                {
+                    $factory: topology.location_servers_section,
+                    name: 'servers',
+                    label: '@mo:server.label',
+                    fields: [
+                        {
+                            $type: 'location_association_table',
+                            adapter: topology.location_adapter,
+                            other_entity: 'server',
+                            footer: false,
+                            name: 'cn',
+                            columns: [
+                                {
+                                    name: 'cn',
+                                    link: true
+                                },
+                                {
+                                    name: 'ipalocationweight'
+                                },
+                                {
+                                    name: 'location_relative_weight'
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        }
+    ],
+    adder_dialog: {
+        fields: [
+            {
+                $type: 'text',
+                name: 'idnsname',
+                required: true
+            },
+            'description'
+        ]
+    }
+};};
+
+topology.location_adapter = declare([mod_field.Adapter], {
+    load: function(data) {
+        var result = this.get_record(data);
+        if (result.servers_server === undefined) return [];
+
+        result = result.servers_server;
+
+        this.result_name = 'servers';
+        var servers = this.get_record(data);
+        this.result_name = 'result';
+
+        var output = [];
+
+        for (var i=0, l=result.length; i<l; i++) {
+            output.push(servers[result[i]]);
+        }
+
+        return output;
+    }
+});
+
+topology.location_servers_section = function (spec) {
+    spec = spec || {};
+
+    var that = IPA.section(spec);
+
+    return that;
+};
+
+topology.location_server_adder_dialog = function(spec) {
+    spec = spec || {};
+
+    var that = IPA.entity_adder_dialog(spec);
+
+    that.init = function() {
+        that.added.attach(function() {
+            that.facet.refresh();
+            that.facet.on_update.notify();
+        });
+    };
+
+    that.create_add_command = function(record) {
+        var pkey = that.facet.get_pkey();
+        var command = that.entity_adder_dialog_create_add_command(record);
+
+        command.set_option('ipalocation_location', pkey);
+
+        return command;
+    };
+
+    that.init();
+
+    return that;
+};
+
+topology.location_association_table_widget = function(spec) {
+
+    spec = spec || {};
+    spec.name = spec.name || 'servers';
+
+    var that = IPA.association_table_widget(spec);
+
+    that.create_add_dialog = function() {
+
+        var entity_label = that.entity.metadata.label_singular;
+        var pkey = that.facet.get_pkey();
+        var other_entity_label = that.other_entity.metadata.label_singular;
+
+        var title = that.add_title;
+        title = title.replace('${entity}', entity_label);
+        title = title.replace('${primary_key}', pkey);
+        title = title.replace('${other_entity}', other_entity_label);
+
+        return topology.location_server_adder_dialog({
+            title: title,
+            entity: that.other_entity.name,
+            method: 'mod',
+            options: {
+                'ipalocation_location': pkey
+            },
+            sections: [
+                {
+                    fields: [
+                        {
+                            $type: 'entity_select',
+                            name: 'cn',
+                            required: true,
+                            other_entity: that.other_entity.name,
+                            other_field: 'cn',
+                            filter_options: {
+                                'not_in_location': pkey
+                            }
+                        },
+                        {
+                            $type: 'text',
+                            name: 'ipalocationweight'
+                        }
+                    ]
+                }
+            ]
+        });
+    };
+
+
+    that.remove = function(values, on_success, on_error) {
+
+        var pkey = '';
+
+        var batch = rpc.batch_command({
+            on_success: function(data) {
+                that.remove_button.set_enabled(false);
+                that.facet.refresh();
+
+                var count = data.result.count;
+                var msg = text.get('@i18n:association.removed').replace('${count}', count);
+                IPA.notify_success(msg);
+            },
+            on_error: on_error
+        });
+
+        var command, value;
+        for(var i = 0, l=values.length; i<l; i++) {
+            value = values[i];
+
+            command = rpc.command({
+                entity: that.other_entity.name,
+                method: 'mod',
+                args: [value],
+                options: {
+                    'ipalocation_location': pkey
+                }
+            });
+
+            batch.add_command(command);
+        }
+
+        batch.execute();
+    };
+
+    return that;
+};
+
 topology.domainlevel_metadata = function(spec, context) {
     var metadata = metadata_provider.source;
     metadata.objects.domainlevel = {
@@ -970,6 +1218,7 @@ topology.server_spec = make_server_spec();
  */
 topology.domainlevel_spec = make_domainlevel_spec();
 
+topology.location_spec = make_location_spec();
 
 /**
  * Register entity
@@ -985,17 +1234,20 @@ topology.register = function() {
     e.register({type: 'topologysegment', spec: topology.segment_spec});
     e.register({type: 'server', spec: topology.server_spec});
     e.register({type: 'domainlevel', spec: topology.domainlevel_spec});
+    e.register({type: 'location', spec: topology.location_spec});
 
     a.register('domainlevel_set', topology.domainlevel_set_action);
     a.register('segment_add', topology.add_segment_action);
     a.register('segment_del', topology.del_segment_action);
 
     w.register('topology-graph', topology.TopologyGraphWidget);
+    w.register('location_association_table', topology.location_association_table_widget);
     fa.register({
         type: 'topology-graph',
         ctor: topology.TopologyGraphFacet,
         spec: topology.topology_graph_facet_spec
     });
+
 };
 
 phases.on('registration', topology.register);
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to