From fc7c1cbb6a3e2cdec4d1f8b0860c040ac3204e90 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 14 Apr 2011 15:43:57 -0500 Subject: Entitlement download. A Download link has been added to download entitlement certificates. --- install/ui/certificate.js | 24 +++++++++++++++--------- install/ui/dialog.js | 7 ++----- install/ui/entitle.js | 37 ++++++++++++++++++++++++++++++++++++- install/ui/entity.js | 37 +++++++++++++++++++------------------ install/ui/search.js | 13 ++++++++----- install/ui/widget.js | 4 +--- 6 files changed, 81 insertions(+), 41 deletions(-) (limited to 'install') diff --git a/install/ui/certificate.js b/install/ui/certificate.js index c52163629..30ac0d74a 100755 --- a/install/ui/certificate.js +++ b/install/ui/certificate.js @@ -74,7 +74,7 @@ IPA.cert.parse_dn = function(dn) { return result; }; -IPA.cert.get_dialog = function(spec) { +IPA.cert.download_dialog = function(spec) { spec = spec || {}; @@ -82,8 +82,9 @@ IPA.cert.get_dialog = function(spec) { that.width = spec.width || 500; that.height = spec.height || 400; + that.add_pem_delimiters = typeof spec.add_pem_delimiters == 'undefined' ? true : spec.add_pem_delimiters; - that.usercertificate = spec.usercertificate || ''; + that.certificate = spec.certificate || ''; that.add_button(IPA.messages.buttons.close, function() { that.close(); @@ -95,10 +96,15 @@ IPA.cert.get_dialog = function(spec) { style: 'width: 100%; height: 275px;' }).appendTo(that.container); - textarea.val( - IPA.cert.BEGIN_CERTIFICATE+'\n'+ - that.usercertificate+'\n'+ - IPA.cert.END_CERTIFICATE); + var certificate = that.certificate; + + if (that.add_pem_delimiters) { + certificate = IPA.cert.BEGIN_CERTIFICATE+'\n'+ + that.certificate+'\n'+ + IPA.cert.END_CERTIFICATE; + } + + textarea.val(certificate); }; return that; @@ -675,9 +681,9 @@ IPA.cert.status_widget = function(spec) { title = title.replace('${entity}', that.entity_label); title = title.replace('${primary_key}', entity_name); - var dialog = IPA.cert.get_dialog({ - 'title': title, - 'usercertificate': entity_certificate + var dialog = IPA.cert.download_dialog({ + title: title, + certificate: entity_certificate }); dialog.init(); diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 08fba4580..cba5b1abf 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -274,11 +274,8 @@ IPA.dialog = function(spec) { var field; if (field_spec instanceof Object) { - if (field_spec.factory) { - field = field_spec.factory(field_spec); - } else { - field = IPA.text_widget(field_spec); - } + var factory = field_spec.factory || IPA.text_widget; + field = factory(field_spec); } else { var field_name = field_spec; field = IPA.text_widget({ name: field_name, undo: false }); diff --git a/install/ui/entitle.js b/install/ui/entitle.js index 4c9cd13c6..17be45835 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -56,6 +56,11 @@ IPA.entity_factories.entitle = function() { { name: 'end', label: 'End' + }, + { + factory: IPA.entitle.certificate_column, + name: 'certificate', + label: 'Certificate' } ] }). @@ -404,6 +409,36 @@ IPA.entitle.search_facet = function(spec) { return that; }; +IPA.entitle.certificate_column = function(spec) { + + spec = spec || {}; + + var that = IPA.column(spec); + + that.setup = function(container, record) { + container.empty(); + + var certificate = record[that.name]; + + $('', { + 'href': '#download', + 'html': 'Download', + 'click': function() { + var dialog = IPA.cert.download_dialog({ + title: 'Download Certificate', + certificate: certificate, + add_pem_delimiters: false + }); + dialog.init(); + dialog.open(); + return false; + } + }).appendTo(container); + }; + + return that; +}; + IPA.entitle.certificate_dialog = function(spec) { spec = spec || {}; @@ -542,4 +577,4 @@ IPA.entitle.import_dialog = function(spec) { }); return that; -}; \ No newline at end of file +}; diff --git a/install/ui/entity.js b/install/ui/entity.js index 23f792d1e..2cbed5b6b 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -559,42 +559,43 @@ IPA.entity_builder = function(){ } facet.add_section(current_section); var fields = spec.fields; - if (fields){ - var i; - var field; - for (i =0; i < fields.length; i += 1){ - field = fields[i]; - if (field instanceof Object){ - field.entity_name = entity.name; - current_section.add_field(field.factory(field)); - }else{ + if (fields) { + for (var i=0; i