/* Authors:
* Endi Sukma Dewata
');
};
that.setup = function(container) {
that.search_facet_setup(container);
};
return that;
}
function ipa_hbac_details_facet(spec) {
spec = spec || {};
var that = ipa_details_facet(spec);
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', 'read_only': true });
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_rule_details_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);
}
var category = 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', 'category': category,
'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', 'remove_method': 'remove_user'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'host',
'label': 'Accessing',
'template': 'hbac-details-host.html #contents'
});
} else {
section = ipa_rule_details_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);
}
category = 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', 'category': category,
'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', 'remove_method': 'remove_host'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'service',
'label': 'Via Service',
'template': 'hbac-details-service.html #contents'
});
} else {
section = ipa_rule_details_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);
}
category = 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', 'category': category,
'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', 'remove_method': 'remove_service'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'sourcehost',
'label': 'From',
'template': 'hbac-details-sourcehost.html #contents'
});
} else {
section = ipa_rule_details_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);
}
category = 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', 'category': category,
'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', 'remove_method': 'remove_sourcehost'
}));
if (IPA.layout) {
section = that.create_section({
'name': 'accesstime',
'label': 'When',
'template': 'hbac-details-accesstime.html #contents'
});
} else {
section = that.create_section({
'name': 'accesstime',
'label': 'When'
});
/*
section = ipa_rule_details_section({
'name': 'accesstime',
'label': 'When',
'text': 'Rule applies when access is being requested at:',
'field_name': 'accesstimecategory',
'tables': [
{ 'field_name': 'accesstime' }
]
});
that.add_section(section);
*/
}
section.add_field(ipa_hbac_accesstime_widget({
'id': 'accesstime',
'name': 'accesstime', 'label': 'Access Time',
'text': 'Rule applies when access is being requested at:',
'options': [
{ 'value': 'all', 'label': 'Any Time' },
{ 'value': '', 'label': 'Specified Times' }
]
}));
that.details_facet_init();
};
that.update = function() {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var modify_operation = {
'execute': false,
'command': ipa_command({
'method': that.entity_name+'_mod',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
};
var remove_accesstime = {
'template': ipa_command({
'method': that.entity_name+'_remove_accesstime',
'args': [pkey],
'options': {'all': true, 'rights': true}
}),
'commands': []
};
var member_category = {
'usercategory': 'memberuser',
'hostcategory': 'memberhost',
'servicecategory': 'memberservice',
'sourcehostcategory': 'sourcehost'
};
var remove_members = {
'memberuser': {
'category_changed': false,
'has_values': false,
'command': ipa_command({
'method': that.entity_name+'_remove_user',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
},
'memberhost': {
'category_changed': false,
'has_values': false,
'command': ipa_command({
'method': that.entity_name+'_remove_host',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
},
'memberservice': {
'category_changed': false,
'has_values': false,
'command': ipa_command({
'method': that.entity_name+'_remove_service',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
},
'sourcehost': {
'category_changed': false,
'has_values': false,
'command': ipa_command({
'method': that.entity_name+'_remove_sourcehost',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
}
};
var enable_operation = {
'execute': false,
'command': ipa_command({
'method': that.entity_name+'_enable',
'args': [pkey],
'options': {'all': true, 'rights': true}
})
};
for (var i=0; i', {
}).appendTo(table);
var td = $(' ', {
'style': 'width: 100px; text-align: right;',
'html': 'Name:'
}).appendTo(tr);
td = $(' ').appendTo(tr);
var span = $('', { 'name': 'cn' }).appendTo(td);
$('', {
'type': 'text',
'name': 'cn',
'size': 30
}).appendTo(span);
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
td = $(' ', {
'style': 'text-align: right;'
}).appendTo(tr);
td.append('Rule type:');
span = $('', { 'name': 'accessruletype' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'allow'
}).appendTo(span);
span.append('Allow');
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'deny'
}).appendTo(span);
span.append('Deny');
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
tr = $(' ', {
}).appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Description:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
span = $('', { 'name': 'description' }).appendTo(td);
$('', {
'name': 'description',
'rows': 5,
'style': 'width: 100%'
}).appendTo(span);
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
tr = $(' ', {
}).appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Rule status:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
span = $('', { 'name': 'ipaenabledflag' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'TRUE'
}).appendTo(span);
span.append('Active');
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'FALSE'
}).appendTo(span);
span.append('Inactive');
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
};
return that;
}
function ipa_hbac_association_widget(spec) {
spec = spec || {};
var that = ipa_rule_association_widget(spec);
that.category = spec.category;
that.add = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var batch = ipa_batch_command({
'on_success': on_success,
'on_error': on_error
});
var command = ipa_command({
'method': that.entity_name+'_mod',
'args': [pkey],
'options': {'all': true, 'rights': true},
'on_success': function() {
that.category.load(['']);
}
});
command.set_option(that.category.name, '');
batch.add_command(command);
command = ipa_command({
'method': that.entity_name+'_'+that.add_method,
'args': [pkey]
});
command.set_option(that.other_entity, values.join(','));
batch.add_command(command);
batch.execute();
};
that.remove = function(values, on_success, on_error) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var command = ipa_command({
'method': that.entity_name+'_'+that.remove_method,
'args': [pkey],
'on_success': on_success,
'on_error': on_error
});
command.set_option(that.other_entity, values.join(','));
command.execute();
};
return that;
}
function ipa_hbac_accesstime_widget(spec) {
spec = spec || {};
var that = ipa_widget(spec);
that.text = spec.text;
that.options = spec.options || [];
that.init = function() {
that.table = ipa_table_widget({
'id': 'accesstime-table',
'name': 'table', 'label': that.label
});
that.table.create_column({
'name': that.name,
'label': that.label,
'primary_key': true
});
that.widget_init();
};
that.create = function(container) {
that.widget_create(container);
var span = $('', { 'name': 'text' }).appendTo(container);
span.append(that.text);
for (var i=0; i
');
span = $('', { 'name': 'table' }).appendTo(container);
that.table.create(span);
var buttons = $('span[name=buttons]', span);
$('', {
'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.widget_setup(container);
var span = $('span[name="table"]', that.container);
that.table.setup(span);
var button = $('input[name=remove]', span);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-trash',
'click': function() { that.remove(that.container); }
}));
button = $('input[name=add]', span);
button.replaceWith(ipa_button({
'label': button.val(),
'icon': 'ui-icon-plus',
'click': function() { that.add(that.container) }
}));
var input = $('input[name="'+that.name+'"]', that.container);
input.change(function() {
that.show_undo();
});
var undo = that.get_undo();
undo.click(function() {
that.reset();
});
};
that.save = function() {
var value = $('input[name="'+that.name+'"]:checked', that.container).val();
if (value == '') {
return that.table.save();
} else {
return [];
}
};
that.load = function(result) {
that.values = result[that.name] || [];
that.reset();
};
that.set_values = function(values) {
that.set_radio_value(that.container, values && values.length ? '' : 'all');
that.table.tbody.empty();
for (var i=0; values && i').appendTo(table);
var td = $(' ', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append(that.label+': ');
td = $(' ').appendTo(tr);
var span = $('', { 'name': that.name }).appendTo(td);
$('', {
'type': 'text',
'name': that.name,
'size': 40
}).appendTo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append('Example:');
td = $(' ').appendTo(tr);
td.append('Every day between 0800 and 1400:
');
td.append('periodic daily 0800-1400
');
td.append('December 16, 2010 from 10:32 until 10:33:
');
td.append('absolute 201012161032 ~ 201012161033');
};
function add(on_success, on_error) {
var field = dialog.get_field(that.name);
var value = field.save()[0];
var command = ipa_command({
'method': that.entity_name+'_add_'+that.name,
'args': [pkey],
'on_success': function() {
that.refresh();
if (on_success) on_success();
},
'on_error': function() {
that.refresh();
if (on_error) on_error();
}
});
command.set_option(that.name, value);
command.execute();
}
dialog.add_button('Add', function() {
add(
function() { dialog.clear(); }
);
});
dialog.add_button('Add and Close', function() {
add(
function() { dialog.close(); },
function() { dialog.close(); }
);
});
dialog.add_button('Cancel', function() {
dialog.close();
});
dialog.init();
dialog.open(that.container);
};
that.remove = function() {
var values = that.table.get_selected_values();
if (!values.length) {
alert('Select '+that.label+' to be removed.');
return;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var title = 'Remove '+that.label+' from '+that.entity_name+' '+pkey;
var dialog = ipa_deleter_dialog({
'title': title,
'values': values
});
dialog.remove = function() {
var batch = ipa_batch_command({
'on_success': function() {
that.refresh();
dialog.close();
},
'on_error': function() {
that.refresh();
dialog.close();
}
});
for (var i=0; i
'+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); }; return that; }