summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-04-14 15:43:57 -0500
committerAdam Young <ayoung@redhat.com>2011-04-18 11:12:02 -0400
commitfc7c1cbb6a3e2cdec4d1f8b0860c040ac3204e90 (patch)
tree7479196578958f1961a9d7ead4672965b87bf6d4
parent8f9ddb058f922fbd33c4d15986eeb1f5be521cc5 (diff)
downloadfreeipa-fc7c1cbb6a3e2cdec4d1f8b0860c040ac3204e90.tar.gz
freeipa-fc7c1cbb6a3e2cdec4d1f8b0860c040ac3204e90.tar.xz
freeipa-fc7c1cbb6a3e2cdec4d1f8b0860c040ac3204e90.zip
Entitlement download.
A Download link has been added to download entitlement certificates.
-rwxr-xr-xinstall/ui/certificate.js24
-rw-r--r--install/ui/dialog.js7
-rw-r--r--install/ui/entitle.js37
-rw-r--r--install/ui/entity.js37
-rw-r--r--install/ui/search.js13
-rw-r--r--install/ui/widget.js4
6 files changed, 81 insertions, 41 deletions
diff --git a/install/ui/certificate.js b/install/ui/certificate.js
index c5216362..30ac0d74 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 08fba458..cba5b1ab 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 4c9cd13c..17be4583 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];
+
+ $('<a/>', {
+ '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 23f792d1..2cbed5b6 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<fields.length; i++) {
+ var field_spec = fields[i];
+ var field;
+
+ if (field_spec instanceof Object) {
+ field_spec.entity_name = entity.name;
+ var factory = field_spec.factory || IPA.text_widget;
+ field = factory(field_spec);
+ } else {
field = IPA.text_widget({
- name:field,
- entity_name:entity.name
+ name: field_spec,
+ entity_name: entity.name
});
- current_section.add_field(field);
}
+ current_section.add_field(field);
}
}
}
that.entity = function(spec) {
- if (spec instanceof Object){
+ if (spec instanceof Object) {
var factory = spec.factory || IPA.entity;
entity = factory(spec);
} else {
- var name = spec;
- entity = IPA.entity({name: name});
+ entity = IPA.entity({ name: spec });
}
return that;
};
that.dialog = function(spec) {
var dialog;
- if (spec.factory) {
- dialog = spec.factory(spec);
+ if (spec instanceof Object){
+ var factory = spec.factory || IPA.dialog;
+ dialog = factory(spec);
} else {
- dialog = IPA.dialog(spec);
+ dialog = IPA.dialog({ name: spec });
}
entity.dialog(dialog);
return that;
diff --git a/install/ui/search.js b/install/ui/search.js
index f2789f62..7f00ebfa 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -414,13 +414,16 @@ IPA.search_facet = function(spec) {
var columns = spec.columns || [];
for (var i=0; i<columns.length; i++) {
- var column = columns[i];
- if (column instanceof Object) {
- var factory = column.factory || IPA.column;
- that.add_column(factory(column));
+ var column_spec = columns[i];
+ var column;
+
+ if (column_spec instanceof Object) {
+ var factory = column_spec.factory || IPA.column;
+ column = factory(column_spec);
} else {
- that.create_column({ name: column });
+ column = IPA.column({ name: column_spec });
}
+ that.add_column(column);
}
return that;
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 744e6ed4..8680086e 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1007,14 +1007,12 @@ IPA.column = function (spec) {
var that = {};
- if (spec.format){
- that.format = spec.format;
- }
that.name = spec.name;
that.label = spec.label;
that.primary_key = spec.primary_key;
that.width = spec.width;
that.entity_name = spec.entity_name;
+ that.format = spec.format;
that.setup = spec.setup || setup;