diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2016-12-09 13:08:05 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-03-14 10:40:10 +0100 |
commit | 587b7324fb1f6899deb151c30662362c18c5258e (patch) | |
tree | e2fe66f5de873dd5d672b28b44ccd6d99b63fb1f | |
parent | de4d4a51b542b8e473919dbc14f7a0810944b544 (diff) | |
download | freeipa-587b7324fb1f6899deb151c30662362c18c5258e.tar.gz freeipa-587b7324fb1f6899deb151c30662362c18c5258e.tar.xz freeipa-587b7324fb1f6899deb151c30662362c18c5258e.zip |
WebUI: allow to show rows with same pkey in tables
Allows to show rows which have the same primary key. Used in Vault.
https://fedorahosted.org/freeipa/ticket/5426
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r-- | install/ui/src/freeipa/association.js | 24 | ||||
-rw-r--r-- | install/ui/src/freeipa/automember.js | 5 | ||||
-rw-r--r-- | install/ui/src/freeipa/dns.js | 5 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 56 | ||||
-rw-r--r-- | install/ui/src/freeipa/hbactest.js | 16 | ||||
-rw-r--r-- | install/ui/src/freeipa/service.js | 10 | ||||
-rw-r--r-- | install/ui/src/freeipa/topology.js | 4 |
7 files changed, 90 insertions, 30 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index 04b375a94..27a76a5cd 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -1042,6 +1042,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) { that.facet_group = spec.facet_group; that.read_only = spec.read_only; + that.show_values_with_dup_key = spec.show_values_with_dup_key || false; that.associator = spec.associator || IPA.bulk_associator; that.add_method = spec.add_method || 'add_member'; @@ -1318,6 +1319,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) { that.get_records_map = function(data) { var records_map = $.ordered_map(); + var pkeys_map = $.ordered_map(); var association_name = that.get_attribute_name(); var pkey_name = that.managed_entity.metadata.primary_key; @@ -1326,10 +1328,18 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) { var pkey = pkeys[i]; var record = {}; record[pkey_name] = pkey; - records_map.put(pkey, record); + var compound_pkey = pkey; + if (that.show_values_with_dup_key) { + compound_pkey = pkey + i; + } + records_map.put(compound_pkey, record); + pkeys_map.put(compound_pkey, pkey); } - return records_map; + return { + records_map: records_map, + pkeys_map: pkeys_map + }; }; that.refresh = function() { @@ -1488,16 +1498,22 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) { that.get_records_map = function(data) { var records_map = $.ordered_map(); + var pkeys_map = $.ordered_map(); var pkeys = data.result.result[that.attribute]; for (var i=0; pkeys && i<pkeys.length; i++) { var pkey = pkeys[i]; var record = {}; record[that.attribute] = pkey; - records_map.put(pkey, record); + var compound_pkey = pkey + i; + records_map.put(compound_pkey, record); + pkeys_map.put(compound_pkey, pkey); } - return records_map; + return { + records_map: records_map, + pkeys_map: pkeys_map + }; }; that.refresh = function() { diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js index 0a7396729..a1d56a1b1 100644 --- a/install/ui/src/freeipa/automember.js +++ b/install/ui/src/freeipa/automember.js @@ -167,9 +167,10 @@ IPA.automember.rule_search_facet = function(spec) { return name; }; - that.create_get_records_command = function(pkeys, on_success, on_error) { + that.create_get_records_command = function(records, pkeys, on_success, on_error) { - var batch = that.table_facet_create_get_records_command(pkeys, on_success, on_error); + var batch = that.table_facet_create_get_records_command(records, pkeys, + on_success, on_error); for (var i=0; i<batch.commands.length; i++) { var command = batch.commands[i]; diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js index df6dbbd75..1ea3aaa98 100644 --- a/install/ui/src/freeipa/dns.js +++ b/install/ui/src/freeipa/dns.js @@ -875,7 +875,9 @@ IPA.dns.record_search_facet = function(spec) { var that = IPA.nested_search_facet(spec); - that.get_records = function(pkeys, on_success, on_error) { + that.get_records = function(records, pkeys_list, on_success, on_error) { + + var pkeys = pkeys_list.keys; var batch = rpc.batch_command({ name: that.get_records_command_name(), @@ -887,6 +889,7 @@ IPA.dns.record_search_facet = function(spec) { for (var i=0; i<pkeys.length; i++) { var pkey = pkeys[i]; + var call_pkey = pkeys_list.get(pkey); var command = rpc.command({ entity: that.table.entity.name, diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index c3d0b498e..2bf5b9628 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -1835,6 +1835,14 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { var that = IPA.facet(spec, no_init); /** + * Sets whether table on the facet will or will not show items with the + * same key. + * + * @property {boolean} + */ + that.show_values_with_dup_key = spec.show_values_with_dup_key || false; + + /** * Names of additional row attributes which will be send to another facet * during navigation as URL parameters. * @@ -2074,11 +2082,13 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { * * @protected * @param {Object} data RPC command data - * @return {ordered_map} record map + * @return {Object} ordered_maps with records and with pkeys. keys + * are composed from pkey and index. */ that.get_records_map = function(data) { var records_map = $.ordered_map(); + var pkeys_map = $.ordered_map(); var result = data.result.result; var pkey_name = that.managed_entity.metadata.primary_key || @@ -2089,11 +2099,21 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { var record = result[i]; var pkey = adapter.load(record, pkey_name)[0]; if (that.filter_records(records_map, pkey, record)) { - records_map.put(pkey, record); + // This solution allows to show tables where are the same + // primary keys. (i.e. {User|Service} Vaults) + var compound_pkey = pkey; + if (that.show_values_with_dup_key) { + compound_pkey = pkey + i; + } + records_map.put(compound_pkey, record); + pkeys_map.put(compound_pkey, pkey); } } - return records_map; + return { + records_map: records_map, + pkeys_map: pkeys_map + }; }; /** @@ -2110,7 +2130,9 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { that.load_page = function(data) { // get primary keys (and the complete records if search_all_entries is true) - var records_map = that.get_records_map(data); + var records = that.get_records_map(data); + var records_map = records.records_map; + var pkeys_map = records.pkeys_map; var total = records_map.length; that.table.total_pages = total ? Math.ceil(total / that.table.page_length) : 1; @@ -2146,11 +2168,11 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { // sort map based on primary keys if (that.sort_enabled) { - records_map = records_map.sort(); + pkeys_map = pkeys_map.sort(); } // trim map leaving the entries visible in the current page only - records_map = records_map.slice(start-1, end); + pkeys_map = pkeys_map.slice(start-1, end); var columns = that.table.columns.values; if (columns.length == 1) { // show primary keys only @@ -2167,16 +2189,19 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { // get the complete records that.get_records( records_map, + pkeys_map, function(data, text_status, xhr) { var results = data.result.results; - for (var i=0; i<records_map.length; i++) { - var pkey = records_map.keys[i]; + var show_records_map = $.ordered_map(); + for (var i=0; i<pkeys_map.length; i++) { + var pkey = pkeys_map.keys[i]; var record = records_map.get(pkey); // merge the record obtained from the refresh() // with the record obtained from get_records() $.extend(record, results[i].result); + show_records_map.put(pkey, record); } - that.load_records(records_map.values); + that.load_records(show_records_map.values); }, function(xhr, text_status, error_thrown) { that.load_records([]); @@ -2249,9 +2274,9 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { * @param {Function} on_success command success handler * @param {Function} on_failure command error handler */ - that.create_get_records_command = function(records, on_success, on_error) { + that.create_get_records_command = function(records, pkeys_list, on_success, on_error) { - var pkeys = records.keys; + var pkeys = pkeys_list.keys; var batch = rpc.batch_command({ name: that.get_records_command_name(), @@ -2261,11 +2286,12 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { for (var i=0; i<pkeys.length; i++) { var pkey = pkeys[i]; + var call_pkey = pkeys_list.get(pkey); var command = rpc.command({ entity: that.table.entity.name, method: 'show', - args: [pkey] + args: [call_pkey] }); if (that.show_command_additional_attr) { @@ -2304,13 +2330,13 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) { * Execute command for obtaining complete records * * @protected - * @param {Array.<string>} pkeys primary keys + * @param records_map of all records * @param {Function} on_success command success handler * @param {Function} on_failure command error handler */ - that.get_records = function(pkeys, on_success, on_error) { + that.get_records = function(records, pkeys, on_success, on_error) { - var batch = that.create_get_records_command(pkeys, on_success, on_error); + var batch = that.create_get_records_command(records, pkeys, on_success, on_error); batch.execute(); }; diff --git a/install/ui/src/freeipa/hbactest.js b/install/ui/src/freeipa/hbactest.js index 9ac4e8293..83e609381 100644 --- a/install/ui/src/freeipa/hbactest.js +++ b/install/ui/src/freeipa/hbactest.js @@ -706,12 +706,15 @@ IPA.hbac.test_run_facet = function(spec) { that.get_records_map = function(data) { var records_map = $.ordered_map(); + var pkeys_map = $.ordered_map(); var matched = data.result.matched; if (that.show_matched && matched) { for (var i=0; i<matched.length; i++) { var pkey = matched[i]; - records_map.put(pkey, { matched: true }); + var compound_pkey = pkey + i; + records_map.put(compound_pkey, { matched: true }); + pkeys_map.put(compound_pkey, pkey); } } @@ -719,11 +722,16 @@ IPA.hbac.test_run_facet = function(spec) { if (that.show_unmatched && notmatched) { for (i=0; i<notmatched.length; i++) { pkey = notmatched[i]; - records_map.put(pkey, { matched: false }); + compound_pkey = pkey + i; + records_map.put(compound_pkey, { matched: false }); + pkeys_map.put(compound_pkey, pkey); } } - return records_map; + return { + records_map: records_map, + pkeys_map: pkeys_map + }; }; that.get_records_command_name = function() { @@ -811,4 +819,4 @@ exp.register = function() { phases.on('registration', exp.register); return exp; -});
\ No newline at end of file +}); diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js index 279f842a0..752ff98e3 100644 --- a/install/ui/src/freeipa/service.js +++ b/install/ui/src/freeipa/service.js @@ -430,6 +430,7 @@ IPA.service.search_facet = function(spec) { that.get_records_map = function(data) { var records_map = $.ordered_map(); + var pkeys_map = $.ordered_map(); var result = data.result.result; var pkey_name = that.managed_entity.metadata.primary_key || @@ -443,11 +444,16 @@ IPA.service.search_facet = function(spec) { pkey = adapter.load(record, that.alternative_pkey)[0]; } if (that.filter_records(records_map, pkey, record)) { - records_map.put(pkey, record); + var compound_pkey = pkey + i; + records_map.put(compound_pkey, record); + pkeys_map.put(compound_pkey, pkey); } } - return records_map; + return { + records_map: records_map, + pkeys_map: pkeys_map + }; }; return that; diff --git a/install/ui/src/freeipa/topology.js b/install/ui/src/freeipa/topology.js index 7559d78e5..e98cb1e0a 100644 --- a/install/ui/src/freeipa/topology.js +++ b/install/ui/src/freeipa/topology.js @@ -490,7 +490,7 @@ topology.servers_search_facet = function(spec, no_init) { var that = IPA.search_facet(spec); - that.create_get_records_command = function(pkeys, on_success, on_error) { + that.create_get_records_command = function(records, pkeys, on_success, on_error) { var on_success_extended = function(data, text_status, xhr) { // Call original on_success handler @@ -560,7 +560,7 @@ topology.servers_search_facet = function(spec, no_init) { dialog.open(); }; - var batch = that.table_facet_create_get_records_command(pkeys, + var batch = that.table_facet_create_get_records_command(records, pkeys, on_success_extended, on_error); return batch; |