entity i18n

Updated the user,group,host, hostgroup, netgroup, service, and all policy
entities to use the newer framework functions, in order to
replaced the old array style definitions which did not support i18n.
update a few of the newer framerwork functions to get the lables from the
meta data.

Fixed the unit tests which were expecting a details facet for users,
no longer automatically created
This commit is contained in:
Adam Young 2010-12-04 00:29:05 -05:00 committed by Endi Sukma Dewata
parent 37f48c0019
commit 10f3c0825b
11 changed files with 369 additions and 220 deletions

View File

@ -338,7 +338,7 @@ function ipa_details_list_section(spec){
}
};
// Deprecated: Used for backward compatibility only.
// This is to allow declarative style programming for details
function input(spec){
that.create_field(spec);
return that;
@ -349,7 +349,7 @@ function ipa_details_list_section(spec){
return that;
}
// Deprecated: Used for backward compatibility only.
// shorthand notation used for declarative definitions of details pages
function ipa_stanza(spec) {
return ipa_details_list_section(spec);
}

View File

@ -89,10 +89,14 @@ function ipa_group_add_dialog(spec) {
that.add_dialog_init();
that.add_field(ipa_text_widget({name:'cn', label:'Name', undo: false}));
that.add_field(ipa_text_widget({name:'description', label:'Description', undo: false}));
that.add_field(ipa_checkbox_widget({name:'posix', label:'Is this a POSIX group?', undo: false}));
that.add_field(ipa_text_widget({name:'gidnumber', label:'GID', undo: false}));
that.add_field(ipa_text_widget({name:'cn', entity_name:'group',
undo: false}));
that.add_field(ipa_text_widget({name:'description',
entity_name:'group', undo: false}));
that.add_field(ipa_checkbox_widget({name:'posix', entity_name:'group',
undo: false}));
that.add_field(ipa_text_widget({name:'gidnumber', entity_name:'group',
undo: false}));
};
return that;
@ -105,11 +109,9 @@ function ipa_group_search_facet(spec) {
var that = ipa_search_facet(spec);
that.init = function() {
that.create_column({name:'cn', label:'Name'});
that.create_column({name:'gidnumber', label:'GID'});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'cn'});
that.create_column({name:'gidnumber'});
that.create_column({name:'description'});
that.search_facet_init();
};
@ -130,20 +132,9 @@ function ipa_group_details_facet(spec) {
});
that.add_section(section);
section.create_field({
name: 'cn',
label: 'Group Name'
});
section.create_field({
name: 'description',
label: 'Description'
});
section.create_field({
name: 'gidnumber',
label: 'Group ID'
});
section.create_field({name: 'cn' });
section.create_field({name: 'description'});
section.create_field({name: 'gidnumber' });
that.details_facet_init();
};

View File

