From 4270e26adb56b6d1b7a9e80433581b82519d9eec Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 18 Mar 2011 16:43:54 -0400 Subject: define entities using builder and more declarative syntax merged hbac and sudo in to single files associaton facet and table supports linking --- install/ui/sudo.js | 1276 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1276 insertions(+) create mode 100644 install/ui/sudo.js (limited to 'install/ui/sudo.js') diff --git a/install/ui/sudo.js b/install/ui/sudo.js new file mode 100644 index 00000000..742895a4 --- /dev/null +++ b/install/ui/sudo.js @@ -0,0 +1,1276 @@ +/*jsl:import ipa.js */ + +/* Authors: + * Endi Sukma 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, 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 . + */ + +/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ + + +IPA.entity_factories.sudorule = function () { + + return IPA.entity_builder(). + entity('sudorule'). + search_facet({ + columns:['cn','description','cmdcategory'], + add_fields:['cn'] + }). + facet(IPA.sudorule_details_facet({ + 'name': 'details' + })). + build(); +}; + +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(); + +}; + +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(); +}; + + +/* +* 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 + }); + + for (var i=0; i= 0) { + // prepare command to remove members if needed + var attribute = field.name.substring(0, p); + var other_entity = field.name.substring(p+1); + + if (member_operations[attribute] && values.length) { + member_operations[attribute].command.set_option(other_entity, values.join(',')); + member_operations[attribute].has_values = true; + } + continue; + } + + // skip unchanged field + if (!field.is_dirty(span)) continue; + + // check enable/disable + if (field.name == 'ipaenabledflag') { + if (values[0] == 'FALSE') enable_operation.command.method = that.entity_name+'_disable'; + enable_operation.execute = true; + continue; + } + + + if (categories[field.name] && values[0] == 'all') { + categories[field.name].remove_values = true; + } + + // use setattr/addattr if param_info not available + if (!param_info) { + for (var k=0; k', { + 'style': 'width: 100%;' + }).appendTo(container); + + var param_info = IPA.get_entity_param(that.entity_name, 'cn'); + + var tr = $('').appendTo(table); + + var td = $('', { + style: 'width: 100px; text-align: right;', + html: param_info.label+':', + title: param_info ? param_info.doc : 'cn' + }).appendTo(tr); + + td = $('').appendTo(tr); + + var field = that.get_field('cn'); + + var span = $('', { + name: 'cn', + title: param_info ? param_info.doc : 'cn' + }).appendTo(td); + + $('