mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
HBAC Services
The HBAC Service search and details pages have been added under the HBAC tab. This requires some changes to the framework. Currently the navigation framework doesn't support multiple entities under one tab. As a temporary solution, an 'entity' URL parameter is used to determine the entity to be displayed. This parameter is now only used by HBAC tab, but its use might be expanded later. The navigation framework needs be redesigned to provide more flexibility. The search page in all entities except DNS records have been changed to use the ipa_search_widget. The Select/Unselect All checbox and Delete button now work correctly and consistently. The Add dialog has been enhanced to render and work in a more consistent way while still supporting custom widgets & layouts. For the search page, the Add button will refresh the search results and clear the fields in the dialog box. The framework now provides some extension points which can be overriden by the subclasses: - init(): for initialization and configuration - create(): for creating the layout dynamically or from template - setup(): for setting the look and feel - load(): for loading the data Entity and facet initialization is now done after IPA.init(). This is to ensure the metadata is loaded first so the entities and facets can use localized messages/labels/titles. The group entity has been partially converted to use the new framework. The unit tests have been updated accordingly.
This commit is contained in:
parent
569f4e1a5c
commit
65c9442e26
@ -21,160 +21,80 @@
|
|||||||
|
|
||||||
/* REQUIRES: ipa.js */
|
/* REQUIRES: ipa.js */
|
||||||
|
|
||||||
var IPA_ADD_POPULATE = 1;
|
|
||||||
var IPA_ADD_UPDATE = 2;
|
|
||||||
|
|
||||||
function ipa_add_field(spec) {
|
|
||||||
|
|
||||||
spec = spec || {};
|
|
||||||
|
|
||||||
var that = {};
|
|
||||||
that.name = spec.name;
|
|
||||||
that.label = spec.label;
|
|
||||||
that._entity_name = spec.entity_name;
|
|
||||||
|
|
||||||
that.init = spec.init;
|
|
||||||
that.setup = spec.setup;
|
|
||||||
|
|
||||||
that.__defineGetter__("entity_name", function(){
|
|
||||||
return that._entity_name;
|
|
||||||
});
|
|
||||||
|
|
||||||
that.__defineSetter__("entity_name", function(entity_name){
|
|
||||||
that._entity_name = entity_name;
|
|
||||||
});
|
|
||||||
|
|
||||||
return that;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ipa_add_dialog(spec) {
|
function ipa_add_dialog(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
var that = {};
|
var that = ipa_dialog(spec);
|
||||||
|
|
||||||
that.name = spec.name;
|
that.name = spec.name;
|
||||||
that.title = spec.title;
|
that.title = spec.title;
|
||||||
that._entity_name = spec.entity_name;
|
that._entity_name = spec.entity_name;
|
||||||
|
|
||||||
that.init = spec.init;
|
that.init = function() {
|
||||||
|
|
||||||
that.fields = [];
|
that.add_button('Add', function() {
|
||||||
that.fields_by_name = {};
|
var record = that.get_record();
|
||||||
|
that.add(
|
||||||
|
record,
|
||||||
|
function() {
|
||||||
|
var entity = IPA.get_entity(that.entity_name);
|
||||||
|
var facet = entity.get_facet('search');
|
||||||
|
var table = facet.table;
|
||||||
|
table.refresh(that.container);
|
||||||
|
that.clear(that.container);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
var dialog = $('<div/>');
|
that.add_button('Add and Edit', function() {
|
||||||
|
var record = that.get_record();
|
||||||
|
that.add(
|
||||||
|
record,
|
||||||
|
function() {
|
||||||
|
that.close();
|
||||||
|
|
||||||
that.__defineGetter__("entity_name", function(){
|
var pkey_name = IPA.metadata[that.entity_name].primary_key;
|
||||||
return that._entity_name;
|
var pkey = record[pkey_name];
|
||||||
});
|
|
||||||
|
|
||||||
that.__defineSetter__("entity_name", function(entity_name){
|
var state = {};
|
||||||
that._entity_name = entity_name;
|
state[that.entity_name + '-facet'] = 'details';
|
||||||
|
state[that.entity_name + '-pkey'] = pkey;
|
||||||
|
$.bbq.pushState(state);
|
||||||
|
},
|
||||||
|
function() { that.close(); }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
for (var i=0; i<that.fields.length; i++) {
|
that.add_button('Cancel', function() {
|
||||||
that.fields[i].entity_name = entity_name;
|
that.close();
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
that.get_fields = function() {
|
|
||||||
return that.fields;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.get_field = function(name) {
|
|
||||||
return that.fields_by_name[name];
|
|
||||||
};
|
|
||||||
|
|
||||||
that.add_field = function(field) {
|
|
||||||
that.fields.push(field);
|
|
||||||
that.fields_by_name[field.name] = field;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.create_field = function(spec) {
|
|
||||||
var field = ipa_add_field(spec);
|
|
||||||
that.add_field(field);
|
|
||||||
return field;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.open = function() {
|
|
||||||
dialog.empty();
|
|
||||||
dialog.attr('id', that.name);
|
|
||||||
dialog.attr('title', that.title);
|
|
||||||
|
|
||||||
for (var i = 0; i < that.fields.length; ++i) {
|
|
||||||
var field = that.fields[i];
|
|
||||||
if (field.setup) {
|
|
||||||
field.setup(dialog, IPA_ADD_POPULATE);
|
|
||||||
} else {
|
|
||||||
dialog.append('<label>' + field.label + '</label>');
|
|
||||||
dialog.append('<input type="text" name="' + field.name + '" />');
|
|
||||||
dialog.append('<br/>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.dialog({
|
|
||||||
modal: true,
|
|
||||||
buttons: {
|
|
||||||
'Add': that.add,
|
|
||||||
'Add and edit': that.add_and_edit,
|
|
||||||
'Cancel': that.cancel
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
that.add = function(evt, called_from_add_and_edit) {
|
that.add = function(record, on_success, on_error) {
|
||||||
var pkey = [];
|
|
||||||
var options = {};
|
|
||||||
var pkey_name = IPA.metadata[that.entity_name].primary_key;
|
var pkey_name = IPA.metadata[that.entity_name].primary_key;
|
||||||
|
|
||||||
function add_win(data, text_status, xhr) {
|
var args = [];
|
||||||
if (called_from_add_and_edit) {
|
var options = {};
|
||||||
var state = {};
|
|
||||||
state[that.entity_name + '-facet'] = 'details';
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
state[that.entity_name + '-pkey'] = pkey[0];
|
|
||||||
$.bbq.pushState(state);
|
|
||||||
}else{
|
|
||||||
dialog.find('input').each( function () {
|
|
||||||
$(this).val('');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i = 0; i < that.fields.length; ++i) {
|
|
||||||
var field = that.fields[i];
|
var field = that.fields[i];
|
||||||
if (field.setup) {
|
|
||||||
var value = field.setup(dialog, IPA_ADD_UPDATE);
|
var value = record[field.name];
|
||||||
if (value != null) {
|
if (!value) continue;
|
||||||
if (field.name == pkey_name){
|
|
||||||
pkey = [value];
|
if (field.name == pkey_name) {
|
||||||
} else {
|
args.push(value);
|
||||||
options[field.name] = value;
|
} else {
|
||||||
}
|
options[field.name] = value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.find('input').each(function () {
|
|
||||||
var jobj = $(this);
|
|
||||||
var attr = jobj.attr('name');
|
|
||||||
var value = jobj.val();
|
|
||||||
if (value) {
|
|
||||||
if (pkey.length == 0 && attr == pkey_name)
|
|
||||||
pkey = [jobj.val()];
|
|
||||||
else if (options[attr] == null)
|
|
||||||
options[attr] = jobj.val();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ipa_cmd('add', pkey, options, add_win, null, that.entity_name);
|
ipa_cmd('add', args, options, on_success, on_error, that.entity_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.add_and_edit = function(evt) {
|
that.super_init = that.super('init');
|
||||||
that.add(evt, true);
|
|
||||||
dialog.dialog('close');
|
|
||||||
};
|
|
||||||
|
|
||||||
that.cancel = function() {
|
|
||||||
dialog.dialog('close');
|
|
||||||
};
|
|
||||||
|
|
||||||
if (that.init) that.init();
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ function ipa_association_widget(spec) {
|
|||||||
'name': 'add',
|
'name': 'add',
|
||||||
'value': IPA.messages.button.enroll
|
'value': IPA.messages.button.enroll
|
||||||
}).appendTo(buttons);
|
}).appendTo(buttons);
|
||||||
}
|
};
|
||||||
|
|
||||||
that.setup = function(container) {
|
that.setup = function(container) {
|
||||||
|
|
||||||
@ -302,7 +302,6 @@ function ipa_association_widget(spec) {
|
|||||||
|
|
||||||
var dialog = ipa_association_adder_dialog({
|
var dialog = ipa_association_adder_dialog({
|
||||||
'title': title,
|
'title': title,
|
||||||
'parent': container,
|
|
||||||
'entity_name': that.entity_name,
|
'entity_name': that.entity_name,
|
||||||
'pkey': pkey,
|
'pkey': pkey,
|
||||||
'other_entity': that.other_entity,
|
'other_entity': that.other_entity,
|
||||||
@ -318,7 +317,9 @@ function ipa_association_widget(spec) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.remove = function(container) {
|
that.remove = function(container) {
|
||||||
@ -336,7 +337,6 @@ function ipa_association_widget(spec) {
|
|||||||
|
|
||||||
var dialog = ipa_association_deleter_dialog({
|
var dialog = ipa_association_deleter_dialog({
|
||||||
'title': title,
|
'title': title,
|
||||||
'parent': container,
|
|
||||||
'entity_name': that.entity_name,
|
'entity_name': that.entity_name,
|
||||||
'pkey': pkey,
|
'pkey': pkey,
|
||||||
'other_entity': that.other_entity,
|
'other_entity': that.other_entity,
|
||||||
@ -353,7 +353,40 @@ function ipa_association_widget(spec) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.refresh = function(container) {
|
||||||
|
|
||||||
|
function on_success(data, text_status, xhr) {
|
||||||
|
|
||||||
|
that.tbody.empty();
|
||||||
|
|
||||||
|
var column_name = that.columns[0].name;
|
||||||
|
var values = data.result.result[column_name];
|
||||||
|
//TODO, this is masking an error where the wrong
|
||||||
|
//direction association is presented upon page reload.
|
||||||
|
//if the values is unset, it is because
|
||||||
|
//form.associationColumns[0] doesn't exist in the results
|
||||||
|
if (!values) return;
|
||||||
|
|
||||||
|
for (var i = 0; i<values.length; i++){
|
||||||
|
var record = that.get_record(data.result.result, i);
|
||||||
|
that.add_row(container, record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(xhr, text_status, error_thrown) {
|
||||||
|
var div = $('#'+that.id, container).empty();
|
||||||
|
div.append('<p>Error: '+error_thrown.name+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.title+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.message+'</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||||
|
ipa_cmd('show', [pkey], {'rights': true}, on_success, on_error, that.entity_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
@ -373,13 +406,15 @@ function ipa_association_facet(spec) {
|
|||||||
return pkey != that.pkey || other_entity != that.other_entity;
|
return pkey != that.pkey || other_entity != that.other_entity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
that.setup_views(container);
|
||||||
|
};
|
||||||
|
|
||||||
that.setup = function(container, unspecified) {
|
that.setup = function(container, unspecified) {
|
||||||
|
|
||||||
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||||
that.other_entity = $.bbq.getState(that.entity_name + '-enroll', true) || '';
|
that.other_entity = $.bbq.getState(that.entity_name + '-enroll', true) || '';
|
||||||
|
|
||||||
that.setup_views(container);
|
|
||||||
|
|
||||||
//TODO I18N
|
//TODO I18N
|
||||||
var header_message = that.other_entity + '(s) enrolled in ' +
|
var header_message = that.other_entity + '(s) enrolled in ' +
|
||||||
that.entity_name + ' ' + that.pkey;
|
that.entity_name + ' ' + that.pkey;
|
||||||
@ -403,12 +438,6 @@ function ipa_association_facet(spec) {
|
|||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function association_list_create(obj_name, jobj)
|
|
||||||
{
|
|
||||||
search_create(obj_name, [], jobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ipa_deleter_dialog_setup() {
|
function ipa_deleter_dialog_setup() {
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
@ -31,23 +31,20 @@ IPA.is_field_writable = function(rights){
|
|||||||
alert('no right');
|
alert('no right');
|
||||||
}
|
}
|
||||||
return rights.indexOf('w') > -1;
|
return rights.indexOf('w') > -1;
|
||||||
}
|
};
|
||||||
|
|
||||||
function ipa_details_field(spec) {
|
function ipa_details_field(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
spec.create = spec.create || create;
|
|
||||||
spec.setup = spec.setup || setup;
|
|
||||||
spec.load = spec.load || load;
|
|
||||||
spec.save = spec.save || save;
|
|
||||||
|
|
||||||
var that = ipa_widget(spec);
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
function create(container) {
|
that.create = spec.create || create;
|
||||||
}
|
that.setup = spec.setup || setup;
|
||||||
|
that.load = spec.load || load;
|
||||||
|
that.save = spec.save || save;
|
||||||
|
|
||||||
function setup(container) {
|
function create(container) {
|
||||||
|
|
||||||
var dl = $('dl', container);
|
var dl = $('dl', container);
|
||||||
|
|
||||||
@ -65,6 +62,9 @@ function ipa_details_field(spec) {
|
|||||||
}).appendTo(dl);
|
}).appendTo(dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setup(container) {
|
||||||
|
}
|
||||||
|
|
||||||
function load(container, result) {
|
function load(container, result) {
|
||||||
|
|
||||||
var multivalue = false;
|
var multivalue = false;
|
||||||
@ -187,10 +187,6 @@ function ipa_details_section(spec){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
that.get_fields = function() {
|
|
||||||
return that.fields;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.get_field = function(name) {
|
that.get_field = function(name) {
|
||||||
return that.fields_by_name[name];
|
return that.fields_by_name[name];
|
||||||
};
|
};
|
||||||
@ -231,6 +227,13 @@ function ipa_details_section(spec){
|
|||||||
return field;
|
return field;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
|
var field = that.fields[i];
|
||||||
|
field.init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Deprecated: Used for backward compatibility only.
|
// Deprecated: Used for backward compatibility only.
|
||||||
function input(spec){
|
function input(spec){
|
||||||
that.create_field(spec);
|
that.create_field(spec);
|
||||||
@ -253,10 +256,13 @@ function ipa_details_facet(spec) {
|
|||||||
|
|
||||||
var that = ipa_facet(spec);
|
var that = ipa_facet(spec);
|
||||||
|
|
||||||
that.init = spec.init || init;
|
|
||||||
that.is_dirty = spec.is_dirty || ipa_details_is_dirty;
|
that.is_dirty = spec.is_dirty || ipa_details_is_dirty;
|
||||||
that.setup = spec.setup || ipa_details_setup;
|
|
||||||
that.create = spec.create || ipa_details_create;
|
that.create = spec.create || ipa_details_create;
|
||||||
|
that.setup = spec.setup || ipa_details_setup;
|
||||||
|
that.load = spec.load || ipa_details_load;
|
||||||
|
that.update = spec.update || ipa_details_update;
|
||||||
|
that.reset = spec.reset || ipa_details_reset;
|
||||||
|
that.display = spec.display || ipa_details_display;
|
||||||
|
|
||||||
that.sections = [];
|
that.sections = [];
|
||||||
that.sections_by_name = {};
|
that.sections_by_name = {};
|
||||||
@ -273,10 +279,6 @@ function ipa_details_facet(spec) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
that.get_sections = function() {
|
|
||||||
return that.sections;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.get_section = function(name) {
|
that.get_section = function(name) {
|
||||||
return that.sections_by_name[name];
|
return that.sections_by_name[name];
|
||||||
};
|
};
|
||||||
@ -293,8 +295,12 @@ function ipa_details_facet(spec) {
|
|||||||
return section;
|
return section;
|
||||||
};
|
};
|
||||||
|
|
||||||
function init() {
|
that.init = function() {
|
||||||
}
|
for (var i=0; i<that.sections.length; i++) {
|
||||||
|
var section = that.sections[i];
|
||||||
|
section.init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
@ -321,38 +327,7 @@ function ipa_details_is_dirty() {
|
|||||||
return pkey != this.pkey;
|
return pkey != this.pkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_details_setup(container, unspecified) {
|
function ipa_details_create(container)
|
||||||
|
|
||||||
var facet = this;
|
|
||||||
|
|
||||||
facet.setup_views(container);
|
|
||||||
|
|
||||||
facet.pkey = $.bbq.getState(facet.entity_name + '-pkey', true) || '';
|
|
||||||
if (!facet.pkey && !unspecified) return;
|
|
||||||
|
|
||||||
function on_success(data, text_status, xhr) {
|
|
||||||
var result = data.result.result;
|
|
||||||
|
|
||||||
ipa_details_cache[facet.entity_name] = $.extend(true, {}, result);
|
|
||||||
facet.create(container, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function on_failure(xhr, text_status, error_thrown) {
|
|
||||||
var details = $('.details', container).empty();
|
|
||||||
details.append('<p>Error: '+error_thrown.name+'</p>');
|
|
||||||
details.append('<p>'+error_thrown.title+'</p>');
|
|
||||||
details.append('<p>'+error_thrown.message+'</p>');
|
|
||||||
}
|
|
||||||
|
|
||||||
var params = [];
|
|
||||||
if (facet.pkey) params.push(facet.pkey);
|
|
||||||
|
|
||||||
ipa_cmd(
|
|
||||||
'show', params, {all: true, rights: true}, on_success, on_failure, facet.entity_name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ipa_details_create(container, result)
|
|
||||||
{
|
{
|
||||||
var facet = this;
|
var facet = this;
|
||||||
|
|
||||||
@ -364,6 +339,8 @@ function ipa_details_create(container, result)
|
|||||||
var entity_name = container.attr('id');
|
var entity_name = container.attr('id');
|
||||||
container.attr('title', entity_name);
|
container.attr('title', entity_name);
|
||||||
|
|
||||||
|
facet.setup_views(container);
|
||||||
|
|
||||||
var details = $('<div/>', {
|
var details = $('<div/>', {
|
||||||
'class': 'details'
|
'class': 'details'
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
@ -377,7 +354,7 @@ function ipa_details_create(container, result)
|
|||||||
'icon': 'ui-icon-refresh',
|
'icon': 'ui-icon-refresh',
|
||||||
'class': 'details-reset',
|
'class': 'details-reset',
|
||||||
'click': function() {
|
'click': function() {
|
||||||
ipa_details_reset(container);
|
facet.reset(container);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -389,7 +366,7 @@ function ipa_details_create(container, result)
|
|||||||
'icon': 'ui-icon-check',
|
'icon': 'ui-icon-check',
|
||||||
'class': 'details-update',
|
'class': 'details-update',
|
||||||
'click': function() {
|
'click': function() {
|
||||||
ipa_details_update(container, ipa_details_cache[facet.entity_name][pkey_name][0]);
|
facet.update(container, ipa_details_cache[facet.entity_name][pkey_name][0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -410,52 +387,111 @@ function ipa_details_create(container, result)
|
|||||||
'class': 'details-section'
|
'class': 'details-section'
|
||||||
}).appendTo(details);
|
}).appendTo(details);
|
||||||
|
|
||||||
section.setup(div, result);
|
section.create(div);
|
||||||
|
|
||||||
details.append('<hr/>');
|
details.append('<hr/>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ipa_details_setup(container, unspecified) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
function ipa_details_section_setup(container, result) {
|
for (var i = 0; i < that.sections.length; ++i) {
|
||||||
var section = this;
|
var section = that.sections[i];
|
||||||
var fields = section.get_fields();
|
|
||||||
|
|
||||||
if (section.template) {
|
var div = $(
|
||||||
var template = IPA.get_template(section.template);
|
'#'+that.entity_name+'-'+that.name+'-'+section.name,
|
||||||
container.load(template, function(data, text_status, xhr) {
|
container
|
||||||
for (var i = 0; i < fields.length; ++i) {
|
);
|
||||||
var field = fields[i];
|
|
||||||
field.create(container);
|
section.setup(div, unspecified);
|
||||||
field.setup(container);
|
}
|
||||||
field.load(container, result);
|
}
|
||||||
}
|
|
||||||
});
|
function ipa_details_load(container, unspecified) {
|
||||||
return;
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||||
|
if (!that.pkey && !unspecified) return;
|
||||||
|
|
||||||
|
function on_success(data, text_status, xhr) {
|
||||||
|
var result = data.result.result;
|
||||||
|
|
||||||
|
ipa_details_cache[that.entity_name] = $.extend(true, {}, result);
|
||||||
|
for (var i = 0; i < that.sections.length; ++i) {
|
||||||
|
var section = that.sections[i];
|
||||||
|
|
||||||
|
var div = $(
|
||||||
|
'#'+that.entity_name+'-'+that.name+'-'+section.name,
|
||||||
|
container
|
||||||
|
);
|
||||||
|
|
||||||
|
section.load(div, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
section.create(container);
|
function on_failure(xhr, text_status, error_thrown) {
|
||||||
|
var details = $('.details', container).empty();
|
||||||
|
details.append('<p>Error: '+error_thrown.name+'</p>');
|
||||||
|
details.append('<p>'+error_thrown.title+'</p>');
|
||||||
|
details.append('<p>'+error_thrown.message+'</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = [];
|
||||||
|
if (that.pkey) params.push(that.pkey);
|
||||||
|
|
||||||
|
ipa_cmd(
|
||||||
|
'show', params, {all: true, rights: true}, on_success, on_failure, that.entity_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ipa_details_section_create(container) {
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
if (that.template) return;
|
||||||
|
|
||||||
|
var dl = $('<dl/>', {
|
||||||
|
'id': that.name,
|
||||||
|
'class': 'entryattrs'
|
||||||
|
}).appendTo(container);
|
||||||
|
|
||||||
|
var fields = that.fields;
|
||||||
for (var i = 0; i < fields.length; ++i) {
|
for (var i = 0; i < fields.length; ++i) {
|
||||||
var field = fields[i];
|
var field = fields[i];
|
||||||
field.create(container);
|
field.create(container);
|
||||||
field.setup(container);
|
|
||||||
field.load(container, result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_details_section_create(container, result) {
|
function ipa_details_section_setup(container, unspecified) {
|
||||||
var section = this;
|
var that = this;
|
||||||
|
if (that.template) return;
|
||||||
|
|
||||||
var dl = $('<dl/>', {
|
var fields = that.fields;
|
||||||
'id': section.name,
|
for (var i = 0; i < fields.length; ++i) {
|
||||||
'class': 'entryattrs'
|
var field = fields[i];
|
||||||
}).appendTo(container);
|
field.setup(container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_details_section_load(container, result) {
|
function ipa_details_section_load(container, result) {
|
||||||
var section = this;
|
var that = this;
|
||||||
var fields = section.get_fields();
|
var fields = that.fields;
|
||||||
|
|
||||||
|
if (that.template) {
|
||||||
|
var template = IPA.get_template(that.template);
|
||||||
|
container.load(
|
||||||
|
template,
|
||||||
|
function(data, text_status, xhr) {
|
||||||
|
for (var i = 0; i < fields.length; ++i) {
|
||||||
|
var field = fields[i];
|
||||||
|
field.setup(container);
|
||||||
|
field.load(container, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (var j=0; j<fields.length; j++) {
|
for (var j=0; j<fields.length; j++) {
|
||||||
var field = fields[j];
|
var field = fields[j];
|
||||||
@ -465,7 +501,8 @@ function ipa_details_section_load(container, result) {
|
|||||||
|
|
||||||
function ipa_details_update(container, pkey, on_win, on_fail)
|
function ipa_details_update(container, pkey, on_win, on_fail)
|
||||||
{
|
{
|
||||||
var obj_name = container.attr('id');
|
var facet = this;
|
||||||
|
var entity_name = facet.entity_name;
|
||||||
|
|
||||||
function update_on_win(data, text_status, xhr) {
|
function update_on_win(data, text_status, xhr) {
|
||||||
if (on_win)
|
if (on_win)
|
||||||
@ -474,8 +511,8 @@ function ipa_details_update(container, pkey, on_win, on_fail)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var result = data.result.result;
|
var result = data.result.result;
|
||||||
ipa_details_cache[obj_name] = $.extend(true, {}, result);
|
ipa_details_cache[entity_name] = $.extend(true, {}, result);
|
||||||
ipa_details_display(container, result);
|
facet.display(container, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_on_fail(xhr, text_status, error_thrown) {
|
function update_on_fail(xhr, text_status, error_thrown) {
|
||||||
@ -490,20 +527,17 @@ function ipa_details_update(container, pkey, on_win, on_fail)
|
|||||||
var modlist = {'all': true, 'setattr': [], 'addattr': [], 'rights': true};
|
var modlist = {'all': true, 'setattr': [], 'addattr': [], 'rights': true};
|
||||||
var attrs_wo_option = {};
|
var attrs_wo_option = {};
|
||||||
|
|
||||||
var facet = ipa_entity_get_details_facet(obj_name);
|
for (var i=0; i<facet.sections.length; i++) {
|
||||||
var sections = facet.get_sections();
|
var section = facet.sections[i];
|
||||||
for (var i=0; i<sections.length; i++) {
|
|
||||||
var section = sections[i];
|
|
||||||
var fields = section.get_fields();
|
|
||||||
|
|
||||||
var div = $('#'+facet.entity_name+'-'+facet.name+'-'+section.name, container);
|
var div = $('#'+facet.entity_name+'-'+facet.name+'-'+section.name, container);
|
||||||
|
|
||||||
for (var j=0; j<fields.length; j++) {
|
for (var j=0; j<section.fields.length; j++) {
|
||||||
var field = fields[j];
|
var field = section.fields[j];
|
||||||
|
|
||||||
values = field.save(div);
|
values = field.save(div);
|
||||||
|
|
||||||
var param_info = ipa_get_param_info(obj_name, field.name);
|
var param_info = ipa_get_param_info(entity_name, field.name);
|
||||||
if (param_info) {
|
if (param_info) {
|
||||||
if (param_info['primary_key']) continue;
|
if (param_info['primary_key']) continue;
|
||||||
if (values.length === 1) {
|
if (values.length === 1) {
|
||||||
@ -526,7 +560,7 @@ function ipa_details_update(container, pkey, on_win, on_fail)
|
|||||||
modlist['addattr'].push(attr + '=' + values[i]);
|
modlist['addattr'].push(attr + '=' + values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipa_cmd('mod', [pkey], modlist, update_on_win, update_on_fail, obj_name);
|
ipa_cmd('mod', [pkey], modlist, update_on_win, update_on_fail, entity_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -555,16 +589,14 @@ var _ipa_span_hint_template = '<span class="attrhint">Hint: D</span>';
|
|||||||
* (basically an associative array with attr:value pairs) */
|
* (basically an associative array with attr:value pairs) */
|
||||||
function ipa_details_display(container, result)
|
function ipa_details_display(container, result)
|
||||||
{
|
{
|
||||||
var entity_name = container.attr('id');
|
var facet = this;
|
||||||
|
|
||||||
/* remove all <dd> tags i.e. all attribute values */
|
/* remove all <dd> tags i.e. all attribute values */
|
||||||
$('dd', container).remove();
|
$('dd', container).remove();
|
||||||
|
|
||||||
/* go through all <dt> tags and pair them with newly created <dd>s */
|
/* go through all <dt> tags and pair them with newly created <dd>s */
|
||||||
var facet = ipa_entity_get_details_facet(entity_name);
|
for (var i=0; i<facet.sections.length; i++) {
|
||||||
var sections = facet.get_sections();
|
var section = facet.sections[i];
|
||||||
for (var i=0; i<sections.length; i++) {
|
|
||||||
var section = sections[i];
|
|
||||||
|
|
||||||
var div = $('#'+facet.entity_name+'-'+facet.name+'-'+section.name, container);
|
var div = $('#'+facet.entity_name+'-'+facet.name+'-'+section.name, container);
|
||||||
|
|
||||||
@ -752,10 +784,11 @@ function _ipa_create_text_input(attr, value, param_info, rights)
|
|||||||
|
|
||||||
function ipa_details_reset(container)
|
function ipa_details_reset(container)
|
||||||
{
|
{
|
||||||
var obj_name = container.attr('id');
|
var facet = this;
|
||||||
|
var entity_name = facet.entity_name;
|
||||||
|
|
||||||
if (ipa_details_cache[obj_name]){
|
if (ipa_details_cache[entity_name]){
|
||||||
ipa_details_display(container, ipa_details_cache[obj_name]);
|
facet.display(container, ipa_details_cache[entity_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,10 @@ function ipa_facet(spec) {
|
|||||||
that.label = spec.label;
|
that.label = spec.label;
|
||||||
that._entity_name = spec.entity_name;
|
that._entity_name = spec.entity_name;
|
||||||
|
|
||||||
that.init = spec.init;
|
that.init = spec.init || init;
|
||||||
that.setup = spec.setup;
|
that.create = spec.create || create;
|
||||||
|
that.setup = spec.setup || setup;
|
||||||
|
that.load = spec.load || load;
|
||||||
|
|
||||||
that.__defineGetter__("entity_name", function(){
|
that.__defineGetter__("entity_name", function(){
|
||||||
return that._entity_name;
|
return that._entity_name;
|
||||||
@ -43,6 +45,25 @@ function ipa_facet(spec) {
|
|||||||
|
|
||||||
that.setup_views = ipa_facet_setup_views;
|
that.setup_views = ipa_facet_setup_views;
|
||||||
|
|
||||||
|
that.super = function(name) {
|
||||||
|
var method = that[name];
|
||||||
|
return function () {
|
||||||
|
return method.apply(that, arguments);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function create() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,30 +75,34 @@ function ipa_entity(spec) {
|
|||||||
that.name = spec.name;
|
that.name = spec.name;
|
||||||
that.label = spec.label;
|
that.label = spec.label;
|
||||||
|
|
||||||
that.setup = spec.setup;
|
that.setup = spec.setup || ipa_entity_setup;
|
||||||
|
|
||||||
that.add_dialog = null;
|
that.dialogs = [];
|
||||||
|
that.dialogs_by_name = {};
|
||||||
|
|
||||||
that.facets = [];
|
that.facets = [];
|
||||||
that.facets_by_name = {};
|
that.facets_by_name = {};
|
||||||
|
|
||||||
this.facet_name = null;
|
that.facet_name = null;
|
||||||
|
|
||||||
that.associations = [];
|
that.associations = [];
|
||||||
that.associations_by_name = {};
|
that.associations_by_name = {};
|
||||||
|
|
||||||
that.get_add_dialog = function() {
|
that.super = function(name) {
|
||||||
return that.add_dialog;
|
var method = that[name];
|
||||||
|
return function () {
|
||||||
|
return method.apply(that, arguments);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_add_dialog = function(spec) {
|
that.get_dialog = function(name) {
|
||||||
spec.entity_name = that.name;
|
return that.dialogs_by_name[name];
|
||||||
that.add_dialog = ipa_add_dialog(spec);
|
|
||||||
return that.add_dialog;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_facets = function() {
|
that.add_dialog = function(dialog) {
|
||||||
return that.facets;
|
dialog.entity_name = that.name;
|
||||||
|
that.dialogs.push(dialog);
|
||||||
|
that.dialogs_by_name[dialog.name] = dialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_facet = function(name) {
|
that.get_facet = function(name) {
|
||||||
@ -90,25 +115,6 @@ function ipa_entity(spec) {
|
|||||||
that.facets_by_name[facet.name] = facet;
|
that.facets_by_name[facet.name] = facet;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.create_search_facet = function(spec) {
|
|
||||||
var facet = ipa_search_facet(spec);
|
|
||||||
that.add_facet(facet);
|
|
||||||
return facet;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.create_details_facet = function(spec) {
|
|
||||||
var facet = ipa_details_facet(spec);
|
|
||||||
that.add_facet(facet);
|
|
||||||
facet.init();
|
|
||||||
return facet;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.create_association_facet = function(spec) {
|
|
||||||
var facet = ipa_association_facet(spec);
|
|
||||||
that.add_facet(facet);
|
|
||||||
return facet;
|
|
||||||
};
|
|
||||||
|
|
||||||
that.get_associations = function() {
|
that.get_associations = function() {
|
||||||
return that.associations;
|
return that.associations;
|
||||||
};
|
};
|
||||||
@ -128,6 +134,13 @@ function ipa_entity(spec) {
|
|||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
for (var i=0; i<that.facets.length; i++) {
|
||||||
|
var facet = that.facets[i];
|
||||||
|
facet.init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,10 +167,11 @@ function ipa_entity_get_search_facet(entity_name) {
|
|||||||
var facet = entity.get_facet('search');
|
var facet = entity.get_facet('search');
|
||||||
if (facet) return facet;
|
if (facet) return facet;
|
||||||
|
|
||||||
facet = entity.create_search_facet({
|
facet = ipa_search_facet({
|
||||||
'name': 'search',
|
'name': 'search',
|
||||||
'label': 'Search'
|
'label': 'Search'
|
||||||
});
|
});
|
||||||
|
entity.add_facet(facet);
|
||||||
|
|
||||||
return facet;
|
return facet;
|
||||||
}
|
}
|
||||||
@ -180,18 +194,20 @@ function ipa_entity_set_add_definition(entity_name, data) {
|
|||||||
|
|
||||||
var entity = ipa_get_entity(entity_name);
|
var entity = ipa_get_entity(entity_name);
|
||||||
|
|
||||||
var dialog = entity.create_add_dialog({
|
var dialog = ipa_add_dialog({
|
||||||
'name': data[0],
|
'name': 'add',
|
||||||
'title': data[1]
|
'title': data[1]
|
||||||
});
|
});
|
||||||
|
entity.add_dialog(dialog);
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
for (var i=0; i<data[2].length; i++) {
|
for (var i=0; i<data[2].length; i++) {
|
||||||
var field = data[2][i];
|
var field = data[2][i];
|
||||||
dialog.create_field({
|
dialog.add_field(ipa_text_widget({
|
||||||
name: field[0],
|
name: field[0],
|
||||||
label: field[1],
|
label: field[1],
|
||||||
setup: field[2]
|
setup: field[2]
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,10 +224,11 @@ function ipa_entity_get_details_facet(entity_name) {
|
|||||||
var facet = entity.get_facet('details');
|
var facet = entity.get_facet('details');
|
||||||
if (facet) return facet;
|
if (facet) return facet;
|
||||||
|
|
||||||
facet = entity.create_details_facet({
|
facet = ipa_details_facet({
|
||||||
'name': 'details',
|
'name': 'details',
|
||||||
'label': 'Details'
|
'label': 'Details'
|
||||||
});
|
});
|
||||||
|
entity.add_facet(facet);
|
||||||
|
|
||||||
return facet;
|
return facet;
|
||||||
}
|
}
|
||||||
@ -233,9 +250,10 @@ function ipa_entity_get_association_facet(entity_name) {
|
|||||||
var facet = entity.get_facet('associate');
|
var facet = entity.get_facet('associate');
|
||||||
if (facet) return facet;
|
if (facet) return facet;
|
||||||
|
|
||||||
facet = entity.create_association_facet({
|
facet = ipa_association_facet({
|
||||||
'name': 'associate'
|
'name': 'associate'
|
||||||
});
|
});
|
||||||
|
entity.add_facet(facet);
|
||||||
|
|
||||||
return facet;
|
return facet;
|
||||||
}
|
}
|
||||||
@ -293,9 +311,9 @@ function ipa_entity_setup(container, unspecified) {
|
|||||||
|
|
||||||
container.empty();
|
container.empty();
|
||||||
|
|
||||||
if (facet.setup) {
|
facet.create(container);
|
||||||
facet.setup(container, unspecified);
|
facet.setup(container, unspecified);
|
||||||
}
|
facet.load(container, unspecified);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_facet_setup_views(container) {
|
function ipa_facet_setup_views(container) {
|
||||||
@ -305,10 +323,9 @@ function ipa_facet_setup_views(container) {
|
|||||||
var ul = $('<ul/>', {'class': 'entity-views'}).appendTo(container);
|
var ul = $('<ul/>', {'class': 'entity-views'}).appendTo(container);
|
||||||
|
|
||||||
var entity = IPA.get_entity(facet.entity_name);
|
var entity = IPA.get_entity(facet.entity_name);
|
||||||
var facets = entity.get_facets();
|
|
||||||
|
|
||||||
for (var i=0; i<facets.length; i++) {
|
for (var i=0; i<entity.facets.length; i++) {
|
||||||
var other_facet = facets[i];
|
var other_facet = entity.facets[i];
|
||||||
var facet_name = other_facet.name;
|
var facet_name = other_facet.name;
|
||||||
|
|
||||||
if (other_facet.label) {
|
if (other_facet.label) {
|
||||||
@ -352,17 +369,19 @@ function ipa_facet_setup_views(container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_entity_quick_links(tr, attr, value, entry_attrs) {
|
function ipa_entity_quick_links(container, name, value, entry_attrs) {
|
||||||
|
|
||||||
var obj_name = tr.closest('.entity-container').attr('title');
|
var obj_name = container.closest('.entity-container').attr('title');
|
||||||
var pkey = IPA.metadata[obj_name].primary_key;
|
var pkey = IPA.metadata[obj_name].primary_key;
|
||||||
var pkey_value = entry_attrs[pkey][0];
|
var pkey_value = entry_attrs[pkey];
|
||||||
|
|
||||||
var td = $("<td/>").appendTo(tr);
|
var span = $('span[name="'+name+'"]', container);
|
||||||
|
span.empty();
|
||||||
|
|
||||||
$("<a/>", {
|
$("<a/>", {
|
||||||
href: "#details",
|
href: '#details',
|
||||||
title: "Details",
|
title: 'Details',
|
||||||
|
text: 'Details',
|
||||||
click: function() {
|
click: function() {
|
||||||
var state = {};
|
var state = {};
|
||||||
state[obj_name+'-facet'] = 'details';
|
state[obj_name+'-facet'] = 'details';
|
||||||
@ -370,7 +389,7 @@ function ipa_entity_quick_links(tr, attr, value, entry_attrs) {
|
|||||||
nav_push_state(state);
|
nav_push_state(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).appendTo(td);
|
}).appendTo(span);
|
||||||
|
|
||||||
var attribute_members = IPA.metadata[obj_name].attribute_members;
|
var attribute_members = IPA.metadata[obj_name].attribute_members;
|
||||||
for (attr_name in attribute_members) {
|
for (attr_name in attribute_members) {
|
||||||
@ -379,6 +398,8 @@ function ipa_entity_quick_links(tr, attr, value, entry_attrs) {
|
|||||||
var m = objs[i];
|
var m = objs[i];
|
||||||
var label = IPA.metadata[m].label;
|
var label = IPA.metadata[m].label;
|
||||||
|
|
||||||
|
span.append(' | ');
|
||||||
|
|
||||||
$("<a/>", {
|
$("<a/>", {
|
||||||
href: '#'+m,
|
href: '#'+m,
|
||||||
title: label,
|
title: label,
|
||||||
@ -393,7 +414,7 @@ function ipa_entity_quick_links(tr, attr, value, entry_attrs) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}(m)
|
}(m)
|
||||||
}).append(' | ' ).appendTo(td);
|
}).appendTo(span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,52 @@
|
|||||||
|
|
||||||
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
||||||
|
|
||||||
|
function ipa_group() {
|
||||||
|
|
||||||
|
var that = ipa_entity({
|
||||||
|
'name': 'group'
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
var dialog = ipa_group_add_dialog({
|
||||||
|
'name': 'add',
|
||||||
|
'title': 'Add New Group'
|
||||||
|
});
|
||||||
|
that.add_dialog(dialog);
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPA.add_entity(ipa_group());
|
||||||
|
|
||||||
|
function ipa_group_add_dialog(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_add_dialog(spec);
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
this.super_init();
|
||||||
|
|
||||||
|
this.add_field(ipa_text_widget({name:'cn', label:'Name'}));
|
||||||
|
this.add_field(ipa_text_widget({name:'description', label:'Description'}));
|
||||||
|
this.add_field(ipa_checkbox_widget({name:'posix', label:'Is this a POSIX group?'}));
|
||||||
|
this.add_field(ipa_text_widget({name:'gidnumber', label:'GID'}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
ipa_entity_set_search_definition('group', [
|
ipa_entity_set_search_definition('group', [
|
||||||
['cn', 'Name', null],
|
['cn', 'Name', null],
|
||||||
['gidnumber', 'GID', null],
|
['gidnumber', 'GID', null],
|
||||||
@ -27,15 +73,6 @@ ipa_entity_set_search_definition('group', [
|
|||||||
['quick_links', 'Quick Links', ipa_entity_quick_links]
|
['quick_links', 'Quick Links', ipa_entity_quick_links]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ipa_entity_set_add_definition('group', [
|
|
||||||
'dialog-add-group', 'Add New Group', [
|
|
||||||
['cn', 'Name', null],
|
|
||||||
['description', 'Description', null],
|
|
||||||
['posix', 'Is this a POSIX group?', f_posix],
|
|
||||||
['gidnumber', 'GID', null]
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
ipa_entity_set_details_definition('group',[
|
ipa_entity_set_details_definition('group',[
|
||||||
ipa_stanza({name:'identity', label:'Group Details'}).
|
ipa_stanza({name:'identity', label:'Group Details'}).
|
||||||
input({name:'cn', label:'Group Name'}).
|
input({name:'cn', label:'Group Name'}).
|
||||||
@ -48,24 +85,3 @@ ipa_entity_set_association_definition('group', {
|
|||||||
'rolegroup': { associator: 'serial' },
|
'rolegroup': { associator: 'serial' },
|
||||||
'taskgroup': { associator: 'serial' }
|
'taskgroup': { associator: 'serial' }
|
||||||
});
|
});
|
||||||
|
|
||||||
function f_posix(dlg, mode)
|
|
||||||
{
|
|
||||||
function checkbox_on_click() {
|
|
||||||
var jobj = $(this);
|
|
||||||
if (jobj.attr('checked'))
|
|
||||||
jobj.attr('checked', false);
|
|
||||||
else
|
|
||||||
jobj.attr('checked', true);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (mode == IPA_ADD_POPULATE) {
|
|
||||||
dlg.append('<label>Is this a POSIX group?</label>');
|
|
||||||
dlg.append('<input type="checkbox" name="posix" />');
|
|
||||||
dlg.children().last().click(checkbox_on_click);
|
|
||||||
} else {
|
|
||||||
if (dlg.find('input:checkbox[name=posix]').attr('checked'))
|
|
||||||
return (true);
|
|
||||||
return (false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -26,114 +26,144 @@ function ipa_hbac() {
|
|||||||
'name': 'hbac'
|
'name': 'hbac'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
that.init = function() {
|
that.init = function() {
|
||||||
|
|
||||||
that.create_add_dialog({
|
var dialog = ipa_hbac_add_dialog({
|
||||||
'name': 'add',
|
'name': 'add',
|
||||||
'title': 'Add New Rule',
|
'title': 'Add New Rule'
|
||||||
'init': ipa_hbac_add_init
|
|
||||||
});
|
});
|
||||||
|
that.add_dialog(dialog);
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
that.create_search_facet({
|
var facet = ipa_hbac_search_facet({
|
||||||
'name': 'search',
|
'name': 'search',
|
||||||
'label': 'Search',
|
'label': 'Search'
|
||||||
'init': ipa_hbac_search_init,
|
|
||||||
'setup': ipa_hbac_search_setup
|
|
||||||
});
|
});
|
||||||
|
that.add_facet(facet);
|
||||||
|
|
||||||
that.create_details_facet({
|
facet = ipa_hbac_details_facet({
|
||||||
'name': 'details',
|
'name': 'details',
|
||||||
'label': 'Details',
|
'label': 'Details'
|
||||||
'init': ipa_hbac_details_init
|
|
||||||
});
|
});
|
||||||
};
|
that.add_facet(facet);
|
||||||
|
|
||||||
that.init();
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPA.add_entity(ipa_hbac());
|
IPA.add_entity(ipa_hbac());
|
||||||
|
|
||||||
function ipa_hbac_add_init() {
|
function ipa_hbac_add_dialog(spec) {
|
||||||
this.create_field({name:'cn', label:'Rule Name'});
|
|
||||||
this.create_field({name:'accessruletype', label:'Rule type (allow/deny)'});
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_add_dialog(spec);
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
|
||||||
|
that.add_field(ipa_text_widget({
|
||||||
|
'name': 'cn',
|
||||||
|
'label': 'Rule Name'
|
||||||
|
}));
|
||||||
|
|
||||||
|
that.add_field(ipa_text_widget({
|
||||||
|
'name': 'accessruletype',
|
||||||
|
'label': 'Rule type (allow/deny)'
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_hbac_search_init() {
|
function ipa_hbac_search_facet(spec) {
|
||||||
|
|
||||||
this.create_column({name:'cn', label:'Rule Name'});
|
spec = spec || {};
|
||||||
this.create_column({name:'usercategory', label:'Who'});
|
|
||||||
this.create_column({name:'hostcategory', label:'Accessing'});
|
|
||||||
this.create_column({name:'servicecategory', label:'Via Service'});
|
|
||||||
this.create_column({name:'sourcehostcategory', label:'From'});
|
|
||||||
this.create_column({name:'ipaenabledflag', label:'Active'});
|
|
||||||
|
|
||||||
this.create_column({
|
var that = ipa_search_facet(spec);
|
||||||
name: 'quick_links',
|
|
||||||
label: 'Quick Links',
|
|
||||||
setup: ipa_hbac_quick_links
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function ipa_hbac_search_setup(container) {
|
that.super_init = that.super('init');
|
||||||
|
that.super_create = that.super('create');
|
||||||
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
var that = this;
|
that.init = function() {
|
||||||
|
|
||||||
that.filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
that.create_column({name:'cn', label:'Rule Name'});
|
||||||
|
that.create_column({name:'usercategory', label:'Who'});
|
||||||
|
that.create_column({name:'hostcategory', label:'Accessing'});
|
||||||
|
that.create_column({name:'ipaenabledflag', label:'Active'});
|
||||||
|
that.create_column({name:'servicecategory', label:'Via Service'});
|
||||||
|
that.create_column({name:'sourcehostcategory', label:'From'});
|
||||||
|
|
||||||
|
that.create_column({
|
||||||
|
name: 'quick_links',
|
||||||
|
label: 'Quick Links',
|
||||||
|
setup: ipa_hbac_quick_links
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
|
||||||
|
var that = this;
|
||||||
/*
|
/*
|
||||||
// Not yet implemented
|
// Not yet implemented
|
||||||
|
|
||||||
var left_buttons = $('<span/>', {
|
var left_buttons = $('<span/>', {
|
||||||
'style': 'float: left;'
|
'style': 'float: left;'
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
|
|
||||||
left_buttons.append(ipa_button({
|
left_buttons.append(ipa_button({
|
||||||
'label': 'Troubleshoot Rules'
|
'label': 'Troubleshoot Rules'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
left_buttons.append(ipa_button({
|
left_buttons.append(ipa_button({
|
||||||
'label': 'Cull Disabled Rules'
|
'label': 'Cull Disabled Rules'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var right_buttons = $('<span/>', {
|
|
||||||
'style': 'float: right;'
|
|
||||||
}).appendTo(container);
|
|
||||||
|
|
||||||
right_buttons.append(ipa_button({
|
|
||||||
'label': 'Login Services'
|
|
||||||
}));
|
|
||||||
|
|
||||||
right_buttons.append(ipa_button({
|
|
||||||
'label': 'Login Svc Groups'
|
|
||||||
}));
|
|
||||||
|
|
||||||
container.append('<br/><br/>');
|
|
||||||
*/
|
*/
|
||||||
search_create(that.entity_name, that.columns, container);
|
var right_buttons = $('<span/>', {
|
||||||
|
'style': 'float: right;'
|
||||||
|
}).appendTo(container);
|
||||||
|
|
||||||
ipa_button({
|
right_buttons.append(ipa_button({
|
||||||
'label': IPA.messages.button.add,
|
'label': 'HBAC Services',
|
||||||
'icon': 'ui-icon-plus',
|
'click': function() {
|
||||||
'click': function() {
|
var state = {};
|
||||||
var entity = IPA.get_entity(that.entity_name);
|
state['entity'] = 'hbacsvc';
|
||||||
entity.add_dialog.open();
|
nav_push_state(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).appendTo($('.search-controls', container));
|
}));
|
||||||
|
/*
|
||||||
|
right_buttons.append(ipa_button({
|
||||||
|
'label': 'Login Svc Groups'
|
||||||
|
}));
|
||||||
|
*/
|
||||||
|
container.append('<br/><br/>');
|
||||||
|
|
||||||
search_load(container, that.filter);
|
that.super_create(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_hbac_quick_links(tr, attr, value, entry_attrs) {
|
function ipa_hbac_quick_links(container, name, value, record) {
|
||||||
|
|
||||||
var column = this;
|
var column = this;
|
||||||
var facet = column.facet;
|
var facet = column.facet;
|
||||||
|
|
||||||
var pkey = IPA.metadata[column.entity_name].primary_key;
|
var pkey = IPA.metadata[column.entity_name].primary_key;
|
||||||
var pkey_value = entry_attrs[pkey][0];
|
var pkey_value = record[pkey];
|
||||||
|
|
||||||
var td = $('<td/>').appendTo(tr);
|
var span = $('span[name='+name+']', container);
|
||||||
|
|
||||||
$('<a/>', {
|
$('<a/>', {
|
||||||
'href': '#details',
|
'href': '#details',
|
||||||
@ -146,9 +176,9 @@ function ipa_hbac_quick_links(tr, attr, value, entry_attrs) {
|
|||||||
nav_push_state(state);
|
nav_push_state(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).appendTo(td);
|
}).appendTo(span);
|
||||||
|
|
||||||
td.append(' | ');
|
span.append(' | ');
|
||||||
|
|
||||||
$('<a/>', {
|
$('<a/>', {
|
||||||
'href': '#test-rule',
|
'href': '#test-rule',
|
||||||
@ -161,212 +191,224 @@ function ipa_hbac_quick_links(tr, attr, value, entry_attrs) {
|
|||||||
nav_push_state(state);
|
nav_push_state(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).appendTo(td);
|
}).appendTo(span);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_hbac_details_init() {
|
function ipa_hbac_details_facet(spec) {
|
||||||
|
|
||||||
var that = this;
|
spec = spec || {};
|
||||||
var section;
|
|
||||||
|
|
||||||
if (IPA.layout) {
|
var that = ipa_details_facet(spec);
|
||||||
section = that.create_section({
|
|
||||||
'name': 'general',
|
|
||||||
'label': 'General',
|
|
||||||
'template': 'hbac-details-general.html #contents'
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
that.super_init = that.super('init');
|
||||||
section = ipa_hbac_details_general_section({
|
that.super_create = that.super('create');
|
||||||
'name': 'general',
|
that.super_setup = that.super('setup');
|
||||||
'label': 'General'
|
|
||||||
});
|
|
||||||
that.add_section(section);
|
|
||||||
}
|
|
||||||
|
|
||||||
section.create_text({ 'name': 'cn', 'label': 'Name' });
|
that.init = function() {
|
||||||
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) {
|
var section;
|
||||||
section = that.create_section({
|
|
||||||
'name': 'user',
|
|
||||||
'label': 'Who',
|
|
||||||
'template': 'hbac-details-user.html #contents'
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
if (IPA.layout) {
|
||||||
section = ipa_hbac_details_tables_section({
|
section = that.create_section({
|
||||||
'name': 'user',
|
'name': 'general',
|
||||||
'label': 'Who',
|
'label': 'General',
|
||||||
'text': 'Rule applies when access is requested by:',
|
'template': 'hbac-details-general.html #contents'
|
||||||
'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' });
|
} else {
|
||||||
section.add_field(ipa_hbac_association_widget({
|
section = ipa_hbac_details_general_section({
|
||||||
'id': that.entity_name+'-memberuser_user',
|
'name': 'general',
|
||||||
'name': 'memberuser_user', 'label': 'Users',
|
'label': 'General'
|
||||||
'other_entity': 'user', 'add_method': 'add_user', 'delete_method': 'remove_user'
|
});
|
||||||
}));
|
that.add_section(section);
|
||||||
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.create_text({ 'name': 'cn', 'label': 'Name' });
|
||||||
section = that.create_section({
|
section.create_radio({ 'name': 'accessruletype', 'label': 'Rule Type' });
|
||||||
'name': 'host',
|
section.create_textarea({ 'name': 'description', 'label': 'Description' });
|
||||||
'label': 'Accessing',
|
section.create_radio({ 'name': 'ipaenabledflag', 'label': 'Enabled' });
|
||||||
'template': 'hbac-details-host.html #contents'
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
if (IPA.layout) {
|
||||||
section = ipa_hbac_details_tables_section({
|
section = that.create_section({
|
||||||
'name': 'host',
|
'name': 'user',
|
||||||
'label': 'Accessing',
|
'label': 'Who',
|
||||||
'text': 'Rule applies when access is requested to:',
|
'template': 'hbac-details-user.html #contents'
|
||||||
'field_name': 'hostcategory',
|
});
|
||||||
'options': [
|
|
||||||
{ 'value': 'all', 'label': 'Any Host' },
|
|
||||||
{ 'value': '', 'label': 'Specified Hosts and Groups' }
|
|
||||||
],
|
|
||||||
'tables': [
|
|
||||||
{ 'field_name': 'memberhost_host' },
|
|
||||||
{ 'field_name': 'memberhost_hostgroup' }
|
|
||||||
],
|
|
||||||
'columns': [
|
|
||||||
]
|
|
||||||
});
|
|
||||||
that.add_section(section);
|
|
||||||
}
|
|
||||||
|
|
||||||
section.create_radio({ 'name': 'hostcategory', 'label': 'Host category' });
|
} else {
|
||||||
section.add_field(ipa_hbac_association_widget({
|
section = ipa_hbac_details_tables_section({
|
||||||
'id': that.entity_name+'-memberhost_host',
|
'name': 'user',
|
||||||
'name': 'memberhost_host', 'label': 'Hosts',
|
'label': 'Who',
|
||||||
'other_entity': 'host', 'add_method': 'add_host', 'delete_method': 'remove_host'
|
'text': 'Rule applies when access is requested by:',
|
||||||
}));
|
'field_name': 'usercategory',
|
||||||
section.add_field(ipa_hbac_association_widget({
|
'options': [
|
||||||
'id': that.entity_name+'-memberhost_hostgroup',
|
{ 'value': 'all', 'label': 'Anyone' },
|
||||||
'name': 'memberhost_hostgroup', 'label': 'Host Groups',
|
{ 'value': '', 'label': 'Specified Users and Groups' }
|
||||||
'other_entity': 'hostgroup', 'add_method': 'add_host', 'delete_method': 'remove_host'
|
],
|
||||||
}));
|
'tables': [
|
||||||
|
{ 'field_name': 'memberuser_user' },
|
||||||
|
{ 'field_name': 'memberuser_group' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
that.add_section(section);
|
||||||
|
}
|
||||||
|
|
||||||
if (IPA.layout) {
|
section.create_radio({ name: 'usercategory', label: 'User category' });
|
||||||
section = that.create_section({
|
section.add_field(ipa_hbac_association_widget({
|
||||||
'name': 'service',
|
'id': that.entity_name+'-memberuser_user',
|
||||||
'label': 'Via Service',
|
'name': 'memberuser_user', 'label': 'Users',
|
||||||
'template': 'hbac-details-service.html #contents'
|
'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'
|
||||||
|
}));
|
||||||
|
|
||||||
} else {
|
if (IPA.layout) {
|
||||||
section = ipa_hbac_details_tables_section({
|
section = that.create_section({
|
||||||
'name': 'service',
|
'name': 'host',
|
||||||
'label': 'Via Service',
|
'label': 'Accessing',
|
||||||
'text': 'Rule applies when access is requested via:',
|
'template': 'hbac-details-host.html #contents'
|
||||||
'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' });
|
} else {
|
||||||
section.add_field(ipa_hbac_association_widget({
|
section = ipa_hbac_details_tables_section({
|
||||||
'id': that.entity_name+'-memberservice_hbacsvc',
|
'name': 'host',
|
||||||
'name': 'memberservice_hbacsvc', 'label': 'Services',
|
'label': 'Accessing',
|
||||||
'other_entity': 'hbacsvc', 'add_method': 'add_service', 'delete_method': 'remove_service'
|
'text': 'Rule applies when access is requested to:',
|
||||||
}));
|
'field_name': 'hostcategory',
|
||||||
section.add_field(ipa_hbac_association_widget({
|
'options': [
|
||||||
'id': that.entity_name+'-memberservice_hbacsvcgroup',
|
{ 'value': 'all', 'label': 'Any Host' },
|
||||||
'name': 'memberservice_hbacsvcgroup', 'label': 'Service Groups',
|
{ 'value': '', 'label': 'Specified Hosts and Groups' }
|
||||||
'other_entity': 'hbacsvcgroup', 'add_method': 'add_service', 'delete_method': 'remove_service'
|
],
|
||||||
}));
|
'tables': [
|
||||||
|
{ 'field_name': 'memberhost_host' },
|
||||||
|
{ 'field_name': 'memberhost_hostgroup' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
that.add_section(section);
|
||||||
|
}
|
||||||
|
|
||||||
if (IPA.layout) {
|
section.create_radio({ 'name': 'hostcategory', 'label': 'Host category' });
|
||||||
section = that.create_section({
|
section.add_field(ipa_hbac_association_widget({
|
||||||
'name': 'sourcehost',
|
'id': that.entity_name+'-memberhost_host',
|
||||||
'label': 'From',
|
'name': 'memberhost_host', 'label': 'Hosts',
|
||||||
'template': 'hbac-details-sourcehost.html #contents'
|
'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'
|
||||||
|
}));
|
||||||
|
|
||||||
} else {
|
if (IPA.layout) {
|
||||||
section = ipa_hbac_details_tables_section({
|
section = that.create_section({
|
||||||
'name': 'sourcehost',
|
'name': 'service',
|
||||||
'label': 'From',
|
'label': 'Via Service',
|
||||||
'text': 'Rule applies when access is being initiated from:',
|
'template': 'hbac-details-service.html #contents'
|
||||||
'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' });
|
} else {
|
||||||
section.add_field(ipa_hbac_association_widget({
|
section = ipa_hbac_details_tables_section({
|
||||||
'id': that.entity_name+'-sourcehost_host',
|
'name': 'service',
|
||||||
'name': 'sourcehost_host', 'label': 'Host',
|
'label': 'Via Service',
|
||||||
'other_entity': 'host', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
|
'text': 'Rule applies when access is requested via:',
|
||||||
}));
|
'field_name': 'servicecategory',
|
||||||
section.add_field(ipa_hbac_association_widget({
|
'options': [
|
||||||
'id': that.entity_name+'-sourcehost_hostgroup',
|
{ 'value': 'all', 'label': 'Any Service' },
|
||||||
'name': 'sourcehost_hostgroup', 'label': 'Host Groups',
|
{ 'value': '', 'label': 'Specified Services and Groups' }
|
||||||
'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'delete_method': 'remove_sourcehost'
|
],
|
||||||
}));
|
'tables': [
|
||||||
|
{ 'field_name': 'memberservice_hbacsvc' },
|
||||||
|
{ 'field_name': 'memberservice_hbacsvcgroup' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
that.add_section(section);
|
||||||
|
}
|
||||||
|
|
||||||
if (IPA.layout) {
|
section.create_radio({ 'name': 'servicecategory', 'label': 'Service category' });
|
||||||
section = that.create_section({
|
section.add_field(ipa_hbac_association_widget({
|
||||||
'name': 'accesstime',
|
'id': that.entity_name+'-memberservice_hbacsvc',
|
||||||
'label': 'When',
|
'name': 'memberservice_hbacsvc', 'label': 'Services',
|
||||||
'template': 'hbac-details-accesstime.html #contents'
|
'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'
|
||||||
|
}));
|
||||||
|
|
||||||
} else {
|
if (IPA.layout) {
|
||||||
section = ipa_hbac_details_tables_section({
|
section = that.create_section({
|
||||||
'name': 'accesstime',
|
'name': 'sourcehost',
|
||||||
'label': 'When',
|
'label': 'From',
|
||||||
'text': 'Rule applies when access is being requested at:',
|
'template': 'hbac-details-sourcehost.html #contents'
|
||||||
'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({
|
} else {
|
||||||
'id': that.entity_name+'-accesstime',
|
section = ipa_hbac_details_tables_section({
|
||||||
'name': 'accesstime', 'label': 'Access Time'
|
'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){
|
function ipa_hbac_details_general_section(spec){
|
||||||
@ -473,8 +515,6 @@ function ipa_hbac_details_tables_section(spec){
|
|||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
spec.create = create;
|
|
||||||
|
|
||||||
var that = ipa_details_section(spec);
|
var that = ipa_details_section(spec);
|
||||||
|
|
||||||
that.text = spec.text;
|
that.text = spec.text;
|
||||||
@ -485,7 +525,7 @@ function ipa_hbac_details_tables_section(spec){
|
|||||||
|
|
||||||
that.super_setup = that.super('setup');
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
function create(container) {
|
that.create = function(container) {
|
||||||
|
|
||||||
if (that.template) return;
|
if (that.template) return;
|
||||||
|
|
||||||
@ -512,7 +552,13 @@ function ipa_hbac_details_tables_section(spec){
|
|||||||
'id': that.entity_name+'-'+table.field_name
|
'id': that.entity_name+'-'+table.field_name
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
var fields = that.fields;
|
||||||
|
for (var i = 0; i < fields.length; ++i) {
|
||||||
|
var field = fields[i];
|
||||||
|
field.create(container);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
@ -528,30 +574,30 @@ function ipa_hbac_association_widget(spec) {
|
|||||||
that.add_method = spec.add_method;
|
that.add_method = spec.add_method;
|
||||||
that.delete_method = spec.delete_method;
|
that.delete_method = spec.delete_method;
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
that.super_create = that.super('create');
|
that.super_create = that.super('create');
|
||||||
that.super_setup = that.super('setup');
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
that.create = function(container) {
|
that.init = function() {
|
||||||
|
// create a column if none defined
|
||||||
// create a column when none defined
|
|
||||||
if (!that.columns.length) {
|
if (!that.columns.length) {
|
||||||
that.create_column({
|
that.create_column({
|
||||||
'name': that.name,
|
'name': that.name,
|
||||||
'label': IPA.metadata[that.other_entity].label,
|
'label': IPA.metadata[that.other_entity].label,
|
||||||
'primary_key': true,
|
'primary_key': true
|
||||||
'link': false
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
|
||||||
that.super_create(container);
|
that.super_create(container);
|
||||||
|
|
||||||
var div = $('#'+that.id, container);
|
var div = $('#'+that.id, container);
|
||||||
|
|
||||||
var buttons = $('span[name=buttons]', div);
|
var buttons = $('span[name=buttons]', div);
|
||||||
if (buttons.children().length) {
|
|
||||||
// widget loaded from template
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<input/>', {
|
$('<input/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
@ -588,7 +634,6 @@ function ipa_hbac_association_widget(spec) {
|
|||||||
|
|
||||||
var dialog = ipa_association_adder_dialog({
|
var dialog = ipa_association_adder_dialog({
|
||||||
'title': title,
|
'title': title,
|
||||||
'parent': container,
|
|
||||||
'entity_name': that.entity_name,
|
'entity_name': that.entity_name,
|
||||||
'pkey': pkey,
|
'pkey': pkey,
|
||||||
'other_entity': that.other_entity,
|
'other_entity': that.other_entity,
|
||||||
@ -604,7 +649,9 @@ function ipa_hbac_association_widget(spec) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.remove = function(container) {
|
that.remove = function(container) {
|
||||||
@ -622,7 +669,6 @@ function ipa_hbac_association_widget(spec) {
|
|||||||
|
|
||||||
var dialog = ipa_association_deleter_dialog({
|
var dialog = ipa_association_deleter_dialog({
|
||||||
'title': title,
|
'title': title,
|
||||||
'parent': container,
|
|
||||||
'entity_name': that.entity_name,
|
'entity_name': that.entity_name,
|
||||||
'pkey': pkey,
|
'pkey': pkey,
|
||||||
'other_entity': that.other_entity,
|
'other_entity': that.other_entity,
|
||||||
@ -639,7 +685,40 @@ function ipa_hbac_association_widget(spec) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.refresh = function(container) {
|
||||||
|
|
||||||
|
function on_success(data, text_status, xhr) {
|
||||||
|
|
||||||
|
that.tbody.empty();
|
||||||
|
|
||||||
|
var column_name = that.columns[0].name;
|
||||||
|
var values = data.result.result[column_name];
|
||||||
|
//TODO, this is masking an error where the wrong
|
||||||
|
//direction association is presented upon page reload.
|
||||||
|
//if the values is unset, it is because
|
||||||
|
//form.associationColumns[0] doesn't exist in the results
|
||||||
|
if (!values) return;
|
||||||
|
|
||||||
|
for (var i = 0; i<values.length; i++){
|
||||||
|
var record = that.get_record(data.result.result, i);
|
||||||
|
that.add_row(container, record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(xhr, text_status, error_thrown) {
|
||||||
|
var div = $('#'+that.id, container).empty();
|
||||||
|
div.append('<p>Error: '+error_thrown.name+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.title+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.message+'</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
that.save = function(container) {
|
||||||
@ -655,30 +734,30 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
|
|
||||||
var that = ipa_table_widget(spec);
|
var that = ipa_table_widget(spec);
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
that.super_create = that.super('create');
|
that.super_create = that.super('create');
|
||||||
that.super_setup = that.super('setup');
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
that.create = function(container) {
|
that.init = function() {
|
||||||
|
// create a column if none defined
|
||||||
// create a column when none defined
|
|
||||||
if (!that.columns.length) {
|
if (!that.columns.length) {
|
||||||
that.create_column({
|
that.create_column({
|
||||||
'name': that.name,
|
'name': that.name,
|
||||||
'label': that.label,
|
'label': that.label,
|
||||||
'primary_key': true,
|
'primary_key': true
|
||||||
'link': false
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
|
||||||
that.super_create(container);
|
that.super_create(container);
|
||||||
|
|
||||||
var div = $('#'+that.id);
|
var div = $('#'+that.id);
|
||||||
|
|
||||||
var buttons = $('span[name=buttons]', div);
|
var buttons = $('span[name=buttons]', div);
|
||||||
if (buttons.children().length) {
|
|
||||||
// widget loaded from template
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<input/>', {
|
$('<input/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
@ -716,8 +795,7 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
var title = 'Add '+that.label+' to '+that.entity_name+' '+pkey;
|
var title = 'Add '+that.label+' to '+that.entity_name+' '+pkey;
|
||||||
|
|
||||||
var dialog = ipa_dialog({
|
var dialog = ipa_dialog({
|
||||||
'title': title,
|
'title': title
|
||||||
'parent': container
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.add_field(ipa_text_widget({
|
dialog.add_field(ipa_text_widget({
|
||||||
@ -782,7 +860,9 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialog.add_button('Add', function() {
|
dialog.add_button('Add', function() {
|
||||||
add();
|
add(
|
||||||
|
function() { dialog.clear(container); }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.add_button('Add and Close', function() {
|
dialog.add_button('Add and Close', function() {
|
||||||
@ -796,7 +876,9 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
dialog.close();
|
dialog.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.remove = function(container) {
|
that.remove = function(container) {
|
||||||
@ -813,11 +895,10 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
|
|
||||||
var dialog = ipa_deleter_dialog({
|
var dialog = ipa_deleter_dialog({
|
||||||
'title': title,
|
'title': title,
|
||||||
'parent': container,
|
|
||||||
'values': values
|
'values': values
|
||||||
});
|
});
|
||||||
|
|
||||||
that.remove = function() {
|
dialog.remove = function() {
|
||||||
var batch = ipa_batch_command();
|
var batch = ipa_batch_command();
|
||||||
|
|
||||||
for (var i=0; i<values.length; i++) {
|
for (var i=0; i<values.length; i++) {
|
||||||
@ -841,7 +922,36 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
dialog.open();
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.refresh = function(container) {
|
||||||
|
|
||||||
|
function on_success(data, text_status, xhr) {
|
||||||
|
|
||||||
|
that.tbody.empty();
|
||||||
|
|
||||||
|
var column_name = that.columns[0].name;
|
||||||
|
var values = data.result.result[column_name];
|
||||||
|
if (!values) return;
|
||||||
|
|
||||||
|
for (var i = 0; i<values.length; i++){
|
||||||
|
var record = that.get_record(data.result.result, i);
|
||||||
|
that.add_row(container, record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(xhr, text_status, error_thrown) {
|
||||||
|
var div = $('#'+that.id, container).empty();
|
||||||
|
div.append('<p>Error: '+error_thrown.name+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.title+'</p>');
|
||||||
|
div.append('<p>'+error_thrown.message+'</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
that.save = function(container) {
|
||||||
|
177
install/static/hbacsvc.js
Executable file
177
install/static/hbacsvc.js
Executable file
@ -0,0 +1,177 @@
|
|||||||
|
/* Authors:
|
||||||
|
* Endi Sukma Dewata <edewata@redhat.com>
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Red Hat
|
||||||
|
* see file 'COPYING' for use and warranty information
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; version 2 only
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
||||||
|
|
||||||
|
function ipa_hbacsvc() {
|
||||||
|
|
||||||
|
var that = ipa_entity({
|
||||||
|
'name': 'hbacsvc'
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
var dialog = ipa_hbacsvc_add_dialog({
|
||||||
|
'name': 'add',
|
||||||
|
'title': 'Add New HBAC Service'
|
||||||
|
});
|
||||||
|
that.add_dialog(dialog);
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
|
var facet = ipa_hbacsvc_search_facet({
|
||||||
|
'name': 'search',
|
||||||
|
'label': 'Search'
|
||||||
|
});
|
||||||
|
that.add_facet(facet);
|
||||||
|
|
||||||
|
facet = ipa_hbacsvc_details_facet({
|
||||||
|
'name': 'details',
|
||||||
|
'label': 'Details'
|
||||||
|
});
|
||||||
|
that.add_facet(facet);
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPA.add_entity(ipa_hbacsvc());
|
||||||
|
|
||||||
|
function ipa_hbacsvc_add_dialog(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_add_dialog(spec);
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
this.super_init();
|
||||||
|
|
||||||
|
this.add_field(ipa_text_widget({name:'cn', label:'Name'}));
|
||||||
|
this.add_field(ipa_text_widget({name:'description', label:'Description'}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ipa_hbacsvc_search_facet(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_search_facet(spec);
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
that.super_create = that.super('create');
|
||||||
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
that.create_column({name:'cn', label:'Service', primary_key: true});
|
||||||
|
that.create_column({name:'description', label:'Description'});
|
||||||
|
|
||||||
|
that.create_column({
|
||||||
|
name: 'quick_links',
|
||||||
|
label: 'Quick Links',
|
||||||
|
setup: ipa_hbacsvc_quick_links
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
var right_buttons = $('<span/>', {
|
||||||
|
'style': 'float: right;'
|
||||||
|
}).appendTo(container);
|
||||||
|
|
||||||
|
right_buttons.append(ipa_button({
|
||||||
|
'label': 'HBAC Rules',
|
||||||
|
'click': function() {
|
||||||
|
var state = {};
|
||||||
|
state['entity'] = 'hbac';
|
||||||
|
nav_push_state(state);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
container.append('<br/><br/>');
|
||||||
|
|
||||||
|
that.super_create(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ipa_hbacsvc_quick_links(container, name, value, record) {
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
var pkey = IPA.metadata[that.entity_name].primary_key;
|
||||||
|
var pkey_value = record[pkey];
|
||||||
|
|
||||||
|
var link = $('<a/>', {
|
||||||
|
'href': '#details',
|
||||||
|
'title': 'Details',
|
||||||
|
'text': 'Details',
|
||||||
|
'click': function() {
|
||||||
|
var state = {};
|
||||||
|
state[that.entity_name+'-facet'] = 'details';
|
||||||
|
state[that.entity_name+'-pkey'] = pkey_value;
|
||||||
|
nav_push_state(state);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var span = $('span[name="'+name+'"]', container);
|
||||||
|
span.html(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ipa_hbacsvc_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 = that.create_section({
|
||||||
|
'name': 'general',
|
||||||
|
'label': 'General'
|
||||||
|
});
|
||||||
|
|
||||||
|
section.create_field({ 'name': 'cn', 'label': 'Name' });
|
||||||
|
section.create_field({ 'name': 'description', 'label': 'Description' });
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
@ -24,6 +24,7 @@
|
|||||||
<script type="text/javascript" src="user.js"></script>
|
<script type="text/javascript" src="user.js"></script>
|
||||||
<script type="text/javascript" src="group.js"></script>
|
<script type="text/javascript" src="group.js"></script>
|
||||||
<script type="text/javascript" src="hbac.js"></script>
|
<script type="text/javascript" src="hbac.js"></script>
|
||||||
|
<script type="text/javascript" src="hbacsvc.js"></script>
|
||||||
<script type="text/javascript" src="host.js"></script>
|
<script type="text/javascript" src="host.js"></script>
|
||||||
<script type="text/javascript" src="hostgroup.js"></script>
|
<script type="text/javascript" src="hostgroup.js"></script>
|
||||||
<script type="text/javascript" src="netgroup.js"></script>
|
<script type="text/javascript" src="netgroup.js"></script>
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
/*global $:true, location:true */
|
/*global $:true, location:true */
|
||||||
|
|
||||||
/*Forward defined due to circular dependency with IPA.*/
|
/*Forward defined due to circular dependency with IPA.*/
|
||||||
var ipa_cmd;
|
|
||||||
var IPA = ( function () {
|
var IPA = ( function () {
|
||||||
|
|
||||||
var that = {
|
var that = {
|
||||||
|
@ -134,7 +134,12 @@ function _nav_update_tabs(nls, container)
|
|||||||
_nav_update_tabs(tab.children, container2);
|
_nav_update_tabs(tab.children, container2);
|
||||||
|
|
||||||
} else if (tab.setup) {
|
} else if (tab.setup) {
|
||||||
var entity = IPA.get_entity(tab.name);
|
var entity_name = tab.name;
|
||||||
|
|
||||||
|
// TODO: do not hard-code
|
||||||
|
if (entity_name == 'hbac' && nav_get_state('entity')) entity_name = nav_get_state('entity');
|
||||||
|
|
||||||
|
var entity = IPA.get_entity(entity_name);
|
||||||
entity.setup(container2);
|
entity.setup(container2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,13 +249,16 @@ function ipa_records_facet(spec){
|
|||||||
return pkey != that.pkey || record != that.record;
|
return pkey != that.pkey || record != that.record;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function create(container) {
|
||||||
|
that.setup_views(container);
|
||||||
|
}
|
||||||
|
|
||||||
function setup(container, unspecified){
|
function setup(container, unspecified){
|
||||||
|
|
||||||
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||||
that.record = $.bbq.getState(that.entity_name + '-record', true) || '';
|
that.record = $.bbq.getState(that.entity_name + '-record', true) || '';
|
||||||
|
|
||||||
that.container = container;
|
that.container = container;
|
||||||
that.setup_views(container);
|
|
||||||
|
|
||||||
container.attr('title', that.entity_name);
|
container.attr('title', that.entity_name);
|
||||||
|
|
||||||
@ -445,6 +448,7 @@ function ipa_records_facet(spec){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.create = create;
|
||||||
that.setup = setup;
|
that.setup = setup;
|
||||||
that.load = load;
|
that.load = load;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* Authors:
|
/* Authors:
|
||||||
* Pavel Zuna <pzuna@redhat.com>
|
* Pavel Zuna <pzuna@redhat.com>
|
||||||
* Adam Young <ayoung@redhat.com>
|
* Adam Young <ayoung@redhat.com>
|
||||||
|
* Endi S. Dewata <edewata@redhat.com>
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Red Hat
|
* Copyright (C) 2010 Red Hat
|
||||||
* see file 'COPYING' for use and warranty information
|
* see file 'COPYING' for use and warranty information
|
||||||
@ -21,22 +22,175 @@
|
|||||||
|
|
||||||
/* REQUIRES: ipa.js */
|
/* REQUIRES: ipa.js */
|
||||||
|
|
||||||
|
function ipa_search_widget(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_table_widget(spec);
|
||||||
|
|
||||||
|
that.super_create = that.super('create');
|
||||||
|
that.super_setup = that.super('setup');
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
|
||||||
|
var div = $('#'+that.id);
|
||||||
|
|
||||||
|
var search_controls = $('<div/>', {
|
||||||
|
'class': 'search-controls'
|
||||||
|
}).appendTo(div);
|
||||||
|
|
||||||
|
var search_filter = $('<span/>', {
|
||||||
|
'class': 'search-filter'
|
||||||
|
}).appendTo(search_controls);
|
||||||
|
|
||||||
|
this.filter = $('<input/>', {
|
||||||
|
'type': 'text',
|
||||||
|
'name': 'search-' + that.entity_name + '-filter'
|
||||||
|
}).appendTo(search_filter);
|
||||||
|
|
||||||
|
ipa_button({
|
||||||
|
'label': IPA.messages.button.find,
|
||||||
|
'icon': 'ui-icon-search',
|
||||||
|
'click': function() { that.find(container); }
|
||||||
|
}).appendTo(search_filter);
|
||||||
|
|
||||||
|
ipa_button({
|
||||||
|
'label': IPA.messages.button.remove,
|
||||||
|
'icon': 'ui-icon-trash',
|
||||||
|
'click': function() { that.remove(container); }
|
||||||
|
}).appendTo(search_filter);
|
||||||
|
|
||||||
|
ipa_button({
|
||||||
|
'label': IPA.messages.button.add,
|
||||||
|
'icon': 'ui-icon-plus',
|
||||||
|
'click': function() { that.add(container); }
|
||||||
|
}).appendTo(search_filter);
|
||||||
|
|
||||||
|
search_controls.append('<span class="search-buttons"></span>');
|
||||||
|
|
||||||
|
var search_results = $('<div/>', {
|
||||||
|
'class': 'search-results'
|
||||||
|
}).appendTo(div);
|
||||||
|
|
||||||
|
that.super_create(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.setup = function(container) {
|
||||||
|
|
||||||
|
that.super_setup(container);
|
||||||
|
|
||||||
|
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
||||||
|
this.filter.val(filter);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.find = function(container) {
|
||||||
|
var filter = this.filter.val();
|
||||||
|
var state = {};
|
||||||
|
state[that.entity_name + '-filter'] = filter;
|
||||||
|
$.bbq.pushState(state);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.add = function(container) {
|
||||||
|
|
||||||
|
var entity = IPA.get_entity(that.entity_name);
|
||||||
|
|
||||||
|
var dialog = entity.get_dialog('add');
|
||||||
|
dialog.open(container);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.remove = function(container) {
|
||||||
|
|
||||||
|
var values = that.get_selected_values();
|
||||||
|
|
||||||
|
if (!values.length) {
|
||||||
|
alert('Select '+that.label+' to be removed.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var title = 'Remove '+that.label;
|
||||||
|
|
||||||
|
var dialog = ipa_deleter_dialog({
|
||||||
|
'title': title,
|
||||||
|
'parent': container,
|
||||||
|
'values': values
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.remove = function() {
|
||||||
|
var batch = ipa_batch_command();
|
||||||
|
|
||||||
|
for (var i=0; i<values.length; i++) {
|
||||||
|
var command = ipa_command({
|
||||||
|
'method': that.entity_name+'_del'
|
||||||
|
});
|
||||||
|
command.add_arg(values[i]);
|
||||||
|
batch.add_command(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
batch.execute(
|
||||||
|
function() {
|
||||||
|
that.refresh(container);
|
||||||
|
dialog.close();
|
||||||
|
},
|
||||||
|
function() {
|
||||||
|
that.refresh(container);
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
|
dialog.open(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.refresh = function(container) {
|
||||||
|
|
||||||
|
function on_success(data, text_status, xhr) {
|
||||||
|
|
||||||
|
that.tbody.empty();
|
||||||
|
|
||||||
|
var result = data.result.result;
|
||||||
|
for (var i = 0; i<result.length; i++) {
|
||||||
|
var record = that.get_record(result[i], 0);
|
||||||
|
that.add_row(container, record);
|
||||||
|
}
|
||||||
|
|
||||||
|
var summary = $('span[name=summary]', that.tfoot);
|
||||||
|
|
||||||
|
if (data.result.truncated) {
|
||||||
|
summary.text(
|
||||||
|
'Query returned results than configured size limit will show.' +
|
||||||
|
'First ' + data.result.count + ' results shown.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
summary.text(data.result.summary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(xhr, text_status, error_thrown) {
|
||||||
|
var search_results = $('.search-results', container);
|
||||||
|
search_results.append('<p>Error: '+error_thrown.name+'</p>');
|
||||||
|
search_results.append('<p>'+error_thrown.title+'</p>');
|
||||||
|
search_results.append('<p>'+error_thrown.message+'</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
||||||
|
ipa_cmd(
|
||||||
|
'find', [filter], {all: true}, on_success, on_error, that.entity_name
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
function ipa_search_column(spec) {
|
function ipa_search_column(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
spec.init = spec.init || init;
|
|
||||||
spec.setup = spec.setup || setup;
|
|
||||||
|
|
||||||
var that = ipa_column_widget(spec);
|
var that = ipa_column_widget(spec);
|
||||||
|
|
||||||
function init() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup(tr, attr, value, entry_attrs) {
|
|
||||||
search_generate_td(tr, attr, value, entry_attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +201,9 @@ function ipa_search_facet(spec) {
|
|||||||
var that = ipa_facet(spec);
|
var that = ipa_facet(spec);
|
||||||
|
|
||||||
that.init = spec.init || init;
|
that.init = spec.init || init;
|
||||||
|
that.create = spec.create || ipa_search_facet_create;
|
||||||
that.setup = spec.setup || setup;
|
that.setup = spec.setup || setup;
|
||||||
|
that.load = spec.load || load;
|
||||||
|
|
||||||
that.columns = [];
|
that.columns = [];
|
||||||
that.columns_by_name = {};
|
that.columns_by_name = {};
|
||||||
@ -85,6 +241,24 @@ function ipa_search_facet(spec) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
|
that.table = ipa_search_widget({
|
||||||
|
'id': that.entity_name+'-search',
|
||||||
|
'name': that.entity_name, 'label': IPA.metadata[that.entity_name].label,
|
||||||
|
'entity_name': that.entity_name
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var i=0; i<that.columns.length; i++) {
|
||||||
|
var column = that.columns[i];
|
||||||
|
|
||||||
|
var param_info = ipa_get_param_info(that.entity_name, column.name);
|
||||||
|
var primary_key = param_info && param_info['primary_key'];
|
||||||
|
|
||||||
|
column.primary_key = primary_key;
|
||||||
|
column.link = primary_key;
|
||||||
|
|
||||||
|
that.table.add_column(column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
that.is_dirty = function() {
|
that.is_dirty = function() {
|
||||||
@ -92,30 +266,24 @@ function ipa_search_facet(spec) {
|
|||||||
return filter != that.filter;
|
return filter != that.filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function ipa_search_facet_create(container) {
|
||||||
|
|
||||||
|
container.attr('title', that.entity_name);
|
||||||
|
|
||||||
|
$('<div/>', {
|
||||||
|
'id': that.entity_name+'-search'
|
||||||
|
}).appendTo(container);
|
||||||
|
|
||||||
|
that.table.create(container);
|
||||||
|
}
|
||||||
|
|
||||||
function setup(container, unspecified) {
|
function setup(container, unspecified) {
|
||||||
|
that.table.setup(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
function load(container, unspecified) {
|
||||||
that.filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
that.filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
||||||
|
that.table.refresh(container);
|
||||||
search_create(that.entity_name, that.columns, container);
|
|
||||||
|
|
||||||
ipa_button({
|
|
||||||
'label': IPA.messages.button.add,
|
|
||||||
'icon': 'ui-icon-plus',
|
|
||||||
'click': function() {
|
|
||||||
var entity = IPA.get_entity(that.entity_name);
|
|
||||||
if (entity) {
|
|
||||||
entity.add_dialog.open();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var dialog = ipa_entity_get_add_dialog(that.entity_name);
|
|
||||||
dialog.open();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).appendTo($('.search-controls', container));
|
|
||||||
|
|
||||||
search_load(container, that.filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spec.columns) {
|
if (spec.columns) {
|
||||||
@ -126,196 +294,9 @@ function ipa_search_facet(spec) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
that.init();
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function search_create(entity_name, columns, container) {
|
|
||||||
|
|
||||||
function find_on_click() {
|
|
||||||
var filter = $(this).prev('input[type=text]').val();
|
|
||||||
var state = {};
|
|
||||||
state[entity_name + '-filter'] = filter;
|
|
||||||
$.bbq.pushState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_on_click_outer() {
|
|
||||||
var delete_list = [];
|
|
||||||
var delete_dialog = $('<div></div>', {
|
|
||||||
title: IPA.messages.button.remove
|
|
||||||
});
|
|
||||||
|
|
||||||
function delete_on_click() {
|
|
||||||
ipa_cmd('del', delete_list, {}, delete_on_win, null, entity_name);
|
|
||||||
delete_dialog.dialog('close');
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_on_win() {
|
|
||||||
for (var i = 0; i < delete_list.length; ++i) {
|
|
||||||
var chk = container.find(
|
|
||||||
'.search-selector[title=' + delete_list[i] + ']'
|
|
||||||
);
|
|
||||||
if (chk)
|
|
||||||
chk.closest('tr').remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancel_on_click() {
|
|
||||||
delete_dialog.dialog('close');
|
|
||||||
}
|
|
||||||
|
|
||||||
container.find('.search-selector').each(function () {
|
|
||||||
var jobj = $(this);
|
|
||||||
if (jobj.attr('checked'))
|
|
||||||
delete_list.push(jobj.attr('title'));
|
|
||||||
});
|
|
||||||
|
|
||||||
if (delete_list.length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
delete_dialog.text(IPA.messages.search.delete_confirm);
|
|
||||||
|
|
||||||
delete_dialog.dialog({
|
|
||||||
modal: true,
|
|
||||||
buttons: {
|
|
||||||
'Delete': delete_on_click,
|
|
||||||
'Cancel': cancel_on_click
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!container) {
|
|
||||||
alert('ERROR: search_create: Second argument "container" missing!');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.attr('title', entity_name);
|
|
||||||
|
|
||||||
var search_controls = $('<div/>', {
|
|
||||||
'class': 'search-controls'
|
|
||||||
}).appendTo(container);
|
|
||||||
|
|
||||||
var search_filter = $('<span/>', {
|
|
||||||
'class': 'search-filter'
|
|
||||||
}).appendTo(search_controls);
|
|
||||||
|
|
||||||
var filter = $('<input/>', {
|
|
||||||
'type': 'text',
|
|
||||||
'name': 'search-' + entity_name + '-filter'
|
|
||||||
}).appendTo(search_filter);
|
|
||||||
|
|
||||||
ipa_button({
|
|
||||||
'label': IPA.messages.button.find,
|
|
||||||
'icon': 'ui-icon-search',
|
|
||||||
'click': find_on_click
|
|
||||||
}).appendTo(search_filter);
|
|
||||||
|
|
||||||
ipa_button({
|
|
||||||
'label': IPA.messages.button.remove,
|
|
||||||
'icon': 'ui-icon-trash',
|
|
||||||
'click': delete_on_click_outer
|
|
||||||
}).appendTo(search_filter);
|
|
||||||
|
|
||||||
search_controls.append('<span class="search-buttons"></span>');
|
|
||||||
|
|
||||||
var search_results = $('<div/>', {
|
|
||||||
'class': 'search-results'
|
|
||||||
}).appendTo(container);
|
|
||||||
|
|
||||||
var search_table = $('<table/>', {
|
|
||||||
'class': 'search-table'
|
|
||||||
}).appendTo(search_results);
|
|
||||||
|
|
||||||
search_table.append('<thead><tr></tr></thead>');
|
|
||||||
search_table.append('<tbody></tbody>');
|
|
||||||
search_table.append('<tfoot></tfoot>');
|
|
||||||
|
|
||||||
var tr = search_table.find('tr');
|
|
||||||
search_insert_checkbox_th(tr);
|
|
||||||
for (var i = 0; i < columns.length; ++i) {
|
|
||||||
var c = columns[i];
|
|
||||||
search_insert_th(tr, entity_name, c.name, c.label, c.setup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function search_insert_checkbox_th(jobj)
|
|
||||||
{
|
|
||||||
function select_all_on_click() {
|
|
||||||
var jobj = $(this);
|
|
||||||
|
|
||||||
var checked = jobj.is(':checked');
|
|
||||||
if (checked) {
|
|
||||||
jobj.attr('title', 'Unselect All');
|
|
||||||
} else {
|
|
||||||
jobj.attr('title', 'Select All');
|
|
||||||
}
|
|
||||||
|
|
||||||
var chks = jobj.closest('.entity-container').find('.search-selector').get();
|
|
||||||
for (var i = 0; i < chks.length; ++i)
|
|
||||||
chks[i].checked = checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
var checkbox = $('<input />', {
|
|
||||||
type: 'checkbox',
|
|
||||||
title: 'Select All'
|
|
||||||
});
|
|
||||||
checkbox.click(select_all_on_click);
|
|
||||||
|
|
||||||
var th = $('<th></th>');
|
|
||||||
th.append(checkbox);
|
|
||||||
|
|
||||||
jobj.append(th);
|
|
||||||
}
|
|
||||||
|
|
||||||
var _search_th_template = '<th abbr="A" title="C">N</th>';
|
|
||||||
|
|
||||||
function search_insert_th(jobj, obj_name, attr, name, render_call)
|
|
||||||
{
|
|
||||||
var th = _search_th_template.replace('A', attr);
|
|
||||||
|
|
||||||
var param_info = ipa_get_param_info(obj_name, attr);
|
|
||||||
if (param_info && param_info['label'])
|
|
||||||
th = th.replace('N', param_info['label']);
|
|
||||||
else
|
|
||||||
th = th.replace('N', name);
|
|
||||||
|
|
||||||
if (typeof render_call == 'function')
|
|
||||||
th = th.replace('C', render_call.name);
|
|
||||||
else
|
|
||||||
th = th.replace('C', '-');
|
|
||||||
|
|
||||||
jobj.append(th);
|
|
||||||
}
|
|
||||||
|
|
||||||
function search_load(container, criteria, on_win, on_fail)
|
|
||||||
{
|
|
||||||
var entity_name = container.attr('id');
|
|
||||||
|
|
||||||
function search_on_success(data, text_status, xhr) {
|
|
||||||
if (on_win)
|
|
||||||
on_win(data, text_status, xhr);
|
|
||||||
if (data.error)
|
|
||||||
return;
|
|
||||||
search_display(entity_name, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
function search_on_error(xhr, text_status, error_thrown) {
|
|
||||||
if (on_fail)
|
|
||||||
on_fail(xhr, text_status, error_thrown);
|
|
||||||
|
|
||||||
var search_results = $('.search-results', container);
|
|
||||||
search_results.append('<p>Error: '+error_thrown.name+'</p>');
|
|
||||||
search_results.append('<p>'+error_thrown.title+'</p>');
|
|
||||||
search_results.append('<p>'+error_thrown.message+'</p>');
|
|
||||||
}
|
|
||||||
|
|
||||||
ipa_cmd(
|
|
||||||
'find', [criteria], {all: true}, search_on_success, search_on_error, entity_name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function search_generate_tr(thead, tbody, entry_attrs)
|
function search_generate_tr(thead, tbody, entry_attrs)
|
||||||
{
|
{
|
||||||
var obj_name = tbody.closest('.entity-container').attr('title');
|
var obj_name = tbody.closest('.entity-container').attr('title');
|
||||||
@ -387,27 +368,3 @@ function search_generate_td(tr, attr, value, entry_attrs)
|
|||||||
|
|
||||||
tr.append(_search_td_template.replace('A', attr).replace('V', value));
|
tr.append(_search_td_template.replace('A', attr).replace('V', value));
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_display(obj_name, data)
|
|
||||||
{
|
|
||||||
var selector = '.entity-container[title=' + obj_name + ']';
|
|
||||||
var thead = $(selector + ' thead');
|
|
||||||
var tbody = $(selector + ' tbody');
|
|
||||||
var tfoot = $(selector + ' tfoot');
|
|
||||||
|
|
||||||
tbody.find('tr').remove();
|
|
||||||
|
|
||||||
var result = data.result.result;
|
|
||||||
for (var i = 0; i < result.length; ++i)
|
|
||||||
search_generate_tr(thead, tbody, result[i]);
|
|
||||||
|
|
||||||
if (data.result.truncated) {
|
|
||||||
tfoot.text(
|
|
||||||
'Query returned results than configured size limit will show.' +
|
|
||||||
'First ' + data.result.count + ' results shown.'
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
tfoot.text(data.result.summary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -26,115 +26,202 @@ function ipa_service() {
|
|||||||
'name': 'service'
|
'name': 'service'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
that.init = function() {
|
that.init = function() {
|
||||||
that.create_add_dialog({
|
|
||||||
|
var dialog = ipa_service_add_dialog({
|
||||||
'name': 'add',
|
'name': 'add',
|
||||||
'title': 'Add New Service',
|
'title': 'Add New Service'
|
||||||
'init': ipa_service_add_init
|
|
||||||
});
|
});
|
||||||
|
that.add_dialog(dialog);
|
||||||
|
dialog.init();
|
||||||
|
|
||||||
that.create_search_facet({
|
var facet = ipa_service_search_facet({
|
||||||
'name': 'search',
|
'name': 'search',
|
||||||
'label': 'Search',
|
'label': 'Search'
|
||||||
'init': ipa_service_search_init
|
|
||||||
});
|
});
|
||||||
|
that.add_facet(facet);
|
||||||
|
|
||||||
that.create_details_facet({
|
facet = ipa_service_details_facet({
|
||||||
'name': 'details',
|
'name': 'details',
|
||||||
'label': 'Details',
|
'label': 'Details'
|
||||||
'init': ipa_service_details_init
|
|
||||||
});
|
});
|
||||||
};
|
that.add_facet(facet);
|
||||||
|
|
||||||
that.init();
|
facet = ipa_association_facet({
|
||||||
|
'name': 'associate'
|
||||||
|
});
|
||||||
|
that.add_facet(facet);
|
||||||
|
|
||||||
|
that.create_association({
|
||||||
|
'name': 'host',
|
||||||
|
'add_method': 'add_host',
|
||||||
|
'delete_method': 'remove_host'
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPA.add_entity(ipa_service());
|
IPA.add_entity(ipa_service());
|
||||||
|
|
||||||
function ipa_service_add_init() {
|
function ipa_service_add_dialog(spec) {
|
||||||
|
|
||||||
this.create_field({
|
spec = spec || {};
|
||||||
name: 'krbprincipalname',
|
|
||||||
label: 'Principal',
|
|
||||||
setup: service_add_krbprincipalname
|
|
||||||
});
|
|
||||||
|
|
||||||
this.create_field({name:'service', label:'Service'});
|
var that = ipa_add_dialog(spec);
|
||||||
this.create_field({name:'host', label:'Host Name'});
|
|
||||||
|
that.super_init = that.super('init');
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
|
||||||
|
this.super_init();
|
||||||
|
|
||||||
|
this.add_field(ipa_widget({
|
||||||
|
name: 'krbprincipalname',
|
||||||
|
label: 'Principal'
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.add_field(ipa_text_widget({name:'service', label:'Service'}));
|
||||||
|
this.add_field(ipa_text_widget({name:'host', label:'Host Name'}));
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create = function() {
|
||||||
|
|
||||||
|
var table = $('<table/>').appendTo(that.container);
|
||||||
|
|
||||||
|
var field = that.get_field('service');
|
||||||
|
|
||||||
|
var tr = $('<tr/>').appendTo(table);
|
||||||
|
|
||||||
|
var td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
td.append(field.label+': ');
|
||||||
|
|
||||||
|
td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
|
||||||
|
$('<input/>', {
|
||||||
|
'type': 'text',
|
||||||
|
'name': 'service',
|
||||||
|
'size': 20
|
||||||
|
}).appendTo(td);
|
||||||
|
|
||||||
|
field = that.get_field('host');
|
||||||
|
|
||||||
|
tr = $('<tr/>').appendTo(table);
|
||||||
|
|
||||||
|
td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
td.append(field.label+': ');
|
||||||
|
|
||||||
|
td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
|
||||||
|
$('<input/>', {
|
||||||
|
'type': 'text',
|
||||||
|
'name': 'host',
|
||||||
|
'size': 40
|
||||||
|
}).appendTo(td);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.get_record = function() {
|
||||||
|
var record = {};
|
||||||
|
|
||||||
|
var field = that.get_field('service');
|
||||||
|
var service = field.save(that.container)[0];
|
||||||
|
|
||||||
|
field = that.get_field('host');
|
||||||
|
var host = field.save(that.container)[0];
|
||||||
|
|
||||||
|
record['krbprincipalname'] = service+'/'+host;
|
||||||
|
|
||||||
|
return record;
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_service_search_init() {
|
function ipa_service_search_facet(spec) {
|
||||||
|
|
||||||
this.create_column({name:'krbprincipalname', label:'Principal'});
|
spec = spec || {};
|
||||||
|
|
||||||
this.create_column({
|
var that = ipa_search_facet(spec);
|
||||||
name: 'quick_links',
|
|
||||||
label: 'Quick Links',
|
that.super_init = that.super('init');
|
||||||
setup: ipa_entity_quick_links
|
|
||||||
});
|
that.init = function() {
|
||||||
|
|
||||||
|
this.create_column({name:'krbprincipalname', label:'Principal'});
|
||||||
|
|
||||||
|
this.create_column({
|
||||||
|
name: 'quick_links',
|
||||||
|
label: 'Quick Links',
|
||||||
|
setup: ipa_entity_quick_links
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_service_details_init() {
|
function ipa_service_details_facet(spec) {
|
||||||
|
|
||||||
var section = this.create_section({name:'details', label:'Service Details'});
|
spec = spec || {};
|
||||||
|
|
||||||
section.create_field({
|
var that = ipa_details_facet(spec);
|
||||||
name: 'krbprincipalname',
|
|
||||||
label: 'Principal',
|
|
||||||
setup: service_krbprincipalname_setup,
|
|
||||||
load: service_krbprincipalname_load
|
|
||||||
});
|
|
||||||
|
|
||||||
section.create_field({
|
that.super_init = that.super('init');
|
||||||
name: 'service',
|
|
||||||
label: 'Service',
|
|
||||||
load: service_service_load
|
|
||||||
});
|
|
||||||
|
|
||||||
section.create_field({
|
that.init = function() {
|
||||||
name: 'host',
|
|
||||||
label: 'Host Name',
|
|
||||||
load: service_host_load
|
|
||||||
});
|
|
||||||
|
|
||||||
section = this.create_section({name:'provisioning', label:'Provisioning'});
|
var section = this.create_section({name:'details', label:'Service Details'});
|
||||||
|
|
||||||
section.create_field({
|
section.create_field({
|
||||||
name: 'provisioning_status',
|
name: 'krbprincipalname',
|
||||||
label: 'Status',
|
label: 'Principal'
|
||||||
load: service_provisioning_status_load
|
});
|
||||||
});
|
|
||||||
|
|
||||||
section = this.create_section({name:'certificate', label:'Service Certificate'});
|
section.create_field({
|
||||||
|
name: 'service',
|
||||||
|
label: 'Service',
|
||||||
|
load: service_service_load
|
||||||
|
});
|
||||||
|
|
||||||
section.create_field({
|
section.create_field({
|
||||||
name: 'certificate_status',
|
name: 'host',
|
||||||
label: 'Status',
|
label: 'Host Name',
|
||||||
load: service_usercertificate_load
|
load: service_host_load
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function service_add_krbprincipalname(add_dialog, mode) {
|
section = this.create_section({name:'provisioning', label:'Provisioning'});
|
||||||
if (mode == IPA_ADD_UPDATE) {
|
|
||||||
var service = add_dialog.find('input[name=service]').val();
|
|
||||||
var host = add_dialog.find('input[name=host]').val();
|
|
||||||
return service+'/'+host;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ipa_entity_set_association_definition('service', {
|
section.create_field({
|
||||||
'host': { add_method: 'add_host', delete_host: 'remove_host' }
|
name: 'provisioning_status',
|
||||||
});
|
label: 'Status',
|
||||||
|
load: service_provisioning_status_load
|
||||||
|
});
|
||||||
|
|
||||||
function service_krbprincipalname_setup(container) {
|
section = this.create_section({name:'certificate', label:'Service Certificate'});
|
||||||
// skip krbprincipalname
|
|
||||||
}
|
|
||||||
|
|
||||||
function service_krbprincipalname_load(container, result) {
|
section.create_field({
|
||||||
// skip krbprincipalname
|
name: 'certificate_status',
|
||||||
|
label: 'Status',
|
||||||
|
load: service_usercertificate_load
|
||||||
|
});
|
||||||
|
|
||||||
|
that.super_init();
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function service_service_load(container, result) {
|
function service_service_load(container, result) {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
test("Testing ipa_details_section.setup().", function() {
|
test("Testing ipa_details_section.create().", function() {
|
||||||
|
|
||||||
IPA.ajax_options.async = false;
|
IPA.ajax_options.async = false;
|
||||||
|
|
||||||
@ -34,8 +34,6 @@ test("Testing ipa_details_section.setup().", function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var result = {};
|
|
||||||
|
|
||||||
var section = ipa_details_section({name:'IDIDID', label:'NAMENAMENAME'}).
|
var section = ipa_details_section({name:'IDIDID', label:'NAMENAMENAME'}).
|
||||||
input({name:'cn', label:'Entity Name'}).
|
input({name:'cn', label:'Entity Name'}).
|
||||||
input({name:'description', label:'Description'}).
|
input({name:'description', label:'Description'}).
|
||||||
@ -44,7 +42,7 @@ test("Testing ipa_details_section.setup().", function() {
|
|||||||
|
|
||||||
var fields = section.fields;
|
var fields = section.fields;
|
||||||
var container = $("<div/>");
|
var container = $("<div/>");
|
||||||
section.setup(container, result);
|
section.create(container);
|
||||||
|
|
||||||
var dl = container.find('dl');
|
var dl = container.find('dl');
|
||||||
|
|
||||||
@ -80,7 +78,7 @@ test("Testing ipa_details_section.setup().", function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
test("Testing details lifecycle: create, save ().", function(){
|
test("Testing details lifecycle: create, setup, load.", function(){
|
||||||
|
|
||||||
IPA.ajax_options.async = false;
|
IPA.ajax_options.async = false;
|
||||||
|
|
||||||
@ -168,7 +166,9 @@ test("Testing details lifecycle: create, save ().", function(){
|
|||||||
|
|
||||||
var entity = ipa_get_entity(obj_name);
|
var entity = ipa_get_entity(obj_name);
|
||||||
var facet = entity.get_facet('details');
|
var facet = entity.get_facet('details');
|
||||||
facet.create(container, result);
|
facet.create(container);
|
||||||
|
facet.setup(container);
|
||||||
|
facet.load(container, result);
|
||||||
|
|
||||||
var contact = container.find('dl#contact.entryattrs');
|
var contact = container.find('dl#contact.entryattrs');
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ test("Testing details lifecycle: create, save ().", function(){
|
|||||||
);
|
);
|
||||||
|
|
||||||
same(
|
same(
|
||||||
dts[5].title, facet.get_sections()[0].get_fields()[5].name,
|
dts[5].title, facet.sections[0].fields[5].name,
|
||||||
'Checking dt title'
|
'Checking dt title'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ test("Testing details lifecycle: create, save ().", function(){
|
|||||||
|
|
||||||
ok (load_manager_called, 'load manager called');
|
ok (load_manager_called, 'load manager called');
|
||||||
|
|
||||||
ipa_details_update(container,
|
facet.update(container,
|
||||||
'kfrog',
|
'kfrog',
|
||||||
function(){update_success_called = true},
|
function(){update_success_called = true},
|
||||||
function(){update_failure_called = true});
|
function(){update_failure_called = true});
|
||||||
@ -265,7 +265,11 @@ test("Testing ipa_details_section_setup again()",function(){
|
|||||||
var details = $("<div/>");
|
var details = $("<div/>");
|
||||||
container.append(details);
|
container.append(details);
|
||||||
|
|
||||||
section.setup(container, details, section);
|
var result = {};
|
||||||
|
|
||||||
|
section.create(container);
|
||||||
|
section.setup(container);
|
||||||
|
section.load(container, result);
|
||||||
|
|
||||||
ok(container.find('hr'),'hr');
|
ok(container.find('hr'),'hr');
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ test('Testing ipa_entity_set_search_definition().', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Testing ipa_entity_generate_views().', function() {
|
test('Testing ipa_facet_setup_views().', function() {
|
||||||
|
|
||||||
var orig_show_page = IPA.show_page;
|
var orig_show_page = IPA.show_page;
|
||||||
IPA.ajax_options.async = false;
|
IPA.ajax_options.async = false;
|
||||||
@ -83,9 +83,10 @@ test('Testing ipa_entity_generate_views().', function() {
|
|||||||
|
|
||||||
IPA.add_entity(entity);
|
IPA.add_entity(entity);
|
||||||
|
|
||||||
var facet = entity.create_association_facet({
|
var facet = ipa_association_facet({
|
||||||
'name': 'associate'
|
'name': 'associate'
|
||||||
});
|
});
|
||||||
|
entity.add_facet(facet);
|
||||||
|
|
||||||
var container = $('<div/>');
|
var container = $('<div/>');
|
||||||
|
|
||||||
@ -179,11 +180,12 @@ test('Testing ipa_entity_quick_links().', function() {
|
|||||||
|
|
||||||
var tbody = $('<tbody/>').appendTo(search_table);
|
var tbody = $('<tbody/>').appendTo(search_table);
|
||||||
var tr = $('<tr/>').appendTo(tbody);
|
var tr = $('<tr/>').appendTo(tbody);
|
||||||
|
var td = $('<td/>').appendTo(tr);
|
||||||
|
var span = $('<span/>', {name:'quick_links'}).appendTo(td);
|
||||||
|
|
||||||
ipa_entity_quick_links(tr, null, null, entry_attrs);
|
ipa_entity_quick_links(tr, 'quick_links', null, entry_attrs);
|
||||||
|
|
||||||
var td = tr.children().first();
|
var link = span.children().first();
|
||||||
var link = td.children().first();
|
|
||||||
|
|
||||||
equals(
|
equals(
|
||||||
link.attr('href'), '#details',
|
link.attr('href'), '#details',
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript" src="qunit.js"></script>
|
<script type="text/javascript" src="qunit.js"></script>
|
||||||
<script type="text/javascript" src="../jquery.js"></script>
|
<script type="text/javascript" src="../jquery.js"></script>
|
||||||
|
<script type="text/javascript" src="../jquery.ba-bbq.js"></script>
|
||||||
<script type="text/javascript" src="../jquery-ui.js"></script>
|
<script type="text/javascript" src="../jquery-ui.js"></script>
|
||||||
<script type="text/javascript" src="../ipa.js"></script>
|
<script type="text/javascript" src="../ipa.js"></script>
|
||||||
<script type="text/javascript" src="ipa_tests.js"></script>
|
<script type="text/javascript" src="ipa_tests.js"></script>
|
||||||
|
@ -68,6 +68,11 @@ $(function() {
|
|||||||
$('#loggedinas a').fragment(
|
$('#loggedinas a').fragment(
|
||||||
{'user-facet':'details', 'user-pkey':ipa_whoami_pkey},2);
|
{'user-facet':'details', 'user-pkey':ipa_whoami_pkey},2);
|
||||||
|
|
||||||
|
for (var i=0; i<IPA.entities.length; i++) {
|
||||||
|
var entity = IPA.entities[i];
|
||||||
|
entity.init();
|
||||||
|
}
|
||||||
|
|
||||||
var navigation = $('#navigation');
|
var navigation = $('#navigation');
|
||||||
|
|
||||||
if (whoami.hasOwnProperty('memberof_rolegroup') &&
|
if (whoami.hasOwnProperty('memberof_rolegroup') &&
|
||||||
|
@ -32,10 +32,12 @@ function ipa_widget(spec) {
|
|||||||
that.read_only = spec.read_only;
|
that.read_only = spec.read_only;
|
||||||
that._entity_name = spec.entity_name;
|
that._entity_name = spec.entity_name;
|
||||||
|
|
||||||
|
that.init = spec.init || init;
|
||||||
that.create = spec.create || create;
|
that.create = spec.create || create;
|
||||||
that.setup = spec.setup || setup;
|
that.setup = spec.setup || setup;
|
||||||
that.load = spec.load || load;
|
that.load = spec.load || load;
|
||||||
that.save = spec.save || save;
|
that.save = spec.save || save;
|
||||||
|
that.clear = spec.clear || clear;
|
||||||
|
|
||||||
that.super = function(name) {
|
that.super = function(name) {
|
||||||
var method = that[name];
|
var method = that[name];
|
||||||
@ -52,6 +54,9 @@ function ipa_widget(spec) {
|
|||||||
that._entity_name = entity_name;
|
that._entity_name = entity_name;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
}
|
||||||
|
|
||||||
function create(container) {
|
function create(container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +70,9 @@ function ipa_widget(spec) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clear(container) {
|
||||||
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +82,16 @@ function ipa_text_widget(spec) {
|
|||||||
|
|
||||||
var that = ipa_widget(spec);
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
|
that.size = spec.size || 30;
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
$('<input/>', {
|
||||||
|
'type': 'text',
|
||||||
|
'name': that.name,
|
||||||
|
'size': that.size
|
||||||
|
}).appendTo(container);
|
||||||
|
};
|
||||||
|
|
||||||
that.load = function(container, result) {
|
that.load = function(container, result) {
|
||||||
that.value = result[that.name] || '';
|
that.value = result[that.name] || '';
|
||||||
var input = $('input[name="'+that.name+'"]', container);
|
var input = $('input[name="'+that.name+'"]', container);
|
||||||
@ -101,6 +119,46 @@ function ipa_text_widget(spec) {
|
|||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.clear = function(container) {
|
||||||
|
var input = $('input[name="'+that.name+'"]', container);
|
||||||
|
input.val('');
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ipa_checkbox_widget(spec) {
|
||||||
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
|
that.create = function(container) {
|
||||||
|
$('<input/>', {
|
||||||
|
'type': 'checkbox',
|
||||||
|
'name': that.name
|
||||||
|
}).appendTo(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.load = function(container, result) {
|
||||||
|
var value = result[that.name] || '';
|
||||||
|
$('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked');
|
||||||
|
};
|
||||||
|
|
||||||
|
that.save = function(container) {
|
||||||
|
var values = [];
|
||||||
|
|
||||||
|
var value = $('input[name="'+that.name+'"]', container).is(':checked');
|
||||||
|
values.push(value);
|
||||||
|
|
||||||
|
return values;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.clear = function(container) {
|
||||||
|
var input = $('input[name="'+that.name+'"]', container).get(0);
|
||||||
|
input.checked = false;
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,28 +166,21 @@ function ipa_radio_widget(spec) {
|
|||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
spec.setup = spec.setup || setup;
|
|
||||||
spec.load = spec.load || load;
|
|
||||||
spec.save = spec.save || save;
|
|
||||||
|
|
||||||
var that = ipa_widget(spec);
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
function setup(container) {
|
that.load = function(container, result) {
|
||||||
}
|
|
||||||
|
|
||||||
function load(container, result) {
|
|
||||||
var value = result[that.name] || '';
|
var value = result[that.name] || '';
|
||||||
$('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked');
|
$('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked');
|
||||||
}
|
};
|
||||||
|
|
||||||
function save(container) {
|
that.save = function(container) {
|
||||||
var values = [];
|
var values = [];
|
||||||
|
|
||||||
var value = $('input[name="'+that.name+'"]:checked', container).val();
|
var value = $('input[name="'+that.name+'"]:checked', container).val();
|
||||||
values.push(value);
|
values.push(value);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
@ -138,28 +189,37 @@ function ipa_textarea_widget(spec) {
|
|||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
|
||||||
spec.setup = spec.setup || setup;
|
|
||||||
spec.load = spec.load || load;
|
|
||||||
spec.save = spec.save || save;
|
|
||||||
|
|
||||||
var that = ipa_widget(spec);
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
function setup(container) {
|
that.rows = spec.rows || 5;
|
||||||
}
|
that.cols = spec.cols || 40;
|
||||||
|
|
||||||
function load(container, result) {
|
that.create = function(container) {
|
||||||
|
$('<textarea/>', {
|
||||||
|
'rows': that.rows,
|
||||||
|
'cols': that.cols,
|
||||||
|
'name': that.name
|
||||||
|
}).appendTo(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.load = function(container, result) {
|
||||||
var value = result[that.name] || '';
|
var value = result[that.name] || '';
|
||||||
$('textarea[name="'+that.name+'"]', container).val(value);
|
$('textarea[name="'+that.name+'"]', container).val(value);
|
||||||
}
|
};
|
||||||
|
|
||||||
function save(container) {
|
that.save = function(container) {
|
||||||
var values = [];
|
var values = [];
|
||||||
|
|
||||||
var value = $('textarea[name="'+that.name+'"]', container).val();
|
var value = $('textarea[name="'+that.name+'"]', container).val();
|
||||||
values.push(value);
|
values.push(value);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
that.clear = function(container) {
|
||||||
|
var input = $('input[name="'+that.name+'"]', container);
|
||||||
|
input.val('');
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
@ -199,8 +259,42 @@ function ipa_column_widget(spec) {
|
|||||||
var that = ipa_widget(spec);
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
that.primary_key = spec.primary_key;
|
that.primary_key = spec.primary_key;
|
||||||
|
that.setup = spec.setup || setup;
|
||||||
that.link = spec.link;
|
that.link = spec.link;
|
||||||
|
|
||||||
|
function setup(container, name, value, record) {
|
||||||
|
|
||||||
|
var span = $('span[name="'+name+'"]', container);
|
||||||
|
|
||||||
|
var param_info = ipa_get_param_info(that.entity_name, name);
|
||||||
|
var primary_key = that.primary_key || param_info && param_info['primary_key'];
|
||||||
|
|
||||||
|
if (primary_key && that.link) {
|
||||||
|
var link = $('<a/>', {
|
||||||
|
'href': '#'+value,
|
||||||
|
'html': value,
|
||||||
|
'click': function (value) {
|
||||||
|
return function() {
|
||||||
|
var state = {};
|
||||||
|
state[that.entity_name + '-facet'] = 'details';
|
||||||
|
state[that.entity_name + '-pkey'] = value;
|
||||||
|
//Before this will work, we need to set the tab one level up
|
||||||
|
//for example:
|
||||||
|
//state['identity'] = 0;
|
||||||
|
//but we have no way of getting the index.
|
||||||
|
|
||||||
|
$.bbq.pushState(state);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}(value)
|
||||||
|
});
|
||||||
|
span.html(link);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
span.html(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,12 +338,6 @@ function ipa_table_widget(spec) {
|
|||||||
function create(container) {
|
function create(container) {
|
||||||
|
|
||||||
var div = $('#'+that.id, container);
|
var div = $('#'+that.id, container);
|
||||||
if (div.children().length) {
|
|
||||||
// widget loaded from template
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.empty();
|
|
||||||
|
|
||||||
var table = $('<table/>', {
|
var table = $('<table/>', {
|
||||||
'class': 'search-table'
|
'class': 'search-table'
|
||||||
@ -269,11 +357,17 @@ function ipa_table_widget(spec) {
|
|||||||
}).appendTo(th);
|
}).appendTo(th);
|
||||||
|
|
||||||
for (var i=0; i<that.columns.length; i++) {
|
for (var i=0; i<that.columns.length; i++) {
|
||||||
|
var column = that.columns[i];
|
||||||
th = $('<th/>').appendTo(tr);
|
th = $('<th/>').appendTo(tr);
|
||||||
|
|
||||||
|
var label = column.label;
|
||||||
|
|
||||||
|
var param_info = ipa_get_param_info(that.entity_name, column.name);
|
||||||
|
if (param_info && param_info['label']) label = param_info['label'];
|
||||||
|
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'style': 'float: left;',
|
'style': 'float: left;',
|
||||||
'html': that.columns[i].label
|
'html': label
|
||||||
}).appendTo(th);
|
}).appendTo(th);
|
||||||
|
|
||||||
if (i == that.columns.length-1) {
|
if (i == that.columns.length-1) {
|
||||||
@ -303,6 +397,16 @@ function ipa_table_widget(spec) {
|
|||||||
'name': that.columns[i].name
|
'name': that.columns[i].name
|
||||||
}).appendTo(td);
|
}).appendTo(td);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tfoot = $('<tfoot/>').appendTo(table);
|
||||||
|
|
||||||
|
tr = $('<tr/>').appendTo(tfoot);
|
||||||
|
|
||||||
|
td = $('<td/>', { colspan: that.columns.length+1 }).appendTo(tr);
|
||||||
|
|
||||||
|
$('<span/>', {
|
||||||
|
'name': 'summary'
|
||||||
|
}).appendTo(td);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup(container) {
|
function setup(container) {
|
||||||
@ -310,6 +414,7 @@ function ipa_table_widget(spec) {
|
|||||||
that.table = $('table', div);
|
that.table = $('table', div);
|
||||||
that.thead = $('thead', that.table);
|
that.thead = $('thead', that.table);
|
||||||
that.tbody = $('tbody', that.table);
|
that.tbody = $('tbody', that.table);
|
||||||
|
that.tfoot = $('tfoot', that.table);
|
||||||
|
|
||||||
var select_all_checkbox = $('input[name=select]', that.thead);
|
var select_all_checkbox = $('input[name=select]', that.thead);
|
||||||
select_all_checkbox.attr('title', 'Select All');
|
select_all_checkbox.attr('title', 'Select All');
|
||||||
@ -378,7 +483,9 @@ function ipa_table_widget(spec) {
|
|||||||
var record = {};
|
var record = {};
|
||||||
for (var i=0; i<that.columns.length; i++){
|
for (var i=0; i<that.columns.length; i++){
|
||||||
var name = that.columns[i].name;
|
var name = that.columns[i].name;
|
||||||
record[name] = result[name][index];
|
var values = result[name];
|
||||||
|
if (!values) continue;
|
||||||
|
record[name] = values[index];
|
||||||
}
|
}
|
||||||
return record;
|
return record;
|
||||||
};
|
};
|
||||||
@ -394,35 +501,12 @@ function ipa_table_widget(spec) {
|
|||||||
var name = column.name;
|
var name = column.name;
|
||||||
var value = record[name];
|
var value = record[name];
|
||||||
|
|
||||||
var span = $('span[name="'+name+'"]', tr);
|
|
||||||
span.html(value);
|
|
||||||
|
|
||||||
if (column.primary_key) {
|
if (column.primary_key) {
|
||||||
// set checkbox value
|
// set checkbox value
|
||||||
$('input[name="select"]', tr).val(value);
|
$('input[name="select"]', tr).val(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.primary_key && column.link) {
|
column.setup(tr, name, value, record);
|
||||||
// wrap value with a link
|
|
||||||
var link = $('<a/>', {
|
|
||||||
'click': function (value) {
|
|
||||||
return function() {
|
|
||||||
var state = {};
|
|
||||||
state[that.other_entity + '-facet'] = 'details';
|
|
||||||
state[that.other_entity + '-pkey'] = value;
|
|
||||||
//Before this will work, we need to set the tab one level up
|
|
||||||
//for example:
|
|
||||||
//state['identity'] = 0;
|
|
||||||
//but we have no way of getting the index.
|
|
||||||
|
|
||||||
$.bbq.pushState(state);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}(value)
|
|
||||||
});
|
|
||||||
span.before(link);
|
|
||||||
link.append(span);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -475,11 +559,10 @@ function ipa_dialog(spec) {
|
|||||||
|
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
that.name = spec.name;
|
||||||
that.title = spec.title;
|
that.title = spec.title;
|
||||||
that.parent = spec.parent;
|
|
||||||
that._entity_name = spec.entity_name;
|
that._entity_name = spec.entity_name;
|
||||||
|
|
||||||
that.container = $('<div/>').appendTo(that.parent);
|
|
||||||
that.width = spec.width || 400;
|
that.width = spec.width || 400;
|
||||||
|
|
||||||
that.buttons = {};
|
that.buttons = {};
|
||||||
@ -520,10 +603,32 @@ function ipa_dialog(spec) {
|
|||||||
that.fields_by_name[field.name] = field;
|
that.fields_by_name[field.name] = field;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.init = function() {
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create content layout
|
* Create content layout
|
||||||
*/
|
*/
|
||||||
that.create = function() {
|
that.create = function() {
|
||||||
|
|
||||||
|
var table = $('<table/>').appendTo(that.container);
|
||||||
|
|
||||||
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
|
var field = that.fields[i];
|
||||||
|
|
||||||
|
var tr = $('<tr/>').appendTo(table);
|
||||||
|
|
||||||
|
var td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
td.append(field.label+': ');
|
||||||
|
|
||||||
|
td = $('<td/>', {
|
||||||
|
'style': 'vertical-align: top;'
|
||||||
|
}).appendTo(tr);
|
||||||
|
|
||||||
|
field.create(td);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -535,7 +640,9 @@ function ipa_dialog(spec) {
|
|||||||
/**
|
/**
|
||||||
* Open dialog
|
* Open dialog
|
||||||
*/
|
*/
|
||||||
that.open = function() {
|
that.open = function(container) {
|
||||||
|
|
||||||
|
that.container = $('<div/>').appendTo(container);
|
||||||
|
|
||||||
that.create();
|
that.create();
|
||||||
that.setup();
|
that.setup();
|
||||||
@ -552,11 +659,28 @@ function ipa_dialog(spec) {
|
|||||||
that.container.dialog('option', name, value);
|
that.container.dialog('option', name, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.get_record = function() {
|
||||||
|
var record = {};
|
||||||
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
|
var field = that.fields[i];
|
||||||
|
var values = field.save(that.container);
|
||||||
|
record[field.name] = values[0];
|
||||||
|
}
|
||||||
|
return record;
|
||||||
|
};
|
||||||
|
|
||||||
that.close = function() {
|
that.close = function() {
|
||||||
that.container.dialog('destroy');
|
that.container.dialog('destroy');
|
||||||
that.container.remove();
|
that.container.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.clear = function() {
|
||||||
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
|
var field = that.fields[i];
|
||||||
|
field.clear(that.container);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,13 +779,13 @@ function ipa_adder_dialog(spec) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
that.open = function() {
|
that.open = function(container) {
|
||||||
that.buttons = {
|
that.buttons = {
|
||||||
'Enroll': that.add,
|
'Enroll': that.add,
|
||||||
'Cancel': that.close
|
'Cancel': that.close
|
||||||
};
|
};
|
||||||
|
|
||||||
that.super_open();
|
that.super_open(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.get_filter = function() {
|
that.get_filter = function() {
|
||||||
@ -744,13 +868,13 @@ function ipa_deleter_dialog(spec) {
|
|||||||
}).appendTo(that.container);
|
}).appendTo(that.container);
|
||||||
};
|
};
|
||||||
|
|
||||||
that.open = function() {
|
that.open = function(container) {
|
||||||
that.buttons = {
|
that.buttons = {
|
||||||
'Delete': that.remove,
|
'Delete': that.remove,
|
||||||
'Cancel': that.close
|
'Cancel': that.close
|
||||||
};
|
};
|
||||||
|
|
||||||
that.super_open();
|
that.super_open(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
Loading…
Reference in New Issue
Block a user