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 <mbabinsk@redhat.com>
This commit is contained in:
Petr Vobornik 2015-11-24 17:27:37 +01:00
parent 768d1965aa
commit b4aa222e42
2 changed files with 33 additions and 9 deletions

View File

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

View File

@ -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 = $('<div/>', { '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);
}