/* Authors:
* Endi Sukma Dewata
');
that.super_create(container);
};
return that;
}
function ipa_hbac_quick_links(container, name, value, record) {
var column = this;
var facet = column.facet;
var pkey = IPA.metadata[column.entity_name].primary_key;
var pkey_value = record[pkey];
var span = $('span[name='+name+']', container);
$('', {
'href': '#details',
'title': 'Details',
'text': 'Details',
'click': function() {
var state = {};
state[column.entity_name+'-facet'] = 'details';
state[column.entity_name+'-pkey'] = pkey_value;
nav_push_state(state);
return false;
}
}).appendTo(span);
span.append(' | ');
$('', {
'href': '#test-rule',
'title': 'Test Rule',
'text': 'Test Rule',
'click': function() {
var state = {};
state[column.entity_name+'-facet'] = 'test-rule';
state[column.entity_name+'-pkey'] = pkey_value;
nav_push_state(state);
return false;
}
}).appendTo(span);
}
function ipa_hbac_details_facet(spec) {
spec = spec || {};
var that = ipa_details_facet(spec);
that.super_init = that.super('init');
that.super_create = that.super('create');
that.super_setup = that.super('setup');
that.init = function() {
var section;
if (IPA.layout) {
section = that.create_section({
'name': 'general',
'label': 'General',
'template': 'hbac-details-general.html #contents'
});
} else {
section = ipa_hbac_details_general_section({
'name': 'general',
'label': 'General'
});
that.add_section(section);
}
section.create_text({ 'name': 'cn', 'label': 'Name' });
section.create_radio({ 'name': 'accessruletype', 'label': 'Rule Type' });
section.create_textarea({ 'name': 'description', 'label': 'Description' });
section.create_radio({ 'name': 'ipaenabledflag', 'label': 'Enabled' });
if (IPA.layout) {
section = that.create_section({
'name': 'user',
'label': 'Who',
'template': 'hbac-details-user.html #contents'
});
} else {
section = ipa_hbac_details_tables_section({
'name': 'user',
'label': 'Who',
'text': 'Rule applies when access is requested by:',
'field_name': 'usercategory',
'options': [
{ 'value': 'all', 'label': 'Anyone' },
{ 'value': '', 'label': 'Specified Users and Groups' }
],
'tables': [
{ 'field_name': 'memberuser_user' },
{ 'field_name': 'memberuser_group' }
]
});
that.add_section(section);
}
section.create_radio({ name: 'usercategory', label: 'User category' });
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberuser_user',
'name': 'memberuser_user', 'label': 'Users',
'other_entity': 'user', 'add_method': 'add_user', 'delete_method': 'remove_user'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberuser_group',
'name': 'memberuser_group', 'label': 'Groups',
'other_entity': 'group', 'add_method': 'add_user', 'delete_method': 'remove_user'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'host',
'label': 'Accessing',
'template': 'hbac-details-host.html #contents'
});
} else {
section = ipa_hbac_details_tables_section({
'name': 'host',
'label': 'Accessing',
'text': 'Rule applies when access is requested to:',
'field_name': 'hostcategory',
'options': [
{ 'value': 'all', 'label': 'Any Host' },
{ 'value': '', 'label': 'Specified Hosts and Groups' }
],
'tables': [
{ 'field_name': 'memberhost_host' },
{ 'field_name': 'memberhost_hostgroup' }
]
});
that.add_section(section);
}
section.create_radio({ 'name': 'hostcategory', 'label': 'Host category' });
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberhost_host',
'name': 'memberhost_host', 'label': 'Hosts',
'other_entity': 'host', 'add_method': 'add_host', 'delete_method': 'remove_host'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberhost_hostgroup',
'name': 'memberhost_hostgroup', 'label': 'Host Groups',
'other_entity': 'hostgroup', 'add_method': 'add_host', 'delete_method': 'remove_host'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'service',
'label': 'Via Service',
'template': 'hbac-details-service.html #contents'
});
} else {
section = ipa_hbac_details_tables_section({
'name': 'service',
'label': 'Via Service',
'text': 'Rule applies when access is requested via:',
'field_name': 'servicecategory',
'options': [
{ 'value': 'all', 'label': 'Any Service' },
{ 'value': '', 'label': 'Specified Services and Groups' }
],
'tables': [
{ 'field_name': 'memberservice_hbacsvc' },
{ 'field_name': 'memberservice_hbacsvcgroup' }
]
});
that.add_section(section);
}
section.create_radio({ 'name': 'servicecategory', 'label': 'Service category' });
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberservice_hbacsvc',
'name': 'memberservice_hbacsvc', 'label': 'Services',
'other_entity': 'hbacsvc', 'add_method': 'add_service', 'delete_method': 'remove_service'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-memberservice_hbacsvcgroup',
'name': 'memberservice_hbacsvcgroup', 'label': 'Service Groups',
'other_entity': 'hbacsvcgroup', 'add_method': 'add_service', 'delete_method': 'remove_service'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'sourcehost',
'label': 'From',
'template': 'hbac-details-sourcehost.html #contents'
});
} else {
section = ipa_hbac_details_tables_section({
'name': 'sourcehost',
'label': 'From',
'text': 'Rule applies when access is being initiated from:',
'field_name': 'sourcehostcategory',
'options': [
{ 'value': 'all', 'label': 'Any Host' },
{ 'value': '', 'label': 'Specified Hosts and Groups' }
],
'tables': [
{ 'field_name': 'sourcehost_host' },
{ 'field_name': 'sourcehost_hostgroup' }
]
});
that.add_section(section);
}
section.create_radio({ 'name': 'sourcehostcategory', 'label': 'Source host category' });
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-sourcehost_host',
'name': 'sourcehost_host', 'label': 'Host',
'other_entity': 'host', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
}));
section.add_field(ipa_hbac_association_widget({
'id': that.entity_name+'-sourcehost_hostgroup',
'name': 'sourcehost_hostgroup', 'label': 'Host Groups',
'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'accesstime',
'label': 'When',
'template': 'hbac-details-accesstime.html #contents'
});
} else {
section = ipa_hbac_details_tables_section({
'name': 'accesstime',
'label': 'When',
'text': 'Rule applies when access is being requested at:',
'field_name': 'accesstime',
'options': [
{ 'value': 'all', 'label': 'Any Time' },
{ 'value': '', 'label': 'Specified Times' }
],
'tables': [
{ 'field_name': 'accesstime' }
]
});
that.add_section(section);
}
section.add_field(ipa_hbac_accesstime_widget({
'id': that.entity_name+'-accesstime',
'name': 'accesstime', 'label': 'Access Time'
}));
that.super_init();
};
return that;
}
function ipa_hbac_details_general_section(spec){
spec = spec || {};
var that = ipa_details_section(spec);
that.create = function(container) {
var table = $('', {
'style': 'width: 100%;'
}).appendTo(container);
var tr = $('
', {
}).appendTo(table);
var td = $(' ', {
'style': 'width: 100px; text-align: right;',
'html': 'Name:'
}).appendTo(tr);
td = $(' ').appendTo(tr);
$('', {
'type': 'text',
'name': 'cn',
'size': 30
}).appendTo(td);
td = $(' ', {
'style': 'text-align: right;'
}).appendTo(tr);
td.append('Rule type:');
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'allow'
}).appendTo(td);
td.append('Allow');
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'deny'
}).appendTo(td);
td.append('Deny');
tr = $(' ', {
}).appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Description:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
$('', {
'name': 'description',
'rows': 5,
'style': 'width: 100%'
}).appendTo(td);
tr = $(' ', {
}).appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Rule status:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'TRUE'
}).appendTo(td);
td.append('Active');
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'FALSE'
}).appendTo(td);
td.append('Inactive');
};
return that;
}
function ipa_hbac_details_tables_section(spec){
spec = spec || {};
var that = ipa_details_section(spec);
that.text = spec.text;
that.field_name = spec.field_name;
that.options = spec.options;
that.tables = spec.tables;
that.columns = spec.columns;
that.super_setup = that.super('setup');
that.create = function(container) {
if (that.template) return;
container.append(that.text);
for (var i=0; i
');
for (var i=0; i
'+error_thrown.title+'
'); div.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); }; that.save = function(container) { return []; }; return that; } function ipa_hbac_accesstime_widget(spec) { spec = spec || {}; var that = ipa_table_widget(spec); that.super_init = that.super('init'); that.super_create = that.super('create'); that.super_setup = that.super('setup'); that.init = function() { // create a column if none defined if (!that.columns.length) { that.create_column({ 'name': that.name, 'label': that.label, 'primary_key': true }); } that.super_init(); }; that.create = function(container) { that.super_create(container); var div = $('#'+that.id); var buttons = $('span[name=buttons]', div); $('', { 'type': 'button', 'name': 'remove', 'value': 'Remove '+that.label }).appendTo(buttons); $('', { 'type': 'button', 'name': 'add', 'value': 'Add '+that.label }).appendTo(buttons); }; that.load = function(container, result) { var values = result[that.name] || ''; if (values) { $('input[name="'+that.name+'"][value=""]', container).attr('checked', 'checked'); } else { $('input[name="'+that.name+'"][value="all"]', container).attr('checked', 'checked'); } that.tbody.empty(); for (var i=0; i'+error_thrown.title+'
'); div.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); }; that.save = function(container) { return []; }; return that; }