Removed HBAC access time code.

The HBAC access time is currently not supported, so the related UI
code has been removed to reduce maintenance issue. When the feature
becomes supported in the future the code may be restored/rewritten.

Ticket #546
This commit is contained in:
Endi S. Dewata
2011-07-21 02:23:29 -05:00
committed by Adam Young
parent af339cd546
commit b5fe1e8f61

View File

@@ -358,16 +358,6 @@ IPA.hbacrule_details_facet = function(spec) {
})
};
var remove_accesstime = {
'template': IPA.command({
entity: that.entity_name,
method: 'remove_accesstime',
args: [pkey],
options: {all: true, rights: true}
}),
'commands': []
};
var categories = {
'usercategory': {
'remove_values': false
@@ -476,17 +466,6 @@ IPA.hbacrule_details_facet = function(spec) {
continue;
}
if (field.name == 'accesstime') {
// if accesstime is dirty, it means 'Any Time' is selected,
// so existing values have to be removed
for (var k=0; k<field.values.length; k++) {
var command = IPA.command(remove_accesstime.template);
command.set_option(field.name, field.values[k]);
remove_accesstime.commands.push(command);
}
continue;
}
if (categories[field.name]) {
if (values[0] == 'all') {
categories[field.name].remove_values = true;
@@ -537,8 +516,6 @@ IPA.hbacrule_details_facet = function(spec) {
}
}
batch.add_commands(remove_accesstime.commands);
if (modify_operation.execute) batch.add_command(modify_operation.command);
if (enable_operation.execute) batch.add_command(enable_operation.command);
@@ -714,327 +691,6 @@ IPA.hbacrule_details_general_section = function(spec) {
return that;
};
IPA.hbacrule_accesstime_widget = function(spec) {
spec = spec || {};
var that = IPA.widget(spec);
that.text = spec.text;
that.options = spec.options || [];
that.init = function() {
that.widget_init();
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.table.init();
};
that.create = function(container) {
that.widget_create(container);
var span = $('<span/>', { 'name': 'text' }).appendTo(container);
span.append(that.text);
for (var i=0; i<that.options.length; i++) {
var option = that.options[i];
$('<input/>', {
'type': 'radio',
'name': that.name,
'value': option.value
}).appendTo(container);
container.append(' ');
container.append(option.label);
container.append(' ');
}
that.create_undo(container);
container.append('<br/>');
span = $('<span/>', {
name: 'table',
'class': 'details-field'
}).appendTo(container);
that.table.create(span);
var buttons = $('span[name=buttons]', span);
$('<input/>', {
'type': 'button',
'name': 'remove',
'value': IPA.messages.buttons.remove
}).appendTo(buttons);
$('<input/>', {
'type': 'button',
'name': 'add',
'value': IPA.messages.buttons.add
}).appendTo(buttons);
};
that.setup = function(container) {
that.widget_setup(container);
var span = $('.details-field[name="table"]', that.container);
that.table.setup(span);
var button = $('input[name=remove]', span);
button.replaceWith(IPA.button({
name: 'remove',
'label': button.val(),
'icon': 'remove-icon',
'click': function() { that.remove(that.container); }
}));
button = $('input[name=add]', span);
button.replaceWith(IPA.button({
name: 'add',
'label': button.val(),
'icon': 'add-icon',
'click': function() { that.add(that.container); }
}));
var input = $('input[name="'+that.name+'"]', that.container);
input.change(function() {
that.set_dirty(true);
});
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(record) {
that.values = record[that.name] || [];
that.reset();
};
that.update = function() {
that.set_category(that.container, that.values && that.values.length ? '' : 'all');
that.table.tbody.empty();
for (var i=0; that.values && i<that.values.length; i++) {
var record = {};
record[that.name] = that.values[i];
that.table.add_record(record);
}
};
that.set_category = function(container, value) {
$('input[name="'+that.name+'"][value="'+value+'"]', that.container).get(0).checked = true;
};
that.add = function() {
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
var title = IPA.messages.association.add;
title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular);
title = title.replace('${primary_key}', pkey);
title = title.replace('${other_entity}', that.label);
var dialog = IPA.dialog({
'title': title
});
dialog.add_field(IPA.text_widget({
'name': that.name,
'label': that.label
}));
dialog.create = function() {
var table = $('<table/>').appendTo(dialog.container);
var tr = $('<tr/>').appendTo(table);
var td = $('<td/>', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append(that.label+': ');
td = $('<td/>').appendTo(tr);
var span = $('<span/>', { 'name': that.name }).appendTo(td);
$('<input/>', {
'type': 'text',
'name': that.name,
'size': 40
}).appendTo(span);
tr = $('<tr/>').appendTo(table);
td = $('<td/>', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append('Example:');
td = $('<td/>').appendTo(tr);
td.append('<b>Every day between 0800 and 1400:</b><br/>');
td.append('periodic daily 0800-1400<br/><br/>');
td.append('<b>December 16, 2010 from 10:32 until 10:33:</b><br/>');
td.append('absolute 201012161032 ~ 201012161033<td/>');
};
function add(on_success, on_error) {
var field = dialog.get_field(that.name);
var value = field.save()[0];
var command = IPA.command({
entity: that.entity_name,
method: '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(IPA.messages.buttons.add, function() {
add(
function() { dialog.reset(); }
);
});
dialog.add_button(IPA.messages.buttons.add_and_close, function() {
add(
function() { dialog.close(); },
function() { dialog.close(); }
);
});
dialog.add_button(IPA.messages.buttons.cancel, function() {
dialog.close();
});
dialog.init();
dialog.open(that.container);
};
that.remove = function() {
var values = that.table.get_selected_values();
var title;
if (!values.length) {
title = IPA.messages.dialogs.remove_empty;
alert(title);
return;
}
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
title = IPA.messages.association.remove;
title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular);
title = title.replace('${primary_key}', pkey);
title = title.replace('${other_entity}', that.label);
var dialog = IPA.deleter_dialog({
'title': title,
'values': values
});
dialog.execute = 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<values.length; i++) {
var command = IPA.command({
entity: that.entity_name,
method: 'remove_'+that.name,
args: [pkey]
});
command.set_option(that.name, values[i]);
batch.add_command(command);
}
batch.execute();
};
dialog.init();
dialog.open(that.container);
};
that.refresh = function() {
function on_success(data, text_status, xhr) {
that.load(data.result.result);
}
function on_error(xhr, text_status, error_thrown) {
var summary = $('span[name=summary]', that.table.tfoot).empty();
summary.append(error_thrown.name+': '+error_thrown.message);
}
var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
IPA.command({
entity: that.entity_name,
method: 'show',
args: [pkey],
options: {'rights': true},
on_success: on_success,
on_error: on_error
}).execute();
};
return that;
};
IPA.hbac_deny_warning_dialog = function(container) {
var dialog = IPA.dialog({
'title': 'HBAC Deny Rules found'