From 379a9cc41f04d36538aee11839c1222d408b4f99 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata"
Date: Thu, 18 Nov 2010 20:17:14 -0600
Subject: SUDO Rule Search and Details Pages
The search and details pages for SUDO Rule have been added. Codes
that are shared with HBAC have been moved to rule.js.
The following methods were renamed for consistency:
- ipa_details_load() -> ipa_details_refresh()
- ipa_details_display() -> ipa_details_load()
The ipa_details_cache has been removed because the cache is now
stored in each widget.
The index.xhtml has been removed. All references to it has been
changed to index.html.
The Unselect All checkbox has been fixed. Unnecessary parameter
'container' has been removed.
The unit test has been updated and new test data has been added.
---
install/static/hbac.js | 390 ++++++++++---------------------------------------
1 file changed, 79 insertions(+), 311 deletions(-)
(limited to 'install/static/hbac.js')
diff --git a/install/static/hbac.js b/install/static/hbac.js
index 6b209dd7..f63a489e 100755
--- a/install/static/hbac.js
+++ b/install/static/hbac.js
@@ -26,8 +26,6 @@ function ipa_hbac() {
'name': 'hbac'
});
- that.superior_init = that.superior('init');
-
that.init = function() {
var dialog = ipa_hbac_add_dialog({
@@ -49,7 +47,7 @@ function ipa_hbac() {
});
that.add_facet(facet);
- that.superior_init();
+ that.entity_init();
};
return that;
@@ -63,11 +61,9 @@ function ipa_hbac_add_dialog(spec) {
var that = ipa_add_dialog(spec);
- that.superior_init = that.superior('init');
-
that.init = function() {
- that.superior_init();
+ that.add_dialog_init();
that.add_field(ipa_text_widget({
'name': 'cn',
@@ -91,10 +87,6 @@ function ipa_hbac_search_facet(spec) {
var that = ipa_search_facet(spec);
- that.superior_init = that.superior('init');
- that.superior_create = that.superior('create');
- that.superior_setup = that.superior('setup');
-
that.init = function() {
that.create_column({name:'cn', label:'Rule Name'});
@@ -104,16 +96,12 @@ function ipa_hbac_search_facet(spec) {
that.create_column({name:'servicecategory', label:'Via Service'});
that.create_column({name:'sourcehostcategory', label:'From'});
- that.superior_init();
+ that.search_facet_init();
};
that.create = function(container) {
- var that = this;
-
-
/*
-
// Not yet implemented
var left_buttons = $('', {
@@ -127,9 +115,11 @@ function ipa_hbac_search_facet(spec) {
left_buttons.append(ipa_button({
'label': 'Cull Disabled Rules'
}));
-
*/
- var ul = $('.action-panel ul');
+ var entity_container = $('#' + that.entity_name);
+ var action_panel = $('.action-panel', entity_container);
+
+ var ul = $('ul', action_panel);
$('', {
title: 'hbacsvc',
@@ -153,7 +143,7 @@ function ipa_hbac_search_facet(spec) {
}
}).appendTo(ul);
- that.superior_create(container);
+ that.search_facet_create(container);
// TODO: replace with IPA.metadata[that.entity_name].label
container.children().last().prepend(
@@ -171,10 +161,6 @@ function ipa_hbac_details_facet(spec) {
var that = ipa_details_facet(spec);
- that.superior_init = that.superior('init');
- that.superior_create = that.superior('create');
- that.superior_setup = that.superior('setup');
-
that.init = function() {
var section;
@@ -207,7 +193,7 @@ function ipa_hbac_details_facet(spec) {
});
} else {
- section = ipa_hbac_details_tables_section({
+ section = ipa_rule_details_section({
'name': 'user',
'label': 'Who',
'text': 'Rule applies when access is requested by:',
@@ -228,12 +214,12 @@ function ipa_hbac_details_facet(spec) {
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberuser_user',
'name': 'memberuser_user', 'label': 'Users', 'category': category,
- 'other_entity': 'user', 'add_method': 'add_user', 'delete_method': 'remove_user'
+ 'other_entity': 'user', 'add_method': 'add_user', 'remove_method': 'remove_user'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberuser_group',
'name': 'memberuser_group', 'label': 'Groups', 'category': category,
- 'other_entity': 'group', 'add_method': 'add_user', 'delete_method': 'remove_user'
+ 'other_entity': 'group', 'add_method': 'add_user', 'remove_method': 'remove_user'
}));
if (IPA.layout) {
@@ -244,7 +230,7 @@ function ipa_hbac_details_facet(spec) {
});
} else {
- section = ipa_hbac_details_tables_section({
+ section = ipa_rule_details_section({
'name': 'host',
'label': 'Accessing',
'text': 'Rule applies when access is requested to:',
@@ -265,12 +251,12 @@ function ipa_hbac_details_facet(spec) {
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberhost_host',
'name': 'memberhost_host', 'label': 'Hosts', 'category': category,
- 'other_entity': 'host', 'add_method': 'add_host', 'delete_method': 'remove_host'
+ 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberhost_hostgroup',
'name': 'memberhost_hostgroup', 'label': 'Host Groups', 'category': category,
- 'other_entity': 'hostgroup', 'add_method': 'add_host', 'delete_method': 'remove_host'
+ 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host'
}));
if (IPA.layout) {
@@ -281,7 +267,7 @@ function ipa_hbac_details_facet(spec) {
});
} else {
- section = ipa_hbac_details_tables_section({
+ section = ipa_rule_details_section({
'name': 'service',
'label': 'Via Service',
'text': 'Rule applies when access is requested via:',
@@ -302,12 +288,12 @@ function ipa_hbac_details_facet(spec) {
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberservice_hbacsvc',
'name': 'memberservice_hbacsvc', 'label': 'Services', 'category': category,
- 'other_entity': 'hbacsvc', 'add_method': 'add_service', 'delete_method': 'remove_service'
+ 'other_entity': 'hbacsvc', 'add_method': 'add_service', 'remove_method': 'remove_service'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberservice_hbacsvcgroup',
'name': 'memberservice_hbacsvcgroup', 'label': 'Service Groups', 'category': category,
- 'other_entity': 'hbacsvcgroup', 'add_method': 'add_service', 'delete_method': 'remove_service'
+ 'other_entity': 'hbacsvcgroup', 'add_method': 'add_service', 'remove_method': 'remove_service'
}));
if (IPA.layout) {
@@ -318,7 +304,7 @@ function ipa_hbac_details_facet(spec) {
});
} else {
- section = ipa_hbac_details_tables_section({
+ section = ipa_rule_details_section({
'name': 'sourcehost',
'label': 'From',
'text': 'Rule applies when access is being initiated from:',
@@ -339,12 +325,12 @@ function ipa_hbac_details_facet(spec) {
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-sourcehost_host',
'name': 'sourcehost_host', 'label': 'Host', 'category': category,
- 'other_entity': 'host', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
+ 'other_entity': 'host', 'add_method': 'add_sourcehost', 'remove_method': 'remove_sourcehost'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-sourcehost_hostgroup',
'name': 'sourcehost_hostgroup', 'label': 'Host Groups', 'category': category,
- 'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
+ 'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'remove_method': 'remove_sourcehost'
}));
if (IPA.layout) {
@@ -360,7 +346,7 @@ function ipa_hbac_details_facet(spec) {
'label': 'When'
});
/*
- section = ipa_hbac_details_tables_section({
+ section = ipa_rule_details_section({
'name': 'accesstime',
'label': 'When',
'text': 'Rule applies when access is being requested at:',
@@ -383,10 +369,10 @@ function ipa_hbac_details_facet(spec) {
]
}));
- that.superior_init();
+ that.details_facet_init();
};
- that.update = function(container) {
+ that.update = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
@@ -466,13 +452,13 @@ function ipa_hbac_details_facet(spec) {
for (var i=0; i', { 'name': that.field_name }).appendTo(container);
-
- for (var i=0; i', {
- 'type': 'radio',
- 'name': that.field_name,
- 'value': option.value
- }).appendTo(span);
-
- span.append(option.label);
- }
-
- span.append(' ');
-
- $('', {
- 'name': 'undo',
- 'class': 'ui-state-highlight ui-corner-all',
- 'style': 'display: none;',
- 'html': 'undo'
- }).appendTo(span);
-
- span.append('
');
-
- for (var i=0; i', { 'name': table.field_name }).appendTo(span);
-
- var field = that.get_field(table.field_name);
- field.create(table_span);
- }
- };
-
- return that;
-}
-
function ipa_hbac_association_widget(spec) {
spec = spec || {};
- var that = ipa_table_widget(spec);
+ var that = ipa_rule_association_widget(spec);
- that.other_entity = spec.other_entity;
that.category = spec.category;
- that.add_method = spec.add_method;
- that.delete_method = spec.delete_method;
-
- that.superior_init = that.superior('init');
- that.superior_create = that.superior('create');
-
- 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.superior_init();
- };
-
- that.create = function(container) {
-
- that.superior_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.remove(that.container); }
- }));
-
- button = $('input[name=add]', that.table);
- button.replaceWith(ipa_button({
- 'label': button.val(),
- 'icon': 'ui-icon-plus',
- 'click': function() { that.add(that.container) }
- }));
-
- 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(container, result) {
-
- that.values = result[that.name] || [];
- that.hide_undo(that.container);
- that.set_values(that.container, that.values);
- };
-
- that.set_values = function(container, values) {
-
- that.tbody.empty();
- for (var i=0; values && iError: '+error_thrown.name+'
');
- summary.append(''+error_thrown.title+'
');
- summary.append(''+error_thrown.message+'
');
- }
-
- var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
- ipa_cmd('show', [pkey], {'rights': true}, on_success, on_error, that.entity_name);
+ command.execute();
};
return that;
@@ -1008,10 +781,6 @@ function ipa_hbac_accesstime_widget(spec) {
that.text = spec.text;
that.options = spec.options || [];
- that.superior_init = that.superior('init');
- that.superior_create = that.superior('create');
- that.superior_setup = that.superior('setup');
-
that.init = function() {
that.table = ipa_table_widget({
@@ -1025,12 +794,12 @@ function ipa_hbac_accesstime_widget(spec) {
'primary_key': true
});
- that.superior_init();
+ that.widget_init();
};
that.create = function(container) {
- that.superior_create(container);
+ that.widget_create(container);
var span = $('', { 'name': 'text' }).appendTo(container);
@@ -1101,32 +870,31 @@ function ipa_hbac_accesstime_widget(spec) {
var input = $('input[name="'+that.name+'"]', that.container);
input.change(function() {
- that.show_undo(that.container);
+ that.show_undo();
});
- var undo = that.get_undo(that.container);
+ var undo = that.get_undo();
undo.click(function() {
- that.reset(that.container);
+ that.reset();
});
};
- that.save = function(container) {
+ that.save = function() {
var value = $('input[name="'+that.name+'"]:checked', that.container).val();
if (value == '') {
- return that.table.save(that.container);
+ return that.table.save();
} else {
return [];
}
};
- that.load = function(container, result) {
+ that.load = function(result) {
that.values = result[that.name] || [];
- that.set_values(that.container, that.values);
- that.hide_undo(that.container);
+ that.reset();
};
- that.set_values = function(container, values) {
+ that.set_values = function(values) {
that.set_radio_value(that.container, values && values.length ? '' : 'all');
@@ -1134,7 +902,7 @@ function ipa_hbac_accesstime_widget(spec) {
for (var i=0; values && i