Added extensible UI framework.

The entity definitions have been converted into classes. The entity
init() method will use the builder to construct the facets and dialogs.
The UI can be customized by creating a subclass of the original entity
in extension.js and then overriding the init() method.

Ticket #2043
This commit is contained in:
Endi S. Dewata 2011-11-02 14:07:07 -05:00 committed by Petr Vobornik
parent 5db9fed8a5
commit 8ca348b99e
17 changed files with 355 additions and 198 deletions

View File

@ -23,11 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.permission = function() {
IPA.aci = {};
return IPA.entity_builder().
entity('permission').
facet_groups([ 'privilege' , 'settings' ]).
IPA.aci.permission_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.facet_groups([ 'privilege' , 'settings' ]).
search_facet({
columns:['cn']
}).
@ -78,15 +82,19 @@ IPA.entity_factories.permission = function() {
label: IPA.messages.objects.permission.target
}
]
}).
build();
});
};
return that;
};
IPA.aci.privilege_entity = function(spec) {
IPA.entity_factories.privilege = function() {
return IPA.entity_builder().
entity('privilege').
facet_groups([ 'role', 'settings', 'permission' ]).
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.facet_groups([ 'role', 'settings', 'permission' ]).
search_facet({
columns: [
'cn',
@ -130,16 +138,19 @@ IPA.entity_factories.privilege = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.aci.role_entity = function(spec) {
IPA.entity_factories.role = function() {
return IPA.entity_builder().
entity('role').
facet_groups([ 'member', 'settings', 'privilege' ]).
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.facet_groups([ 'member', 'settings', 'privilege' ]).
search_facet({
columns: [
'cn',
@ -176,15 +187,19 @@ IPA.entity_factories.role = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.aci.selfservice_entity = function(spec) {
IPA.entity_factories.selfservice = function() {
return IPA.entity_builder().
entity('selfservice').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns:['aciname']}).
details_facet({
sections:[{
@ -204,15 +219,19 @@ IPA.entity_factories.selfservice = function() {
object_type:'user',
name:'attrs'
}]
}).
build();
});
};
return that;
};
IPA.aci.delegation_entity = function(spec) {
IPA.entity_factories.delegation = function() {
return IPA.entity_builder().
entity('delegation').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns:['aciname']}).
details_facet({sections:[
{
@ -261,8 +280,10 @@ IPA.entity_factories.delegation = function() {
object_type: 'user',
join: true
}]
}).
build();
});
};
return that;
};
@ -738,3 +759,9 @@ IPA.target_section = function(spec) {
return that;
};
IPA.register('permission', IPA.aci.permission_entity);
IPA.register('privilege', IPA.aci.privilege_entity);
IPA.register('role', IPA.aci.role_entity);
IPA.register('selfservice', IPA.aci.selfservice_entity);
IPA.register('delegation', IPA.aci.delegation_entity);

View File

@ -23,13 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.automount = {};
/**Automount*/
IPA.automount.location_entity = function(spec) {
IPA.entity_factories.automountlocation = function() {
return IPA.entity_builder().
entity({ name: 'automountlocation' }).
facet_groups([ 'automountmap', 'settings' ]).
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.facet_groups([ 'automountmap', 'settings' ]).
search_facet({
title: IPA.metadata.objects.automountlocation.label,
columns:['cn']
@ -52,14 +54,19 @@ IPA.entity_factories.automountlocation = function() {
}).
adder_dialog({
fields: [ 'cn' ]
}).
build();
});
};
return that;
};
IPA.entity_factories.automountmap = function() {
return IPA.entity_builder().
entity({ name: 'automountmap' }).
containing_entity('automountlocation').
IPA.automount.map_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.containing_entity('automountlocation').
facet_groups([ 'automountkey', 'settings' ]).
nested_search_facet({
facet_group: 'automountkey',
@ -135,14 +142,19 @@ IPA.entity_factories.automountmap = function() {
]
}
]
}).
build();
});
};
return that;
};
IPA.entity_factories.automountkey = function() {
return IPA.entity_builder().
entity({ name: 'automountkey' }).
containing_entity('automountmap').
IPA.automount.key_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.containing_entity('automountmap').
details_facet({
sections: [
{
@ -188,8 +200,10 @@ IPA.entity_factories.automountkey = function() {
return false;
},
fields:['automountkey','automountinformation']
}).
build();
});
};
return that;
};
IPA.automount_key_column = function(spec) {
@ -275,3 +289,7 @@ IPA.get_option_values = function(){
});
return values;
};
IPA.register('automountlocation', IPA.automount.location_entity);
IPA.register('automountmap', IPA.automount.map_entity);
IPA.register('automountkey', IPA.automount.key_entity);

