From 65c9442e2697f9e5d8b6cc2b7c22a6b8da426247 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 9 Nov 2010 14:22:31 -0600 Subject: 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. --- install/static/service.js | 233 +++++++++++++++++++++++++++++++--------------- 1 file changed, 160 insertions(+), 73 deletions(-) (limited to 'install/static/service.js') diff --git a/install/static/service.js b/install/static/service.js index 1b467cb5..6a79af07 100644 --- a/install/static/service.js +++ b/install/static/service.js @@ -26,115 +26,202 @@ function ipa_service() { 'name': 'service' }); + that.super_init = that.super('init'); + that.init = function() { - that.create_add_dialog({ + + var dialog = ipa_service_add_dialog({ 'name': 'add', - 'title': 'Add New Service', - 'init': ipa_service_add_init + 'title': 'Add New Service' }); + that.add_dialog(dialog); + dialog.init(); - that.create_search_facet({ + var facet = ipa_service_search_facet({ 'name': 'search', - 'label': 'Search', - 'init': ipa_service_search_init + 'label': 'Search' }); + that.add_facet(facet); - that.create_details_facet({ + facet = ipa_service_details_facet({ 'name': 'details', - 'label': 'Details', - 'init': ipa_service_details_init + 'label': 'Details' }); - }; + 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; } IPA.add_entity(ipa_service()); -function ipa_service_add_init() { +function ipa_service_add_dialog(spec) { - this.create_field({ - name: 'krbprincipalname', - label: 'Principal', - setup: service_add_krbprincipalname - }); + spec = spec || {}; - this.create_field({name:'service', label:'Service'}); - this.create_field({name:'host', label:'Host Name'}); -} + var that = ipa_add_dialog(spec); -function ipa_service_search_init() { + that.super_init = that.super('init'); - this.create_column({name:'krbprincipalname', label:'Principal'}); + that.init = function() { - this.create_column({ - name: 'quick_links', - label: 'Quick Links', - setup: ipa_entity_quick_links - }); -} + this.super_init(); -function ipa_service_details_init() { + this.add_field(ipa_widget({ + name: 'krbprincipalname', + label: 'Principal' + })); - var section = this.create_section({name:'details', label:'Service Details'}); + this.add_field(ipa_text_widget({name:'service', label:'Service'})); + this.add_field(ipa_text_widget({name:'host', label:'Host Name'})); + }; - section.create_field({ - name: 'krbprincipalname', - label: 'Principal', - setup: service_krbprincipalname_setup, - load: service_krbprincipalname_load - }); + that.create = function() { - section.create_field({ - name: 'service', - label: 'Service', - load: service_service_load - }); + var table = $('').appendTo(that.container); - section.create_field({ - name: 'host', - label: 'Host Name', - load: service_host_load - }); + var field = that.get_field('service'); - section = this.create_section({name:'provisioning', label:'Provisioning'}); + var tr = $('').appendTo(table); - section.create_field({ - name: 'provisioning_status', - label: 'Status', - load: service_provisioning_status_load - }); + var td = $('').appendTo(table); + + td = $('
', { + 'style': 'vertical-align: top;' + }).appendTo(tr); + td.append(field.label+': '); - section = this.create_section({name:'certificate', label:'Service Certificate'}); + td = $('', { + 'style': 'vertical-align: top;' + }).appendTo(tr); - section.create_field({ - name: 'certificate_status', - label: 'Status', - load: service_usercertificate_load - }); -} + $('', { + 'type': 'text', + 'name': 'service', + 'size': 20 + }).appendTo(td); + + field = that.get_field('host'); + + tr = $('
', { + 'style': 'vertical-align: top;' + }).appendTo(tr); + td.append(field.label+': '); + + td = $('', { + 'style': 'vertical-align: top;' + }).appendTo(tr); + + $('', { + '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]; -function service_add_krbprincipalname(add_dialog, mode) { - 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; + record['krbprincipalname'] = service+'/'+host; + + return record; + }; + + return that; } -ipa_entity_set_association_definition('service', { - 'host': { add_method: 'add_host', delete_host: 'remove_host' } -}); +function ipa_service_search_facet(spec) { -function service_krbprincipalname_setup(container) { - // skip krbprincipalname + spec = spec || {}; + + var that = ipa_search_facet(spec); + + that.super_init = that.super('init'); + + 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 service_krbprincipalname_load(container, result) { - // skip krbprincipalname +function ipa_service_details_facet(spec) { + + spec = spec || {}; + + var that = ipa_details_facet(spec); + + that.super_init = that.super('init'); + + that.init = function() { + + var section = this.create_section({name:'details', label:'Service Details'}); + + section.create_field({ + name: 'krbprincipalname', + label: 'Principal' + }); + + section.create_field({ + name: 'service', + label: 'Service', + load: service_service_load + }); + + section.create_field({ + name: 'host', + label: 'Host Name', + load: service_host_load + }); + + section = this.create_section({name:'provisioning', label:'Provisioning'}); + + section.create_field({ + name: 'provisioning_status', + label: 'Status', + load: service_provisioning_status_load + }); + + section = this.create_section({name:'certificate', label:'Service Certificate'}); + + section.create_field({ + name: 'certificate_status', + label: 'Status', + load: service_usercertificate_load + }); + + that.super_init(); + }; + + return that; } function service_service_load(container, result) { -- cgit