From 7e02caeb6924d57b2ad3a786f46668c544b055b5 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata
Date: Thu, 2 Dec 2010 22:12:59 -0600
Subject: [PATCH] HBAC Service Groups adjustments
The association facet for HBAC Service Groups has been removed
and replaced with an association table in the details page.
The ipa_association_table_widget has been modified to support
multiple columns in the table itself and in the adder dialog.
The ipa_association_adder_dialog and ipa_association_facet have
been refactored.
The ipa_sudorule_association_widget and ipa_rule_association_widget
has been removed because their functionalities have been merged into
ipa_association_table_widget.
---
install/static/associate.js | 701 ++++++++++++++++++++++++++--------------
install/static/details.js | 1 +
install/static/entity.js | 2 +-
install/static/hbac.js | 11 +-
install/static/hbacsvcgroup.js | 30 +-
install/static/host.js | 2 +-
install/static/ipa.js | 4 +-
install/static/rule.js | 167 ----------
install/static/service.js | 2 +-
install/static/sudocmdgroup.js | 2 +-
install/static/sudorule.js | 60 +---
install/static/widget.js | 8 +-
12 files changed, 508 insertions(+), 482 deletions(-)
diff --git a/install/static/associate.js b/install/static/associate.js
index 04fc3759870fa3f1161255d09884664d4cfe7f7f..1a96362f5955ba217a921d43c3711e3266e9bd52 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -141,12 +141,6 @@ function ipa_association_adder_dialog(spec) {
that.pkey = spec.pkey;
that.other_entity = spec.other_entity;
- that.associator = spec.associator;
- that.method = spec.method || 'add_member';
-
- that.on_success = spec.on_success;
- that.on_error = spec.on_error;
-
that.init = function() {
if (!that.columns.length) {
var pkey_name = IPA.metadata[that.other_entity].primary_key;
@@ -165,7 +159,7 @@ function ipa_association_adder_dialog(spec) {
that.search = function() {
execute_search(that.get_filter());
- }
+ };
function execute_search(filter){
function on_success(data, text_status, xhr) {
@@ -179,22 +173,7 @@ function ipa_association_adder_dialog(spec) {
}
ipa_cmd('find', [filter], {'all': true}, on_success, null, that.other_entity);
- };
-
- that.add = function() {
-
- var associator = that.associator({
- 'entity_name': that.entity_name,
- 'pkey': that.pkey,
- 'other_entity': that.other_entity,
- 'values': that.get_selected_values(),
- 'method': that.method,
- 'on_success': that.on_success,
- 'on_error': that.on_error
- });
-
- associator.execute();
- };
+ }
return that;
}
@@ -246,7 +225,7 @@ function ipa_association_config(spec) {
that.name = spec.name;
that.associator = spec.associator;
that.add_method = spec.add_method;
- that.delete_method = spec.delete_method;
+ that.remove_method = spec.remove_method;
return that;
}
@@ -257,19 +236,352 @@ function ipa_association_table_widget(spec) {
var that = ipa_table_widget(spec);
- that.facet = spec.facet;
that.other_entity = spec.other_entity;
- that.add = spec.add;
- that.remove = spec.remove;
+ that.associator = spec.associator || bulk_associator;
+ that.add_method = spec.add_method || 'add_member';
+ that.remove_method = spec.remove_method || 'remove_member';
- that.create = function(container) {
+ that.adder_columns = [];
+ that.adder_columns_by_name = {};
+ that.get_adder_column = function(name) {
+ return that.adder_columns_by_name[name];
+ };
+
+ that.add_adder_column = function(column) {
+ column.entity_name = that.entity_name;
+ that.adder_columns.push(column);
+ that.adder_columns_by_name[column.name] = column;
+ };
+
+ that.create_adder_column = function(spec) {
+ var column = ipa_column(spec);
+ that.add_adder_column(column);
+ return column;
+ };
+
+ that.init = function() {
+
+ var entity = IPA.get_entity(that.entity_name);
+ var association = entity.get_association(that.other_entity);
+
+ if (association) {
+ if (association.associator) {
+ that.associator = association.associator == 'serial' ? serial_associator : bulk_associator;
+ }
+
+ if (association.add_method) that.add_method = association.add_method;
+ if (association.remove_method) that.remove_method = association.remove_method;
+ }
+
+ // create a column if none defined
if (!that.columns.length) {
- var pkey_name = IPA.metadata[that.other_entity].primary_key;
+ that.create_column({
+ 'name': that.name,
+ 'label': IPA.metadata[that.other_entity].label,
+ 'primary_key': true
+ });
+ }
- var column = that.create_column({
- name: pkey_name,
+ that.table_init();
+ };
+
+ that.create = function(container) {
+
+ that.table_create(container);
+
+ var buttons = $('span[name=buttons]', container);
+
+ $('', {
+ 'type': 'button',
+ 'name': 'remove',
+ 'value': 'Remove '+that.label
+ }).appendTo(buttons);
+
+ $('', {
+ 'type': 'button',
+ 'name': 'add',
+ 'value': 'Add '+that.label
+ }).appendTo(buttons);
+ };
+
+ that.setup = function(container) {
+
+ that.table_setup(container);
+
+ var button = $('input[name=remove]', container);
+ button.replaceWith(ipa_button({
+ 'label': button.val(),
+ 'icon': 'ui-icon-trash',
+ 'click': function() { that.show_remove_dialog(); }
+ }));
+
+ button = $('input[name=add]', container);
+ button.replaceWith(ipa_button({
+ 'label': button.val(),
+ 'icon': 'ui-icon-plus',
+ 'click': function() { that.show_add_dialog() }
+ }));
+ };
+
+ that.get_records = function(on_success, on_error) {
+
+ if (!that.values.length) return;
+
+ var batch = ipa_batch_command({
+ 'name': that.entity_name+'_'+that.name,
+ 'on_success': on_success,
+ 'on_error': on_error
+ });
+
+ for (var i=0; i', {
+ 'id': that.entity_name+'-'+that.other_entity,
+ html: $('',{ html: header_message })
+ }).appendTo(container);
+
+ var span = $('', { 'name': 'association' }).appendTo(container);
+
+ that.table.create(span);
+
+ var action_panel = that.get_action_panel();
var li = $('.action-controls', action_panel);
// creating generic buttons for layout
@@ -313,32 +648,120 @@ function ipa_association_table_widget(spec) {
'name': 'add',
'value': IPA.messages.button.enroll
}).appendTo(li);
+
};
that.setup = function(container) {
- that.table_setup(container);
+ that.facet_setup(container);
+
+ var span = $('span[name=association]', that.container);
+
+ that.table.setup(span);
// replacing generic buttons with ipa_button and setting click handler
- var action_panel = that.facet.get_action_panel();
+ var action_panel = that.get_action_panel();
var button = $('input[name=remove]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-trash',
- 'click': function() { that.remove(); }
+ 'click': function() { that.show_remove_dialog(); }
}));
button = $('input[name=add]', action_panel);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-plus',
- 'click': function() { that.add() }
+ 'click': function() { that.show_add_dialog() }
}));
};
+ that.show_add_dialog = function() {
+
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
+ var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
+
+ var dialog = ipa_association_adder_dialog({
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity
+ });
+
+ if (that.adder_columns.length) {
+ dialog.set_columns(that.adder_columns);
+ }
+
+ dialog.add = function() {
+
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+
+ var associator = that.associator({
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'values': dialog.get_selected_values(),
+ 'method': that.add_method,
+ 'on_success': function() {
+ that.refresh();
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh();
+ dialog.close();
+ }
+ });
+
+ associator.execute();
+ };
+
+ dialog.init();
+
+ dialog.open(that.container);
+ };
+
+ that.show_remove_dialog = function() {
+
+ var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
+ var values = that.table.get_selected_values();
+
+ if (!values.length) {
+ alert('Select '+label+' to be removed.');
+ return;
+ }
+
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
+
+ var dialog = ipa_association_deleter_dialog({
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'values': values,
+ 'associator': that.associator,
+ 'method': that.remove_method,
+ 'on_success': function() {
+ that.refresh();
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh();
+ dialog.close();
+ }
+ });
+
+ dialog.init();
+
+ dialog.open(that.container);
+ };
+
that.get_records = function(pkeys, on_success, on_error) {
+ if (!pkeys.length) return;
+
var batch = ipa_batch_command({
'name': that.entity_name+'_'+that.name,
'on_success': on_success,
@@ -367,17 +790,17 @@ function ipa_association_table_widget(spec) {
function on_success(data, text_status, xhr) {
- that.tbody.empty();
+ that.table.empty();
var pkeys = data.result.result[that.name];
if (!pkeys) return;
- if (that.columns.length == 1) { // show pkey only
- var name = that.columns[0].name;
+ if (that.table.columns.length == 1) { // show pkey only
+ var name = that.table.columns[0].name;
for (var i=0; iError: '+error_thrown.name+'
');
summary.append(''+error_thrown.title+'
');
summary.append(''+error_thrown.message+'
');
@@ -405,198 +828,6 @@ function ipa_association_table_widget(spec) {
ipa_cmd('show', [pkey], {'rights': true}, on_success, on_error, that.entity_name);
};
- return that;
-}
-
-function ipa_association_facet(spec) {
-
- spec = spec || {};
-
- var that = ipa_facet(spec);
-
- that.other_entity = spec.other_entity;
-
- that.associator = spec.associator || bulk_associator;
- that.add_method = spec.add_method || 'add_member';
- that.delete_method = spec.delete_method || 'remove_member';
-
- that.columns = [];
- that.columns_by_name = {};
-
- that.adder_columns = [];
- that.adder_columns_by_name = {};
-
- that.get_column = function(name) {
- return that.columns_by_name[name];
- };
-
- that.add_column = function(column) {
- column.entity_name = that.entity_name;
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
- };
-
- that.create_column = function(spec) {
- var column = ipa_column(spec);
- that.add_column(column);
- return column;
- };
-
- that.get_adder_column = function(name) {
- return that.adder_columns_by_name[name];
- };
-
- that.add_adder_column = function(column) {
- column.entity_name = that.entity_name;
- that.adder_columns.push(column);
- that.adder_columns_by_name[column.name] = column;
- };
-
- that.create_adder_column = function(spec) {
- var column = ipa_column(spec);
- that.add_adder_column(column);
- return column;
- };
-
- that.is_dirty = function() {
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- return pkey != that.pkey || other_entity != that.other_entity;
- };
-
- that.init = function() {
-
- var entity = IPA.get_entity(that.entity_name);
- var association = entity.get_association(that.other_entity);
-
- if (association) {
- if (association.associator) {
- that.associator = association.associator == 'serial' ? serial_associator : bulk_associator;
- }
-
- if (association.add_method) that.add_method = association.add_method;
- if (association.delete_method) that.delete_method = association.delete_method;
- }
-
- var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
-
- that.table = ipa_association_table_widget({
- 'id': that.entity_name+'-'+that.other_entity,
- 'name': that.name,
- 'label': label,
- 'entity_name': that.entity_name,
- 'other_entity': that.other_entity,
- 'facet': that
- });
-
- if (that.columns.length) {
- that.table.set_columns(that.columns);
- }
-
- that.table.add = function() { that.add(); };
- that.table.remove = function() { that.remove() };
-
- that.facet_init();
- };
-
- that.create = function(container) {
-
- that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
-
- //TODO I18N
- var header_message = that.other_entity + '(s) enrolled in ' +
- that.entity_name + ' ' + that.pkey;
-
- $('', {
- 'id': that.entity_name+'-'+that.other_entity,
- html: $('',{ html: header_message })
- }).appendTo(container);
-
- var span = $('', { 'name': 'association' }).appendTo(container);
-
- that.table.create(span);
- };
-
- that.setup = function(container) {
-
- that.facet_setup(container);
-
- var span = $('span[name=association]', that.container);
-
- that.table.setup(span);
- };
-
- that.add = function() {
-
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
- var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
-
- var dialog = ipa_association_adder_dialog({
- 'title': title,
- 'entity_name': that.entity_name,
- 'pkey': pkey,
- 'other_entity': that.other_entity,
- 'associator': that.associator,
- 'method': that.add_method,
- 'on_success': function() {
- that.refresh();
- dialog.close();
- },
- 'on_error': function() {
- that.refresh();
- dialog.close();
- }
- });
-
- if (that.adder_columns.length) {
- dialog.set_columns(that.adder_columns);
- }
-
- dialog.init();
-
- dialog.open(that.container);
- };
-
- that.remove = function() {
-
- var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
- var values = that.table.get_selected_values();
-
- if (!values.length) {
- alert('Select '+label+' to be removed.');
- return;
- }
-
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
-
- var dialog = ipa_association_deleter_dialog({
- 'title': title,
- 'entity_name': that.entity_name,
- 'pkey': pkey,
- 'other_entity': that.other_entity,
- 'values': values,
- 'associator': that.associator,
- 'method': that.delete_method,
- 'on_success': function() {
- that.refresh();
- dialog.close();
- },
- 'on_error': function() {
- that.refresh();
- dialog.close();
- }
- });
-
- dialog.init();
-
- dialog.open(that.container);
- };
-
- that.refresh = function(){
- that.table.refresh();
- };
-
that.association_facet_init = that.init;
return that;
diff --git a/install/static/details.js b/install/static/details.js
index a3f1b2a5cc796c5c579c65e701bfb881673178ab..1d27ea8826ef5d7483322686d933709087ad86e3 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -272,6 +272,7 @@ function ipa_details_section(spec){
};
// methods that should be invoked by subclasses
+ that.section_init = that.init;
that.section_create = that.create;
that.section_setup = that.setup;
that.section_load = that.load;
diff --git a/install/static/entity.js b/install/static/entity.js
index 548623e2d838bfa931d50273fee16132d1cb0499..dcb7e6f8290fe99dededdeecbe6f2d97da5c284b 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -330,7 +330,7 @@ function ipa_entity_set_association_definition(entity_name, data) {
'name': other_entity,
'associator': config.associator,
'add_method': config.add_method,
- 'delete_method': config.delete_method
+ 'remove_method': config.remove_method
});
}
}
diff --git a/install/static/hbac.js b/install/static/hbac.js
index a85a89a51c507ca0ef108a398bc1cb61899d1919..f0f2f96d780e1ec4970fca8855d6678983a1f812 100755
--- a/install/static/hbac.js
+++ b/install/static/hbac.js
@@ -553,8 +553,7 @@ function ipa_hbac_details_general_section(spec){
'style': 'width: 100%;'
}).appendTo(container);
- var tr = $('
', {
- }).appendTo(table);
+ var tr = $('
').appendTo(table);
var td = $(' | ', {
'style': 'width: 100px; text-align: right;',
@@ -613,8 +612,7 @@ function ipa_hbac_details_general_section(spec){
'html': 'undo'
}).appendTo(span);
- tr = $('
', {
- }).appendTo(table);
+ tr = $('
').appendTo(table);
td = $(' | ', {
'style': 'text-align: right; vertical-align: top;',
@@ -642,8 +640,7 @@ function ipa_hbac_details_general_section(spec){
'html': 'undo'
}).appendTo(span);
- tr = $('
', {
- }).appendTo(table);
+ tr = $('
').appendTo(table);
td = $(' | ', {
'style': 'text-align: right; vertical-align: top;',
@@ -689,7 +686,7 @@ function ipa_hbac_association_widget(spec) {
spec = spec || {};
- var that = ipa_rule_association_widget(spec);
+ var that = ipa_association_table_widget(spec);
that.category = spec.category;
diff --git a/install/static/hbacsvcgroup.js b/install/static/hbacsvcgroup.js
index 94a79c026a5846632534508de427bc8e1474ab4b..1972e6c56b1a34e7ca4eeedb52fb34309af2bdb7 100755
--- a/install/static/hbacsvcgroup.js
+++ b/install/static/hbacsvcgroup.js
@@ -31,7 +31,7 @@ function ipa_hbacsvcgroup() {
that.create_association({
'name': 'hbacsvc',
'add_method': 'add_member',
- 'delete_method': 'remove_member'
+ 'remove_method': 'remove_member'
});
var dialog = ipa_hbacsvcgroup_add_dialog({
@@ -53,13 +53,6 @@ function ipa_hbacsvcgroup() {
});
that.add_facet(facet);
- facet = ipa_hbacsvcgroup_member_hbacsvc_facet({
- 'name': 'member_hbacsvc',
- 'label': IPA.metadata['hbacsvc'].label+' '+IPA.messages.association.members,
- 'other_entity': 'hbacsvc'
- });
- that.add_facet(facet);
-
that.entity_init();
};
@@ -152,17 +145,30 @@ function ipa_hbacsvcgroup_details_facet(spec) {
section.create_field({ 'name': 'cn', 'label': 'Name' });
section.create_field({ 'name': 'description', 'label': 'Description' });
+ section = ipa_details_section({
+ 'name': 'services',
+ 'label': 'Services'
+ });
+ that.add_section(section);
+
+ var field = ipa_hbacsvcgroup_member_hbacsvc_table_widget({
+ 'name': 'member_hbacsvc',
+ 'label': 'Services',
+ 'other_entity': 'hbacsvc'
+ });
+ section.add_field(field);
+
that.details_facet_init();
};
return that;
}
-function ipa_hbacsvcgroup_member_hbacsvc_facet(spec) {
+function ipa_hbacsvcgroup_member_hbacsvc_table_widget(spec) {
spec = spec || {};
- var that = ipa_association_facet(spec);
+ var that = ipa_association_table_widget(spec);
that.init = function() {
@@ -197,7 +203,7 @@ function ipa_hbacsvcgroup_member_hbacsvc_facet(spec) {
that.create_column({
name: 'description',
label: 'Description',
- width: '150px'
+ width: '350px'
});
that.create_adder_column({
@@ -213,7 +219,7 @@ function ipa_hbacsvcgroup_member_hbacsvc_facet(spec) {
width: '100px'
});
- that.association_facet_init();
+ that.association_table_widget_init();
};
return that;
diff --git a/install/static/host.js b/install/static/host.js
index 484b64771ecf6f1be948974f424606476375a276..90477165c56a2bb41c03493d71c2d697304d968d 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -427,7 +427,7 @@ function ipa_host_managedby_host_facet(spec) {
var that = ipa_association_facet(spec);
that.add_method = 'add_managedby';
- that.delete_method = 'remove_managedby';
+ that.remove_method = 'remove_managedby';
that.init = function() {
diff --git a/install/static/ipa.js b/install/static/ipa.js
index 6f44e358c6a1caef4262c6efab5fcedf8fa28183..10993af85271f6b9f5b0cc95660a8bfede459cfa 100644
--- a/install/static/ipa.js
+++ b/install/static/ipa.js
@@ -57,8 +57,8 @@ var IPA = ( function () {
that.layouts_dir = 'layouts';
that.get_template = function(path) {
- if (!that.layout) return path;
- return that.layouts_dir+'/'+that.layout+'/'+path;
+ var layout = that.layout || 'default';
+ return that.layouts_dir+'/'+layout+'/'+path;
};
/* initialize the IPA JSON-RPC helper
diff --git a/install/static/rule.js b/install/static/rule.js
index b73fb56a7f51ff33354e0ebf82bb4498a2ae6869..ec1eb72ce1e5f7898e233f8e05c3a43ec7aceff1 100755
--- a/install/static/rule.js
+++ b/install/static/rule.js
@@ -77,170 +77,3 @@ function ipa_rule_details_section(spec){
return that;
}
-
-function ipa_rule_association_widget(spec) {
-
- spec = spec || {};
-
- var that = ipa_table_widget(spec);
-
- that.other_entity = spec.other_entity;
-
- that.add_method = spec.add_method;
- that.remove_method = spec.remove_method;
-
- that.init = function() {
- // create a column if none defined
- if (!that.columns.length) {
- that.create_column({
- 'name': that.name,
- 'label': IPA.metadata[that.other_entity].label,
- 'primary_key': true
- });
- }
-
- that.table_init();
- };
-
- that.create = function(container) {
-
- that.table_create(container);
-
- var buttons = $('span[name=buttons]', container);
-
- $('', {
- 'type': 'button',
- 'name': 'remove',
- 'value': 'Remove '+that.label
- }).appendTo(buttons);
-
- $('', {
- 'type': 'button',
- 'name': 'add',
- 'value': 'Add '+that.label
- }).appendTo(buttons);
- };
-
- that.setup = function(container) {
-
- that.table_setup(container);
-
- var button = $('input[name=remove]', that.table);
- button.replaceWith(ipa_button({
- 'label': button.val(),
- 'icon': 'ui-icon-trash',
- 'click': function() { that.show_remove_dialog(); }
- }));
-
- button = $('input[name=add]', that.table);
- button.replaceWith(ipa_button({
- 'label': button.val(),
- 'icon': 'ui-icon-plus',
- 'click': function() { that.show_add_dialog() }
- }));
-
- var entity = IPA.get_entity(that.entity_name);
- var association = entity.get_association(that.other_entity);
-
- if (association && association.associator == 'serial') {
- that.associator = serial_associator;
- } else {
- that.associator = bulk_associator;
- }
- };
-
- that.load = function(result) {
- that.values = result[that.name] || [];
- that.reset();
- };
-
- that.set_values = function(values) {
-
- that.tbody.empty();
- for (var i=0; values && i