View File

@ -23,8 +23,11 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js, widget.js */
/* DNS */
IPA.entity_factories.dnszone = function() {
IPA.dns = {};
IPA.dns.zone_entity = function(spec) {
var that = IPA.entity(spec);
if (!IPA.dns_enabled) {
var except = {
@ -33,9 +36,9 @@ IPA.entity_factories.dnszone = function() {
throw except;
}
return IPA.entity_builder().
entity('dnszone').
facet_groups([ 'dnsrecord', 'settings' ]).
that.init = function(params) {
params.builder.facet_groups([ 'dnsrecord', 'settings' ]).
search_facet({
title: IPA.metadata.objects.dnszone.label,
columns: [ 'idnsname' ]
@ -140,8 +143,10 @@ IPA.entity_factories.dnszone = function() {
]
}
]
}).
build();
});
};
return that;
};
IPA.dnszone_details_facet = function(spec) {
@ -429,7 +434,9 @@ IPA.dns_record_search_load = function (result) {
}
};
IPA.entity_factories.dnsrecord = function() {
IPA.dns.record_entity = function(spec) {
var that = IPA.entity(spec);
if (!IPA.dns_enabled) {
var except = {
@ -438,9 +445,9 @@ IPA.entity_factories.dnsrecord = function() {
throw except;
}
return IPA.entity_builder().
entity('dnsrecord').
containing_entity('dnszone').
that.init = function(params) {
params.builder.containing_entity('dnszone').
details_facet({
post_update_hook:function(data){
var result = data.result.result;
@ -604,8 +611,10 @@ IPA.entity_factories.dnsrecord = function() {
required: true
}
]
}).
build();
});
};
return that;
};
IPA.dnsrecord_redirection_dialog = function(spec) {
@ -710,3 +719,6 @@ IPA.dnsrecord_get_delete_values = function() {
return value_array;
};
IPA.register('dnszone', IPA.dns.zone_entity);
IPA.register('dnsrecord', IPA.dns.record_entity);

View File

@ -29,16 +29,17 @@ IPA.entitle.unregistered = 'unregistered';
IPA.entitle.online = 'online';
IPA.entitle.offline = 'offline';
IPA.entity_factories.entitle = function() {
IPA.entitle.entity = function(spec) {
var builder = IPA.entity_builder();
spec = spec || {};
builder.
entity({
factory: IPA.entitle.entity,
name: 'entitle'
}).
facet_groups([ 'account', 'certificates' ]).
var that = IPA.entity(spec);
that.status = IPA.entitle.unregistered;
that.init = function(params) {
params.builder.facet_groups([ 'account', 'certificates' ]).
details_facet({
factory: IPA.entitle.details_facet,
label: IPA.messages.objects.entitle.account,
@ -171,17 +172,7 @@ IPA.entity_factories.entitle = function() {
}
]
});
return builder.build();
};
IPA.entitle.entity = function(spec) {
spec = spec || {};
var that = IPA.entity(spec);
that.status = IPA.entitle.unregistered;
};
that.get_accounts = function(on_success, on_error) {
@ -751,3 +742,5 @@ IPA.entitle.download_widget = function(spec) {
return that;
};
IPA.register('entitle', IPA.entitle.entity);

View File

@ -52,6 +52,9 @@ IPA.entity = function(spec) {
that.redirect_facet = spec.redirect_facet;
that.containing_entity = null;
that.init = function(params) {
};
that.get_containing_entity = function() {
return that.containing_entity ?
IPA.get_entity(that.containing_entity) : null;
@ -282,7 +285,7 @@ IPA.nested_tabs = function(entity_name) {
return siblings;
};
IPA.entity_builder = function(){
IPA.entity_builder = function() {
var that = {};
@ -523,10 +526,7 @@ IPA.entity_builder = function(){
};
that.build = function(){
var item = entity;
entity = null;
return item;
return entity;
};
return that;

View File

@ -24,11 +24,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.group = function () {
IPA.group = {};
return IPA.entity_builder().
entity('group').
search_facet({
IPA.group.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'gidnumber',
@ -117,8 +121,10 @@ IPA.entity_factories.group = function () {
},
'gidnumber'
]
}).
build();
});
};
return that;
};
IPA.group_nonposix_checkbox_widget = function (spec) {
@ -136,7 +142,7 @@ IPA.group_nonposix_checkbox_widget = function (spec) {
return that;
};
IPA.group_adder_dialog = function (spec) {
IPA.group_adder_dialog = function(spec) {
spec = spec || {};
@ -161,3 +167,5 @@ IPA.group_adder_dialog = function (spec) {
return that;
};
IPA.register('group', IPA.group.entity);

View File

@ -23,10 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.hbacrule = function() {
return IPA.entity_builder().
entity('hbacrule').
search_facet({
IPA.hbac = {};
IPA.hbac.rule_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
search_all: true,
columns: [
'cn',
@ -39,14 +44,19 @@ IPA.entity_factories.hbacrule = function() {
}).
adder_dialog({
fields: [ 'cn' ]
}).
build();
});
};
return that;
};
IPA.entity_factories.hbacsvc = function() {
return IPA.entity_builder().
entity('hbacsvc').
search_facet({
IPA.hbac.service_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'description'
@ -99,15 +109,19 @@ IPA.entity_factories.hbacsvc = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.hbac.service_group_entity = function(spec) {
IPA.entity_factories.hbacsvcgroup = function() {
return IPA.entity_builder().
entity('hbacsvcgroup').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'description'
@ -159,8 +173,10 @@ IPA.entity_factories.hbacsvcgroup = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.hbacrule_details_facet = function(spec) {
@ -557,3 +573,7 @@ IPA.hbacrule_details_facet = function(spec) {
return that;
};
IPA.register('hbacrule', IPA.hbac.rule_entity);
IPA.register('hbacsvc', IPA.hbac.service_entity);
IPA.register('hbacsvcgroup', IPA.hbac.service_group_entity);

View File

@ -24,11 +24,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.host = function () {
IPA.host = {};
return IPA.entity_builder().
entity('host').
search_facet({
IPA.host.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'fqdn',
'description',
@ -166,8 +170,10 @@ IPA.entity_factories.host = function () {
}).
deleter_dialog({
factory: IPA.host_deleter_dialog
}).
build();
});
};
return that;
};
IPA.host_fqdn_section = function(spec) {
@ -779,3 +785,5 @@ IPA.host_certificate_status_widget = function (spec) {
return that;
};
IPA.register('host', IPA.host.entity);

View File

@ -22,12 +22,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.hostgroup = {};
IPA.entity_factories.hostgroup = function() {
IPA.hostgroup.entity = function(spec) {
return IPA.entity_builder().
entity('hostgroup').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'description'
@ -77,9 +80,10 @@ IPA.entity_factories.hostgroup = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.register('hostgroup', IPA.hostgroup.entity);

View File

@ -38,7 +38,7 @@
<script type="text/javascript" src="aci.js"></script>
<script type="text/javascript" src="entitle.js"></script>
<script type="text/javascript" src="extension.js"></script>
<script type="text/javascript" src="develop.js"></script>
<script type="text/javascript" src="webui.js"></script>

View File

@ -25,7 +25,7 @@
/* REQUIRES: jquery.ordered-map.js */
/*global $:true, location:true */
var IPA = ( function () {
var IPA = function() {
var that = {
jsonrpc_id: 0
@ -172,22 +172,37 @@ var IPA = ( function () {
batch.execute();
};
that.register = function(name, factory) {
that.entity_factories[name] = factory;
};
that.get_entities = function() {
return that.entities.values;
};
that.get_entity = function(name) {
var entity = that.entities.get(name);
if (!entity){
if (!entity) {
var factory = that.entity_factories[name];
if (!factory){
if (!factory) {
return null;
}
try {
entity = factory();
var builder = that.entity_builder();
builder.entity({
factory: factory,
name: name
});
entity = builder.build();
entity.init({
builder: builder
});
that.add_entity(entity);
} catch (e) {
if (e.expected){
/*expected exceptions thrown by builder just mean that
@ -256,7 +271,7 @@ var IPA = ( function () {
};
return that;
}());
}();
/**
* Call an IPA command over JSON-RPC.

View File

@ -22,11 +22,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.netgroup = function() {
IPA.netgroup = {};
return IPA.entity_builder().
entity('netgroup').
search_facet({
IPA.netgroup.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'description'
@ -76,6 +80,10 @@ IPA.entity_factories.netgroup = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.register('netgroup', IPA.netgroup.entity);

View File

@ -23,11 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
/**pwpolicy*/
IPA.entity_factories.pwpolicy = function() {
return IPA.entity_builder().
entity('pwpolicy').
search_facet({
IPA.pwpolicy = {};
IPA.pwpolicy.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns:['cn','cospriority']}).
details_facet({
sections:[
@ -63,18 +67,21 @@ IPA.entity_factories.pwpolicy = function() {
'cospriority'
],
height: 300
}).
build();
});
};
return that;
};
/**
krbtpolicy
Does not have search
*/
IPA.entity_factories.krbtpolicy = function() {
return IPA.entity_builder().
entity('krbtpolicy').
details_facet({
IPA.krbtpolicy = {};
IPA.krbtpolicy.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.details_facet({
title: IPA.metadata.objects.krbtpolicy.label,
sections: [
{
@ -86,6 +93,11 @@ IPA.entity_factories.krbtpolicy = function() {
}
],
needs_update: true
}).
build();
});
};
return that;
};
IPA.register('pwpolicy', IPA.pwpolicy.entity);
IPA.register('krbtpolicy', IPA.krbtpolicy.entity);

View File

@ -23,14 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.config = {};
IPA.config.entity = function(spec) {
/* Configuration */
var that = IPA.entity(spec);
IPA.entity_factories.config = function(){
return IPA.entity_builder().
entity('config').
details_facet({
that.init = function(params) {
params.builder.details_facet({
title: IPA.metadata.objects.config.label,
sections: [
{
@ -80,6 +81,10 @@ IPA.entity_factories.config = function(){
}
],
needs_update: true
}).
build();
});
};
return that;
};
IPA.register('config', IPA.config.entity);

View File

@ -23,11 +23,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.entity_factories.service = function() {
IPA.service = {};
return IPA.entity_builder().
entity('service').
search_facet({
IPA.service.entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [ 'krbprincipalname' ]
}).
details_facet({
@ -81,10 +85,11 @@ IPA.entity_factories.service = function() {
adder_dialog({
factory: IPA.service_adder_dialog,
height: 350
}).
build();
};
});
};
return that;
};
IPA.service_adder_dialog = function(spec) {
@ -341,3 +346,5 @@ IPA.service_certificate_status_widget = function (spec) {
return that;
};
IPA.register('service', IPA.service.entity);

View File

@ -22,12 +22,15 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.sudo = {};
IPA.entity_factories.sudorule = function() {
IPA.sudo.rule_entity = function(spec) {
return IPA.entity_builder().
entity('sudorule').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'ipaenabledflag',
@ -39,15 +42,19 @@ IPA.entity_factories.sudorule = function() {
}).
adder_dialog({
fields: [ 'cn' ]
}).
build();
});
};
return that;
};
IPA.entity_factories.sudocmd = function() {
IPA.sudo.command_entity = function(spec) {
return IPA.entity_builder().
entity('sudocmd').
search_facet({
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'sudocmd',
'description'
@ -100,15 +107,19 @@ IPA.entity_factories.sudocmd = function() {
name: 'description'
}
]
}).
build();
});
};
return that;
};
IPA.entity_factories.sudocmdgroup = function() {
return IPA.entity_builder().
entity('sudocmdgroup').
search_facet({
IPA.sudo.command_group_entity = function(spec) {
var that = IPA.entity(spec);
that.init = function(params) {
params.builder.search_facet({
columns: [
'cn',
'description'
@ -160,11 +171,11 @@ IPA.entity_factories.sudocmdgroup = function() {
name: 'description'
}
]
}).
build();
};
});
};
IPA.sudo = {};
return that;
};
IPA.sudorule_details_facet = function(spec) {
@ -1186,3 +1197,7 @@ IPA.sudo.rule_association_adder_dialog = function(spec) {
return that;
};
IPA.register('sudorule', IPA.sudo.rule_entity);
IPA.register('sudocmd', IPA.sudo.command_entity);
IPA.register('sudocmdgroup', IPA.sudo.command_group_entity);

View File

@ -23,19 +23,20 @@
/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
IPA.user = {};
IPA.entity_factories.user = function() {
IPA.user.entity = function(spec) {
var that = IPA.entity(spec);
var link = true;
if (IPA.nav && IPA.nav.name == 'self-service') {
link = false;
}
var builder = IPA.entity_builder();
that.init = function(params) {
builder.
entity('user').
search_facet({
params.builder.search_facet({
columns: [
'uid',
'givenname',
@ -105,7 +106,8 @@ IPA.entity_factories.user = function() {
{
name: 'misc',
fields: ['carlicense']
}]}).
}]
}).
association_facet({
name: 'memberof_group',
associator: IPA.serial_associator,
@ -167,8 +169,9 @@ IPA.entity_factories.user = function() {
}
]
});
};
return builder.build();
return that;
};
IPA.user_adder_dialog = function(spec) {
@ -461,3 +464,5 @@ IPA.user_password_widget = function(spec) {
return that;
};
IPA.register('user', IPA.user.entity);