/*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, facet.js, entity.js,hbac.js */ IPA.hbac.test_entity = function(spec) { var that = IPA.entity(spec); that.get_default_metadata = function() { return IPA.metadata.commands[that.name]; }; that.init = function() { that.entity_init(); that.label = IPA.messages.objects.hbactest.label; that.builder.facet_groups([ 'default' ]). facet({ factory: IPA.hbac.test_select_facet, name: 'user', label: 'Who', managed_entity_name: 'user', disable_breadcrumb: true, facet_group: 'default', columns: [ 'uid', 'givenname', 'sn' ] }). facet({ factory: IPA.hbac.test_select_facet, name: 'targethost', label: 'Accessing', managed_entity_name: 'host', disable_breadcrumb: true, facet_group: 'default', columns: [ 'fqdn', 'description', { name: 'has_keytab', label: IPA.messages.objects.host.enrolled } ] }). facet({ factory: IPA.hbac.test_select_facet, name: 'service', label: 'Via Service', managed_entity_name: 'hbacsvc', disable_breadcrumb: true, facet_group: 'default', columns: [ 'cn', 'description' ] }). facet({ factory: IPA.hbac.test_select_facet, name: 'sourcehost', label: 'From Host', managed_entity_name: 'host', disable_breadcrumb: true, facet_group: 'default', columns: [ 'fqdn', 'description', { name: 'has_keytab', label: IPA.messages.objects.host.enrolled } ] }). facet({ factory: IPA.hbac.test_rules_facet, name: 'rules', label: 'On Rules', managed_entity_name: 'hbacrule', disable_breadcrumb: true, facet_group: 'default', columns: [ 'cn', 'ipaenabledflag', 'description' ] }). facet({ factory: IPA.hbac.test_run_facet, name: 'run', label: 'Run Test', managed_entity_name: 'hbacrule', disable_breadcrumb: true, pagination: true, facet_group: 'default', columns: [ 'cn', { name: 'matched', label: 'Matched' }, 'ipaenabledflag', 'description' ] }); }; return that; }; IPA.hbac.test_facet = function(spec) { spec = spec || {}; var that = IPA.table_facet(spec); var init = function() { that.managed_entity = IPA.get_entity(that.managed_entity_name); var columns = that.columns.values; for (var i=0; i', { 'class': 'hbac-test-navigation-buttons' }).appendTo(container); var facet_group = that.entity.get_facet_group('default'); var index = facet_group.get_facet_index(that.name); if (index > 0) { that.back_button = IPA.button({ name: 'back', label: 'Back', icon: 'ui-icon ui-icon-triangle-1-w', click: function() { if (!that.back_button.hasClass('action-button-disabled')) { that.back(); } return false; } }).appendTo(buttons); buttons.append(' '); } that.next_button = IPA.button({ name: 'next', label: 'Next', icon: 'ui-icon ui-icon-triangle-1-e', click: function() { if (!that.next_button.hasClass('action-button-disabled')) { that.next(); } return false; } }).appendTo(buttons); }; that.find = function() { var filter = that.filter.val(); var state = {}; state[that.entity.name+'-'+that.name+'-filter'] = filter; IPA.nav.push_state(state); }; that.back = function() { var facet_group = that.entity.get_facet_group('default'); var index = facet_group.get_facet_index(that.name); if (index <= 0) return; var facet = facet_group.get_facet_by_index(index - 1); var state = {}; state[that.entity.name+'-facet'] = facet.name; IPA.nav.push_state(state); }; that.next = function() { var facet_group = that.entity.get_facet_group('default'); var index = facet_group.get_facet_index(that.name); if (index >= facet_group.get_facet_count() - 1) return; var facet = facet_group.get_facet_by_index(index + 1); var state = {}; state[that.entity.name+'-facet'] = facet.name; IPA.nav.push_state(state); }; that.get_pkeys = function(data) { var result = data.result.result; var pkey_name = that.managed_entity.metadata.primary_key; var pkeys = []; for (var i=0; i', { 'class': 'hbac-test-header' }).appendTo(container); var title = $('', { text: that.label, 'class': 'hbac-test-title' }).appendTo(header); var filter_container = $('
', { 'class': 'search-filter' }).appendTo(header); that.filter = $('', { type: 'text', name: 'filter' }).appendTo(filter_container); that.filter.keypress(function(e) { /* if the key pressed is the enter key */ if (e.which == 13) { that.find(); } }); that.find_button = IPA.action_button({ name: 'find', icon: 'search-icon', click: function() { that.find(); return false; } }).appendTo(filter_container); header.append(IPA.create_network_spinner()); var content = $('
', { 'class': 'hbac-test-content' }).appendTo(container); that.table.create(content); var id = that.entity.name+'-'+that.name+'-external'; var pkey_name = that.managed_entity.metadata.primary_key; var tr = $('').appendTo(that.table.tfoot); var td = $('', { name: 'external' }).appendTo(tr); that.external_radio = $('', { id: id, type: 'radio', name: pkey_name, value: '__external__', click: function() { that.selected_values = [ that.external_radio.val() ]; } }).appendTo(td); $('