@ -87,7 +87,7 @@ function ipa_host_add_dialog(spec) {
that.add_field(ipa_text_widget({
'name': 'fqdn',
'label': 'Name',
entity_name:'host',
'size': 40,
'undo': false
}));
@ -104,10 +104,11 @@ function ipa_host_search_facet(spec) {
that.init = function() {
that.create_column({name:'fqdn', label:'Name'});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'enrolled', label:'Enrolled?'});
that.create_column({name:'manages', label:'Manages?'});
that.create_column({name:'fqdn'});
that.create_column({name:'description'});
//TODO use the value of this field to set enrollment status
that.create_column({name:'krblastpwdchange', label:'Enrolled?'});
that.create_column({name:'nshostlocation'});
that.search_facet_init();
};
@ -129,25 +130,16 @@ function ipa_host_details_facet(spec) {
});
that.add_section(section);
section.create_field({
'name': 'fqdn',
'label': 'Fully Qualified Domain Name'
});
section.create_field({
'name': 'krbprincipalname',
'label': 'Kerberos Principal'
});
section.create_field({'name': 'fqdn'});
section.create_field({'name': 'krbprincipalname'});
//TODO add this to the host plugin
section.create_field({
'name': 'serverhostname',
'label': 'Server Host Name'
});
section.create_field({
'name': 'description',
'label': 'Description'
});
section.create_field({'name': 'description'});
section = ipa_details_list_section({
'name': 'enrollment',
@ -155,6 +147,7 @@ function ipa_host_details_facet(spec) {
});
that.add_section(section);
//TODO add label to messages
section.add_field(host_provisioning_status_widget({
'name': 'provisioning_status',
'label': 'Status',

View File

@ -20,23 +20,48 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
ipa_entity_set_search_definition('hostgroup', [
['cn', 'Name', null],
['description', 'Description', null]
]);
ipa_entity_set_add_definition('hostgroup', [
'dialog-add-hostgroup', 'Add New Hostgroup', [
['cn', 'Name', null],
['description', 'Description', null]
]
]);
IPA.add_entity( function() {
var that = ipa_entity({
'name': 'hostgroup'
});
that.init = function() {
var search_facet = ipa_search_facet({
name: 'search',
label: 'Search',
entity_name: that.name
});
search_facet.create_column({name:'cn'});
search_facet.create_column({name:'description'});
that.add_facet(search_facet);
that.add_facet(function() {
var that = ipa_details_facet({name:'details',label:'Details'});
that.add_section(
ipa_stanza({name:'identity', label:'Hostgroup Details'}).
input({name:'cn'}).
input({name: 'description'}));
return that;
}());
var dialog = ipa_add_dialog({
name: 'add',
title: 'Add Hostgroup',
entity_name:'hostgroup'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'cn',
entity_name:'hostgroup'}));
dialog.add_field(ipa_text_widget({ name: 'description',
entity_name:'hostgroup' }));
that.create_association_facets();
that.entity_init();
}
return that;
}());
ipa_entity_set_details_definition('hostgroup', [
ipa_stanza({name:'identity', label:'Hostgroup Details'}).
input({name:'cn', label:'Name'}).
input({name: 'description', label:'Description'})
]);
ipa_entity_set_association_definition('hostgroup', {
});

View File

@ -20,24 +20,48 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
ipa_entity_set_search_definition('netgroup', [
['cn', 'Name', null],
['description', 'Description', null]
]);
IPA.add_entity( function() {
var that = ipa_entity({
'name': 'netgroup'
});
that.init = function() {
var search_facet = ipa_search_facet({
name: 'search',
label: 'Search',
entity_name: that.name
});
search_facet.create_column({name:'cn'});
search_facet.create_column({name:'description'});
that.add_facet(search_facet);
that.add_facet(function() {
var that = ipa_details_facet({name:'details',label:'Details'});
that.add_section(
ipa_stanza({name:'identity', label:'Netgroup Details'}).
input({name:'cn'}).
input({name: 'description'}).
input({name:'nisdomainname'}));
return that;
}());
var dialog = ipa_add_dialog({
name: 'add',
title: 'Add Netgroup',
entity_name:'netgroup'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'cn',
entity_name:'netgroup'}));
dialog.add_field(ipa_text_widget({ name: 'description',
entity_name:'netgroup' }));
that.create_association_facets();
that.entity_init();
}
return that;
}());
ipa_entity_set_add_definition('netgroup', [
'dialog-add-netgroup', 'Add New Netgroup', [
['cn', 'Name', null],
['description', 'Description', null]
]
]);
ipa_entity_set_details_definition('netgroup', [
ipa_stanza({name:'identity', label:'Netgroup Details'}).
input({name:'cn', label:'Name'}).
input({name:'description', label:'Description'}).
input({name:'nisdomainname', label:'NIS Domain'})
]);
ipa_entity_set_association_definition('netgroup', {
});

View File

@ -21,46 +21,72 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
/* DNS */
ipa_entity_set_search_definition('dnszone', [
['idnsname', 'Zone Name', null]
]);
IPA.add_entity(function (){
var that = ipa_entity({
name: 'dnszone'
});
that.init = function() {
var search_facet = ipa_search_facet({
name: 'search',
label: 'Search',
entity_name: that.name
});
search_facet.create_column({name:'idnsname'});
that.add_facet(search_facet);
that.add_facet(function() {
var that = ipa_details_facet({name:'details',label:'Details'});
that.add_section(
ipa_stanza({name:'identity', label:'DNS Zone Details'}).
input({name:'idnsname'}).
input({name:'idnszoneactive'}).
input({name:'idnssoamname'}).
input({name:'idnssoarname'}).
input({name:'idnssoaserial'}).
input({name:'idnssoarefresh'}).
input({name:'idnssoaretry'}).
input({name:'idnssoaexpire'}).
input({name:'idnssoaminimum'}).
input({name:'dnsttl'}).
input({name:'dnsclass'}).
input({name:'idnsallowdynupdate'}).
input({name:'idnsupdatepolicy'}));
return that;
}());
that.add_facet( ipa_records_facet({
'name': 'records',
'label': IPA.metadata.dnsrecord.label
}));
var dialog = ipa_add_dialog({
name: 'add',
title: 'Add DNS Zone',
entity_name:'dnszone'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'idnsname',
entity_name:'dnszone'}));
dialog.add_field(ipa_text_widget({ name: 'idnssoamname',
entity_name:'dnszone'}));
dialog.add_field(ipa_text_widget({ name: 'idnssoarname',
entity_name:'dnszone'}));
that.create_association_facets();
that.entity_init();
}
ipa_entity_set_add_definition('dnszone', [
'dialog-add-dns', 'Add New Zone', [
['idnsname', 'Name', null],
['idnssoamname', 'Authoritative name server'],
['idnssoarname','administrator e-mail address']
]
]);
ipa_entity_set_details_definition('dnszone', [
ipa_stanza({name:'identity', label:'DNS Zone Details'}).
input({name:'idnsname', label:'DNS Name'}).
input({name:'idnszoneactive', label:'Zone Active'}).
input({name:'idnssoamname', label:'Authoritative name server'}).
input({name:'idnssoarname', label:'administrator e-mail address'}).
input({name:'idnssoaserial', label:'SOA serial'}).
input({name:'idnssoarefresh', label:'SOA refresh'}).
input({name:'idnssoaretry', label:'SOA retry'}).
input({name:'idnssoaexpire', label:'SOA expire'}).
input({name:'idnssoaminimum', label:'SOA minimum'}).
input({name:'dnsttl', label:'SOA time to live'}).
input({name:'dnsclass', label:'SOA class'}).
input({name:'idnsallowdynupdate', label:'allow dynamic update?'}).
input({name:'idnsupdatepolicy', label:'BIND update policy'})
]);
ipa_entity_set_association_definition('dnszone', {
});
return that;
}());
ipa_entity_set_facet_definition('dnszone', [
ipa_records_facet({
'name': 'records',
'label': 'Records'
})]
);
function ipa_records_facet(spec){
@ -256,7 +282,6 @@ function ipa_records_facet(spec){
};
function create(container) {
// that.setup_views(container);
}
function setup(container){
@ -322,9 +347,6 @@ function ipa_records_facet(spec){
'click': function(){delete_records(records_table);}
}).appendTo(action_controls);
div.append('<span class="records-buttons"></span>');
var records_results = $('<div/>', {
@ -349,8 +371,9 @@ function ipa_records_facet(spec){
}
})
));
tr.append($('<th>Resource</th>'));
tr.append($('<th>Record Type</th>'));
tr.append($('<th/>',{
text: ipa_get_param_info("dnsrecord", "idnsname").label }));
tr.append($('<th>Record Type</th>'));
tr.append($('<th>Data</th>'));
refresh();
@ -472,50 +495,97 @@ function ipa_records_facet(spec){
/**Automount*/
ipa_entity_set_search_definition('automountlocation', [
['cn', 'Name', null]
]);
IPA.add_entity(function (){
var that = ipa_entity({
name: 'automountlocation'
});
ipa_entity_set_add_definition('automountlocation', [
'dialog-add-location', 'Add New Location', [
['cn', 'Name', null]
]
]);
ipa_entity_set_details_definition('automountlocation', [
ipa_stanza({name:'identity', label:'Automount Location Details'}).
input({name:'cn', label:'Automount Location'})
]);
var search_facet = ipa_search_facet({
name: 'search',
label: 'Search',
entity_name: that.name
});
that.init = function() {
search_facet.create_column({name:'cn'});
that.add_facet(search_facet);
ipa_entity_set_association_definition('automountlocation', {
});
that.add_facet(function() {
var that = ipa_details_facet({name:'details',label:'Details'});
that.add_section(
ipa_stanza({name:'identity', label:'Automount Location Details'}).
input({name:'cn'}));
return that;
}());
var dialog = ipa_add_dialog({
name: 'add',
title: 'Add Automount Location',
entity_name:'automountlocation'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'cn',
entity_name:'automountlocation'}));
that.create_association_facets();
that.entity_init();
}
return that;
}());
/**pwpolicy*/
ipa_entity_set_search_definition('pwpolicy', [
['cn', 'Name', null]
]);
IPA.add_entity(function (){
var that = ipa_entity({
name: 'pwpolicy'
});
ipa_entity_set_add_definition('pwpolicy', [
'dialog-add-dns', 'Add New Location', [
['cn', 'Name', null]
]
]);
ipa_entity_set_details_definition('pwpolicy', [
ipa_stanza({name:'identity', label:'Password Policy'}).
input({name:'krbmaxpwdlife',label:'Max Password Life'}).
input({name:'krbminpwdlife',label:'Min Password Life'}).
input({name:'krbpwdhistorylength',label:'Password History Length'}).
input({name:'krbpwdmindiffchars',
label:'Min Different Characters'}).
input({name:'krbpwdminlength', label:'Password Minimum Length'})
]);
var search_facet = ipa_search_facet({
name: 'search',
label: 'Search',
entity_name: that.name
});
that.init = function() {
search_facet.create_column({name:'cn'});
that.add_facet(search_facet);
that.add_facet(function() {
var that = ipa_details_facet({name:'details',label:'Details'});
that.add_section(
ipa_stanza({name:'identity', label:'Password Policy'}).
input({name:'krbmaxpwdlife'}).
input({name:'krbminpwdlife'}).
input({name:'krbpwdhistorylength'}).
input({name:'krbpwdmindiffchars'}).
input({name:'krbpwdminlength'}));
return that;
}());
var dialog = ipa_add_dialog({
name: 'add',
title: 'Add Password Policy',
entity_name:'pwpolicy'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'cn',
entity_name:'pwpolicy'}));
that.create_association_facets();
that.entity_init();
}
return that;
}());
ipa_entity_set_association_definition('pwpolicy', {
});
/**
@ -525,9 +595,9 @@ ipa_entity_set_association_definition('pwpolicy', {
ipa_entity_set_details_definition('krbtpolicy', [
ipa_stanza({name:'identity', label:'Krbtpolicy Location Details'}).
input({name:'cn', label:'Krbtpolicy Location'}).
input({name:'krbmaxrenewableage', label:'Max Renewable Age'}).
input({name:'krbmaxticketlife', label:'Max Ticket Life'})
input({name:'cn'}).
input({name:'krbmaxrenewableage'}).
input({name:'krbmaxticketlife'})
]);
IPA.get_entity('krbtpolicy').default_facet = 'details';

View File

@ -285,6 +285,13 @@ function ipa_search_facet(spec) {
};
that.create_column = function(spec) {
if (!spec.label){
var param_info = ipa_get_param_info(this.entity_name, spec.name);
if (param_info){
spec.label = param_info.label;
}
}
var column = ipa_column(spec);
that.add_column(column);
return column;

View File

@ -80,7 +80,6 @@ function ipa_service_add_dialog(spec) {
that.add_field(ipa_widget({
name: 'krbprincipalname',
label: 'Principal'
}));
that.add_field(ipa_text_widget({
@ -159,7 +158,7 @@ function ipa_service_search_facet(spec) {
that.init = function() {
that.create_column({name:'krbprincipalname', label:'Principal'});
that.create_column({name:'krbprincipalname'});
that.search_facet_init();
};
@ -181,8 +180,7 @@ function ipa_service_details_facet(spec) {
that.add_section(section);
section.create_field({
name: 'krbprincipalname',
label: 'Principal'
name: 'krbprincipalname'
});
section.create_field({

View File

@ -109,8 +109,12 @@ test('Testing ipa_facet_setup_views().', function() {
var views = ul.children();
/*5 Views:
one for each of 3 associations
one for search
a blank one for the action controls*/
equals(
views.length, 6,
views.length, 5,
'Checking number of views'
);
@ -142,7 +146,8 @@ test('Testing ipa_facet_setup_views().', function() {
var search_facets = $('li.search-facet', action_panel);
equals(search_facets.length,1,'one search facet in action panel');
var entity_facets = $('li.entity-facet', action_panel);
equals(entity_facets.length,4,'4 entity facets in action panel');
/*No longer automatically adding details, so ony the assoc. facets */
equals(entity_facets.length,3,'3 entity facets in action panel');
for ( var entity_facet = entity_facets.first();

View File

@ -20,71 +20,99 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
ipa_entity_set_search_definition('user', [
['cn', 'Name', null],
['uid', 'Login', null],
['uidnumber', 'UID', null],
['mail', 'EMAIL', null],
['telephonenumber', 'Phone', null],
['title', 'Job Title', null]
]);
ipa_entity_set_add_definition('user', [
'dialog-add-user', 'Add New User', [
['uid', 'Login', null],
['givenname', 'First Name', null],
['sn', 'Last Name', null]
]
]);
function ipa_user(){
var that = ipa_entity({
name: 'user'
});
that.init = function() {
var search_facet = ipa_search_facet({
'name': 'search',
'label': 'Search',
entity_name: that.name
});
search_facet.create_column({name:'cn'});
search_facet.create_column({name:'uid'});
search_facet.create_column({name:'uidnumber'});
search_facet.create_column({name:'mail'});
search_facet.create_column({name:'telephonenumber'});
search_facet.create_column({name:'title'});
that.add_facet(search_facet);
ipa_entity_set_details_definition('user', [
ipa_stanza({name:'identity', label:'Identity Details'}).
input({name:'title', label: 'Title'}).
input({name:'givenname'}).
input({name:'sn'}).
input({name:'cn', label:'Full Name'}).
input({name:'displayname', label:'Display Name'}).
input({name:'initials', label:'Initials'}),
ipa_stanza({name:'account', label:'Account Details'}).
input({name:'nsaccountlock', label:'Account Status',
load:user_status_load}).
input({name:'uid'}).
input({name:'userpassword',
load: user_password_load}).
input({name:'uidnumber'}).
input({name:'gidnumber', label:'GID'}).
input({name:'loginshell'}).
input({name:'homedirectory'}),
ipa_stanza({name:'contact', label:'Contact Details'}).
input({name:'mail'}).
input({name:'telephonenumber'}).
input({name:'pager'}).
input({name:'mobile'}).
input({name:'facsimiletelephonenumber'}),
ipa_stanza({name:'address', label:'Mailing Address'}).
input({name:'street'}).
input({name:'location', label:'City'}).
input({name:'state', label:'State', load:user_state_load}).
input({name:'postalcode', label:'ZIP'}),
ipa_stanza({name:'employee', label:'Employee Information'}).
input({name:'ou', label:'Org. Unit'}).
input({name:'manager', label:'Manager'}),
ipa_stanza({name:'misc', label:'Misc. Information'}).
input({name:'carlicense', label:'Car License'})
]);
that.add_facet(details_facet({name:'details',label:'Details'}));
var dialog = ipa_add_dialog({
'name': 'add',
'title': 'Add User'
});
that.add_dialog(dialog);
dialog.init();
dialog.add_field(ipa_text_widget({ name: 'uid',entity_name:'user' }));
dialog.add_field(ipa_text_widget({ name: 'givenname',
entity_name:'user' }));
dialog.add_field(ipa_text_widget({ name: 'sn',entity_name:'user' }));
/*eventually, we need to call
entity.create_association_facets();
but we are currently defining the associator using the global
function after the registration of the entity */
that.entity_init();
}
function details_facet(spec) {
spec = spec || {};
var that = ipa_details_facet(spec);
var sections =[
ipa_stanza({name:'identity', label:'Identity Details'}).
input({name:'title'}).
input({name:'givenname'}).
input({name:'sn'}).
input({name:'cn'}).
input({name:'displayname'}).
input({name:'initials'}),
ipa_stanza({name:'account', label:'Account Details'}).
input({name:'nsaccountlock', load:user_status_load}).
input({name:'uid'}).
input({name:'userpassword', load: user_password_load}).
input({name:'uidnumber'}).
input({name:'gidnumber'}).
input({name:'loginshell'}).
input({name:'homedirectory'}),
ipa_stanza({name:'contact', label:'Contact Details'}).
input({name:'mail'}).
input({name:'telephonenumber'}).
input({name:'pager'}).
input({name:'mobile'}).
input({name:'facsimiletelephonenumber'}),
ipa_stanza({name:'address', label:'Mailing Address'}).
input({name:'street'}).
input({name:'location'}).
input({name:'state', load:user_state_load}).
input({name:'postalcode'}),
ipa_stanza({name:'employee', label:'Employee Information'}).
input({name:'ou', label:'Org. Unit'}).
input({name:'manager'}),
ipa_stanza({name:'misc', label:'Misc. Information'}).
input({name:'carlicense'})
];
for (var i = 0; i < sections.length; i += 1){
that.add_section(sections[i]);
}
return that;
}
return that;
}
IPA.add_entity(ipa_user());
ipa_entity_set_association_definition('user', {
'group': { associator: 'serial' },
'netgroup': { associator: 'serial' },
'rolegroup': { associator: 'serial' },
'taskgroup': { associator: 'serial' }
});
/* ATTRIBUTE CALLBACKS */

View File

@ -28,10 +28,18 @@ function ipa_widget(spec) {
that.id = spec.id;
that.name = spec.name;
that.label = spec.label;
that.label = spec.label ;
that.read_only = spec.read_only;
that._entity_name = spec.entity_name;
if (spec.entity_name && ! spec.label){
var param_info = ipa_get_param_info(spec.entity_name, spec.name);
if (param_info){
that.label = param_info.label;
}
}
that.width = spec.width;
that.height = spec.height;