');
- var delete_list = [];
- container.find('.search-selector').each(function () {
- if (this.checked){
- delete_list.push(this.title);
- confirm_list.append($('',{text: this.title}));
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var label = IPA.metadata[that.other_entity].label;
+ var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
+
+ var dialog = ipa_adder_dialog({
+ 'name': 'adder_dialog',
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'associator': that.associator,
+ 'method': that.add_method,
+ 'on_success': function() {
+ that.refresh(container);
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh(container);
+ dialog.close();
}
});
- if (delete_list.length == 0){
+
+ dialog.open();
+ }
+
+ function remove(container) {
+
+ var values = that.get_selected_values();
+
+ if (!values.length) {
+ alert('Select '+that.label+' to be removed.');
return;
}
- delete_dialog.append(confirm_list);
- delete_dialog.append(
- $('',
- {text:IPA.messages.search.delete_confirm}));
-
- delete_dialog.dialog({
- modal: true,
- buttons: {
- 'Delete': delete_on_click,
- 'Cancel': cancel_on_click
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var label = IPA.metadata[that.other_entity].label;
+ var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
+
+ var dialog = ipa_deleter_dialog({
+ 'name': 'deleter_dialog',
+ 'title': title,
+ 'entity_name': that.entity_name,
+ 'pkey': pkey,
+ 'other_entity': that.other_entity,
+ 'values': values,
+ 'associator': that.associator,
+ 'method': that.delete_method,
+ 'on_success': function() {
+ that.refresh(container);
+ dialog.close();
+ },
+ 'on_error': function() {
+ that.refresh(container);
+ dialog.close();
}
});
+
+ dialog.open();
}
- that.refresh = function(container) {
+ return that;
+}
- function refresh_on_success(data, text_status, xhr) {
- var tbody = container.find('.search-table tbody');
- tbody.empty();
- var associationList = data.result.result[that.columns[0].column];
- //TODO, this is masking an error where the wrong
- //direction association is presented upon page reload.
- //if the associationList is unset, it is because
- //form.associationColumns[0] doesn't exist in the results
- if (!associationList) return;
+function ipa_association_facet(spec) {
+ spec = spec || {};
- for (var j = 0; j < associationList.length; j++){
- var association = associationList[j];
- var row = $('
').appendTo(tbody);
- search_generate_checkbox_td(row, association);
+ var that = ipa_facet(spec);
+ that.other_entity = null;
- for (var k = 0; k < that.columns.length ;k++){
- var column = that.columns[k].column;
- $('
',{
- html:data.result.result[column][j],
- }).appendTo(row);
- }
- }
+ that.is_dirty = function() {
+ var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+ var other_entity = $.bbq.getState(that.entity_name + '-enroll', true) || '';
+ return pkey != that.pkey || other_entity != that.other_entity;
+ };
- tbody.find('.search-a-pkey').click(function () {
- var jobj = $(this);
- var state = {};
- state[that.other_entity + '-facet'] = 'details';
- state[that.other_entity + '-pkey'] = $(this).text();
- //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);
- });
- }
+ that.setup = function(container, unspecified) {
- function refresh_on_error(xhr, text_status, error_thrown) {
- var search_results = $('.search-results', container).empty();
- search_results.append('
+ Rule applies when access is requested to:
+ Any Host
+ Specified Hosts and Groups
+
+
+
+
+
+
+
+
+
+
+ Host
+
+
+
+
+
+
+
+
+
+
+
+
+
+ host
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Host Group
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hostgroups
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/install/static/layouts/default/hbac-details-service.html b/install/static/layouts/default/hbac-details-service.html
new file mode 100755
index 00000000..380cb1bb
--- /dev/null
+++ b/install/static/layouts/default/hbac-details-service.html
@@ -0,0 +1,75 @@
+
+
+
+ Via Service
+
+
+
+
+
+
+ Rule applies when access is requested via:
+ Any Service
+ Specified Services and Groups
+
+
+
+
+
+
+
+
+
+
+ Service
+
+
+
+
+
+
+
+
+
+
+
+
+
+ service
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Service Group
+
+
+
+
+
+
+
+
+
+
+
+
+
+ services
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/install/static/layouts/default/hbac-details-sourcehost.html b/install/static/layouts/default/hbac-details-sourcehost.html
new file mode 100755
index 00000000..12e934c0
--- /dev/null
+++ b/install/static/layouts/default/hbac-details-sourcehost.html
@@ -0,0 +1,75 @@
+
+
+
+ From
+
+
+
+
+
+
+ Rule applies when access is being initiated from:
+ Any Host
+ Specified Hosts and Groups
+
+
+
+
+
+
+
+
+
+
+ Host
+
+
+
+
+
+
+
+
+
+
+
+
+
+ host
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Host Group
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hosts
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/install/static/layouts/default/hbac-details-user.html b/install/static/layouts/default/hbac-details-user.html
new file mode 100755
index 00000000..ef41b6f8
--- /dev/null
+++ b/install/static/layouts/default/hbac-details-user.html
@@ -0,0 +1,75 @@
+
+
+
+ Who
+
+
+
+
+
+
+ Rule applies when access is requested by:
+ Anyone
+ Specified Users and Groups
+
+
+
+
+
+
+
+
+
+
+ User
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ User Group
+
+
+
+
+
+
+
+
+
+
+
+
+
+ users
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/install/static/navigation.js b/install/static/navigation.js
index 72b58ee0..0434f58c 100644
--- a/install/static/navigation.js
+++ b/install/static/navigation.js
@@ -51,8 +51,10 @@ function nav_create(nls, container, tabclass)
var tabs = $('.' + tabclass);
tabs.tabs({
select: function(event, ui) {
+ var panel = $(ui.panel);
+ var parent = panel.parent();
+ var id = parent.attr('id');
var state = {};
- var id = $(ui.panel).parent().attr('id');
state[id] = ui.index;
nav_push_state(state);
return true;
@@ -87,6 +89,8 @@ function nav_generate_tabs(nls, container, tabclass, depth)
if (tab.children) {
nav_generate_tabs(tab.children, div, tabclass, depth +1 );
} else {
+ div.addClass('entity-container');
+
var entity = ipa_get_entity(tab.name);
entity.label = tab.label;
entity.setup = tab.setup;
diff --git a/install/static/policy.js b/install/static/policy.js
index dd544771..f0fa0cd9 100644
--- a/install/static/policy.js
+++ b/install/static/policy.js
@@ -259,7 +259,6 @@ function ipa_records_facet(spec){
that.setup_views(container);
container.attr('title', that.entity_name);
- container.addClass('search-container');
var h2 = $('',{
text: "Records for DNS Zone:" + that.pkey
@@ -291,15 +290,23 @@ function ipa_records_facet(spec){
//}));
- ipa_make_button('ui-icon-search', IPA.messages.button.find).
- click(function(){load(container)}).appendTo(control_span);
+ ipa_button({
+ 'label': IPA.messages.button.find,
+ 'icon': 'ui-icon-search',
+ 'click': function(){load(container)}
+ }).appendTo(control_span);
- ipa_make_button('ui-icon-plus', IPA.messages.button.add).
- click(add_click).appendTo(control_span);
+ ipa_button({
+ 'label': IPA.messages.button.add,
+ 'icon': 'ui-icon-plus',
+ 'click': add_click
+ }).appendTo(control_span);
- ipa_make_button('ui-icon-trash', IPA.messages.button.delete).
- click(function(){delete_records(records_table);}).
- appendTo(control_span);
+ ipa_button({
+ 'label': IPA.messages.button.delete,
+ 'icon': 'ui-icon-trash',
+ 'click': function(){delete_records(records_table);}
+ }).appendTo(control_span);
div.append('');
@@ -416,7 +423,7 @@ function ipa_records_facet(spec){
//TODO this is cut and pasted from search, we need to unify
function display(obj_name, data){
- var selector = '.search-container[title=' + obj_name + ']';
+ var selector = '.entity-container[title=' + obj_name + ']';
var thead = $(selector + ' thead');
var tbody = $(selector + ' tbody');
var tfoot = $(selector + ' tfoot');
diff --git a/install/static/search.js b/install/static/search.js
index 62fffbe9..508f6ed4 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -25,14 +25,10 @@ function ipa_search_column(spec) {
spec = spec || {};
- var that = {};
+ spec.init = spec.init || init;
+ spec.setup = spec.setup || setup;
- that.name = spec.name;
- that.label = spec.label || that.name;
- that.facet = spec.facet;
-
- that.init = spec.init || init;
- that.setup = spec.setup || setup;
+ var that = ipa_column_widget(spec);
function init() {
}
@@ -56,6 +52,18 @@ function ipa_search_facet(spec) {
that.columns = [];
that.columns_by_name = {};
+ that.__defineGetter__("entity_name", function(){
+ return that._entity_name;
+ });
+
+ that.__defineSetter__("entity_name", function(entity_name){
+ that._entity_name = entity_name;
+
+ for (var i=0; i', {
'class': 'search-controls'
@@ -198,11 +207,17 @@ function search_create(entity_name, columns, container) {
'name': 'search-' + entity_name + '-filter'
}).appendTo(search_filter);
- ipa_make_button('ui-icon-search', IPA.messages.button.find).
- click(find_on_click).appendTo(search_filter);
+ ipa_button({
+ 'label': IPA.messages.button.find,
+ 'icon': 'ui-icon-search',
+ 'click': find_on_click
+ }).appendTo(search_filter);
- ipa_make_button('ui-icon-trash',IPA.messages.button.delete).
- click(delete_on_click_outer).appendTo(search_filter);
+ ipa_button({
+ 'label': IPA.messages.button.delete,
+ 'icon': 'ui-icon-trash',
+ 'click': delete_on_click_outer
+ }).appendTo(search_filter);
search_controls.append('');
@@ -231,20 +246,17 @@ function search_insert_checkbox_th(jobj)
function select_all_on_click() {
var jobj = $(this);
- var checked = null;
- if (jobj.attr('checked')) {
- checked = true;
+ var checked = jobj.is(':checked');
+ if (checked) {
jobj.attr('title', 'Unselect All');
} else {
- checked = false;
jobj.attr('title', 'Select All');
}
- jobj.attr('checked', checked);
- var chks = jobj.closest('.search-container').find('.search-selector');
+ var chks = jobj.closest('.entity-container').find('.search-selector').get();
for (var i = 0; i < chks.length; ++i)
chks[i].checked = checked;
- };
+ }
var checkbox = $('', {
type: 'checkbox',
@@ -307,7 +319,7 @@ function search_load(container, criteria, on_win, on_fail)
function search_generate_tr(thead, tbody, entry_attrs)
{
- var obj_name = tbody.closest('.search-container').attr('title');
+ var obj_name = tbody.closest('.entity-container').attr('title');
var pkey = IPA.metadata[obj_name].primary_key;
var pkey_value = entry_attrs[pkey];
@@ -368,7 +380,7 @@ var _search_a_pkey_template = 'V';
function search_generate_td(tr, attr, value, entry_attrs)
{
- var obj_name = tr.closest('.search-container').attr('title');
+ var obj_name = tr.closest('.entity-container').attr('title');
var param_info = ipa_get_param_info(obj_name, attr);
if (param_info && param_info['primary_key'])
@@ -379,7 +391,7 @@ function search_generate_td(tr, attr, value, entry_attrs)
function search_display(obj_name, data)
{
- var selector = '.search-container[title=' + obj_name + ']';
+ var selector = '.entity-container[title=' + obj_name + ']';
var thead = $(selector + ' thead');
var tbody = $(selector + ' tbody');
var tfoot = $(selector + ' tfoot');
diff --git a/install/static/service.js b/install/static/service.js
index 21b2d0b9..1b467cb5 100644
--- a/install/static/service.js
+++ b/install/static/service.js
@@ -126,36 +126,45 @@ function service_add_krbprincipalname(add_dialog, mode) {
}
ipa_entity_set_association_definition('service', {
- 'host': { method: 'add_host' }
+ 'host': { add_method: 'add_host', delete_host: 'remove_host' }
});
-function service_krbprincipalname_setup(container, dl, section) {
+function service_krbprincipalname_setup(container) {
// skip krbprincipalname
}
-function service_krbprincipalname_load(container, dt, result) {
+function service_krbprincipalname_load(container, result) {
// skip krbprincipalname
}
-function service_service_load(container, dt, result) {
+function service_service_load(container, result) {
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
+
var krbprincipalname = result['krbprincipalname'][0];
var service = krbprincipalname.replace(/\/.*$/, '');
var dd = ipa_create_first_dd(this.name, service);
dt.after(dd);
}
-function service_host_load(container, dt, result) {
+function service_host_load(container, result) {
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
+
var krbprincipalname = result['krbprincipalname'][0];
var host = krbprincipalname.replace(/^.*\//, '').replace(/@.*$/, '');
var dd = ipa_create_first_dd(this.name, host);
dt.after(dd);
}
-function service_provisioning_status_load(container, dt, result) {
+function service_provisioning_status_load(container, result) {
// skip provisioning_status
}
-function service_usercertificate_load(container, dt, result) {
+function service_usercertificate_load(container, result) {
+
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
var panel = certificate_status_panel({
'entity_type': 'service',
diff --git a/install/static/test/all_tests.html b/install/static/test/all_tests.html
index 50c5155d..64412b01 100644
--- a/install/static/test/all_tests.html
+++ b/install/static/test/all_tests.html
@@ -8,6 +8,7 @@
+
diff --git a/install/static/test/association_tests.js b/install/static/test/association_tests.js
index 05e43ce4..9f49abf7 100644
--- a/install/static/test/association_tests.js
+++ b/install/static/test/association_tests.js
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-test("Testing serial_associate().", function() {
+test("Testing serial_associator().", function() {
expect(10);
@@ -26,25 +26,25 @@ test("Testing serial_associate().", function() {
var counter = 0;
- var form = {
+ var params = {
method: "add_member",
pkey: "test",
- oneObj: "user",
- manyObj: "group"
+ entity_name: "user",
+ other_entity: "group"
};
- var manyObjPkeys = ['user1', 'user2', 'user3'];
+ params.values = ['user1', 'user2', 'user3'];
ipa_cmd = function(name, args, options, win_callback, fail_callback, objname) {
counter++;
equals(
- name, form.method,
+ name, params.method,
"Checking ipa_cmd() parameter: method"
);
equals(
- objname, form.manyObj,
+ objname, params.other_entity,
"Checking ipa_cmd() parameter: object name"
);
@@ -58,17 +58,17 @@ test("Testing serial_associate().", function() {
return 0;
};
- var on_success = function() {
+ params.on_success = function() {
ok(true, "on_success() is invoked.");
};
- var associator = serial_associate(form, manyObjPkeys, on_success);
- //associator.associateNext();
+ var associator = serial_associator(params);
+ associator.execute();
ipa_cmd = orig_ipa_cmd;
});
-test("Testing BulkAssociator().", function() {
+test("Testing bulk_associator().", function() {
expect(5);
@@ -76,36 +76,36 @@ test("Testing BulkAssociator().", function() {
var counter = 0;
- var form = {
+ var params = {
method: "add_member",
pkey: "test",
- oneObj: "user",
- manyObj: "group"
+ entity_name: "user",
+ other_entity: "group"
};
- var manyObjPkeys = ['user1', 'user2', 'user3'];
+ params.values = ['user1', 'user2', 'user3'];
ipa_cmd = function(name, args, options, win_callback, fail_callback, objname) {
counter++;
equals(
- name, form.method,
+ name, params.method,
"Checking ipa_cmd() parameter: method"
);
equals(
- objname, form.oneObj,
+ objname, params.entity_name,
"Checking ipa_cmd() parameter: object name"
);
equals(
- args[0], form.pkey,
+ args[0], params.pkey,
"Checking ipa_cmd() parameter: primary key"
);
equals(
- options[form.manyObj], "user1,user2,user3",
- "Checking ipa_cmd() parameter: options[\""+form.manyObj+"\"]"
+ options[params.other_entity], "user1,user2,user3",
+ "Checking ipa_cmd() parameter: options[\""+params.other_entity+"\"]"
);
var response = {};
@@ -113,12 +113,12 @@ test("Testing BulkAssociator().", function() {
return 0;
};
- var on_success = function() {
+ params.on_success = function() {
ok(true, "on_success() is invoked.");
};
- var associator = bulk_associate(form, manyObjPkeys, on_success);
- //associator.associateNext();
+ var associator = bulk_associator(params);
+ associator.execute();
ipa_cmd = orig_ipa_cmd;
});
diff --git a/install/static/test/details_tests.html b/install/static/test/details_tests.html
index e96fa4b7..3cb20c56 100644
--- a/install/static/test/details_tests.html
+++ b/install/static/test/details_tests.html
@@ -8,6 +8,7 @@
+
diff --git a/install/static/test/details_tests.js b/install/static/test/details_tests.js
index 4a60216e..8482f6df 100644
--- a/install/static/test/details_tests.js
+++ b/install/static/test/details_tests.js
@@ -19,45 +19,96 @@
*/
-test("Testing ipa_details_create().", function() {
+test("Testing ipa_details_section.setup().", function() {
- var name = 'NAMENAMENAME';
- var identity = 'IDIDID';
+ IPA.ajax_options.async = false;
+
+ IPA.init(
+ "data",
+ true,
+ function(data, text_status, xhr) {
+ ok(true, "ipa_init() succeeded.");
+ },
+ function(xhr, text_status, error_thrown) {
+ ok(false, "ipa_init() failed: "+error_thrown);
+ }
+ );
+
+ var result = {};
- var section = ipa_stanza({name:identity, label:name}).
+ var section = ipa_stanza({name:'IDIDID', label:'NAMENAMENAME'}).
input({name:'cn', label:'Entity Name'}).
input({name:'description', label:'Description'}).
input({name:'number', label:'Entity ID'});
- var details = section.fields;
- var parent = $("");
- var container = $("");
- parent.append(container);
- ipa_details_section_setup(parent,container, section);
+ var fields = section.fields;
+ var container = $("");
+ section.setup(container, result);
- ok(parent.find('hr').length);
+ var dl = container.find('dl');
- var h2= parent.find('h2');
- ok(h2.length);
- ok(h2[0].innerHTML.indexOf(name) > 1,"find name in html");
+ same(
+ dl.length, 1,
+ 'Checking dl tag'
+ );
+
+ same(
+ dl.attr('id'), section.name,
+ 'Checking section name'
+ );
+
+ var dts = $('dt', dl);
+ same(
+ dts.length, fields.length, // each field generates dt & dd
+ 'Checking number of children'
+ );
+
+ for (var i=0; i");
var obj_name = 'user';
ipa_entity_set_details_definition(obj_name, [
@@ -116,46 +168,42 @@ test("Testing details lifecycle:setup, load, save ().", function(){
var entity = ipa_get_entity(obj_name);
var facet = entity.get_facet('details');
- var sections = facet.get_sections();
- ipa_details_create(container, sections);
+ facet.create(container, result);
var contact = container.find('dl#contact.entryattrs');
- ok(contact);
- var identity = container.find('dl#identity.entryattrs');
- ok(identity);
- var dts= identity.find('dt');
- ok(dts);
- same(6, dts.length);
- same('initials',dts[5].title);
- //TODO extract into Fixture
- IPA.ajax_options.async = false;
- $.ajaxSetup(IPA.ajax_options);
- IPA.json_url = './data';
- IPA.use_static_files = true;
-
- container.attr('id','user');
-
- ok (setup_status_called , 'setup status called');
+ ok(
+ contact,
+ 'dl tag for contact is created'
+ );
+ var identity = container.find('dl#identity.entryattrs');
- ipa_details_load(container,
- 'kfrog',
- function(){load_success_called = true},
- function(){load_failure_called = true});
+ ok(
+ identity,
+ 'dl tag for identity is created'
+ );
- ok (load_success_called,'load success called');
- ok (!load_failure_called,'load failure not called');
+ var dts= identity.find('dt');
+ same(
+ dts.length, 6,
+ 'Checking dt tags for identity'
+ );
- ok (load_manager_called, 'load manager called');
+ same(
+ dts[5].title, facet.get_sections()[0].get_fields()[5].name,
+ 'Checking dt title'
+ );
+ container.attr('id','user');
- ipa_details_load(container,
- 'kfrog',
- function(){load_success_called = true},
- function(){load_failure_called = true});
+ ok (
+ setup_status_called,
+ 'Setup status called'
+ );
+ ok (load_manager_called, 'load manager called');
ipa_details_update(container,
'kfrog',
@@ -183,34 +231,3 @@ test("Testing _ipa_create_text_input().", function(){
same(text[0].value,value );
same(text[0].type,"text" );
});
-
-
-test("Testing ipa_details_section_setup()",function(){
-
- var section = ipa_stanza({name: 'IDIDID', label: 'NAMENAMENAME'}).
- input({name:'cn', label:'Entity Name'}).
- input({name:'description', label:'Description'}).
- input({name:'number', label:'Entity ID'});
- var fields = section.fields;
- var container = $("");
- var details = $("");
- container.append(details);
-
- ipa_details_section_setup(container, details, section);
-
- ok(container.find('hr'));
-
- var h2= container.find('h2');
- ok(h2);
- ok(h2[0].innerHTML.indexOf(section.label) > 1,"find name in html");
-
- var dl = container.find('dl');
- ok(dl);
- same(dl[0].children.length,3);
- same(dl[0].id, section.name);
- same(dl[0].children[0].title, fields[0].name);
- same(dl[0].children[0].innerHTML, fields[0].label+":");
- same(dl[0].children[2].title, fields[2].name);
- same(dl[0].children[2].innerHTML, fields[2].label+":");
-
-});
diff --git a/install/static/test/entity_tests.html b/install/static/test/entity_tests.html
index 0f796295..cd6b6409 100644
--- a/install/static/test/entity_tests.html
+++ b/install/static/test/entity_tests.html
@@ -7,6 +7,7 @@
+
diff --git a/install/static/test/entity_tests.js b/install/static/test/entity_tests.js
index cc43b879..08fc3111 100644
--- a/install/static/test/entity_tests.js
+++ b/install/static/test/entity_tests.js
@@ -170,7 +170,7 @@ test('Testing ipa_entity_quick_links().', function() {
var container = $('', {
title: obj_name,
- class: 'search-container'
+ class: 'entity-container'
});
var search_table = $('
', {
diff --git a/install/static/test/navigation_tests.html b/install/static/test/navigation_tests.html
index fa911d6e..16d095ac 100644
--- a/install/static/test/navigation_tests.html
+++ b/install/static/test/navigation_tests.html
@@ -7,6 +7,8 @@
+
+
diff --git a/install/static/user.js b/install/static/user.js
index 5645967d..1b6054d7 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -151,8 +151,10 @@ function on_lock_win(data, textStatus, xhr)
/* ATTRIBUTE CALLBACKS */
var toggle_temp = 'S Toggle';
-function user_status_load(container, dt, result)
-{
+function user_status_load(container, result) {
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
+
var memberof = result['memberof'];
var dd;
@@ -223,8 +225,10 @@ function resetpwd_on_click(){
return false;
}
-function user_password_load(container, dt, result)
-{
+function user_password_load(container, result) {
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
+
dt.after(ipa_create_first_dd(
this.name,
$('',{
@@ -245,8 +249,10 @@ var states = [
'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA',
'WA', 'WV', 'WI', 'WY', ''
];
-function user_state_load(container, dt, result)
-{
+function user_state_load(container, result) {
+ var dt = $('dt[title='+this.name+']', container);
+ if (!dt.length) return;
+
var next = dt.next();
next.css('clear', 'none');
next.css('width', '70px');
diff --git a/install/static/widget.js b/install/static/widget.js
new file mode 100755
index 00000000..bf893e04
--- /dev/null
+++ b/install/static/widget.js
@@ -0,0 +1,473 @@
+/* Authors:
+ * Endi Sukma Dewata
+ *
+ * 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 */
+
+function ipa_widget(spec) {
+
+ spec = spec || {};
+
+ var that = {};
+
+ that.id = spec.id;
+ that.name = spec.name;
+ that.label = spec.label;
+ that.read_only = spec.read_only;
+ that._entity_name = spec.entity_name;
+
+ that.create = spec.create || create;
+ that.setup = spec.setup || setup;
+ that.load = spec.load || load;
+ that.save = spec.save || save;
+
+ that.super = function(name) {
+ var method = that[name];
+ return function () {
+ return method.apply(that, arguments);
+ };
+ };
+
+ that.__defineGetter__("entity_name", function(){
+ return that._entity_name;
+ });
+
+ that.__defineSetter__("entity_name", function(entity_name){
+ that._entity_name = entity_name;
+ });
+
+ function create(container) {
+ }
+
+ function setup(container) {
+ }
+
+ function load(container, result) {
+ }
+
+ function save(container) {
+ return [];
+ }
+
+ return that;
+}
+
+function ipa_text_widget(spec) {
+
+ spec = spec || {};
+
+ spec.setup = spec.setup || setup;
+ spec.load = spec.load || load;
+ spec.save = spec.save || save;
+
+ var that = ipa_widget(spec);
+
+ function setup(container) {
+ }
+
+ function load(container, result) {
+ that.value = result[that.name] || '';
+ var input = $('input[name="'+that.name+'"]', container);
+
+ var param_info = ipa_get_param_info(that.entity_name, that.name);
+ if (param_info.primary_key) {
+ input.replaceWith($('', { 'html': that.value.toString() }));
+
+ } else {
+ input.val(that.value);
+ }
+ }
+
+ function save(container) {
+ var values = [];
+
+ if (that.value) {
+ values.push(that.value);
+
+ } else {
+ var input = $('input[name="'+that.name+'"]', container);
+ values.push(input.val());
+ }
+
+ return values;
+ }
+
+ return that;
+}
+
+function ipa_radio_widget(spec) {
+
+ spec = spec || {};
+
+ spec.setup = spec.setup || setup;
+ spec.load = spec.load || load;
+ spec.save = spec.save || save;
+
+ var that = ipa_widget(spec);
+
+ function setup(container) {
+ }
+
+ function load(container, result) {
+ var value = result[that.name] || '';
+ $('input[name="'+that.name+'"][value="'+value+'"]', container).attr('checked', 'checked');
+ }
+
+ function save(container) {
+ var values = [];
+
+ var value = $('input[name="'+that.name+'"]:checked', container).val();
+ values.push(value);
+
+ return values;
+ }
+
+ return that;
+}
+
+function ipa_textarea_widget(spec) {
+
+ spec = spec || {};
+
+ spec.setup = spec.setup || setup;
+ spec.load = spec.load || load;
+ spec.save = spec.save || save;
+
+ var that = ipa_widget(spec);
+
+ function setup(container) {
+ }
+
+ function load(container, result) {
+ var value = result[that.name] || '';
+ $('textarea[name="'+that.name+'"]', container).val(value);
+ }
+
+ function save(container) {
+ var values = [];
+
+ var value = $('textarea[name="'+that.name+'"]', container).val();
+ values.push(value);
+
+ return values;
+ }
+
+ return that;
+}
+
+function ipa_button_widget(spec) {
+
+ spec = spec || {};
+
+ spec.setup = spec.setup || setup;
+ spec.load = spec.load || load;
+ spec.save = spec.save || save;
+
+ var that = ipa_widget(spec);
+
+ that.click = spec.click;
+
+ function setup(container) {
+ var input = $('[name="'+that.name+'"]', container);
+ input.replaceWith(ipa_button({ 'label': that.label, 'click': that.click }));
+ }
+
+ function load(container, result) {
+ }
+
+ function save(container) {
+ var values = [];
+ return values;
+ }
+
+ return that;
+}
+
+function ipa_column_widget(spec) {
+
+ spec = spec || {};
+
+ var that = ipa_widget(spec);
+
+ that.primary_key = spec.primary_key;
+ that.link = spec.link;
+
+ return that;
+}
+
+function ipa_table_widget(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);
+
+ that.add = spec.add;
+ that.remove = spec.remove;
+
+ that.columns = [];
+ that.columns_by_name = {};
+
+ that.get_columns = function() {
+ return that.columns;
+ };
+
+ that.get_column = function(name) {
+ return that.columns_by_name[name];
+ };
+
+ that.add_column = function(column) {
+ column.entity_name = that.entity_name;
+ that.columns.push(column);
+ that.columns_by_name[column.name] = column;
+ };
+
+ that.create_column = function(spec) {
+ var column = ipa_column_widget(spec);
+ that.add_column(column);
+ return column;
+ };
+
+ function create(container) {
+
+ var div = $('#'+that.id, container);
+ if (div.children().length) {
+ // widget loaded from template
+ return;
+ }
+
+ div.empty();
+
+ var table = $('
', {
+ 'class': 'search-table'
+ }).appendTo(div);
+
+ var thead = $('').appendTo(table);
+
+ var tr = $('