From 7e062f7247d8900638a2f8458712245948e7296e Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Jan 11 2012 17:04:20 +0000 Subject: Added external fields for HBAC Test. A text field has been added for specifying external user, host, and service for HBAC testing. Ticket #388 --- diff --git a/install/ui/facet.js b/install/ui/facet.js index 4ffd43d..0680c15 100644 --- a/install/ui/facet.js +++ b/install/ui/facet.js @@ -602,9 +602,13 @@ IPA.table_facet = function(spec) { batch.execute(); }; + that.get_selected_values = function() { + return that.table.get_selected_values(); + }; + that.select_changed = function() { - that.selected_values = that.table.get_selected_values(); + that.selected_values = that.get_selected_values(); if (that.remove_button) { if (that.selected_values.length === 0) { diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js index b195c79..7f7030b 100644 --- a/install/ui/hbactest.js +++ b/install/ui/hbactest.js @@ -37,7 +37,7 @@ IPA.hbac.test_entity = function(spec) { that.builder.facet_groups([ 'default' ]). facet({ - factory: IPA.hbac.test_facet, + factory: IPA.hbac.test_select_facet, name: 'user', label: 'Who', managed_entity_name: 'user', @@ -50,7 +50,7 @@ IPA.hbac.test_entity = function(spec) { ] }). facet({ - factory: IPA.hbac.test_facet, + factory: IPA.hbac.test_select_facet, name: 'targethost', label: 'Accessing', managed_entity_name: 'host', @@ -66,7 +66,7 @@ IPA.hbac.test_entity = function(spec) { ] }). facet({ - factory: IPA.hbac.test_facet, + factory: IPA.hbac.test_select_facet, name: 'service', label: 'Via Service', managed_entity_name: 'hbacsvc', @@ -78,7 +78,7 @@ IPA.hbac.test_entity = function(spec) { ] }). facet({ - factory: IPA.hbac.test_facet, + factory: IPA.hbac.test_select_facet, name: 'sourcehost', label: 'From Host', managed_entity_name: 'host', @@ -100,7 +100,6 @@ IPA.hbac.test_entity = function(spec) { managed_entity_name: 'hbacrule', disable_breadcrumb: true, facet_group: 'default', - multivalued: true, columns: [ 'cn', 'ipaenabledflag', @@ -135,7 +134,6 @@ IPA.hbac.test_facet = function(spec) { spec = spec || {}; var that = IPA.table_facet(spec); - that.multivalued = spec.multivalued; var init = function() { @@ -151,51 +149,6 @@ IPA.hbac.test_facet = function(spec) { } that.init_table(that.managed_entity); - that.table.multivalued = that.multivalued ? true : false; - }; - - that.create_content = function(container) { - - var header = $('

', { - text: that.label - }).appendTo(container); - - 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 div = $('
', { - style: 'position: relative; height: 200px' - }).appendTo(container); - - that.table.create(div); - - container.append('
'); - - that.create_buttons(container); }; that.create_buttons = function(container) { @@ -311,13 +264,124 @@ IPA.hbac.test_facet = function(spec) { command.execute(); }; + init(); + + return that; +}; + +IPA.hbac.test_select_facet = function(spec) { + + var that = IPA.hbac.test_facet(spec); + + var init = function() { + that.table.multivalued = false; + + that.table.set_values = function(values) { + if (values && values.length && values[0] === '__external__') { + if (that.external_radio) that.external_radio.attr('checked', true); + } else { + that.table.table_set_values(values); + } + }; + }; + + that.create_content = function(container) { + + var header = $('

', { + text: that.label + }).appendTo(container); + + 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 div = $('
', { + style: 'position: relative; height: 200px' + }).appendTo(container); + + that.table.create(div); + + container.append('
'); + + var id = that.entity.name+'-'+that.name+'-external'; + var pkey_name = that.managed_entity.metadata.primary_key; + + that.external_radio = $('', { + id: id, + type: 'radio', + name: pkey_name, + value: '__external__', + click: function() { + that.selected_values = [ that.external_radio.val() ]; + } + }).appendTo(container); + + $('