On 11/24/2015 02:09 PM, Martin Babinsky wrote:
On 11/24/2015 12:17 PM, Petr Vobornik wrote:
On 11/24/2015 12:10 PM, Ludwig Krispenz wrote:
Hi Petr,

I'm testing these patches.Two observations so far:
- in Topology->IPA Servers I see a table of my servers and the managed
suffix column I see both suffixes, ipaca and the realm,
but if I select one of the servers I Only see the realm suffix, this was
different in the demo video

implemented in patch 927 (separate thread)

- the graph layou is not stable. If I arrange it and the try some
actions on a segment, eg try to remove one (which is rejected), the
graph does change again-

Not sure if I understand it correctly. One can set static position to a
node by double clicking on it (this needs to be somehow communicated)
otherwise it is random - each refresh.

Maybe we should not refresh on failed operation because there is no
change.
+1, failed operations on segments should not trigger graph redraws.

Fixed in patch 936-1.




Ludwig

On 11/20/2015 04:00 PM, Petr Vobornik wrote:
Patches 928-931 are prerequisites.

Patches 932-934 implements the visualization

Patches 935-936 adds 'add' and 'remove' segment functionality to the
visualization page.

https://fedorahosted.org/freeipa/ticket/4286


I have tested the new feature a bit (I have looked also on the code, but
I do not speak JavaScript very well) and so far I have found these issues:

1.) If you first setup topology w/ domain level 0 and try to render
topology graph, you are correctly informed that managed topology is
available on domain level 1 only. IF you raise your domainlevel and
click refresh, you get the same error message, probably because the
request to get domainlevel is sent only in the beginning of session. You
have to logout and then login back to see the graph.

Login/Logout should not be required. Refresh of UI(F5) should be sufficient.

Anyway, fixed in new patch 937.


2.) If I add a new segment using Add dialog and clicking 'Add & edit'
button, I get the following error:

"""
IPA Error 3007: RequirementError

'topologysuffixcn' is required
"""

However the segment is created normally. I guess that there is some bug
when viewing the segment immediately after creation.

Fixed in patch 935-1.


3.) The key with suffix colors should be more descriptive. I would like
to propose the following format:

"""
Color coding of segments by suffix:
{suffix_name} ({suffix_dn})
e.g.
ipaca (o=ipaca)
realm (dc=ipa,dc=test)
"""

4.) It would be nice if the graph canvas could be dynamically resized
based on the container size, but I am not sure how difficult it is to
implement it.
(Graphical nitpick: I would change the color of nodes, green does not
fit very well with the bluish/grey  palette of other WebUI elements)

I would like this, #3 and #4 to go trough additional designer review and therefore fixed in other patch.

Right now I'm not sure what is the correct behavior for the re-sizing.

Atm the canvas size is fixed: 960x500.

1. What should be the canvas size when size of the container is very small, e.g. 330x90? With static positions, nodes would not be visible. 2. Similar issue when nodes are put into corners and then the window is shrunk.

Probably there could be a minimum size and then enlarge the cavas when nodes are dragged.


Otherwise I think that it is a good start and additional features can be
built on top of this patchset.

--
Petr Vobornik
From f760b12f9a852f76fadcd8a27b160442ccb8a0b0 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 24 Nov 2015 17:27:37 +0100
Subject: [PATCH] webui: update topology graph after raising domain level

When topology graph was shown with domain level == 0, a view describing
that domain level needs to be at least 1 was shown.

If domain level is raised, this view is then properly replaced by the
graph when shown again.

https://fedorahosted.org/freeipa/ticket/4286
---
 install/ui/src/freeipa/dialog.js   |  6 +++---
 install/ui/src/freeipa/topology.js | 34 +++++++++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js
index f8f1bba78bee44e6d5e78be9c6c906bd55b9c698..c732a72780d432b45a30cbec2c7ef93cc56a3b72 100644
--- a/install/ui/src/freeipa/dialog.js
+++ b/install/ui/src/freeipa/dialog.js
@@ -1720,10 +1720,10 @@ IPA.command_dialog = dialogs.command_dialog = function(spec) {
             args: that.args,
             options: options,
             on_success: function(data) {
-                that.on_success();
+                that.on_success(data);
             },
-            on_error: function() {
-                that.on_error();
+            on_error: function(data) {
+                that.on_error(data);
             }
         });
         return command;
diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
index 01e036aa41e60492c0f2238b34d00987177f096e..8dfa02a004235251a1ccd929896618a7307b1871 100644
--- a/install/ui/src/freeipa/topology.js
+++ b/install/ui/src/freeipa/topology.js
@@ -337,7 +337,8 @@ topology.domainlevel_set_action = function(spec) {
     that.execute_action = function(facet) {
 
         var dialog = builder.build('dialog', that.dialog);
-        dialog.succeeded.attach(function() {
+        dialog.succeeded.attach(function(data) {
+            IPA.domain_level = data.result.result;
             if (that.refresh) facet.refresh();
         });
         dialog.open();
@@ -622,6 +623,7 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
 
     disabled_view_el: null,
     topology_view_el: null,
+    current_view_el: null,
     visualization_cnt_el: null,
 
     _get_servers: function() {
@@ -800,6 +802,8 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
     },
 
     update: function() {
+        this._update_view();
+
         if (IPA.domain_level < topology.required_domain_level) return;
 
         when(this._get_data()).then(lang.hitch(this, function(data) {
@@ -832,13 +836,33 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
         forward('link-selected');
     },
 
-    render: function() {
-        this.el = $('<div/>', { 'class': this.css_class });
+    _update_view: function() {
+
+        var view;
+
         if (IPA.domain_level < topology.required_domain_level) {
-            this._render_disabled_view().appendTo(this.el);
+            if (!this.disabled_view_el) {
+                view = this._render_disabled_view();
+            } else {
+                view = this.disabled_view_el;
+            }
         } else {
-            this._render_topology_view().appendTo(this.el);
+            if (!this.topology_view_el) {
+                view = this._render_topology_view();
+            } else {
+                view = this.topology_view_el;
+            }
         }
+        if (view !== this.current_view_el) {
+            this.el.empty();
+            view.appendTo(this.el);
+        }
+        this.current_view_el = view;
+    },
+
+    render: function() {
+        this.el = $('<div/>', { 'class': this.css_class });
+        this._update_view();
         if (this.container_node) {
             this.el.appendTo(this.container_node);
         }
-- 
2.4.3

From 8130d8a437d3bba414c0f04a77dcb7350c46567e Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 9 Nov 2015 17:59:59 +0100
Subject: [PATCH] webui: remove segments on topology graph page

https://fedorahosted.org/freeipa/ticket/4286
---
 install/ui/src/freeipa/topology.js | 83 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
index 0d7cae208d619e888d296838b19a8f3b4efe9b41..01e036aa41e60492c0f2238b34d00987177f096e 100644
--- a/install/ui/src/freeipa/topology.js
+++ b/install/ui/src/freeipa/topology.js
@@ -382,7 +382,7 @@ topology.topology_graph_facet_spec = {
     tab_label: 'Topology Graph',
     facet_groups: [topology.search_facet_group],
     facet_group: 'search',
-    actions: ['refresh', 'segment_add'],
+    actions: ['refresh', 'segment_add', 'segment_del'],
     control_buttons: [
         {
             name: 'refresh',
@@ -393,6 +393,11 @@ topology.topology_graph_facet_spec = {
             name: 'segment_add',
             label: '@i18n:buttons.add',
             icon: 'fa-plus'
+        },
+        {
+            name: 'segment_del',
+            label: '@i18n:buttons.remove',
+            icon: 'fa-trash-o'
         }
     ],
     widgets: [
@@ -428,6 +433,15 @@ topology.TopologyGraphFacet = declare([Facet, ActionMixin, HeaderMixin], {
         on(this, 'show', lang.hitch(this, function(args) {
             graph.update();
         }));
+
+        on(graph, 'link-selected', lang.hitch(this, function(data) {
+            this.set_selected_link(data.link);
+        }));
+    },
+
+    set_selected_link: function(link) {
+        this.selected_link = link;
+        this.action_state.put('selected_link', link ? ['link_selected'] : []);
     },
 
     refresh: function() {
@@ -529,9 +543,63 @@ topology.add_segment_action = function(spec) {
     };
 
     that.on_success = function(data) {
+        that.facet.refresh();
+    };
+
+    return that;
+};
+
+/**
+ * Deletes selected segment
+ *
+ * Facet must have 'selected_link' option.
+ *
+ * Facet should reflect the selection in action state: "link_selected"
+ *
+ * @class topology.del_segment_action
+ * @extends IPA.delete_action
+ */
+topology.del_segment_action = function(spec) {
+
+    spec = spec || {};
+    spec.name = spec.name || 'segment_del';
+    spec.enable_cond = spec.enable_cond || ['link_selected'];
+
+    var that = IPA.delete_action(spec);
+
+    that.execute_action = function(facet, on_success, on_error) {
+
+        that.facet = facet;
+
+        var args = [
+            facet.selected_link.suffix.cn[0],
+            facet.selected_link.segment.cn[0]
+        ];
+
+        rpc.command({
+            entity: 'topologysegment',
+            method: that.method,
+            args: args,
+            options: that.options,
+            on_success: that.get_on_success(facet, on_success),
+            on_error: that.get_on_error(facet, on_error)
+        }).execute();
+    };
+
+    that.get_confirm_message = function(facet) {
+        var pkey = facet.selected_link.segment.cn[0];
+        var msg = that.confirm_msg.replace('${object}', pkey);
+        return msg;
+    };
+
+    that.on_success = function(facet, data, text_status, xhr) {
 
         IPA.notify_success(data.result.summary);
         that.facet.refresh();
+        that.facet.set_selected_link(null);
+    };
+
+    that.on_error = function(facet, xhr, text_status, error_thrown) {
     };
 
     return that;
@@ -688,7 +756,8 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
                     target: node_map[target_cn],
                     left: true,
                     right: true,
-                    suffix: suffix
+                    suffix: suffix,
+                    segment: segment
                 };
                 if (direction === 'left') {
                     link.right = false;
@@ -752,6 +821,15 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
     },
 
     _bind_graph_events: function(graph) {
+
+        var self = this;
+        function forward(event) {
+            on(graph, event, function(data) {
+                self.emit(event, data);
+            });
+        }
+
+        forward('link-selected');
     },
 
     render: function() {
@@ -845,6 +923,7 @@ topology.register = function() {
 
     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);
     fa.register({
-- 
2.4.3

From c37fe49d46f7854f442a60541de5290c42e7c9c6 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 6 Nov 2015 18:06:48 +0100
Subject: [PATCH] webui: add segments on topology graph page

https://fedorahosted.org/freeipa/ticket/4286
---
 install/ui/src/freeipa/facet.js    |   8 +-
 install/ui/src/freeipa/topology.js | 147 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 151 insertions(+), 4 deletions(-)

diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 9c3c6f2bd82e2d23cd98220e2c63d6430c36300f..3743794e73a196459375aaa8bbc373ea7cb269b3 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -3004,8 +3004,14 @@ exp.state_evaluator = IPA.state_evaluator = function(spec) {
      */
     that.init = function(facet) {
 
-        if (that.event_name && facet[that.event_name]) {
+        if (!that.event_name) return;
+
+        if (facet[that.event_name] && facet[that.event_name].attach) {
+            // facets based on facet.facet
             facet[that.event_name].attach(that.on_event);
+        } else if (facet.emit) {
+            // facets based on facet/Facet
+            on(facet, that.event_name, that.on_event);
         }
     };
 
diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
index 9151416a55a36f0e1acdf854ce115ea0db0cffa3..0d7cae208d619e888d296838b19a8f3b4efe9b41 100644
--- a/install/ui/src/freeipa/topology.js
+++ b/install/ui/src/freeipa/topology.js
@@ -27,13 +27,14 @@ define([
         './facets/HeaderMixin',
         './facets/Facet',
         './topology_graph',
+        './navigation',
         // plain imports
         './search',
         './entity'],
             function(lang, declare, Evented, Stateful, Deferred, on, all, when,
                 builder, IPA, $, menu, metadata_provider, phases, reg, rpc,
                 text, mod_details, mod_facet, mod_field, ActionMixin,
-                HeaderMixin, Facet, topology_graph) {
+                HeaderMixin, Facet, topology_graph, navigation) {
 /**
  * Topology module
  * @class
@@ -344,6 +345,35 @@ topology.domainlevel_set_action = function(spec) {
     return that;
 };
 
+/**
+ * Sets 'managed-topology' state if topology is managed
+ * @class
+ * @extends facet.state_evaluator
+ */
+topology.managed_topology_evaluator = function(spec) {
+
+    spec = spec || {};
+
+    spec.event = spec.event || 'show';
+
+    var that = IPA.state_evaluator(spec);
+    that.name = spec.name || 'state_evaluator';
+
+    that.on_event = function() {
+
+        var old_state = that.state;
+        that.state = [];
+
+        if (IPA.domain_level >= topology.required_domain_level) {
+            that.state.push('managed-topology');
+        }
+
+        that.notify_on_change(old_state);
+    };
+
+    return that;
+};
+
 
 topology.topology_graph_facet_spec = {
     name: 'topology-graph',
@@ -352,12 +382,17 @@ topology.topology_graph_facet_spec = {
     tab_label: 'Topology Graph',
     facet_groups: [topology.search_facet_group],
     facet_group: 'search',
-    actions: ['refresh'],
+    actions: ['refresh', 'segment_add'],
     control_buttons: [
         {
             name: 'refresh',
             label: '@i18n:buttons.refresh',
             icon: 'fa-refresh'
+        },
+        {
+            name: 'segment_add',
+            label: '@i18n:buttons.add',
+            icon: 'fa-plus'
         }
     ],
     widgets: [
@@ -371,7 +406,12 @@ topology.topology_graph_facet_spec = {
             $type: 'topology-graph',
             name: 'topology-graph'
         }
-    ]
+    ],
+    state: {
+        evaluators: [
+            topology.managed_topology_evaluator
+        ]
+    }
 };
 
 /**
@@ -396,6 +436,106 @@ topology.TopologyGraphFacet = declare([Facet, ActionMixin, HeaderMixin], {
     }
 });
 
+/**
+ * Shows topology segment adder dialog with suffix select
+ *
+ * @class topology.add_segment_action
+ * @extends IPA.action
+ */
+topology.add_segment_action = function(spec) {
+
+    spec = spec || {};
+    spec.name = spec.name || 'segment_add';
+    spec.method = spec.method || 'add';
+    spec.enable_cond = spec.enable_cond || ['managed-topology'];
+
+    var that = IPA.action(spec);
+
+    that.execute_action = function(facet, on_success, on_error) {
+
+        that.facet = facet;
+
+        var entity = reg.entity.get('topologysegment');
+        var title = text.get('@i18n:dialogs.add_title');
+        var label = entity.metadata.label_singular;
+        title = title.replace('${entity}', label);
+
+        var dialog = IPA.entity_adder_dialog({
+            entity: 'topologysegment',
+            title: title,
+            fields: [
+                {
+                    name: 'cn',
+                    required: false
+                },
+                {
+                    $type: 'entity_select',
+                    name: 'suffix',
+                    label: '@mo:topologysuffix.label_singular',
+                    other_entity: 'topologysuffix',
+                    other_field: 'cn',
+                    z_index: 3,
+                    required: true
+                },
+                {
+                    $type: 'entity_select',
+                    name: 'iparepltoposegmentleftnode',
+                    other_entity: 'server',
+                    other_field: 'cn',
+                    z_index: 2
+                },
+                {
+                    $type: 'entity_select',
+                    name: 'iparepltoposegmentrightnode',
+                    other_entity: 'server',
+                    other_field: 'cn',
+                    z_index: 1
+                }
+            ]
+        });
+        dialog.added.attach(that.on_success);
+
+        dialog.show_edit_page = function(entity, result) {
+            var suffix = this.fields.get_field('suffix').save()[0];
+            var cn = result.cn[0];
+            navigation.show_entity(entity.name, 'default', [suffix, cn]);
+        };
+
+        dialog.create_add_command = function(record) {
+
+            var args = [this.fields.get_field('suffix').save()[0]];
+            var cn = this.fields.get_field('cn').save()[0];
+            if (cn) args.push(cn);
+
+            var options = {
+                'iparepltoposegmentleftnode':
+                    this.fields.get_field('iparepltoposegmentleftnode').save()[0],
+                'iparepltoposegmentrightnode':
+                    this.fields.get_field('iparepltoposegmentrightnode').save()[0]
+            };
+
+            var command = rpc.command({
+                entity: this.entity.name,
+                method: this.method,
+                retry: this.retry,
+                args: args,
+                options: options
+            });
+
+            return command;
+        };
+
+        dialog.open();
+    };
+
+    that.on_success = function(data) {
+
+        IPA.notify_success(data.result.summary);
+        that.facet.refresh();
+    };
+
+    return that;
+};
 
 /**
  * Graph widget encapsulates and supply data to graph component
@@ -704,6 +844,7 @@ topology.register = function() {
     e.register({type: 'domainlevel', spec: topology.domainlevel_spec});
 
     a.register('domainlevel_set', topology.domainlevel_set_action);
+    a.register('segment_add', topology.add_segment_action);
 
     w.register('topology-graph', topology.TopologyGraphWidget);
     fa.register({
-- 
2.4.3

-- 
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