summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/ui/src/freeipa/topology.js180
1 files changed, 107 insertions, 73 deletions
diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js
index 4cd25ea30..dc214227f 100644
--- a/install/ui/src/freeipa/topology.js
+++ b/install/ui/src/freeipa/topology.js
@@ -805,6 +805,12 @@ topology.TopologyGraphFacet = declare([Facet, ActionMixin, HeaderMixin], {
this.set_selected_link(data.link);
}.bind(this));
+ on(graph, 'add-agreement', function(link) {
+ var dialog = topology.create_add_dialog();
+ dialog.open();
+ dialog.prefill_dialog(link);
+ });
+
on(this, 'hide', function () {
$(window).off('resize', null, listener);
});
@@ -839,102 +845,129 @@ topology.TopologyGraphFacet = declare([Facet, ActionMixin, HeaderMixin], {
}
});
+
/**
- * Shows topology segment adder dialog with suffix select
+ * Creates segment adder dialog according to spec.
*
- * @class topology.add_segment_action
- * @extends IPA.action
+ * @param spec {Object}
*/
-topology.add_segment_action = function(spec) {
+topology.create_add_dialog = 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);
+ spec.entity = spec.entity || 'topologysegment';
- that.execute_action = function(facet, on_success, on_error) {
+ var entity = reg.entity.get('topologysegment');
+ var title = text.get('@i18n:dialogs.add_title');
+ var label = entity.metadata.label_singular;
+ spec.title = title.replace('${entity}', label);
- 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);
+ spec.fields = spec.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
+ }
+ ];
- 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]);
- };
+ var that = IPA.entity_adder_dialog(spec);
- dialog.create_add_command = function(record) {
+ that.init = function() {
+ that.added.attach(that.on_success);
+ };
- var args = [this.fields.get_field('suffix').save()[0]];
- var cn = this.fields.get_field('cn').save()[0];
- if (cn) args.push(cn);
+ that.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]);
+ };
- var options = {
- 'iparepltoposegmentleftnode':
- this.fields.get_field('iparepltoposegmentleftnode').save()[0],
- 'iparepltoposegmentrightnode':
- this.fields.get_field('iparepltoposegmentrightnode').save()[0]
- };
+ that.create_add_command = function(record) {
- var command = rpc.command({
- entity: this.entity.name,
- method: this.method,
- retry: this.retry,
- args: args,
- options: options
- });
+ var args = [this.fields.get_field('suffix').save()[0]];
+ var cn = this.fields.get_field('cn').save()[0];
+ if (cn) args.push(cn);
- return command;
+ var options = {
+ 'iparepltoposegmentleftnode':
+ this.fields.get_field('iparepltoposegmentleftnode').save()[0],
+ 'iparepltoposegmentrightnode':
+ this.fields.get_field('iparepltoposegmentrightnode').save()[0]
};
- dialog.open();
+ var command = rpc.command({
+ entity: this.entity.name,
+ method: this.method,
+ retry: this.retry,
+ args: args,
+ options: options
+ });
+
+ return command;
};
+
that.on_success = function(data) {
that.facet.refresh();
};
+ that.prefill_dialog = function(link) {
+ that.get_field('iparepltoposegmentleftnode').set_value([link.source.id]);
+ that.get_field('iparepltoposegmentrightnode').set_value([link.target.id]);
+ that.get_field('suffix').set_value([link.suffix]);
+ };
+
+ that.init();
+
+ return that;
+};
+
+/**
+ * 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) {
+
+ var dialog = topology.create_add_dialog();
+
+ dialog.open();
+ };
+
+
return that;
};
@@ -1230,6 +1263,7 @@ topology.TopologyGraphWidget = declare([Stateful, Evented], {
}
forward('link-selected');
+ forward('add-agreement');
},
_update_view: function() {