From fb9ba5bb5cc385e7ffd7f030058c316c5c4facf9 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 1 Dec 2010 20:25:44 -0600 Subject: [PATCH] UI for host managedby A custom facet has been added to manage the host's managedby attribute. The facet defines the add and remove methods, the columns for the association table and enrollment dialog, and the link for the primary key column. --- install/static/host.js | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/install/static/host.js b/install/static/host.js index 5cfceba5c..4f3a636eb 100644 --- a/install/static/host.js +++ b/install/static/host.js @@ -58,6 +58,13 @@ function ipa_host() { }); that.add_facet(facet); + facet = ipa_host_managedby_host_facet({ + 'name': 'managedby_host', + 'label': 'Managed by Hosts', + 'other_entity': 'host' + }); + that.add_facet(facet); + that.create_association_facets(); that.entity_init(); @@ -412,3 +419,62 @@ function host_certificate_status_widget(spec) { return that; } + +function ipa_host_managedby_host_facet(spec) { + + spec = spec || {}; + + var that = ipa_association_facet(spec); + + that.add_method = 'add_managedby'; + that.delete_method = 'remove_managedby'; + + that.init = function() { + + var column = that.create_column({ + name: 'fqdn', + label: 'Name', + primary_key: true + }); + + column.setup = function(container, record) { + container.empty(); + + var value = record[column.name]; + value = value ? value.toString() : ''; + + $('', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + var state = IPA.tab_state(that.other_entity); + state[that.other_entity + '-facet'] = 'details'; + state[that.other_entity + '-pkey'] = value; + $.bbq.pushState(state); + return false; + } + }(value) + }).appendTo(container); + }; + + that.create_column({name: 'description', label: 'Description'}); + + that.create_adder_column({ + name: 'fqdn', + label: 'Name', + primary_key: true, + width: '100px' + }); + + that.create_adder_column({ + name: 'description', + label: 'Description', + width: '100px' + }); + + that.association_facet_init(); + }; + + return that; +} \ No newline at end of file