/* Authors: * Adam Young * Endi S. Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; version 2 only * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ define(['./ipa', './jquery', './details', './search', './association', './entity'], function(IPA, $) { IPA.aci = {}; IPA.aci.permission_entity = function(spec) { var that = IPA.entity(spec); that.init = function() { that.entity_init(); that.builder.facet_groups(['settings', 'privilege']). search_facet({ columns: [ 'cn' ] }). details_facet({ factory: IPA.aci.permission_details_facet, fields: [ { name:'cn', widget: 'identity.cn' }, { type: 'rights', name: 'permissions', widget: 'rights.permissions' }, { type: 'select', name: 'target', widget: 'target.target', enabled: false }, { name: 'filter', widget: 'target.filter', enabled: false }, { type: 'entity_select', name: 'memberof', widget: 'target.memberof', enabled: false }, { name: 'subtree', widget: 'target.subtree', enabled: false }, { type: 'entity_select', name: 'targetgroup', widget: 'target.targetgroup', enabled: false }, { type: 'select', name: 'type', widget: 'target.type', enabled: false }, { name: 'attrs', widget: 'target.attrs', enabled: false }, { name: 'attrs_multi', param: 'attrs', type: 'multivalued', widget: 'target.attrs_multi', enabled: false } ], widgets: [ { type: 'details_table_section', name: 'identity', label: IPA.messages.objects.permission.identity, widgets: [ 'cn' ] }, { type: 'details_table_section', name: 'rights', label: IPA.messages.objects.permission.rights, widgets: [ { type: 'rights', name: 'permissions' } ] }, { type: 'permission_target', container_factory: IPA.details_table_section, label: IPA.messages.objects.permission.target, name: 'target', show_target: false } ], policies: [ IPA.permission_target_policy('target') ] }). association_facet({ name: 'member_privilege', facet_group: 'privilege' }). adder_dialog({ height: 450, fields: [ { name:'cn', widget: 'general.cn' }, { type: 'rights', name: 'permissions', widget: 'general.permissions' }, { type: 'select', name: 'target', widget: 'target.target', enabled: false }, { name: 'filter', widget: 'target.filter', enabled: false }, { type: 'entity_select', name: 'memberof', widget: 'target.memberof', enabled: false }, { name: 'subtree', widget: 'target.subtree', enabled: false }, { type: 'entity_select', name: 'targetgroup', widget: 'target.targetgroup', enabled: false }, { type: 'select', name: 'type', widget: 'target.type', enabled: false }, { name: 'attrs', widget: 'target.attrs', enabled: false }, { name: 'attrs_multi', type: 'multivalued', param: 'attrs', widget: 'target.attrs_multi', enabled: false } ], widgets: [ { type: 'details_table_section_nc', name: 'general', widgets: [ 'cn', { type: 'rights', name: 'permissions' } ] }, { type: 'permission_target', name:'target', show_target: true } ], policies: [ IPA.permission_target_policy('target') ] }); }; return that; }; IPA.aci.permission_details_facet = function(spec) { var that = IPA.details_facet(spec); that.get_refresh_command_name = function() { return that.entity.name+'_show_'+that.pkey; }; return that; }; IPA.aci.privilege_entity = function(spec) { var that = IPA.entity(spec); that.init = function() { that.entity_init(); that.builder.facet_groups(['permission', 'settings', 'role']). search_facet({ columns: [ 'cn', 'description' ] }). details_facet({ sections: [ { name: 'identity', label: IPA.messages.details.identity, fields: [ 'cn', { type: 'textarea', name: 'description' } ] } ] }). association_facet({ name: 'member_role', facet_group: 'role', add_method: 'add_privilege', remove_method: 'remove_privilege', associator: IPA.serial_associator }). association_facet({ name: 'memberof_permission', facet_group: 'permission', add_method: 'add_permission', remove_method: 'remove_permission' }). standard_association_facets(). adder_dialog({ fields: [ 'cn', { type: 'textarea', name: 'description' } ] }); }; return that; }; IPA.aci.role_entity = function(spec) { var that = IPA.entity(spec); that.init = function() { that.entity_init(); that.builder.facet_groups(['member', 'privilege', 'settings']). search_facet({ columns: [ 'cn', 'description' ] }). details_facet({ sections: [ { name: 'identity', label: IPA.messages.objects.role.identity, fields: [ 'cn', { type: 'textarea', name: 'description' } ] } ] }). association_facet({ name: 'memberof_privilege', facet_group: 'privilege', add_method: 'add_privilege', remove_method: 'remove_privilege' }). standard_association_facets(). adder_dialog({ fields: [ 'cn', { type: 'textarea', name: 'description' } ] }); }; return that; }; IPA.aci.selfservice_entity = function(spec) { var that = IPA.entity(spec); that.init = function() { that.entity_init(); that.builder.search_facet({ columns: [ 'aciname' ], pagination: false }). details_facet({ check_rights: false, sections: [ { name: 'general', label: IPA.messages.details.general, fields: [ 'aciname', { type: 'attributes', object_type: 'user', name: 'attrs' } ] } ] }). adder_dialog({ fields: [ 'aciname', { type: 'attributes', object_type: 'user', name: 'attrs' } ] }); }; return that; }; IPA.aci.delegation_entity = function(spec) { var that = IPA.entity(spec); that.group_entity = IPA.get_entity(spec.group_entity || 'group'); that.init = function() { that.entity_init(); that.builder.search_facet({ columns: [ 'aciname' ], pagination: false }). details_facet({ check_rights: false, sections: [ { name: 'general', label: IPA.messages.details.general, fields: [ 'aciname', { type: 'checkboxes', name: 'permissions', required: true, options: IPA.create_options(['read', 'write']) }, { type: 'entity_select', name: 'group', other_entity: that.group_entity, other_field: 'cn' }, { type: 'entity_select', name: 'memberof', other_entity: that.group_entity, other_field: 'cn' }, { type: 'attributes', name: 'attrs', object_type: 'user' } ] } ] }). standard_association_facets(). adder_dialog({ fields: [ 'aciname', { type: 'checkboxes', name: 'permissions', options: IPA.create_options(['read', 'write']) }, { type: 'entity_select', name: 'group', other_entity: that.group_entity, other_field: 'cn' }, { type: 'entity_select', name: 'memberof', other_entity: that.group_entity, other_field: 'cn' }, { type: 'attributes', name: 'attrs', object_type: 'user' } ] }); }; return that; }; IPA.attributes_widget = function(spec) { spec = spec || {}; var that = IPA.checkboxes_widget(spec); that.object_type = spec.object_type; that.skip_unmatched = spec.skip_unmatched === undefined ? false : spec.skip_unmatched; var id = spec.name; that.create = function(container) { that.container = container; var attr_container = $('
', { 'class': 'aci-attribute-table-container' }).appendTo(container); that.$node = that.table = $('', { id:id, 'class':'search-table aci-attribute-table scrollable' }). append(''). append(''). appendTo(attr_container); var tr = $('').appendTo($('thead', that.table)); tr.append($('
', { html: $('', { type: "checkbox", click: function() { $('.aci-attribute', that.table). prop('checked', $(this).prop('checked')); that.value_changed.notify([], that); } }) })).append($('', { 'class': 'aci-attribute-column', html: IPA.messages.objects.aci.attribute })); if (that.undo) { that.create_undo(container); } if (that.object_type) { that.populate(that.object_type); } that.create_error_link(container); }; that.create_options = function(options) { var tbody = $('tbody', that.table); for (var i=0; i').appendTo(tbody); var td = $('').appendTo(tr); var name = that.get_input_name(); var id = that.option_next_id + name; td.append($('',{ id: id, type: 'checkbox', name: name, value: value, 'class': 'aci-attribute', change: function() { that.value_changed.notify([], that); } })); td = $('').appendTo(tr); td.append($('