diff options
author | Endi S. Dewata <edewata@redhat.com> | 2010-11-16 18:10:40 -0600 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2010-11-18 10:12:18 -0500 |
commit | 5da8313b668340494f06afe6d3459f368948588f (patch) | |
tree | c19b19cf32bd8487cf42f21348a1ca97f8fe2f6c /install/static/certificate.js | |
parent | b42271c47d0e672f1a88585f5a87f5db8522f634 (diff) | |
download | freeipa-5da8313b668340494f06afe6d3459f368948588f.tar.gz freeipa-5da8313b668340494f06afe6d3459f368948588f.tar.xz freeipa-5da8313b668340494f06afe6d3459f368948588f.zip |
Service and Host Provisioning
The service and host details pages have been modified to display Kerberos
key provisioning status and to provide a way to unprovision. The host
enrollment via OTP has not been implemented yet.
The ipa_details_field has been modified to remove any old <dd> tags it
created in the previous load operation. This is to support other widgets
that need to perform load operation without removing <dd> tags.
The certificate_status_panel has been converted into a widget. The host
entity has been rewritten using the new framework.
The unit tests has been updated.
Diffstat (limited to 'install/static/certificate.js')
-rwxr-xr-x | install/static/certificate.js | 183 |
1 files changed, 117 insertions, 66 deletions
diff --git a/install/static/certificate.js b/install/static/certificate.js index affc58aa4..265568a04 100755 --- a/install/static/certificate.js +++ b/install/static/certificate.js @@ -389,12 +389,13 @@ function certificate_request_dialog(spec) { return that; } -function certificate_status_panel(spec) { - var that = $('<div/>'); +function certificate_status_widget(spec) { + spec = spec || {}; - that.entity_type = spec.entity_type; - that.entity_label = spec.entity_label || that.entity_type; + var that = ipa_widget(spec); + + that.entity_label = spec.entity_label || that.entity_name; that.result = spec.result; @@ -403,17 +404,16 @@ function certificate_status_panel(spec) { that.get_entity_principal = spec.get_entity_principal; that.get_entity_certificate = spec.get_entity_certificate; - var li1, li2, li3; + that.create = function(container) { - function init() { - var pkey = that.get_entity_pkey(that.result); + that.widget_create(container); - var table = $('<table/>').appendTo(that); + var table = $('<table/>').appendTo(container); var tr = $('<tr/>').appendTo(table); var td = $('<td/>').appendTo(tr); - li1 = $('<li/>', { + $('<li/>', { 'class': 'certificate-status-valid' }).appendTo(td); @@ -421,88 +421,141 @@ function certificate_status_panel(spec) { td.append('Valid Certificate Present:'); td = $('<td/>').appendTo(tr); - ipa_button({ - 'id': 'get_button', + + $('<input/>', { + 'type': 'button', + 'name': 'get', + 'value': 'Get' + }).appendTo(td); + + $('<input/>', { + 'type': 'button', + 'name': 'revoke', + 'value': 'Revoke' + }).appendTo(td); + + $('<input/>', { + 'type': 'button', + 'name': 'view', + 'value': 'View' + }).appendTo(td); + + tr = $('<tr/>').appendTo(table); + + td = $('<td/>').appendTo(tr); + $('<li/>', { + 'class': 'certificate-status-revoked' + }).appendTo(td); + + td = $('<td/>').appendTo(tr); + td.append('Certificate Revoked:'); + + td = $('<td/>').appendTo(tr); + td.append($('<span/>', { + 'name': 'revocation_reason' + })); + td.append(' '); + + $('<input/>', { + 'type': 'button', + 'name': 'restore', + 'value': 'Restore' + }).appendTo(td); + + tr = $('<tr/>').appendTo(table); + + td = $('<td/>').appendTo(tr); + $('<li/>', { + 'class': 'certificate-status-missing' + }).appendTo(td); + + td = $('<td/>').appendTo(tr); + td.append('No Valid Certificate:'); + + td = $('<td/>').appendTo(tr); + $('<input/>', { + 'type': 'button', + 'name': 'create', + 'value': 'New Certificate' + }).appendTo(td); + }; + + that.setup = function(container) { + + that.container = container; + + that.valid = $('li.certificate-status-valid', that.container); + that.revoked = $('li.certificate-status-revoked', that.container); + that.missing = $('li.certificate-status-missing', that.container); + + var button = $('input[name=get]', that.container); + that.get_button = ipa_button({ 'label': 'Get', 'click': function() { - ipa_cmd(that.entity_type+'_show', [pkey], {}, + ipa_cmd(that.entity_name+'_show', [that.pkey], {}, function(data, text_status, xhr) { get_certificate(data.result.result); } ); } - }).appendTo(td); + }); + button.replaceWith(that.get_button); - ipa_button({ - 'id': 'revoke_button', + button = $('input[name=revoke]', that.container); + that.revoke_button = ipa_button({ 'label': 'Revoke', 'click': function() { - ipa_cmd(that.entity_type+'_show', [pkey], {}, + ipa_cmd(that.entity_name+'_show', [that.pkey], {}, function(data, text_status, xhr) { revoke_certificate(data.result.result); } ); } - }).appendTo(td); + }); + button.replaceWith(that.revoke_button); - ipa_button({ - 'id': 'view_button', + button = $('input[name=view]', that.container); + that.view_button = ipa_button({ 'label': 'View', 'click': function() { - ipa_cmd(that.entity_type+'_show', [pkey], {}, + ipa_cmd(that.entity_name+'_show', [that.pkey], {}, function(data, text_status, xhr) { view_certificate(data.result.result); } ); } - }).appendTo(td); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>').appendTo(tr); - li2 = $('<li/>', { - 'class': 'certificate-status-revoked' - }).appendTo(td); - - td = $('<td/>').appendTo(tr); - td.append('Certificate Revoked:'); + }); + button.replaceWith(that.view_button); - td = $('<td/>').appendTo(tr); - td.append($('<span/>', { - 'id': 'revocation_reason' - })); - td.append(' '); + that.revocation_reason = $('span[name=revocation_reason]', that.container); - ipa_button({ - 'id': 'restore_button', + button = $('input[name=restore]', that.container); + that.restore_button = ipa_button({ 'label': 'Restore', 'click': function() { - ipa_cmd(that.entity_type+'_show', [pkey], {}, + ipa_cmd(that.entity_name+'_show', [that.pkey], {}, function(data, text_status, xhr) { restore_certificate(data.result.result); } ); } - }).appendTo(td); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>').appendTo(tr); - li3 = $('<li/>', { - 'class': 'certificate-status-missing' - }).appendTo(td); - - td = $('<td/>').appendTo(tr); - td.append('No Valid Certificate:'); + }); + button.replaceWith(that.restore_button); - td = $('<td/>').appendTo(tr); - ipa_button({ - 'id': 'create_button', + button = $('input[name=create]', that.container); + that.create_button = ipa_button({ 'label': 'New Certificate', 'click': function() { request_certificate(that.result); } - }).appendTo(td); + }); + button.replaceWith(that.create_button); + }; + + that.load = function(container, result) { + + that.result = result; + that.pkey = that.get_entity_pkey(that.result); var entity_certificate = that.get_entity_certificate(that.result); if (entity_certificate) { @@ -510,18 +563,18 @@ function certificate_status_panel(spec) { } else { set_status(CERTIFICATE_STATUS_MISSING); } - } + }; function set_status(status, revocation_reason) { - li1.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_VALID); - li2.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_REVOKED); - li3.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_MISSING); - - $('#get_button', that).css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); - $('#revoke_button', that).css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); - $('#view_button', that).css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); - $('#revocation_reason', that).html(revocation_reason == undefined ? '' : CRL_REASON[revocation_reason]); - $('#restore_button', that).css('visibility', revocation_reason == 6 ? 'visible' : 'hidden'); + that.valid.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_VALID); + that.revoked.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_REVOKED); + that.missing.toggleClass('certificate-status-active', status == CERTIFICATE_STATUS_MISSING); + + that.get_button.css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); + that.revoke_button.css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); + that.view_button.css('visibility', status == CERTIFICATE_STATUS_VALID ? 'visible' : 'hidden'); + that.revocation_reason.html(revocation_reason == undefined ? '' : CRL_REASON[revocation_reason]); + that.restore_button.css('visibility', revocation_reason == 6 ? 'visible' : 'hidden'); } function check_status(serial_number) { @@ -668,7 +721,5 @@ function certificate_status_panel(spec) { dialog.open(); } - init(); - return that; } |