diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2011-11-21 18:58:38 -0600 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-12-07 15:33:23 +0000 |
commit | 84019af3f12a5c8a908e7ca52a8d678e21184dce (patch) | |
tree | fa2e4321e6949b3670b82acafbc9ebb4ec00c25e /install/ui | |
parent | fa32699dbf1c509125e6a39e22b89c58fd1d5078 (diff) | |
download | freeipa-84019af3f12a5c8a908e7ca52a8d678e21184dce.tar.gz freeipa-84019af3f12a5c8a908e7ca52a8d678e21184dce.tar.xz freeipa-84019af3f12a5c8a908e7ca52a8d678e21184dce.zip |
Added external fields for HBAC Test.
A text field has been added for specifying external user, host, and
service for HBAC testing.
Ticket #388
Diffstat (limited to 'install/ui')
-rw-r--r-- | install/ui/facet.js | 6 | ||||
-rw-r--r-- | install/ui/hbactest.js | 173 | ||||
-rw-r--r-- | install/ui/widget.js | 1 |
3 files changed, 127 insertions, 53 deletions
diff --git a/install/ui/facet.js b/install/ui/facet.js index 4ffd43dcd..0680c1502 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 b195c796b..7f7030b9c 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 = $('<h3/>', { - text: that.label - }).appendTo(container); - - var filter_container = $('<div/>', { - 'class': 'search-filter' - }).appendTo(header); - - that.filter = $('<input/>', { - 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 = $('<div/>', { - style: 'position: relative; height: 200px' - }).appendTo(container); - - that.table.create(div); - - container.append('<br/>'); - - 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 = $('<h3/>', { + text: that.label + }).appendTo(container); + + var filter_container = $('<div/>', { + 'class': 'search-filter' + }).appendTo(header); + + that.filter = $('<input/>', { + 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 = $('<div/>', { + style: 'position: relative; height: 200px' + }).appendTo(container); + + that.table.create(div); + + container.append('<br/>'); + + var id = that.entity.name+'-'+that.name+'-external'; + var pkey_name = that.managed_entity.metadata.primary_key; + + that.external_radio = $('<input/>', { + id: id, + type: 'radio', + name: pkey_name, + value: '__external__', + click: function() { + that.selected_values = [ that.external_radio.val() ]; + } + }).appendTo(container); + + $('<label/>', { + text: 'Specify external '+that.managed_entity.metadata.label_singular+':', + 'for': id + }).appendTo(container); + + container.append(' '); + + that.external_text = $('<input/>', { + name: 'external', + focus: function() { + that.external_radio.click(); + } + }).appendTo(container); + + container.append('<br/>'); + + that.create_buttons(container); + }; + + that.get_selected_values = function() { + var values = that.table.get_selected_values(); + if (values && values.length) return values; + + if (that.external_radio && that.external_radio.is(':checked')) { + return [ that.external_radio.val() ]; + } + + return []; + }; + that.reset = function() { that.table.set_values([]); + if (that.external_radio) that.external_radio.attr('checked', false); }; that.save = function(record) { if (that.selected_values && that.selected_values.length) { - record[that.name] = that.selected_values[0]; + var value = that.selected_values[0]; + if (that.external_radio && value === that.external_radio.val()) { + record[that.name] = that.external_text.val(); + } else { + record[that.name] = value; + } } }; @@ -380,6 +444,10 @@ IPA.hbac.test_rules_facet = function(spec) { that.create_buttons(container); }; + that.get_selected_values = function() { + return that.table.get_selected_values(); + }; + that.reset = function() { that.table.set_values([]); if (that.enabled) that.enabled.attr('checked', false); @@ -397,6 +465,7 @@ IPA.hbac.test_rules_facet = function(spec) { record['disabled'] = true; } }; + init(); return that; diff --git a/install/ui/widget.js b/install/ui/widget.js index 0b3581569..ef2c6eb6e 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1413,6 +1413,7 @@ IPA.table_widget = function (spec) { that.table_set_enabled = that.set_enabled; that.table_set_page = that.set_page; that.table_show_error = that.show_error; + that.table_set_values = that.set_values; return that; }; |