From b4aa222e426c2b3f294432be64d95750dd86bc03 Mon Sep 17 00:00:00 2001 From: Petr Vobornik 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 Reviewed-By: Martin Babinsky --- install/ui/src/freeipa/dialog.js | 6 ++--- install/ui/src/freeipa/topology.js | 36 +++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js index f8f1bba78..c732a7278 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 47f72abf0..6654a310a 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'); }, + _update_view: function() { + + var view; + + if (IPA.domain_level < topology.required_domain_level) { + if (!this.disabled_view_el) { + view = this._render_disabled_view(); + } else { + view = this.disabled_view_el; + } + } else { + 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 = $('
', { 'class': this.css_class }); - if (IPA.domain_level < topology.required_domain_level) { - this._render_disabled_view().appendTo(this.el); - } else { - this._render_topology_view().appendTo(this.el); - } + this._update_view(); if (this.container_node) { this.el.appendTo(this.container_node); }