diff options
author | Adam Young <ayoung@redhat.com> | 2011-03-18 16:43:54 -0400 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-03-31 17:29:33 -0400 |
commit | 4270e26adb56b6d1b7a9e80433581b82519d9eec (patch) | |
tree | dcb0982b741d92c0be37e262e70b7cd0969e06d0 /install | |
parent | db91321fd2c94680361ae8196ba9227615f92c39 (diff) | |
download | freeipa-4270e26adb56b6d1b7a9e80433581b82519d9eec.tar.gz freeipa-4270e26adb56b6d1b7a9e80433581b82519d9eec.tar.xz freeipa-4270e26adb56b6d1b7a9e80433581b82519d9eec.zip |
define entities using builder and more declarative syntax
merged hbac and sudo in to single files
associaton facet and table supports linking
Diffstat (limited to 'install')
29 files changed, 1769 insertions, 2692 deletions
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index e8c11c25a..f9c82e150 100644 --- a/install/ui/Makefile.am +++ b/install/ui/Makefile.am @@ -11,10 +11,12 @@ app_DATA = \ aci.js \ add.js \ associate.js \ + automount.js \ caution.png \ centered-bg.png \ check.png \ dialog.js \ + dns.js \ ipa_logo_180x50.png \ ipa.js \ ipa.css \ @@ -25,9 +27,7 @@ app_DATA = \ jquery-ui.css \ certificate.js \ group.js \ - hbacrule.js \ - hbacsvc.js \ - hbacsvcgroup.js \ + hbac.js \ host.js \ hostgroup.js \ index.html \ @@ -36,9 +36,7 @@ app_DATA = \ netgroup.js \ service.js \ serverconfig.js \ - sudorule.js \ - sudocmd.js \ - sudocmdgroup.js \ + sudo.js \ policy.js \ search.js \ rule.js \ diff --git a/install/ui/aci.js b/install/ui/aci.js index bb3bcbea4..d51741245 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -23,6 +23,170 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ +IPA.entity_factories.permission = function() { + + return IPA.entity_builder(). + entity('permission'). + search_facet({ + columns:['cn'], + add_fields:[ + 'cn', + { + factory:IPA.rights_widget, + name: 'permissions', + join: true, undo: false + }, + { + factory: IPA.target_section, + section: 'target', + label: IPA.messages.objects.permission.target, + undo: false + }]}). + details_facet([ + { + section:'identity', + fields: [{ + factory: IPA.text_widget, + name: 'cn', + read_only: true + }] + }, + { + section:'rights', + factory:IPA.rights_section + }, + { + section:'target', + factory:IPA.target_section, + label: IPA.messages.objects.permission.target + }]). + standard_associations(). + build(); +}; + + +IPA.entity_factories.privilege = function() { + return IPA.entity_builder(). + entity('privilege'). + search_facet({ + columns:['cn','description'], + add_fields:['cn', 'description']}). + details_facet([ + { + section:'identity', + label: IPA.messages.details.identity, + fields:['cn','description'] + }]). + association_facet({ + name: 'member_role', + add_method: 'add_privilege', + remove_method: 'remove_privilege', + associator: IPA.serial_associator + }). + association_facet({ + name: 'memberof_permission', + add_method: 'add_permission', + remove_method: 'remove_permission' + }). + standard_associations(). + build(); + +}; + + +IPA.entity_factories.role = function() { + return IPA.entity_builder(). + entity('role'). + search_facet({ + columns:['cn','description'], + add_fields:['cn', 'description']}). + details_facet([ + { + section:'identity', + label:IPA.messages.objects.role.identity, + fields:['cn','description']}]). + association_facet({ + name: 'memberof_privilege', + add_method: 'add_privilege', + remove_method: 'remove_privilege' + }). + standard_associations(). + build(); +}; + + +IPA.entity_factories.selfservice = function() { + return IPA.entity_builder(). + entity('selfservice'). + search_facet({ + columns:['aciname'], + add_fields:[ + 'aciname', + {factory:IPA.attributes_widget, + object_type:'user', + name:'attrs', + undo: false + }]}). + details_facet([ + { + section:'general', + label: IPA.messages.details.general, + fields: [ + 'aciname', + { + factory:IPA.attributes_widget, + object_type:'user', + name:'attrs' + }]}]). + build(); +}; + + +IPA.entity_factories.delegation = function() { + return IPA.entity_builder(). + entity('delegation'). + search_facet({ + columns:['aciname'], + add_fields:[ + 'aciname', + { + factory:IPA.entity_select_widget, + name: 'group', entity: 'group', undo: false + }, + { + factory:IPA.entity_select_widget, + name: 'memberof', entity: 'group', + join: true, undo: false + }, + { + factory:IPA.attributes_widget, + name: 'attrs', object_type: 'user', + join: true, undo: false + }]}). + details_facet([ + { + section:'general', + label: IPA.messages.details.general, + fields:[ + 'aciname', + { + factory:IPA.entity_select_widget, + name: 'group', entity: 'group' + }, + { + factory:IPA.entity_select_widget, + name: 'memberof', entity: 'group', + join: true + }, + { + factory:IPA.attributes_widget, + name: 'attrs', object_type: 'user', + join: true + }]}]). + standard_associations(). + build(); +}; + IPA.attributes_widget = function(spec) { @@ -516,238 +680,5 @@ IPA.permission_details_facet = function(spec) { var that = IPA.details_facet(spec); - that.refresh = function() { - - var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - - var command = IPA.command({ - 'name': that.entity_name+'_show_'+pkey, - 'method': that.entity_name+'_show', - 'args': [pkey], - 'options': { 'all': true, 'rights': true } - }); - - command.on_success = function(data, text_status, xhr) { - that.load(data.result.result); - }; - - command.on_error = function(xhr, text_status, error_thrown) { - var details = $('.details', that.container).empty(); - details.append('<p>Error: '+error_thrown.name+'</p>'); - details.append('<p>'+error_thrown.title+'</p>'); - details.append('<p>'+error_thrown.message+'</p>'); - }; - - command.execute(); - }; - - return that; -}; - -IPA.entity_factories.permission = function() { - - return IPA.entity({ - 'name': 'permission' - }). - facet( - IPA.search_facet(). - column({name:'cn'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.permission.add, - width: '700px' - }). - field(IPA.text_widget({name: 'cn', undo: false})). - field(IPA.rights_widget({ - name: 'permissions', - join: true, undo: false})). - section(IPA.target_section({ - name: 'target', - label: IPA.messages.objects.permission.target, - undo: false - })))). - facet( - IPA.permission_details_facet({ name: 'details' }). - section( - IPA.stanza({ - name:'identity', - label: IPA.messages.objects.permission.identity - }). - input({name: 'cn', read_only: true})). - section(IPA.rights_section()). - section(IPA.target_section({ - name: 'target', - label: IPA.messages.objects.permission.target - }))). - standard_associations(); -}; - - -IPA.entity_factories.privilege = function() { - var that = IPA.entity({ - 'name': 'privilege' - }). - facet( - IPA.search_facet(). - column({name:'cn'}). - column({name:'description'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.privilege.add - }). - field(IPA.text_widget({ name: 'cn', undo: false})). - field(IPA.text_widget( - { name: 'description', undo: false})))). - facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name:'identity', - label: IPA.messages.objects.privilege.identity - }). - input({name: 'cn'}). - input({name: 'description'}))). - facet( - IPA.association_facet({ - name: 'member_role', - add_method: 'add_privilege', - remove_method: 'remove_privilege', - associator: IPA.serial_associator - })). - facet( - IPA.association_facet({ - name: 'memberof_permission', - add_method: 'add_permission', - remove_method: 'remove_permission' - })). - - standard_associations(); - return that; }; - - -IPA.entity_factories.role = function() { - return IPA.entity({ - 'name': 'role' - }). - facet( - IPA.search_facet(). - column({name:'cn'}). - column({name:'description'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.role.add - }). - field(IPA.text_widget({ name: 'cn', undo: false})). - field(IPA.text_widget( - { name: 'description', undo: false})))). - facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name:'identity', - label:IPA.messages.objects.role.identity - }). - input({name: 'cn'}). - input({name: 'description'}))). - facet( - IPA.association_facet({ - name: 'memberof_privilege', - add_method: 'add_privilege', - remove_method: 'remove_privilege' - })). - - standard_associations(); -}; - - -IPA.entity_factories.selfservice = function() { - return IPA.entity({ - 'name': 'selfservice' - }). - facet( - IPA.search_facet(). - column({name:'aciname'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.selfservice.add - }). - field(IPA.text_widget({ name: 'aciname', undo: false})). - field(IPA.attributes_widget({ - object_type:'user', - name:'attrs', undo: false - })))). - facet( - IPA.details_facet({'name':'details'}). - section( - IPA.stanza({ - name: 'general', - label: IPA.messages.details.general - }). - input({name:'aciname'}). - custom_input(IPA.attributes_widget({ - object_type:'user', - name:'attrs' - })))); -}; - - -IPA.entity_factories.delegation = function() { - var that = IPA.entity({ - 'name': 'delegation' - }). - facet( - IPA.search_facet(). - column({name:'aciname'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.delegation.add, - width: '700px' - }). - field(IPA.text_widget({ - name: 'aciname', undo: false - })). - field(IPA.entity_select_widget({ - name: 'group', entity: 'group', undo: false - })). - field(IPA.entity_select_widget({ - name: 'memberof', entity: 'group', - join: true, undo: false - })). - field(IPA.attributes_widget({ - name: 'attrs', object_type: 'user', - join: true, undo: false - })))). - facet( - IPA.details_facet(). - section( - IPA.stanza({ - name: 'general', - label: IPA.messages.details.general - }). - input({name:'aciname'}). - custom_input(IPA.entity_select_widget({ - name:'group', entity:'group' - })). - custom_input(IPA.entity_select_widget({ - name:'memberof', - entity:'group', join: true - })). - custom_input(IPA.rights_widget({ - name: 'permissions', - direction: 'horizontal', join: true - })). - custom_input(IPA.attributes_widget({ - name:'attrs', object_type:'user', - join: true - })))). - standard_associations(); - return that; - -}; diff --git a/install/ui/associate.js b/install/ui/associate.js index e8cb4d0b5..050d8f6db 100644 --- a/install/ui/associate.js +++ b/install/ui/associate.js @@ -270,6 +270,26 @@ IPA.association_config = function (spec) { }; +IPA.association_pkey_setup = function (container, record) { + container.empty(); + var value = record[this.name]; + value = value ? value.toString() : ''; + $('<a/>', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + var state = IPA.tab_state(this.other_entity); + state[this.other_entity + '-facet'] = 'details'; + state[this.other_entity + '-pkey'] = value; + $.bbq.pushState(state); + return false; + }; + }(value) + }).appendTo(container); + }; + + IPA.association_table_widget = function (spec) { spec = spec || {}; @@ -301,7 +321,28 @@ IPA.association_table_widget = function (spec) { return column; }; - that.init = function() { + that.super_create_column = that.create_column; + + that.create_column = function(spec){ + if (spec.link_entity){ + spec.setup = IPA.association_pkey_setup; + } + return that.super_create_column(spec); + }; + /*this is duplicated in the facet... should be unified*/ + var i; + if (spec.columns){ + for (i = 0; i < spec.columns.length; i+= 1){ + that.create_column(spec.columns[i]); + } + } + if (spec.adder_columns){ + for (i = 0; i < spec.adder_columns.length; i+= 1){ + that.create_adder_column(spec.adder_columns[i]); + } + } + + that.create = function(container) { var entity = IPA.get_entity(that.entity_name); var column; @@ -326,9 +367,6 @@ IPA.association_table_widget = function (spec) { } that.table_init(); - }; - - that.create = function(container) { that.table_create(container); @@ -634,6 +672,7 @@ IPA.association_facet = function (spec) { that.adder_columns = []; that.adder_columns_by_name = {}; + that.get_column = function(name) { return that.columns_by_name[name]; }; @@ -645,6 +684,9 @@ IPA.association_facet = function (spec) { that.create_column = function(spec) { var column = IPA.column(spec); + if (spec.link_entity){ + column.setup = IPA.association_pkey_setup; + } that.add_column(column); return column; }; @@ -664,6 +706,18 @@ IPA.association_facet = function (spec) { return column; }; + var i; + if (spec.columns){ + for (i = 0; i < spec.columns.length; i+= 1){ + that.create_column(spec.columns[i]); + } + } + if (spec.adder_columns){ + for (i = 0; i < spec.adder_columns.length; i+= 1){ + that.create_adder_column(spec.adder_columns[i]); + } + } + that.init = function() { that.facet_init(); diff --git a/install/ui/automount.js b/install/ui/automount.js new file mode 100644 index 000000000..a0da4c8c1 --- /dev/null +++ b/install/ui/automount.js @@ -0,0 +1,45 @@ +/*jsl:import ipa.js */ +/*jsl:import search.js */ + +/* Authors: + * Adam Young <ayoung@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, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ + + +/**Automount*/ + +IPA.entity_factories.automountlocation = function() { + return IPA.entity_builder(). + entity('automountlocation'). + search_facet({ + columns:['cn'], + add_fields:['cn'] + }). + details_facet([{ + section:'identity', + label: IPA.messages.objects.automountlocation.identity, + fields:['cn'] + }]). + standard_associations(). + build(); +}; + + diff --git a/install/ui/details.js b/install/ui/details.js index 895c19aa1..1dccb830e 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -78,6 +78,7 @@ IPA.details_section = function(spec) { }; that.multivalued_text = function(spec) { + spec.entity_name = that.entity_name; var field = IPA.multivalued_text_widget(spec); that.add_field(field); return that; @@ -256,29 +257,6 @@ IPA.details_list_section = function(spec) { return that; }; - -/* shorthand notation used for declarative definitions of details pages */ -IPA.stanza = function(spec) { - - spec = spec || {}; - - var that = IPA.details_list_section(spec); - - // This is to allow declarative style programming for details - that.input = function(spec) { - that.text(spec); - return that; - }; - - that.custom_input = function(input) { - that.add_field(input); - return that; - }; - - return that; -}; - - IPA.details_facet = function(spec) { spec = spec || {}; @@ -600,6 +578,11 @@ IPA.details_refresh = function() { args: [], options: { 'all': true, 'rights': true } }); + + if (IPA.refresh_devel_hook){ + IPA.refresh_devel_hook(that.entity_name,command,that.pkey); + } + if (that.pkey){ command.args = [that.pkey]; diff --git a/install/ui/develop.js b/install/ui/develop.js index 462253500..5095905d7 100644 --- a/install/ui/develop.js +++ b/install/ui/develop.js @@ -3,4 +3,11 @@ if (window.location.protocol == 'file:') { IPA.json_url = "test/data"; IPA.use_static_files = true; + + IPA.refresh_devel_hook = function(entity_name,command,pkey){ + if ((entity_name === 'host')||(entity_name === 'permission')){ + command.name = entity_name+'_show_'+pkey; + command.method = entity_name+'_show'; + } + }; } diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 1b2f3192a..17e78af6d 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -79,6 +79,15 @@ IPA.dialog = function(spec) { return that; }; + that.text = function(name){ + that.field(IPA.text_widget({ + name: name, + undo: false, + entity_name : that.entity_name + })); + return that; + }; + that.add_section = function(section) { that.sections.push(section); return that; diff --git a/install/ui/dns.js b/install/ui/dns.js new file mode 100644 index 000000000..e1fce532e --- /dev/null +++ b/install/ui/dns.js @@ -0,0 +1,531 @@ +/*jsl:import ipa.js */ +/*jsl:import search.js */ + +/* Authors: + * Adam Young <ayoung@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, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see <http://www.gnu.org/licenses/>. + */ + +/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ + +/* DNS */ +IPA.entity_factories.dnszone = function() { + + return IPA.entity_builder(). + entity('dnszone'). + search_facet({ + columns:['idnsname'], + add_fields: ['idnsname','idnssoamname','idnssoarname'] + }). + details_facet([{ + section:'identity', + fields:[ + 'idnsname', + 'idnszoneactive', + 'idnssoamname', + 'idnssoarname', + 'idnssoaserial', + 'idnssoarefresh', + 'idnssoaretry', + 'idnssoaexpire', + 'idnssoaminimum', + 'dnsttl', + 'dnsclass', + 'idnsallowdynupdate', + 'idnsupdatepolicy']}]). + facet(IPA.records_facet({ + 'name': 'records', + 'label': IPA.metadata.objects.dnsrecord.label + })). + standard_associations(). + build(); +}; + + +IPA.records_facet = function (spec){ + + spec = spec || {}; + + var that = IPA.facet(spec); + + that.record = null; + + var record_types =[ 'a', 'aaaa', 'dname', 'cname', 'mx', 'ns', 'ptr', + 'srv', 'txt', 'a6', 'afsdb', 'cert', 'ds', + 'key', 'kx', 'loc', 'naptr', 'nsec', + 'rrsig', 'sshfp']; + + function create_type_select(id,add_none) { + var type_select = $('<select/>',{ + id: id + }); + + if (add_none){ + type_select.append($('<option/>',{ + text: '(any)', + value: '' + })); + } + for (var t = 0 ; t < record_types.length ; t += 1){ + var record_type = record_types[t].toUpperCase(); + + type_select.append($('<option/>',{ + text: record_type, + value: record_type + })); + } + return type_select; + } + + + var entry_attrs = {}; + + + function add_click(){ + + var dialog = IPA.dialog({ + title: IPA.messages.objects.dnsrecord.add + }); + + dialog.create = function() { + + var dl = $('<dl/>').appendTo(dialog.container); + + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.resource + }).appendTo(dl); + + var dd = $('<dd/>').appendTo(dl); + + dialog.resource = $('<input/>', { + type: 'text' + }).appendTo(dd); + + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.type + }).appendTo(dl); + + dd = $('<dd/>').appendTo(dl); + + dialog.type = create_type_select('dns-record-type').appendTo(dd); + + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.data + }).appendTo(dl); + + dd = $('<dd/>').appendTo(dl); + + dialog.data = $('<textarea/>', { + rows: 8, + cols: 20 + }).appendTo(dd); + }; + + dialog.add_button(IPA.messages.buttons.add_many, function() { + dialog.add(); + }); + + dialog.add_button(IPA.messages.buttons.add_and_close, function() { + dialog.add(); + dialog.close(); + }); + + dialog.add_button(IPA.messages.buttons.cancel, function() { + dialog.close(); + }); + + dialog.add = function() { + + var pkey = $.bbq.getState(that.entity_name+'-pkey', true); + var resource = dialog.resource.val(); + + var options = {}; + var key = dialog.type.val().toLowerCase()+'record'; + options[key] = dialog.data.val(); + + var command = IPA.command({ + method: 'dnsrecord_add', + args: [pkey, resource], + options: options, + on_success: function(data, text_status, xhr) { + reload(); + } + }); + + command.execute(); + }; + + dialog.init(); + + dialog.open(that.container); + } + + function delete_records(records_table){ + + var zone = $.bbq.getState('dnszone-pkey', true); + + var thead = records_table.find('thead'); + thead.find("INPUT[type='checkbox']"). + attr('checked', false); + + var tbody = records_table.find('tbody'); + + var records = []; + + $('input[type=checkbox]:checked', tbody).each( + function(index, input){ + var tr = $(input).parents('tr'); + var resource = $('[title=idnsname]', tr).text(); + var type = $('[title=type]', tr).text().toLowerCase(); + var data = $('[title=data]', tr).text(); + + records.push({ + resource: resource, + type: type, + data: data + }); + } + ); + + if (records.length === 0){ + return; + } + + var dialog = IPA.dialog({ + title: IPA.messages.buttons.remove + }); + + dialog.create = function() { + + var to_delete_table = + $('<table class="search-table" >'+ + '<thead><tr><th>Resource</th><th>Type</th></tr></thead>'+ + '<tbody></tbody></table>').appendTo(dialog.container); + + var to_delete_body = to_delete_table.find('tbody'); + + for (var i=0; i<records.length; i++) { + var record = records[i]; + + var tr = $('<tr></tr>').appendTo(to_delete_body); + + $('<td/>', { + html: record.resource + }).appendTo(tr); + + $('<td/>', { + html: record.type + }).appendTo(tr); + } + + $('<p/>', { + text: IPA.messages.search.delete_confirm + }).appendTo(dialog.container); + }; + + dialog.add_button(IPA.messages.buttons.remove, function() { + + var batch = IPA.batch_command({ + on_success: function() { + reload(); + dialog.close(); + }, + on_error: function() { + reload(); + dialog.close(); + } + }); + + for (var i=0; i<records.length; i++) { + var record = records[i]; + + var command = IPA.command({ + method: 'dnsrecord_del', + args: [zone, record.resource] + }); + + command.set_option(record.type+'record', record.data); + + batch.add_command(command); + } + + batch.execute(); + }); + + dialog.add_button(IPA.messages.buttons.cancel, function() { + dialog.close(); + }); + + dialog.init(); + + dialog.open(that.container); + } + + that.is_dirty = function() { + var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; + var record = $.bbq.getState(that.entity_name + '-record', true) || ''; + return pkey != that.pkey || record != that.record; + }; + + function create(container) { + + container.attr('title', that.entity_name); + + $('<h1/>',{ + }).append(IPA.create_network_spinner()). + appendTo(container); + + var details = $('<div/>', { + 'class': 'content' + }).appendTo(container); + + var div = $('<div class="search-controls"></div>'). + appendTo(details); + + var control_span =$('<span class="record-filter"></span>').appendTo(div); + control_span.append(IPA.messages.objects.dnsrecord.resource); + control_span.append($('<input />',{ + type: "text", + id: 'dns-record-resource-filter', + name: 'search-' + that.entity_name + '-filter' + })); + + /* + THe OLD DNS plugin allowed for search based on record type. + This one does not. If the plugin gets modified to support + Record type searches, uncomment the followin lines and + adjust the code that modifies the search parameters. + + control_span.append('Type'); + create_type_select('dns-record-type-filter',true). + appendTo(control_span); + */ + + IPA.button({ + 'label': IPA.messages.buttons.find, + 'icon': 'ui-icon-search', + 'click': function(){refresh();} + }).appendTo(control_span); + + var action_panel_ul = $('.action-panel .entity-facet', that.container). + last(); + + var action_controls = $('<li/>',{ + "class":"action-controls"}).appendTo(action_panel_ul); + + + IPA.action_button({ + label: IPA.messages.buttons.remove, + icon: 'ui-icon-trash', + click: function(){ delete_records(records_table); } + }).appendTo(action_controls); + + IPA.action_button({ + label: IPA.messages.buttons.add, + icon: 'ui-icon-plus', + click: add_click + }).appendTo(action_controls); + + div.append('<span class="records-buttons"></span>'); + + var records_results = $('<div/>', { + 'class': 'records-results' + }).appendTo(details); + + var records_table = $('<table/>', { + 'class': 'search-table' + }).appendTo(records_results); + + var thead = $('<thead><tr></tr></thead>').appendTo(records_table); + var tbody = $('<tbody></tbody>').appendTo(records_table); + var tfoot = $('<tfoot></tfoot>').appendTo(records_table); + + var tr = thead.find('tr'); + tr.append($('<th style="width: 15px" />').append( + $('<input />',{ + type: 'checkbox', + click : function (evt){ + tbody.find("INPUT[type='checkbox']"). + attr('checked', this.checked); + } + }))); + tr.append($('<th/>',{ + text: IPA.get_entity_param("dnsrecord", "idnsname").label })); + tr.append($('<th>Record Type</th>')); + tr.append($('<th>Data</th>')); + + } + + function setup(container){ + + that.facet_setup(container); + + that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; + that.record = $.bbq.getState(that.entity_name + '-record', true) || ''; + + + $('h1',container). + html("<span id='headerpkey' />"+IPA.messages.objects.dnsrecord.title+":" + that.pkey); + + + //commented out until data is searchable + //control_span.append('Data'); + //control_span.append($('<input />',{ + // type: "text", + // id: 'dns-record-data-filter', + // name: 'search-' + obj_name + '-filter' + //})); + + + + refresh(); + } + + + function load_on_win(data){ + display(that.entity_name,data); + } + + function load_on_fail(data){ + display(that.entity_name,data); + } + + function reload(){ + refresh(); + } + + + function refresh(){ + + var options = {}; + + var resource_filter = that.container. + find("#dns-record-resource-filter").val(); +// if (resource_filter){ +// options.idnsname = resource_filter; +// } + + var type_filter = that.container.find("#dns-record-type-filter").val(); + if (type_filter){ + options.type = type_filter; + } + + var data_filter = that.container.find("#dns-record-data-filter").val(); + if (data_filter){ + options.data = data_filter; + } + + var pkey = [$.bbq.getState(that.entity_name + '-pkey', true)]; + + if (resource_filter){ + pkey.push(resource_filter); + } + IPA.cmd('dnsrecord_find',pkey,options,load_on_win, load_on_fail); + + } + + + function generate_tr(thead, tbody, result){ + function generate_checkbox_td(tr, pkey) { + var checkbox = $('<input />', { + name: pkey, + title: pkey, + type: 'checkbox', + 'class': 'search-selector' + }); + var td = $('<td></td>'); + + td.append(checkbox); + tr.append(td); + } + + var tr = $('<tr></tr>').appendTo(tbody); + + generate_checkbox_td(tr, /*pkey_value*/ ''); + + //TODO get this fixed on the back end. For now, workaround + + if (result.idnsname){ + tr.append($('<td/>',{ + title:'idnsname', + text: result.idnsname[0] + })); + }else{ + tr.append($('<td/>',{ + title:'idnsname', + text: result.dn.split(',')[0].split('=')[1] + })); + + } + + for (var i = 0; i < record_types.length; i += 1){ + var field_name = record_types[i]; + var field = result[field_name+'record']; + if ( field ){ + var record_type = field_name; + var record_data = field[0]; + break; + } + } + + tr.append($('<td/>',{ + title:'type', + text: record_type + })); + tr.append($('<td/>',{ + title:'data', + text: record_data + })); + } + + //TODO this is cut and pasted from search, we need to unify + function 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){ + generate_tr(thead, tbody, result[i]); + } + + tfoot.find('td').remove(); + if (data.result.truncated) { + var message = IPA.messages.search.truncated; + message = message.replace('${counter}', data.result.count); + tfoot.append($('<td />',{ + colspan:2, + text:message})); + } else { + tfoot.append($('<td/>',{ + colspan:2, + text:data.result.summary})); + } + + } + + that.create = create; + that.setup = setup; + that.refresh = refresh; + + return that; +}; + diff --git a/install/ui/entity.js b/install/ui/entity.js index f8e61af8e..c23ce500a 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -243,99 +243,6 @@ IPA.entity = function (spec) { }; -/*renamed to avoid clash with IPA.get_entity*/ -IPA.fetch_entity = function (entity_name) { - - var entity = IPA.get_entity(entity_name); -/* - if (entity) return entity; - - entity = IPA.entity({ - 'name': entity_name - }); - - IPA.add_entity(entity); -*/ - return entity; -}; - - -IPA.entity_get_search_facet = function (entity_name) { - - var entity = IPA.fetch_entity(entity_name); - - var facet = entity.get_facet('search'); - if (facet) return facet; - - facet = IPA.search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - entity.add_facet(facet); - - return facet; -}; - - -IPA.entity_set_search_definition = function (entity_name, data) { - - var facet = IPA.entity_get_search_facet(entity_name); - - for (var i=0; i<data.length; i++) { - var defn = data[i]; - facet.create_column({ - 'name': defn[0], - 'label': defn[1], - 'setup': defn[2] - }); - } -}; - - -IPA.entity_get_add_dialog = function (entity_name) { - - var entity = IPA.fetch_entity(entity_name); - return entity.get_add_dialog(); -}; - - -IPA.entity_get_details_facet = function (entity_name) { - - var entity = IPA.fetch_entity(entity_name); - - var facet = entity.get_facet('details'); - if (facet) return facet; - - facet = IPA.details_facet({ - 'name': 'details' - }); - entity.add_facet(facet); - - return facet; -}; - - -IPA.entity_set_details_definition = function (entity_name, sections) { - - var facet = IPA.entity_get_details_facet(entity_name); - - for (var i=0; i<sections.length; i++) { - var section = sections[i]; - facet.add_section(section); - } -}; - -IPA.entity_set_facet_definition = function (entity_name, list) { - - var entity = IPA.fetch_entity(entity_name); - - for (var i=0; i<list.length; i++) { - var facet = list[i]; - entity.add_facet(facet); - } -}; - - IPA.current_facet = function (entity){ var facet_name = $.bbq.getState(entity.name + '-facet', true); if (!facet_name && entity.facets.length) { @@ -464,7 +371,6 @@ IPA.back_icon = '<span class="ipa-icon">◀</span>'; IPA. facet_create_action_panel = function(container) { - function build_link(other_facet,label){ var li = $('<li/>', { "class" : other_facet.display_class, @@ -620,3 +526,160 @@ IPA. facet_create_action_panel = function(container) { } return action_panel; }; + +IPA.entity_builder = function(){ + + var that = {}; + + var entity_name ; + var entity = null; + var current_facet = null; + + + function section(spec){ + var current_section = null; + spec.entity_name = entity_name; + + if (spec.section){ + spec.name = spec.section; + if (!spec.label){ + var obj_messages = IPA.messages.objects[entity_name]; + spec.label = obj_messages[spec.section]; + } + } + + if (spec.factory){ + current_section = spec.factory(spec); + }else{ + current_section = IPA.details_list_section(spec); + } + + var fields = spec.fields; + if (fields){ + var i; + var field; + for (i =0; i < fields.length; i += 1){ + field = fields[i]; + if (field instanceof Object){ + field.entity_name = entity_name; + current_section.add_field(field.factory(field)); + }else{ + field = IPA.text_widget({ + name:field, + entity_name:entity_name + }); + current_section.add_field(field); + } + } + } + current_facet.add_section(current_section); + } + + that.entity = function(name){ + entity_name = name; + that.entity_name = name; + entity = IPA.entity({name: name}); + return that; + }; + + that.dialog = function(value){ + current_facet.dialog(value); + return that; + }; + + that.details_facet = function (sections){ + current_facet =IPA.details_facet({entity_name:entity_name}); + entity.facet(current_facet); + + var i; + for ( i =0; i < sections.length; i += 1){ + section(sections[i]); + } + + return that; + }; + + that.get_current_facet = function(){ + return current_facet; + }; + + that.facet = function (facet){ + current_facet = facet; + entity.facet(facet); + return that; + }; + + that.search_facet = function (spec){ + current_facet = IPA.search_facet({entity_name:that.entity_name}); + //once everything usese this mechanism, inline the init code + current_facet.init(); + + var columns = spec.columns; + var i; + for (i = 0; i < columns.length; i +=1){ + if(columns[i] instanceof Object){ + current_facet.column(columns[i]); + }else{ + current_facet.column({name:columns[i]}); + } + } + var current_dialog = + IPA.add_dialog({ + 'name': 'add', + 'title': IPA.messages.objects.user.add, + entity_name: entity_name + }); + + current_facet.dialog(current_dialog); + + var add_fields = spec.add_fields; + for (i = 0; i < add_fields.length; i += 1){ + var field = add_fields[i]; + if (field instanceof Object){ + /* This is a bit of a hack ,and is here to support ACI + permissions. The target section is a group of secveral + widgets together. It makes more sense to do them as a + seciont than as a widgit. However, since they can be mixed + into the flow with the other widgets, the section needs to + be definied here with the fields to get the order correct.*/ + var factory; + if (field.section){ + factory = field.factory; + field.factory = null; + field.name = field.section; + field.section = null; + current_dialog.add_section(factory(field)); + }else{ + field.entity_name = entity_name; + factory = field.factory; + current_dialog.field(factory(field)); + } + }else{ + current_dialog.text(add_fields[i]); + } + } + + entity.facet(current_facet); + return that; + }; + + + that.association_facet = function(spec){ + spec.entity_name = entity_name; + entity.facet(IPA.association_facet(spec)); + return that; + }; + + that.standard_associations = function(){ + entity.standard_associations(); + return that; + }; + + that.build = function(){ + var item = entity; + entity = null; + return item; + }; + + return that; +}; diff --git a/install/ui/group.js b/install/ui/group.js index d2e35e258..cc443cc53 100644 --- a/install/ui/group.js +++ b/install/ui/group.js @@ -26,115 +26,65 @@ IPA.entity_factories.group = function () { - return IPA.entity({ - 'name': 'group' - }). - facet( - IPA.search_facet(). - column({name: 'cn'}). - column({name: 'gidnumber'}). - column({name: 'description'}). - dialog( - IPA.add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.group.add - }). - field(IPA.text_widget({name: 'cn', undo: false})). - field(IPA.text_widget({name: 'description', undo: false})). - field(IPA.checkbox_widget({ - name: 'posix', - label: IPA.messages.objects.group.posix, - undo: false, - checked: 'checked'})). - field(IPA.text_widget({name: 'gidnumber', undo: false})))). - facet( - IPA.details_facet(). - section( - IPA.stanza({ - name: 'details', - label: IPA.messages.objects.group.details - }). - input({name: 'cn' }). - input({name: 'description'}). - input({name: 'gidnumber' }))). - facet( - IPA.group_member_user_facet({ - 'name': 'member_user' - })). - facet( - IPA.association_facet({ + return IPA.entity_builder(). + entity('group'). + search_facet({ + columns:['cn','gidnumber','description'], + add_fields: [ + 'cn', + 'description', + { + factory:IPA.checkbox_widget, + name: 'posix', + label: IPA.messages.objects.group.posix, + undo: false, + checked: 'checked' + }, + 'gidnumber'] + }). + details_facet( + [{ + section:'details', + fields:['cn','description','gidnumber'] + }]). + facet( IPA.association_facet({ + 'name': 'member_user', + columns:[ + { + name: 'uid', + primary_key: true, + link_entity: true + }, + {name: 'uidnumber'}, + {name: 'mail'}, + {name: 'telephonenumber'}, + {name: 'title'} + ], + adder_columns:[ + { + name: 'cn', + width: '100px' + }, + { + name: 'uid', + primary_key: true, + width: '100px' + } + ] + + })). + association_facet({ name: 'memberof_group', associator: IPA.serial_associator - })). - facet( - IPA.association_facet({ - name: 'memberof_netgroup', - associator: IPA.serial_associator - })). - facet( - IPA.association_facet({ - name: 'memberof_role', - associator: IPA.serial_associator - })). - standard_associations(); + }). + association_facet({ + name: 'memberof_netgroup', + associator: IPA.serial_associator + }). + association_facet({ + name: 'memberof_role', + associator: IPA.serial_associator + }). + standard_associations(). + build(); }; - - -IPA.group_member_user_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.association_facet(spec); - - that.init = function() { - - that.create_column({name: 'cn'}); - - var column = that.create_column({ - name: 'uid', - primary_key: true - }); - - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('<a/>', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - var state = IPA.tab_state(that.other_entity); - state[that.other_entity + '-facet'] = 'details'; - state[that.other_entity + '-pkey'] = value; - $.bbq.pushState(state); - return false; - }; - }(value) - }).appendTo(container); - }; - - that.create_column({name: 'uidnumber'}); - that.create_column({name: 'mail'}); - that.create_column({name: 'telephonenumber'}); - that.create_column({name: 'title'}); - - that.create_adder_column({ - name: 'cn', - width: '100px' - }); - - that.create_adder_column({ - name: 'uid', - primary_key: true, - width: '100px' - }); - - that.association_facet_init(); - }; - - return that; - -};
\ No newline at end of file diff --git a/install/ui/hbacrule.js b/install/ui/hbac.js index 743b9e0c5..4b9fe1ed3 100644 --- a/install/ui/hbacrule.js +++ b/install/ui/hbac.js @@ -23,113 +23,130 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ IPA.entity_factories.hbacrule = function () { - - var that = IPA.entity({ - 'name': 'hbacrule' - }); - - that.init = function() { - - var facet = IPA.hbacrule_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - - var dialog = IPA.hbacrule_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.hbacrule.add - }); - facet.dialog(dialog); - - that.add_facet(facet); - - facet = IPA.hbacrule_details_facet({ + return IPA.entity_builder(). + entity('hbacrule'). + search_facet({ + columns:['cn','usercategory','hostcategory','ipaenabledflag', + 'servicecategory','sourcehostcategory'], + add_fields:[ + 'cn', + { + factory: IPA.radio_widget, + 'name': 'accessruletype', + 'options': [ + { 'value': 'allow', + 'label': IPA.messages.objects.hbacrule.allow + }, + { 'value': 'deny', + 'label': IPA.messages.objects.hbacrule.deny + }], + 'undo': false + }]}). + facet(IPA.hbacrule_details_facet({ 'name': 'details' - }); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; + })). + build(); }; +IPA.entity_factories.hbacsvc = function () { + return IPA.entity_builder(). + entity('hbacsvc'). + search_facet({ + columns:['cn','description'], + add_fields:['cn','description']}). + details_facet([{ + section : 'general', + label: IPA.messages.details.general, + fields:[ 'cn', 'description']}]). + build(); +}; - -IPA.hbacrule_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({ - 'name': 'cn', - 'undo': false - })); - - that.add_field(IPA.radio_widget({ - 'name': 'accessruletype', - 'options': [ - { 'value': 'allow', 'label': IPA.messages.objects.hbacrule.allow }, - { 'value': 'deny', 'label': IPA.messages.objects.hbacrule.deny } - ], - 'undo': false - })); - - that.add_dialog_init(); - }; - - return that; +IPA.entity_factories.hbacsvcgroup = function () { + return IPA.entity_builder(). + entity('hbacsvcgroup'). + search_facet({ + columns:['cn', 'description'], + add_fields:['cn', 'description']}). + details_facet([ + { + section: 'general', + label: IPA.messages.details.general, + fields:['cn','description'] + }, + { + section: 'services', + label: IPA.messages.objects.hbacsvcgroup.services, + fields:[{ + factory: IPA.hbacsvcgroup_member_hbacsvc_table_widget, + name: 'member_hbacsvc', + label: IPA.messages.objects.hbacsvcgroup.services, + other_entity: 'hbacsvc', + save_values: false + }] + }]). + build(); }; - -IPA.hbacrule_search_facet = function (spec) { +IPA.hbacsvcgroup_member_hbacsvc_table_widget = function (spec) { spec = spec || {}; - var that = IPA.search_facet(spec); + var that = IPA.association_table_widget(spec); that.init = function() { - that.create_column({name:'cn'}); - that.create_column({name:'usercategory'}); - that.create_column({name:'hostcategory'}); - that.create_column({name:'ipaenabledflag'}); - that.create_column({name:'servicecategory'}); - that.create_column({name:'sourcehostcategory'}); - - that.search_facet_init(); - }; - - that.create = function(container) { - -/* - // Not yet implemented + var column = that.create_column({ + name: 'cn', + primary_key: true, + width: '150px' + }); - var left_buttons = $('<span/>', { - 'style': 'float: left;' - }).appendTo(container); + column.setup = function(container, record) { + container.empty(); + + var value = record[column.name]; + value = value ? value.toString() : ''; + + $('<a/>', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + var state = IPA.tab_state(that.other_entity); + state[that.other_entity + '-facet'] = 'details'; + state[that.other_entity + '-pkey'] = value; + $.bbq.pushState(state); + return false; + }; + }(value) + }).appendTo(container); + }; - left_buttons.append(IPA.button({ - 'label': 'Troubleshoot Rules' - })); + that.create_column({ + name: 'description', + width: '350px' + }); - left_buttons.append(IPA.button({ - 'label': 'Cull Disabled Rules' - })); -*/ + that.create_adder_column({ + name: 'cn', + primary_key: true, + width: '100px' + }); - that.search_facet_create(container); + that.create_adder_column({ + name: 'description', + width: '100px' + }); + that.association_table_widget_init(); }; return that; }; + IPA.hbacrule_details_facet = function (spec) { spec = spec || {}; @@ -315,31 +332,6 @@ IPA.hbacrule_details_facet = function (spec) { 'name': 'sourcehost_hostgroup', 'category': category, 'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'remove_method': 'remove_sourcehost' })); -/* - if (IPA.layout) { - section = that.create_section({ - 'name': 'accesstime', - 'label': 'When', - 'template': 'hbacrule-details-accesstime.html #contents' - }); - - } else { - section = that.create_section({ - 'name': 'accesstime', - 'label': 'When' - }); - } - - section.add_field(ipa_hbacrule_accesstime_widget({ - 'id': 'accesstime', - 'name': 'accesstime', 'label': 'Access Time', - 'text': 'Rule applies when access is being requested at:', - 'options': [ - { 'value': 'all', 'label': 'Any Time' }, - { 'value': '', 'label': 'Specified Times' } - ] - })); -*/ that.details_facet_init(); }; @@ -532,8 +524,6 @@ IPA.hbacrule_details_facet = function (spec) { return; } - //alert(JSON.stringify(batch.to_json())); - batch.execute(); }; diff --git a/install/ui/hbacsvc.js b/install/ui/hbacsvc.js deleted file mode 100644 index 2112f3afe..000000000 --- a/install/ui/hbacsvc.js +++ /dev/null @@ -1,116 +0,0 @@ -/*jsl:import ipa.js */ - -/* 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, either version 3 of the License, or - * (at your option) any later version. - * - * 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, see <http://www.gnu.org/licenses/>. - */ - -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ - -IPA.entity_factories.hbacsvc = function () { - - var that = IPA.entity({ - 'name': 'hbacsvc' - }); - - that.init = function() { - - var facet = IPA.hbacsvc_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - - var dialog = IPA.hbacsvc_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.hbacsvc.add - }); - facet.dialog(dialog); - - that.add_facet(facet); - - facet = IPA.hbacsvc_details_facet({ - 'name': 'details' - }); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; -}; - - - -IPA.hbacsvc_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({name:'cn', undo: false})); - that.add_field(IPA.text_widget({name:'description', undo: false})); - - that.add_dialog_init(); - }; - - return that; -}; - - -IPA.hbacsvc_search_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.search_facet(spec); - - that.init = function() { - - that.create_column({name:'cn', primary_key: true}); - that.create_column({name:'description'}); - - that.search_facet_init(); - }; - - return that; -}; - - -IPA.hbacsvc_details_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = IPA.details_list_section({ - 'name': 'general', - 'label': IPA.messages.details.general - }); - that.add_section(section); - - section.text({name: 'cn'}); - section.text({name: 'description'}); - - that.details_facet_init(); - }; - - return that; -}; diff --git a/install/ui/hbacsvcgroup.js b/install/ui/hbacsvcgroup.js deleted file mode 100644 index a69841397..000000000 --- a/install/ui/hbacsvcgroup.js +++ /dev/null @@ -1,188 +0,0 @@ -/*jsl:import ipa.js */ - -/* 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, either version 3 of the License, or - * (at your option) any later version. - * - * 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, see <http://www.gnu.org/licenses/>. - */ - -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ - -IPA.entity_factories.hbacsvcgroup = function () { - - var that = IPA.entity({ - 'name': 'hbacsvcgroup' - }); - - that.init = function() { - - var facet = IPA.hbacsvcgroup_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - - var dialog = IPA.hbacsvcgroup_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.hbacsvcgroup.add - }); - facet.dialog(dialog); - - that.add_facet(facet); - - facet = IPA.hbacsvcgroup_details_facet({ - 'name': 'details' - }); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; -}; - - -IPA.hbacsvcgroup_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({name:'cn', undo: false})); - that.add_field(IPA.text_widget({name:'description', undo: false})); - - that.add_dialog_init(); - }; - - return that; -}; - - -IPA.hbacsvcgroup_search_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.search_facet(spec); - - that.init = function() { - - that.create_column({name:'cn', primary_key: true}); - that.create_column({name:'description'}); - - that.search_facet_init(); - }; - - - return that; -}; - - -IPA.hbacsvcgroup_details_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = IPA.details_list_section({ - 'name': 'general', - 'label': IPA.messages.details.general - }); - that.add_section(section); - - section.text({name: 'cn'}); - section.text({name: 'description'}); - - section = IPA.details_section({ - 'name': 'services', - 'label': IPA.messages.objects.hbacsvcgroup.services - }); - that.add_section(section); - - var field = IPA.hbacsvcgroup_member_hbacsvc_table_widget({ - 'name': 'member_hbacsvc', - 'label': IPA.messages.objects.hbacsvcgroup.services, - 'other_entity': 'hbacsvc', - 'save_values': false - }); - section.add_field(field); - - that.details_facet_init(); - }; - - return that; -}; - - -IPA.hbacsvcgroup_member_hbacsvc_table_widget = function (spec) { - - spec = spec || {}; - - var that = IPA.association_table_widget(spec); - - that.init = function() { - - var column = that.create_column({ - name: 'cn', - primary_key: true, - width: '150px' - }); - - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('<a/>', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - var state = IPA.tab_state(that.other_entity); - state[that.other_entity + '-facet'] = 'details'; - state[that.other_entity + '-pkey'] = value; - $.bbq.pushState(state); - return false; - }; - }(value) - }).appendTo(container); - }; - - that.create_column({ - name: 'description', - width: '350px' - }); - - that.create_adder_column({ - name: 'cn', - primary_key: true, - width: '100px' - }); - - that.create_adder_column({ - name: 'description', - width: '100px' - }); - - that.association_table_widget_init(); - }; - - return that; -}; diff --git a/install/ui/host.js b/install/ui/host.js index 7d9e8f018..3f9c05d1d 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -26,90 +26,70 @@ IPA.entity_factories.host = function () { - var that = IPA.entity({ - 'name': 'host' - }); - - that.init = function() { - - var facet = IPA.host_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - that.add_facet(facet); - - var dialog = IPA.host_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.host.add - }); - facet.dialog(dialog); - - facet = IPA.host_details_facet({ - 'name': 'details' - }); - that.add_facet(facet); - - facet = IPA.host_managedby_host_facet({ + return IPA.entity_builder(). + entity('host'). + search_facet({ + columns:['fqdn','description',{ + name: 'krblastpwdchange', + label: IPA.messages.objects.host.enrolled, + format: IPA.utc_date_column_format + }], + add_fields: ['fqdn', {factory:IPA.force_host_add_checkbox_widget}] + }). + details_facet([ + { + section:'details', + fields: [ + 'fqdn', + 'krbprincipalname', + { + factory: IPA.text_widget, + name: 'cn', + label: IPA.messages.objects.host.cn, + read_only: true + }, + 'description' ] + }, + { + section:'enrollment', + fields:[ + { + factory: IPA.host_provisioning_status_widget, + 'name': 'provisioning_status', + label: IPA.messages.objects.host.status + } + ] + }, + { + section :'certificate', + fields:[ + { + factory: IPA.host_certificate_status_widget, + 'name': 'certificate_status', + label: IPA.messages.objects.host.status + } + ] + }]). + facet(IPA.host_managedby_host_facet({ name: 'managedby_host' - }); - that.add_facet(facet); - - facet = IPA.association_facet({ + })). + association_facet({ name: 'memberof_hostgroup', associator: IPA.serial_associator - }); - that.add_facet(facet); - - facet = IPA.association_facet({ + }). + association_facet({ name: 'memberof_netgroup', associator: IPA.serial_associator - }); - that.add_facet(facet); - - facet = IPA.association_facet({ + }). + association_facet({ name: 'memberof_role', associator: IPA.serial_associator - }); - that.add_facet(facet); - - that.create_association_facets(); - - that.entity_init(); - }; - - return that; + }). + standard_associations(). + build(); }; -IPA.host_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({ - name: 'fqdn', - size: 40, - undo: false - })); - - var param_info = IPA.get_method_param('host_add', 'force'); - - that.add_field(IPA.checkbox_widget({ - name: 'force', - label: param_info.label, - tooltip: param_info.doc, - undo: false - })); - - that.add_dialog_init(); - }; - - return that; -}; - /* Take an LDAP format date in UTC and format it */ IPA.utc_date_column_format = function(value){ if (!value) { @@ -137,115 +117,16 @@ IPA.utc_date_column_format = function(value){ return formated; }; -IPA.host_search_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.search_facet(spec); - - that.init = function() { - - 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: IPA.messages.objects.host.enrolled, - format: IPA.utc_date_column_format - }); - that.create_column({name:'nshostlocation'}); - that.search_facet_init(); - }; - - return that; -}; - - -IPA.host_details_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = IPA.details_list_section({ - name: 'details', - label: IPA.messages.objects.host.details - }); - that.add_section(section); - - section.text({ - name: 'fqdn', - label: IPA.messages.objects.host.fqdn - }); - - section.text({'name': 'krbprincipalname'}); - - section.text({ - name: 'cn', - label: IPA.messages.objects.host.cn, - read_only: true - }); - - section.text({'name': 'description'}); - - section = IPA.details_list_section({ - name: 'enrollment', - label: IPA.messages.objects.host.enrollment - }); - that.add_section(section); - - section.add_field(IPA.host_provisioning_status_widget({ - 'name': 'provisioning_status', - label: IPA.messages.objects.host.status, - 'facet': that - })); - - section = IPA.details_list_section({ - name: 'certificate', - label: IPA.messages.objects.host.status - }); - that.add_section(section); - - section.add_field(IPA.host_certificate_status_widget({ - 'name': 'certificate_status', - label: IPA.messages.objects.host.status - })); - - that.details_facet_init(); - }; - - that.refresh = function() { - - var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - - var command = IPA.command({ - 'name': that.entity_name+'_show_'+pkey, - 'method': that.entity_name+'_show', - 'args': [pkey], - 'options': { 'all': true, 'rights': true } - }); - - command.on_success = function(data, text_status, xhr) { - that.load(data.result.result); - }; - - command.on_error = function(xhr, text_status, error_thrown) { - var details = $('.details', that.container).empty(); - details.append('<p>Error: '+error_thrown.name+'</p>'); - details.append('<p>'+error_thrown.title+'</p>'); - details.append('<p>'+error_thrown.message+'</p>'); - }; - - command.execute(); - }; - - return that; +IPA.force_host_add_checkbox_widget = function (spec){ + var param_info = IPA.get_method_param('host_add', 'force'); + spec.name = 'force'; + spec.label = param_info.label; + spec.tooltip = param_info.doc; + spec.undo = false; + return IPA.checkbox_widget(spec); }; - IPA.host_provisioning_status_widget = function (spec) { spec = spec || {}; diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js index 4738a26d6..46f2ab68c 100644 --- a/install/ui/hostgroup.js +++ b/install/ui/hostgroup.js @@ -25,49 +25,21 @@ IPA.entity_factories.hostgroup = function() { - var that = IPA.entity({ - 'name': 'hostgroup' - }); - - that.init = function() { - - that.facet( - IPA.search_facet({ - name: 'search', - label: IPA.messages.facets.search, - entity_name: that.name - }). - column({name:'cn'}). - column({name:'description'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.hostgroup.add - }). - field(IPA.text_widget({name: 'cn', undo: false})). - field(IPA.text_widget({name: 'description', undo: false})))); - - that.facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.hostgroup.identity - }). - input({name:'cn'}). - input({name: 'description'}))); - - that.facet( - IPA.association_facet({ - name: 'memberof_hostgroup', - associator: IPA.serial_associator - })); - - that.create_association_facets(); - that.entity_init(); - }; - - return that; + return IPA.entity_builder(). + entity('hostgroup'). + search_facet({columns:['cn','description'], + add_fields:['cn','description']}). + details_facet([{ + section:'identity', + label: IPA.messages.objects.hostgroup.identity, + fields:['cn','description'] + }]). + association_facet({ + name: 'memberof_hostgroup', + associator: IPA.serial_associator + }). + standard_associations(). + build(); }; diff --git a/install/ui/index.html b/install/ui/index.html index bdeb4abfd..83f0fb0eb 100644 --- a/install/ui/index.html +++ b/install/ui/index.html @@ -21,20 +21,18 @@ <script type="text/javascript" src="navigation.js"></script> <script type="text/javascript" src="rule.js"></script> + <script type="text/javascript" src="automount.js"></script> + <script type="text/javascript" src="dns.js"></script> <script type="text/javascript" src="certificate.js"></script> <script type="text/javascript" src="user.js"></script> <script type="text/javascript" src="group.js"></script> - <script type="text/javascript" src="hbacrule.js"></script> - <script type="text/javascript" src="hbacsvc.js"></script> - <script type="text/javascript" src="hbacsvcgroup.js"></script> + <script type="text/javascript" src="hbac.js"></script> <script type="text/javascript" src="host.js"></script> <script type="text/javascript" src="hostgroup.js"></script> <script type="text/javascript" src="netgroup.js"></script> <script type="text/javascript" src="service.js"></script> <script type="text/javascript" src="serverconfig.js"></script> - <script type="text/javascript" src="sudorule.js"></script> - <script type="text/javascript" src="sudocmd.js"></script> - <script type="text/javascript" src="sudocmdgroup.js"></script> + <script type="text/javascript" src="sudo.js"></script> <script type="text/javascript" src="policy.js"></script> <script type="text/javascript" src="aci.js"></script> diff --git a/install/ui/jsl.conf b/install/ui/jsl.conf index 67cf84b12..a32d814b1 100644 --- a/install/ui/jsl.conf +++ b/install/ui/jsl.conf @@ -124,6 +124,7 @@ # To add a set of files, use "+process FileName", "+process Folder\Path\*.js", # or "+process Folder\Path\*.htm". # ++process core.js +process ipa.js +process widget.js +process dialog.js @@ -137,18 +138,16 @@ +process certificate.js +process user.js +process group.js -+process hbacrule.js -+process hbacsvc.js -+process hbacsvcgroup.js ++process hbac.js +process host.js +process hostgroup.js +process netgroup.js +process service.js +process serverconfig.js -+process sudorule.js -+process sudocmd.js -+process sudocmdgroup.js ++process sudo.js +process policy.js +process aci.js +process develop.js ++process dns.js ++process automount.js +process webui.js diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js index 251ffa4d2..9389d0197 100644 --- a/install/ui/netgroup.js +++ b/install/ui/netgroup.js @@ -23,52 +23,18 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ IPA.entity_factories.netgroup = function() { - - var that = IPA.entity({ - 'name': 'netgroup' - }); - - that.init = function() { - - that.facet( - IPA.search_facet({ - name: 'search', - label: IPA.messages.facets.search, - entity_name: that.name - }). - column({name:'cn'}). - column({name:'description'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.netgroup.add - }). - field(IPA.text_widget({ name: 'cn', undo: false})). - field(IPA.text_widget({ name: 'description', undo: false})))); - - that.facet( - IPA.details_facet({name: 'details'}). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.netgroup.identity - }). - input({name: 'cn'}). - input({name: 'description'}). - input({name: 'nisdomainname'}))); - - that.facet( - IPA.association_facet({ - name: 'memberof_netgroup', - associator: IPA.serial_associator - })); - - that.create_association_facets(); - that.entity_init(); - }; - - return that; + return IPA.entity_builder(). + entity('netgroup'). + search_facet({ + columns:['cn','description'], + add_fields:['cn', 'description']}). + details_facet([{ + section:'identity', + fields:['cn','description','nisdomainname']}]). + association_facet({ + name: 'memberof_netgroup', + associator: IPA.serial_associator + }). + standard_associations(). + build(); }; - - - diff --git a/install/ui/policy.js b/install/ui/policy.js index bbbf58049..ec202138c 100644 --- a/install/ui/policy.js +++ b/install/ui/policy.js @@ -23,652 +23,33 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ -/* DNS */ -IPA.entity_factories.dnszone = function() { - - var that = IPA.entity({ - name: 'dnszone' - }); - - that.init = function() { - - that.facet( - IPA.search_facet({ - name: 'search', - label: IPA.messages.facets.search, - entity_name: that.name - }). - column({name:'idnsname'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.dnszone.add - }). - field(IPA.text_widget({ name: 'idnsname', undo: false})). - field(IPA.text_widget({ name: 'idnssoamname', undo: false})). - field(IPA.text_widget({ name: 'idnssoarname', undo: false})))); - - that.facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.dnszone.identity - }). - 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'}))); - - that.facet( - IPA.records_facet({ - 'name': 'records', - 'label': IPA.metadata.objects.dnsrecord.label - })); - - that.create_association_facets(); - that.entity_init(); - }; - - return that; -}; - - -IPA.records_facet = function (spec){ - - spec = spec || {}; - - var that = IPA.facet(spec); - - that.record = null; - - var record_types =[ 'a', 'aaaa', 'dname', 'cname', 'mx', 'ns', 'ptr', - 'srv', 'txt', 'a6', 'afsdb', 'cert', 'ds', - 'key', 'kx', 'loc', 'naptr', 'nsec', - 'rrsig', 'sshfp']; - - function create_type_select(id,add_none) { - var type_select = $('<select/>',{ - id: id - }); - - if (add_none){ - type_select.append($('<option/>',{ - text: '(any)', - value: '' - })); - } - for (var t = 0 ; t < record_types.length ; t += 1){ - var record_type = record_types[t].toUpperCase(); - - type_select.append($('<option/>',{ - text: record_type, - value: record_type - })); - } - return type_select; - } - - - var entry_attrs = {}; - - - function add_click(){ - - var dialog = IPA.dialog({ - title: IPA.messages.objects.dnsrecord.add - }); - - dialog.create = function() { - - var dl = $('<dl/>').appendTo(dialog.container); - - $('<dt/>', { - html: IPA.messages.objects.dnsrecord.resource - }).appendTo(dl); - - var dd = $('<dd/>').appendTo(dl); - - dialog.resource = $('<input/>', { - type: 'text' - }).appendTo(dd); - - $('<dt/>', { - html: IPA.messages.objects.dnsrecord.type - }).appendTo(dl); - - dd = $('<dd/>').appendTo(dl); - - dialog.type = create_type_select('dns-record-type').appendTo(dd); - - $('<dt/>', { - html: IPA.messages.objects.dnsrecord.data - }).appendTo(dl); - - dd = $('<dd/>').appendTo(dl); - - dialog.data = $('<textarea/>', { - rows: 8, - cols: 20 - }).appendTo(dd); - }; - - dialog.add_button(IPA.messages.buttons.add_many, function() { - dialog.add(); - }); - - dialog.add_button(IPA.messages.buttons.add_and_close, function() { - dialog.add(); - dialog.close(); - }); - - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); - }); - - dialog.add = function() { - - var pkey = $.bbq.getState(that.entity_name+'-pkey', true); - var resource = dialog.resource.val(); - - var options = {}; - var key = dialog.type.val().toLowerCase()+'record'; - options[key] = dialog.data.val(); - - var command = IPA.command({ - method: 'dnsrecord_add', - args: [pkey, resource], - options: options, - on_success: function(data, text_status, xhr) { - reload(); - } - }); - - command.execute(); - }; - - dialog.init(); - - dialog.open(that.container); - } - - function delete_records(records_table){ - - var zone = $.bbq.getState('dnszone-pkey', true); - - var thead = records_table.find('thead'); - thead.find("INPUT[type='checkbox']"). - attr('checked', false); - - var tbody = records_table.find('tbody'); - - var records = []; - - $('input[type=checkbox]:checked', tbody).each( - function(index, input){ - var tr = $(input).parents('tr'); - var resource = $('[title=idnsname]', tr).text(); - var type = $('[title=type]', tr).text().toLowerCase(); - var data = $('[title=data]', tr).text(); - - records.push({ - resource: resource, - type: type, - data: data - }); - } - ); - - if (records.length === 0){ - return; - } - - var dialog = IPA.dialog({ - title: IPA.messages.buttons.remove - }); - - dialog.create = function() { - - var to_delete_table = - $('<table class="search-table" >'+ - '<thead><tr><th>Resource</th><th>Type</th></tr></thead>'+ - '<tbody></tbody></table>').appendTo(dialog.container); - - var to_delete_body = to_delete_table.find('tbody'); - - for (var i=0; i<records.length; i++) { - var record = records[i]; - - var tr = $('<tr></tr>').appendTo(to_delete_body); - - $('<td/>', { - html: record.resource - }).appendTo(tr); - - $('<td/>', { - html: record.type - }).appendTo(tr); - } - - $('<p/>', { - text: IPA.messages.search.delete_confirm - }).appendTo(dialog.container); - }; - - dialog.add_button(IPA.messages.buttons.remove, function() { - - var batch = IPA.batch_command({ - on_success: function() { - reload(); - dialog.close(); - }, - on_error: function() { - reload(); - dialog.close(); - } - }); - - for (var i=0; i<records.length; i++) { - var record = records[i]; - - var command = IPA.command({ - method: 'dnsrecord_del', - args: [zone, record.resource] - }); - - command.set_option(record.type+'record', record.data); - - batch.add_command(command); - } - - batch.execute(); - }); - - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); - }); - - dialog.init(); - - dialog.open(that.container); - } - - that.is_dirty = function() { - var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - var record = $.bbq.getState(that.entity_name + '-record', true) || ''; - return pkey != that.pkey || record != that.record; - }; - - function create(container) { - - container.attr('title', that.entity_name); - - $('<h1/>',{ - }).append(IPA.create_network_spinner()). - appendTo(container); - - var details = $('<div/>', { - 'class': 'content' - }).appendTo(container); - - var div = $('<div class="search-controls"></div>'). - appendTo(details); - - var control_span =$('<span class="record-filter"></span>').appendTo(div); - control_span.append(IPA.messages.objects.dnsrecord.resource); - control_span.append($('<input />',{ - type: "text", - id: 'dns-record-resource-filter', - name: 'search-' + that.entity_name + '-filter' - })); - - /* - THe OLD DNS plugin allowed for search based on record type. - This one does not. If the plugin gets modified to support - Record type searches, uncomment the followin lines and - adjust the code that modifies the search parameters. - - control_span.append('Type'); - create_type_select('dns-record-type-filter',true). - appendTo(control_span); - */ - - IPA.button({ - 'label': IPA.messages.buttons.find, - 'icon': 'ui-icon-search', - 'click': function(){refresh();} - }).appendTo(control_span); - - var action_panel_ul = $('.action-panel .entity-facet', that.container). - last(); - - var action_controls = $('<li/>',{ - "class":"action-controls"}).appendTo(action_panel_ul); - - - IPA.action_button({ - label: IPA.messages.buttons.remove, - icon: 'ui-icon-trash', - click: function(){ delete_records(records_table); } - }).appendTo(action_controls); - - IPA.action_button({ - label: IPA.messages.buttons.add, - icon: 'ui-icon-plus', - click: add_click - }).appendTo(action_controls); - - div.append('<span class="records-buttons"></span>'); - - var records_results = $('<div/>', { - 'class': 'records-results' - }).appendTo(details); - - var records_table = $('<table/>', { - 'class': 'search-table' - }).appendTo(records_results); - - var thead = $('<thead><tr></tr></thead>').appendTo(records_table); - var tbody = $('<tbody></tbody>').appendTo(records_table); - var tfoot = $('<tfoot></tfoot>').appendTo(records_table); - - var tr = thead.find('tr'); - tr.append($('<th style="width: 15px" />').append( - $('<input />',{ - type: 'checkbox', - click : function (evt){ - tbody.find("INPUT[type='checkbox']"). - attr('checked', this.checked); - } - }))); - tr.append($('<th/>',{ - text: IPA.get_entity_param("dnsrecord", "idnsname").label })); - tr.append($('<th>Record Type</th>')); - tr.append($('<th>Data</th>')); - - } - - function setup(container){ - - that.facet_setup(container); - - that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - that.record = $.bbq.getState(that.entity_name + '-record', true) || ''; - - - $('h1',container). - html("<span id='headerpkey' />"+IPA.messages.objects.dnsrecord.title+":" + that.pkey); - - - //commented out until data is searchable - //control_span.append('Data'); - //control_span.append($('<input />',{ - // type: "text", - // id: 'dns-record-data-filter', - // name: 'search-' + obj_name + '-filter' - //})); - - - - refresh(); - } - - - function load_on_win(data){ - display(that.entity_name,data); - } - - function load_on_fail(data){ - display(that.entity_name,data); - } - - function reload(){ - refresh(); - } - - - function refresh(){ - - var options = {}; - - var resource_filter = that.container. - find("#dns-record-resource-filter").val(); -// if (resource_filter){ -// options.idnsname = resource_filter; -// } - - var type_filter = that.container.find("#dns-record-type-filter").val(); - if (type_filter){ - options.type = type_filter; - } - - var data_filter = that.container.find("#dns-record-data-filter").val(); - if (data_filter){ - options.data = data_filter; - } - - var pkey = [$.bbq.getState(that.entity_name + '-pkey', true)]; - - if (resource_filter){ - pkey.push(resource_filter); - } - IPA.cmd('dnsrecord_find',pkey,options,load_on_win, load_on_fail); - - } - - - function generate_tr(thead, tbody, result){ - function generate_checkbox_td(tr, pkey) { - var checkbox = $('<input />', { - name: pkey, - title: pkey, - type: 'checkbox', - 'class': 'search-selector' - }); - var td = $('<td></td>'); - - td.append(checkbox); - tr.append(td); - } - - var tr = $('<tr></tr>').appendTo(tbody); - - generate_checkbox_td(tr, /*pkey_value*/ ''); - - //TODO get this fixed on the back end. For now, workaround - - if (result.idnsname){ - tr.append($('<td/>',{ - title:'idnsname', - text: result.idnsname[0] - })); - }else{ - tr.append($('<td/>',{ - title:'idnsname', - text: result.dn.split(',')[0].split('=')[1] - })); - - } - - for (var i = 0; i < record_types.length; i += 1){ - var field_name = record_types[i]; - var field = result[field_name+'record']; - if ( field ){ - var record_type = field_name; - var record_data = field[0]; - break; - } - } - - tr.append($('<td/>',{ - title:'type', - text: record_type - })); - tr.append($('<td/>',{ - title:'data', - text: record_data - })); - } - - //TODO this is cut and pasted from search, we need to unify - function 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){ - generate_tr(thead, tbody, result[i]); - } - - tfoot.find('td').remove(); - if (data.result.truncated) { - var message = IPA.messages.search.truncated; - message = message.replace('${counter}', data.result.count); - tfoot.append($('<td />',{ - colspan:2, - text:message})); - } else { - tfoot.append($('<td/>',{ - colspan:2, - text:data.result.summary})); - } - - } - - that.create = create; - that.setup = setup; - that.refresh = refresh; - - return that; -}; - - -/**Automount*/ - -IPA.entity_factories.automountlocation = function() { - - var that = IPA.entity({ - name: 'automountlocation' - }); - - that.init = function() { - - that.facet( - IPA.search_facet({ - name: 'search', - label: IPA.messages.facets.search, - entity_name: that.name - }). - column({name:'cn'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.automountlocation.add - }). - field(IPA.text_widget({ name: 'cn', undo: false})))); - - that.facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.automountlocation.identity - }). - input({name:'cn'}))); - - that.create_association_facets(); - that.entity_init(); - }; - - return that; -}; - - /**pwpolicy*/ - - IPA.entity_factories.pwpolicy = function() { - - var that = IPA.entity({ - name: 'pwpolicy' - }); - - that.init = function() { - - that.facet( - IPA.search_facet({ - name: 'search', - label: IPA.messages.facets.search, - entity_name: that.name - }). - column({name:'cn'}). - dialog( - IPA.add_dialog({ - name: 'add', - title: IPA.messages.objects.pwpolicy.add, - entity_name:'pwpolicy' - }). - field(IPA.text_widget({name: 'cn', undo: false})). - field(IPA.text_widget({name: 'cospriority', - undo: false})))); - - that.facet( - IPA.details_facet({name:'details'}). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.pwpolicy.identity - }). - input({name:'krbmaxpwdlife'}). - input({name:'krbminpwdlife'}). - input({name:'krbpwdhistorylength'}). - input({name:'krbpwdmindiffchars'}). - input({name:'krbpwdminlength'}))); - that.create_association_facets(); - that.entity_init(); - - }; - - return that; + return IPA.entity_builder(). + entity('pwpolicy'). + search_facet({ + columns:['cn'], + add_fields:['cn', 'cospriority']}). + details_facet([ + { + section : 'identity', + fields:['krbmaxpwdlife','krbminpwdlife','krbpwdhistorylength', + 'krbpwdmindiffchars','krbpwdminlength'] + }]). + standard_associations(). + build(); }; - - /** krbtpolicy Does not have search */ IPA.entity_factories.krbtpolicy = function() { - - var that = IPA.entity({ - name: 'krbtpolicy' - }); - - that.facet( - IPA.details_facet({ - name: 'details' - }). - section( - IPA.stanza({ - name: 'identity', - label: IPA.messages.objects.krbtpolicy.identity - }). - //input({name: 'uid',label:' '}). - input({name: 'krbmaxrenewableage'}). - input({name: 'krbmaxticketlife'}))); - - return that; + return IPA.entity_builder(). + entity('krbtpolicy'). + details_facet([{ + section: 'identity', + fields:[ 'krbmaxrenewableage','krbmaxticketlife' ] + }]). + build(); }; diff --git a/install/ui/search.js b/install/ui/search.js index 101347f98..9d22dfcc4 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -30,6 +30,7 @@ IPA.search_widget = function (spec) { var that = IPA.table_widget(spec); + that.entity_name = spec.entity_name; that.facet = spec.facet; that.create = function(container) { @@ -286,6 +287,7 @@ IPA.search_facet = function(spec) { var that = IPA.facet(spec); + that.entity_name = spec.entity_name; that.columns = []; that.columns_by_name = {}; @@ -406,6 +408,7 @@ IPA.search_facet = function(spec) { that.search_facet_create = that.create; that.search_facet_setup = that.setup; + return that; }; diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js index 6f54bbabe..4d1042314 100644 --- a/install/ui/serverconfig.js +++ b/install/ui/serverconfig.js @@ -28,29 +28,21 @@ /* Configuration */ IPA.entity_factories.config = function(){ - - var that = IPA.entity({ - name: 'config' - }).facet( - IPA.details_facet(). - section( - IPA.stanza({ - name: 'ipaserver', - label: IPA.messages.objects.config.ipaserver - }). - input({ - name: 'cn', - label: IPA.messages.objects.config.cn - }). - input({name:'ipacertificatesubjectbase'}). - input({name:'ipadefaultloginshell'}). - input({name:'ipadefaultprimarygroup'}). - input({name:'ipagroupsearchfields'}). - input({name:'ipahomesrootdir'}). - input({name:'ipamaxusernamelength'}). - input({name:'ipamigrationenabled'}). - input({name:'ipasearchrecordslimit'}). - input({name:'ipasearchtimelimit'}). - input({name:'ipausersearchfields'}))); - return that; + return IPA.entity_builder(). + entity('config'). + details_facet([{ + section: 'ipaserver', + label: IPA.messages.objects.config.ipaserver, + fields: + [{ + factory: IPA.text_widget, + name: 'cn', + label: IPA.messages.objects.config.cn + }, + 'ipacertificatesubjectbase','ipadefaultloginshell', + 'ipadefaultprimarygroup','ipagroupsearchfields', + 'ipahomesrootdir','ipamaxusernamelength', + 'ipamigrationenabled','ipasearchrecordslimit', + 'ipasearchtimelimit','ipausersearchfields']}]). + build(); };
\ No newline at end of file diff --git a/install/ui/service.js b/install/ui/service.js index d8d8ad501..8590550ae 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -25,9 +25,8 @@ IPA.entity_factories.service = function() { - return IPA.entity({ - name: 'service' - }). + return IPA.entity_builder(). + entity('service'). facet( IPA.search_facet(). column({name: 'krbprincipalname'}). @@ -37,13 +36,45 @@ IPA.entity_factories.service = function() { title: IPA.messages.objects.service.add, width: '450px' }))). - facet(IPA.service_details_facet()). + details_facet([ + { + section: 'details', + fields:['krbprincipalname', + { + factory:IPA.service_name_widget, + name: 'service', + label: IPA.messages.objects.service.service, + read_only: true + }, + { + factory:IPA.service_host_widget, + name: 'host', + label: IPA.messages.objects.service.host, + read_only: true + }] + }, + { + section : 'provisioning', + fields:[{ + factory:IPA.service_provisioning_status_widget, + name: 'provisioning_status', + label: IPA.messages.objects.service.status + }] + }, + { + section: 'certificate', + fields:[{ + factory:IPA.service_certificate_status_widget, + name: 'certificate_status', + label: IPA.messages.objects.service.status + }] + }]). facet(IPA.service_managedby_host_facet({ name: 'managedby_host', add_method: 'add_host', remove_method: 'remove_host' - })). - standard_associations(); + })). + standard_associations().build(); }; @@ -69,12 +100,9 @@ IPA.service_select_widget = function(spec) { container.append(select_widget); that.parent_create(container); }; - return that; - }; - IPA.service_add_dialog = function(spec) { spec = spec || {}; @@ -95,15 +123,12 @@ IPA.service_add_dialog = function(spec) { label: IPA.messages.objects.service.host, size: 40, undo: false - })); - - var param_info = IPA.get_method_param('service_add', 'force'); - - that.field( + })). + field( IPA.checkbox_widget({ name: 'force', - label: param_info.label, - tooltip: param_info.doc, + label: IPA.get_method_param('service_add', 'force').label, + tooltip: IPA.get_method_param('service_add', 'force').doc, undo: false })); @@ -126,50 +151,6 @@ IPA.service_add_dialog = function(spec) { }; -IPA.service_details_facet = function(spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec). - section(IPA.stanza({ - name: 'details', - label: IPA.messages.objects.service.details - }). - input({ - name: 'krbprincipalname' - }). - custom_input(IPA.service_name_widget({ - name: 'service', - label: IPA.messages.objects.service.service, - read_only: true - })). - custom_input(IPA.service_host_widget({ - name: 'host', - label: IPA.messages.objects.service.host, - read_only: true - }))). - section( - IPA.stanza({ - name: 'provisioning', - label: IPA.messages.objects.service.provisioning - }). - custom_input(IPA.service_provisioning_status_widget({ - name: 'provisioning_status', - label: IPA.messages.objects.service.status - }))). - section( - IPA.stanza({ - name: 'certificate', - label: IPA.messages.objects.service.certificate - }). - custom_input((IPA.service_certificate_status_widget({ - name: 'certificate_status', - label: IPA.messages.objects.service.status - })))); - - - return that; -}; IPA.service_name_widget = function(spec) { diff --git a/install/ui/sudorule.js b/install/ui/sudo.js index a97a7720a..742895a44 100644 --- a/install/ui/sudorule.js +++ b/install/ui/sudo.js @@ -22,175 +22,325 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ -IPA.sudo = {}; IPA.entity_factories.sudorule = function () { - var that = IPA.entity({ - 'name': 'sudorule' - }); + return IPA.entity_builder(). + entity('sudorule'). + search_facet({ + columns:['cn','description','cmdcategory'], + add_fields:['cn'] + }). + facet(IPA.sudorule_details_facet({ + 'name': 'details' + })). + build(); +}; - that.init = function() { +IPA.entity_factories.sudocmd = function () { + + return IPA.entity_builder(). + entity( 'sudocmd'). + search_facet({ + columns:['sudocmd','description'], + add_fields:['sudocmd','description']}). + details_facet([ + { + section : 'general', + label: IPA.messages.details.general, + fields:['sudocmd','description'] + }, + { + section: 'groups', + label: IPA.messages.objects.sudocmd.groups, + factory: IPA.details_section, + fields:[{ + factory: IPA.sudocmd_member_sudocmdgroup_table_widget, + name: 'memberof_sudocmdgroup', + label: '',//IPA.messages.objects.sudocmd.groups, + other_entity: 'sudocmdgroup', + save_values: false, + columns:[ + { + name: 'cn', + primary_key: true, + width: '150px', + link_entity: true + }, + { + name: 'description', + width: '150px' + } + ], + adder_columns:[ + { + name: 'cn', + primary_key: true, + width: '100px' + }, + { + name: 'description', + width: '100px' + } + ] + }] + }]). + build(); - var facet = IPA.sudorule_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); +}; - var dialog = IPA.sudo.rule_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.sudorule.add - }); - facet.dialog(dialog); +IPA.entity_factories.sudocmdgroup = function () { + return IPA.entity_builder(). + entity('sudocmdgroup'). + search_facet({ + columns:['cn','description'], + add_fields:['cn','description'] + }). + details_facet([ + { + + section: 'general', + label: IPA.messages.dialogs.general, + fields:['cn','description'] + }, + { + section: 'commands', + factory: IPA.details_section, + fields: [{ + factory: IPA.association_table_widget, + name: 'member_sudocmd', + label: IPA.messages.objects.sudocmdgroup.commands, + other_entity: 'sudocmd', + save_values: false, + columns:[ + { + name: 'sudocmd', + primary_key: true, + width: '150px', + link_entity: true + }, + { + name: 'description', + width: '150px' + } + ], + adder_columns: [ + { + name: 'sudocmd', + primary_key: true, + width: '100px' + }, + { + name: 'description', + width: '100px' + } + ] + }] + }]). + build(); +}; - that.add_facet(facet); - facet = IPA.sudorule_details_facet({ - 'name': 'details' +/* +* TODO: user the serial associator to perform back end operations. +*/ +IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) { + + spec = spec || {}; + + var that = IPA.association_table_widget(spec); + + that.association_table_widget_init(); + + that.get_records = function(on_success, on_error) { + + if (!that.values.length) return; + + var batch = IPA.batch_command({ + 'name': that.entity_name+'_'+that.name+'_show', + 'on_success': on_success, + 'on_error': on_error }); - that.add_facet(facet); - that.entity_init(); + for (var i=0; i<that.values.length; i++) { + var value = that.values[i]; + + var command = IPA.command({ + 'method': that.other_entity+'_show', + 'args': [value], + 'options': { + 'all': true, + 'rights': true + } + }); + + batch.add_command(command); + } + + batch.execute(); }; - return that; -}; + that.add = function(values, on_success, on_error) { + if (!values.length) return; -IPA.sudo.rule_add_dialog = function (spec) { + var batch = IPA.batch_command({ + 'name': that.entity_name+'_'+that.name+'_add', + 'on_success': on_success, + 'on_error': on_error + }); - spec = spec || {}; + var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - var that = IPA.add_dialog(spec); + for (var i=0; i<values.length; i++) { + var value = values[i]; - that.init = function() { + var command = IPA.command({ + 'method': that.other_entity+'_add_member', + 'args': [value] + }); - that.add_field(IPA.text_widget({name: 'cn', undo: false})); + command.set_option('sudocmd', pkey); + + batch.add_command(command); + } - that.add_dialog_init(); + batch.execute(); }; - return that; -}; + that.remove = function(values, on_success, on_error) { + if (!values.length) return; -IPA.sudorule_search_facet = function (spec) { + var batch = IPA.batch_command({ + 'name': that.entity_name+'_'+that.name+'_remove', + 'on_success': on_success, + 'on_error': on_error + }); - spec = spec || {}; + var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - var that = IPA.search_facet(spec); + for (var i=0; i<values.length; i++) { + var value = values[i]; - that.init = function() { + var command = IPA.command({ + 'method': that.other_entity+'_remove_member', + 'args': [value] + }); + + command.set_option('sudocmd', pkey); - that.create_column({name:'cn'}); - that.create_column({name:'description'}); - that.create_column({name:'cmdcategory'}); + batch.add_command(command); + } - that.search_facet_init(); + batch.execute(); }; return that; }; +IPA.sudo = {}; + + IPA.sudorule_details_facet = function (spec) { spec = spec || {}; var that = IPA.details_facet(spec); - that.init = function() { - - var section; + var section; - if (IPA.layout) { - section = that.create_section({ - 'name': 'general', - 'label': IPA.messages.dialogs.general, - 'template': 'sudorule-details-general.html #contents' - }); - - } else { - section = IPA.sudo.rule_details_general_section({ - 'name': 'general', - 'label': IPA.messages.dialogs.general - }); - that.add_section(section); - } - - section.text({name: 'cn', read_only: true}); - section.textarea({name: 'description'}); - section.radio({name: 'ipaenabledflag'}); - - section = IPA.rule_details_section({ - 'name': 'user', - 'label': IPA.messages.objects.sudorule.user, - 'field_name': 'usercategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.sudorule.anyone }, - { 'value': '', 'label': IPA.messages.objects.sudorule.specified_users } - ], - 'tables': [ - { 'field_name': 'memberuser_user' }, - { 'field_name': 'memberuser_group' } - ] + if (IPA.layout) { + section = that.create_section({ + 'name': 'general', + 'label': IPA.messages.dialogs.general, + 'template': 'sudorule-details-general.html #contents' }); - that.add_section(section); - - var category = section.radio({ name: 'usercategory' }); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberuser_user', - 'name': 'memberuser_user', 'category': category, - 'other_entity': 'user', 'add_method': 'add_user', 'remove_method': 'remove_user', - 'external': 'externaluser' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberuser_group', - 'name': 'memberuser_group', 'category': category, - 'other_entity': 'group', 'add_method': 'add_user', 'remove_method': 'remove_user' - })); - - section = IPA.rule_details_section({ - 'name': 'host', - 'label': IPA.messages.objects.sudorule.host, - 'field_name': 'hostcategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.sudorule.any_host }, - { 'value': '', 'label': IPA.messages.objects.sudorule.specified_hosts } - ], - 'tables': [ - { 'field_name': 'memberhost_host' }, - { 'field_name': 'memberhost_hostgroup' } - ] + } else { + section = IPA.sudo.rule_details_general_section({ + 'name': 'general', + 'label': IPA.messages.dialogs.general }); that.add_section(section); + } + + section.text({name: 'cn', read_only: true}); + section.textarea({name: 'description'}); + section.radio({name: 'ipaenabledflag'}); + + section = IPA.rule_details_section({ + 'name': 'user', + 'label': IPA.messages.objects.sudorule.user, + 'field_name': 'usercategory', + 'options': [ + { 'value': 'all', 'label': IPA.messages.objects.sudorule.anyone }, + { 'value': '', 'label': IPA.messages.objects.sudorule.specified_users } + ], + 'tables': [ + { 'field_name': 'memberuser_user' }, + { 'field_name': 'memberuser_group' } + ] + }); + that.add_section(section); + + var category = section.radio({ name: 'usercategory' }); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity_name+'-memberuser_user', + 'name': 'memberuser_user', 'category': category, + 'other_entity': 'user', 'add_method': 'add_user', 'remove_method': 'remove_user', + 'external': 'externaluser' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity_name+'-memberuser_group', + 'name': 'memberuser_group', 'category': category, + 'other_entity': 'group', 'add_method': 'add_user', 'remove_method': 'remove_user' + })); + + section = IPA.rule_details_section({ + 'name': 'host', + 'label': IPA.messages.objects.sudorule.host, + 'field_name': 'hostcategory', + 'options': [ + { 'value': 'all', 'label': IPA.messages.objects.sudorule.any_host }, + { 'value': '', 'label': IPA.messages.objects.sudorule.specified_hosts } + ], + 'tables': [ + { 'field_name': 'memberhost_host' }, + { 'field_name': 'memberhost_hostgroup' } + ] + }); + that.add_section(section); + + category = section.radio({ 'name': 'hostcategory' }); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity_name+'-memberhost_host', + 'name': 'memberhost_host', 'category': category, + 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host', + 'external': 'externalhost' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity_name+'-memberhost_hostgroup', + 'name': 'memberhost_hostgroup', 'category': category, + 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host' + })); + + section = IPA.sudo.rule_details_command_section({ + 'name': 'command', + 'label': IPA.messages.objects.sudorule.command + }); + that.add_section(section); - category = section.radio({ 'name': 'hostcategory' }); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberhost_host', - 'name': 'memberhost_host', 'category': category, - 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host', - 'external': 'externalhost' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberhost_hostgroup', - 'name': 'memberhost_hostgroup', 'category': category, - 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host' - })); + section = IPA.sudo.rule_details_runas_section({ + 'name': 'runas', + 'label': IPA.messages.objects.sudorule.runas + }); + that.add_section(section); - section = IPA.sudo.rule_details_command_section({ - 'name': 'command', - 'label': IPA.messages.objects.sudorule.command - }); - that.add_section(section); + that.details_facet_init(); - section = IPA.sudo.rule_details_runas_section({ - 'name': 'runas', - 'label': IPA.messages.objects.sudorule.runas - }); - that.add_section(section); + that.init = function() { - that.details_facet_init(); }; that.update = function() { diff --git a/install/ui/sudocmd.js b/install/ui/sudocmd.js deleted file mode 100644 index 748ec4b88..000000000 --- a/install/ui/sudocmd.js +++ /dev/null @@ -1,271 +0,0 @@ -/*jsl:import ipa.js */ - -/* 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, either version 3 of the License, or - * (at your option) any later version. - * - * 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, see <http://www.gnu.org/licenses/>. - */ - -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js, sudorule.js */ - -IPA.entity_factories.sudocmd = function () { - - var that = IPA.entity({ - 'name': 'sudocmd' - }); - - that.init = function() { - - var facet = IPA.sudocmd_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - - var dialog = IPA.sudo.cmd_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.sudocmd.add - }); - facet.dialog(dialog); - - that.add_facet(facet); - - facet = IPA.sudocmd_details_facet({ - 'name': 'details' - }); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; -}; - - -IPA.sudo.cmd_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({name:'sudocmd', undo: false})); - that.add_field(IPA.text_widget({name:'description', undo: false})); - - that.add_dialog_init(); - }; - - return that; -}; - - -IPA.sudocmd_search_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.search_facet(spec); - - that.init = function() { - - that.create_column({name:'sudocmd', primary_key: true}); - that.create_column({name:'description'}); - - that.search_facet_init(); - }; - - return that; -}; - - -IPA.sudocmd_details_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = IPA.details_list_section({ - 'name': 'general', - 'label': IPA.messages.details.general - }); - that.add_section(section); - - section.text({'name': 'sudocmd'}); - section.text({'name': 'description'}); - - section = IPA.details_section({ - 'name': 'groups', - 'label': IPA.messages.objects.sudocmd.groups - }); - that.add_section(section); - - var field = IPA.sudocmd_member_sudocmdgroup_table_widget({ - 'name': 'memberof_sudocmdgroup', - 'label': IPA.messages.objects.sudocmd.groups, - 'other_entity': 'sudocmdgroup', - 'save_values': false - }); - section.add_field(field); - - that.details_facet_init(); - }; - - return that; -}; - - -IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) { - - spec = spec || {}; - - var that = IPA.association_table_widget(spec); - - that.init = function() { - - var column = that.create_column({ - name: 'cn', - primary_key: true, - width: '150px' - }); - - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('<a/>', { - 'href': '#'+value, - 'click': function (value) { - return function() { - var state = IPA.tab_state(that.other_entity); - state[that.other_entity + '-facet'] = 'details'; - state[that.other_entity + '-pkey'] = value; - $.bbq.pushState(state); - return false; - }; - }(value), - 'html': value - }).appendTo(container); - }; - - that.create_column({ - name: 'description', - width: '150px' - }); - - that.create_adder_column({ - name: 'cn', - primary_key: true, - width: '100px' - }); - - that.create_adder_column({ - name: 'description', - width: '100px' - }); - - that.association_table_widget_init(); - }; - - that.get_records = function(on_success, on_error) { - - if (!that.values.length) return; - - var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_show', - 'on_success': on_success, - 'on_error': on_error - }); - - for (var i=0; i<that.values.length; i++) { - var value = that.values[i]; - - var command = IPA.command({ - 'method': that.other_entity+'_show', - 'args': [value], - 'options': { - 'all': true, - 'rights': true - } - }); - - batch.add_command(command); - } - - batch.execute(); - }; - - that.add = function(values, on_success, on_error) { - - if (!values.length) return; - - var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_add', - 'on_success': on_success, - 'on_error': on_error - }); - - var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - - for (var i=0; i<values.length; i++) { - var value = values[i]; - - var command = IPA.command({ - 'method': that.other_entity+'_add_member', - 'args': [value] - }); - - command.set_option('sudocmd', pkey); - - batch.add_command(command); - } - - batch.execute(); - }; - - that.remove = function(values, on_success, on_error) { - - if (!values.length) return; - - var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_remove', - 'on_success': on_success, - 'on_error': on_error - }); - - var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; - - for (var i=0; i<values.length; i++) { - var value = values[i]; - - var command = IPA.command({ - 'method': that.other_entity+'_remove_member', - 'args': [value] - }); - - command.set_option('sudocmd', pkey); - - batch.add_command(command); - } - - batch.execute(); - }; - - return that; -}; diff --git a/install/ui/sudocmdgroup.js b/install/ui/sudocmdgroup.js deleted file mode 100644 index 47be03d70..000000000 --- a/install/ui/sudocmdgroup.js +++ /dev/null @@ -1,187 +0,0 @@ -/*jsl:import ipa.js */ - -/* 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, either version 3 of the License, or - * (at your option) any later version. - * - * 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, see <http://www.gnu.org/licenses/>. - */ - -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js, sudorule.js */ - -IPA.entity_factories.sudocmdgroup = function () { - - var that = IPA.entity({ - 'name': 'sudocmdgroup' - }); - - that.init = function() { - - var facet = IPA.sudocmdgroup_search_facet({ - 'name': 'search', - 'label': IPA.messages.facets.search - }); - - var dialog = IPA.sudo.cmdgroup_add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.sudocmdgroup.add - }); - facet.dialog(dialog); - - that.add_facet(facet); - - facet = IPA.sudocmdgroup_details_facet({ - 'name': 'details' - }); - that.add_facet(facet); - - that.entity_init(); - }; - - return that; -}; - - -IPA.sudo.cmdgroup_add_dialog = function (spec) { - - spec = spec || {}; - - var that = IPA.add_dialog(spec); - - that.init = function() { - - that.add_field(IPA.text_widget({name:'cn', undo: false})); - that.add_field(IPA.text_widget({name:'description', undo: false})); - - that.add_dialog_init(); - }; - - return that; -}; - - -IPA.sudocmdgroup_search_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.search_facet(spec); - - that.init = function() { - - that.create_column({name:'cn', primary_key: true}); - that.create_column({name:'description'}); - - that.search_facet_init(); - }; - - return that; -}; - - -IPA.sudocmdgroup_details_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.details_facet(spec); - - that.init = function() { - - var section = IPA.details_list_section({ - 'name': 'general', - 'label': IPA.messages.dialogs.general - }); - that.add_section(section); - - section.text({'name': 'cn'}); - section.text({'name': 'description'}); - - section = IPA.details_section({ - 'name': 'commands', - 'label': IPA.messages.objects.sudocmdgroup.commands - }); - that.add_section(section); - - var field = IPA.sudocmdgroup_member_sudocmd_table_widget({ - 'name': 'member_sudocmd', - 'label': IPA.messages.objects.sudocmdgroup.commands, - 'other_entity': 'sudocmd', - 'save_values': false - }); - section.add_field(field); - - that.details_facet_init(); - }; - - return that; -}; - - -IPA.sudocmdgroup_member_sudocmd_table_widget = function (spec) { - - spec = spec || {}; - - var that = IPA.association_table_widget(spec); - - that.init = function() { - - var column = that.create_column({ - name: 'sudocmd', - primary_key: true, - width: '150px' - }); - - column.setup = function(container, record) { - container.empty(); - - var value = record[column.name]; - value = value ? value.toString() : ''; - - $('<a/>', { - 'href': '#'+value, - 'html': value, - 'click': function (value) { - return function() { - var state = IPA.tab_state(that.other_entity); - state[that.other_entity + '-facet'] = 'details'; - state[that.other_entity + '-pkey'] = value; - $.bbq.pushState(state); - return false; - }; - }(value) - }).appendTo(container); - }; - - that.create_column({ - name: 'description', - width: '150px' - }); - - that.create_adder_column({ - name: 'sudocmd', - primary_key: true, - width: '100px' - }); - - that.create_adder_column({ - name: 'description', - width: '100px' - }); - - that.association_table_widget_init(); - }; - - return that; -}; diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 039be0e61..6cc8fd72d 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -18,6 +18,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +var details_container; + module('details', { setup: function() { @@ -27,30 +29,39 @@ module('details', { "data", true, function(data, text_status, xhr) { + IPA.metadata = data.result.results[0]; + IPA.messages = data.result.results[1].messages; + IPA.whoami = data.result.results[2].result[0]; + IPA.env = data.result.results[3].result; + IPA.dns_enabled = data.result.results[4].result; }, function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } ); + details_container = $('<div id="details"/>').appendTo(document.body); + var obj_name = 'user'; - IPA.entity_factories.user= + IPA.entity_factories.user= function(){ return IPA.entity({name:obj_name}); }; IPA.start_entities(); }, teardown: function() { + details_container.remove(); } }); test("Testing IPA.details_section.create().", function() { - var section = IPA.stanza({name:'IDIDID', label:'NAMENAMENAME'}). - input({name:'cn'}). - input({name:'uid'}). - input({name:'mail'}); + var section = IPA.details_list_section({ + name:'IDIDID', label:'NAMENAMENAME'}). + text({name:'cn'}). + text({name:'uid'}). + text({name:'mail'}); section.entity_name = 'user'; section.init(); @@ -143,34 +154,57 @@ test("Testing details lifecycle: create, setup, load.", function(){ load_called = true; } - var container = $("<div/>"); + var container = details_container; var obj_name = 'user'; - var widget = IPA.widget({name: 'cn'}); - - widget.setup = function(container) { - setup_called = true; - widget.widget_setup(container); - }; - - widget.load = function(record) { - load_called = true; - widget.widget_load(record); - }; - - widget.save = function() { - save_called = true; - widget.widget_save(); - }; + function test_widget(){ + var widget = IPA.widget({name: 'cn'}); + + widget.setup = function(container) { + setup_called = true; + widget.widget_setup(container); + }; + + widget.load = function(record) { + load_called = true; + widget.widget_load(record); + }; + + widget.save = function() { + save_called = true; + widget.widget_save(); + }; + return widget; + } - IPA.entity_set_details_definition(obj_name, [ - IPA.stanza({name:'identity', label:'Identity Details'}). - custom_input(widget) - ]); + var entity = IPA. + entity_builder(). + entity('user'). + details_facet([ + { + section: 'identity', + label: IPA.messages.details.identity, + fields:['title','givenname','sn','cn','displayname', 'initials'] + }, + { + section: 'contact', + label:'contact', + fields: + [ {factory: test_widget,name:'test'}, + {factory: IPA.multivalued_text_widget, name:'mail'}, + {factory: IPA.multivalued_text_widget, + name:'telephonenumber'}, + {factory: IPA.multivalued_text_widget, name:'pager'}, + {factory: IPA.multivalued_text_widget, name:'mobile'}, + {factory: IPA.multivalued_text_widget, + name:'facsimiletelephonenumber'}] + }, + ]).build(); + entity.init(); - var entity = IPA.fetch_entity(obj_name); var facet = entity.get_facet('details'); + facet.init(); facet.create(container); facet.setup(container); facet.load(result); @@ -192,7 +226,7 @@ test("Testing details lifecycle: create, setup, load.", function(){ var dts = identity.find('dt'); same( - dts.length, 1, + dts.length, 6, 'Checking dt tags for identity' ); @@ -219,10 +253,11 @@ test("Testing details lifecycle: create, setup, load.", function(){ test("Testing IPA.details_section_setup again()",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 section = IPA.details_list_section({ + name: 'IDIDID', label: 'NAMENAMENAME'}). + text({name:'cn', label:'Entity Name'}). + text({name:'description', label:'Description'}). + text({name:'number', label:'Entity ID'}); var fields = section.fields; var container = $("<div title='entity'/>"); var details = $("<div/>"); diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index c901c35dd..5f7ba9e73 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -18,13 +18,46 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +var entities_container; + module('entity',{ setup: function() { - IPA.entity_factories.user = function(){ - return IPA.entity({name:'user'})}; - IPA.start_entities(); + + IPA.ajax_options.async = false; + + IPA.init( + "data", + true, + function(data, text_status, xhr) { + IPA.metadata = data.result.results[0]; + IPA.messages = data.result.results[1].messages; + IPA.whoami = data.result.results[2].result[0]; + IPA.env = data.result.results[3].result; + IPA.dns_enabled = data.result.results[4].result; + + IPA.entity_factories.user = function(){ + return IPA. + entity_builder(). + entity('user'). + search_facet({ + columns:['uid'], + add_fields:[]}). + build(); + }; + IPA.start_entities(); + }, + function(xhr, text_status, error_thrown) { + ok(false, "ipa_init() failed: "+error_thrown); + } + ); + + entities_container = $('<div id="entities"/>').appendTo(document.body); + }, teardown: function() { + entities_container.remove(); + } }); @@ -34,15 +67,21 @@ test('Testing IPA.entity_set_search_definition().', function() { return true; }; - IPA.entity_set_search_definition('user', [ - ['uid', 'Login', uid_callback] - ]); - var facet = IPA.entity_get_search_facet('user'); - ok( - facet, - 'IPA.entity_get_search_facet(\'user\') is not null' - ); + var entity = IPA. + entity_builder(). + entity('user'). + search_facet({ + columns:['uid'], + add_fields:[]}). + build(); + entity.init(); + + var facet = entity.get_facet('search'); + facet.init(); + facet.create(entities_container); + facet.setup(entities_container); + var column = facet.get_columns()[0]; ok( @@ -56,7 +95,7 @@ test('Testing IPA.entity_set_search_definition().', function() { ); equals( - column.label, 'Login', + column.label, 'User login', 'column.label' ); @@ -65,111 +104,5 @@ test('Testing IPA.entity_set_search_definition().', function() { 'column.setup not null' ); - ok( - column.setup(), - 'column.setup() works' - ); }); -test('Testing ipa_facet_setup_views().', function() { - - var orig_switch_and_show_page = IPA.switch_and_show_page; - 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); - } - ); - - - IPA.start_entities(); - - var entity = IPA.get_entity('user'); - var facet = IPA.search_facet({ - 'name': 'search', - 'label': 'Search' - }); - entity.add_facet(facet); - entity.create_association_facets(); - - - var container = $('<div/>'); - - entity.init(); - entity.setup(container); - - var counter = 0; - IPA.switch_and_show_page = function(entity_name, facet_name, pkey) { - counter++; - }; - - //Container now has two divs, one for the action panel one for content - var action_panel = facet.get_action_panel(); - ok(action_panel.length, 'action panel exists'); - - var ul = $('ul', action_panel); - - var views = ul.children(); - - /*6 Views: - one for each of 3 associations - one for search - one for details - a blank one for the action controls*/ - equals( - views.length, 6, - 'Checking number of views' - ); - - var li = views.first(); - ok( li.children().first().hasClass('action-controls'), - 'Checking that first item in list is placement for controls' - ); - - li = li.next(); // skip action controls - li = li.next(); // skip the header line for Member of - - var attribute_members = IPA.metadata.objects['user'].attribute_members; - for (var attribute_member in attribute_members) { - var objects = attribute_members[attribute_member]; - for (var i = 0; i < objects.length; i++) { - var object = objects[i]; - var title = attribute_member+'_'+object; - - li = li.next(); - var value = li.attr('title'); - equals( - value, title, - 'Checking the '+title+' facet' - ); - } - } - - var pkey_input = $('input[name=pkey]', action_panel); - ok(pkey_input.length,'pkey input exists'); - var search_facets = $('li.search-facet', action_panel); - equals(search_facets.length,0,'search facet should not show up in action panel'); - var entity_facets = $('li.entity-facet', action_panel); - /*No longer automatically adding details, so ony the assoc. facets */ - equals(entity_facets.length,4,'4 hidden entity facets in action panel'); - entity_facets.each(function() { - ok( $(this).hasClass('entity-facet-disabled'), - 'entity facets are disabled'); - }); - - for ( var entity_facet = entity_facets.first(); - entity_facet.length; - entity_facet = entity_facet.next()){ - entity_facet.click(); - } - - equals(counter, 0, 'links are disabled'); - - IPA.switch_and_show_page = orig_switch_and_show_page; -}); diff --git a/install/ui/user.js b/install/ui/user.js index 8e1cb3f91..0ea3acf29 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -23,81 +23,67 @@ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ -IPA.entity_factories.user = function() { - return IPA.entity({ - name: 'user' - }). - facet( - IPA.search_facet(). - column({name:'uid'}). - column({name:'cn'}). - column({name:'uidnumber'}). - column({name:'mail'}). - column({name:'telephonenumber'}). - column({name:'title'}). - dialog( - IPA.add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.user.add - }). - field(IPA.text_widget({ name: 'uid', undo: false })). - field(IPA.text_widget({ name: 'givenname', undo: false })). - field(IPA.text_widget({ name: 'sn', undo: false })))). - facet(IPA.details_facet(). - section( - IPA.stanza({name: 'identity', label: IPA.messages.details.identity}). - input({name:'title'}). - input({name:'givenname'}). - input({name:'sn'}). - input({name:'cn'}). - input({name:'displayname'}). - input({name:'initials'})). - section( - IPA.stanza({name: 'account', label: IPA.messages.objects.user.account}). - custom_input(IPA.user_status_widget({name:'nsaccountlock'})). - input({name:'uid'}). - custom_input(IPA.user_password_widget({name:'userpassword'})). - input({name:'uidnumber'}). - input({name:'gidnumber'}). - input({name:'loginshell'}). - input({name:'homedirectory'})). - section( - IPA.stanza({name: 'contact', label: IPA.messages.objects.user.contact}). - multivalued_text({name:'mail'}). - multivalued_text({name:'telephonenumber'}). - multivalued_text({name:'pager'}). - multivalued_text({name:'mobile'}). - multivalued_text({name:'facsimiletelephonenumber'})). - section( - IPA.stanza({name: 'mailing', label: IPA.messages.objects.user.mailing}). - input({name:'street'}). - input({name:'l'}). - input({name:'st'}). - input({name:'postalcode'})). - section( - IPA.stanza({name: 'employee', label: IPA.messages.objects.user.employee}). - input({name:'ou'}). - input({name:'manager'})). - section( - IPA.stanza({name: 'misc', label: IPA.messages.objects.user.misc}). - input({name:'carlicense'}))). - facet( - IPA.association_facet({ - name: 'memberof_group', - associator: IPA.serial_associator - })). - facet( - IPA.association_facet({ - name: 'memberof_netgroup', - associator: IPA.serial_associator - })). - facet( - IPA.association_facet({ - name: 'memberof_role', - associator: IPA.serial_associator - })). +IPA.entity_factories.user = function() { + var builder = IPA.entity_builder(); + builder. + entity('user'). + search_facet({ + columns:['uid','cn','uidnumber','mail','telephonenumber','title'], + add_fields: ['uid','givenname','sn'] + }). + details_facet([ + { + section: 'identity', + label: IPA.messages.details.identity, + fields:['title','givenname','sn','cn','displayname', 'initials'] + }, + { + section: 'account', + fields:[{factory:IPA.user_status_widget,name:'nsaccountlock'}, + 'uid', + {factory: IPA.user_password_widget,name:'userpassword'}, + 'uidnumber','gidnumber','loginshell','homedirectory'] + }, + { + section: 'contact', + fields: + [ {factory: IPA.multivalued_text_widget, name:'mail'}, + {factory: IPA.multivalued_text_widget, name:'telephonenumber'}, + {factory: IPA.multivalued_text_widget, name:'pager'}, + {factory: IPA.multivalued_text_widget, name:'mobile'}, + {factory: IPA.multivalued_text_widget, name:'facsimiletelephonenumber'}] + }, + { + section: 'mailing', + fields: ['street','l','st','postalcode'] + }, + { + section: 'employee', + fields: ['ou','manager'] + }, + { + section: 'misc', + fields:['carlicense'] + }]). + association_facet({ + name: 'memberof_group', + associator: IPA.serial_associator + }). + association_facet({ + name: 'memberof_netgroup', + associator: IPA.serial_associator + }). + association_facet({ + name: 'memberof_role', + associator: IPA.serial_associator + }). standard_associations(); + + + var entity = builder.build(); + + return entity; }; /* ATTRIBUTE CALLBACKS */ diff --git a/install/ui/webui.js b/install/ui/webui.js index 3223cbf05..4e2c78c47 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -47,6 +47,7 @@ IPA.admin_tab_set = function () { {name:'sudocmd', entity:'sudocmd'}, {name:'sudocmdgroup', entity:'sudocmdgroup'} ]}, +// {name:'automount', entity:'automountlocation'}, {name:'pwpolicy', entity:'pwpolicy'}, {name:'krbtpolicy', entity:'krbtpolicy'} ]}, |