summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-06-07 10:44:34 +0200
committerPetr Vobornik <pvoborni@redhat.com>2012-06-13 16:44:35 +0200
commitf52fa2a0185c8cc4e1c2cacda3eac59209e659f4 (patch)
treef84b4ae4df148dbeeafce93fbfd13b532464d592
parent961aeb80e9d74df6f6b036a6152fdc3f9a6f5b39 (diff)
downloadfreeipa-f52fa2a0185c8cc4e1c2cacda3eac59209e659f4.tar.gz
freeipa-f52fa2a0185c8cc4e1c2cacda3eac59209e659f4.tar.xz
freeipa-f52fa2a0185c8cc4e1c2cacda3eac59209e659f4.zip
Action panel for service provisioning
Servise provisioning status widget was modified only to display the has_keytab status. Button for 'delete key,unprovision' was moved as action to newly created action panel in the same section. This required to moved the creation of the unprovisioning dialog from that widget to new separate dialog. Action for action panel and all required status evaluators for enabling/disabling of that action were also created. https://fedorahosted.org/freeipa/ticket/2252
-rw-r--r--install/ui/service.js186
1 files changed, 107 insertions, 79 deletions
diff --git a/install/ui/service.js b/install/ui/service.js
index 129f166a3..f714e410e 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -57,10 +57,15 @@ IPA.service.entity = function(spec) {
},
{
name: 'provisioning',
+ action_panel: {
+ factory: IPA.action_panel,
+ name: 'provisioning_actions',
+ actions: ['unprovision']
+ },
fields: [
{
type: 'service_provisioning_status',
- name: 'krblastpwdchange',
+ name: 'has_keytab',
label: IPA.messages.objects.service.status
}
]
@@ -75,7 +80,16 @@ IPA.service.entity = function(spec) {
}
]
}
- ]
+ ],
+ actions: [
+ IPA.service.unprovision_action
+ ],
+ state: {
+ evaluators: [
+ IPA.service.has_keytab_evaluator,
+ IPA.service.krbprincipalkey_acl_evaluator
+ ]
+ }
}).
association_facet({
name: 'managedby_host',
@@ -227,7 +241,7 @@ IPA.service_provisioning_status_widget = function (spec) {
that.widget_create(container);
- var div = $('<div/>', {
+ that.status_valid = $('<div/>', {
name: 'kerberos-key-valid',
style: 'display: none;'
}).appendTo(container);
@@ -236,23 +250,15 @@ IPA.service_provisioning_status_widget = function (spec) {
src: 'images/check-icon.png',
style: 'float: left;',
'class': 'status-icon'
- }).appendTo(div);
+ }).appendTo(that.status_valid);
var content_div = $('<div/>', {
style: 'float: left;'
- }).appendTo(div);
-
- content_div.append('<b>'+IPA.messages.objects.service.valid+':</b>');
+ }).appendTo(that.status_valid);
- content_div.append(' ');
+ content_div.append('<b>'+IPA.messages.objects.service.valid+'</b>');
- $('<input/>', {
- 'type': 'button',
- 'name': 'unprovision',
- 'value': IPA.messages.objects.service.delete_key_unprovision
- }).appendTo(content_div);
-
- div = $('<div/>', {
+ that.status_missing = $('<div/>', {
name: 'kerberos-key-missing',
style: 'display: none;'
}).appendTo(container);
@@ -261,114 +267,136 @@ IPA.service_provisioning_status_widget = function (spec) {
src: 'images/caution-icon.png',
style: 'float: left;',
'class': 'status-icon'
- }).appendTo(div);
+ }).appendTo(that.status_missing);
content_div = $('<div/>', {
style: 'float: left;'
- }).appendTo(div);
+ }).appendTo(that.status_missing);
content_div.append('<b>'+IPA.messages.objects.service.missing+'</b>');
+ };
- that.status_valid = $('div[name=kerberos-key-valid]', that.container);
- that.status_missing = $('div[name=kerberos-key-missing]', that.container);
+ that.update = function(values) {
+ that.status = values && values.length ? values[0] : false;
+ set_status(that.status ? 'valid' : 'missing');
+ };
- var button = $('input[name=unprovision]', that.container);
- that.unprovision_button = IPA.button({
- name: 'unprovision',
- 'label': IPA.messages.objects.service.delete_key_unprovision,
- 'click': that.unprovision
- });
- button.replaceWith(that.unprovision_button);
+ that.clear = function() {
+ that.status_valid.css('display', 'none');
+ that.status_missing.css('display', 'none');
};
- that.unprovision = function() {
+ function set_status(status) {
+ that.status_valid.css('display', status == 'valid' ? 'inline' : 'none');
+ that.status_missing.css('display', status == 'missing' ? 'inline' : 'none');
+ }
+
+ return that;
+};
- var label = that.entity.metadata.label_singular;
- var title = IPA.messages.objects.service.unprovision_title;
- title = title.replace('${entity}', label);
+IPA.field_factories['service_provisioning_status'] = IPA.field;
+IPA.widget_factories['service_provisioning_status'] = IPA.service_provisioning_status_widget;
- var dialog = IPA.dialog({
- 'title': title
- });
- dialog.create = function() {
- dialog.container.append(IPA.messages.objects.service.unprovision_confirmation);
- };
+IPA.service.unprovision_dialog = function(spec) {
+
+ spec = spec || {};
+ spec.title = spec.title || IPA.messages.objects.service.unprovision_title;
+
+ var that = IPA.dialog(spec);
+ that.facet = spec.facet;
+
+ var entity_singular = that.entity.metadata.label_singular;
+ that.title = that.title.replace('${entity}', entity_singular);
+
+ that.create = function() {
+ that.container.append(IPA.messages.objects.service.unprovision_confirmation);
+ };
+
+ that.create_buttons = function() {
- dialog.create_button({
+ that.create_button({
name: 'unprovision',
label: IPA.messages.objects.service.unprovision,
click: function() {
- IPA.command({
- entity: that.entity.name,
- method: 'disable',
- args: [that.pkey],
- on_success: function(data, text_status, xhr) {
- set_status('missing');
- dialog.close();
- },
- on_error: function(xhr, text_status, error_thrown) {
- dialog.close();
- }
- }).execute();
+ that.unprovision();
}
});
- dialog.create_button({
+ that.create_button({
name: 'cancel',
label: IPA.messages.buttons.cancel,
click: function() {
- dialog.close();
+ that.close();
}
});
-
- dialog.open(that.container);
-
- return false;
};
- that.update = function(values) {
- that.pkey = values.pkey;
- that.status = values.value;
- set_status(values.value ? 'valid' : 'missing');
- };
+ that.unprovision = function() {
- that.clear = function() {
- that.status_valid.css('display', 'none');
- that.status_missing.css('display', 'none');
+ var principal_f = that.facet.fields.get_field('krbprincipalname');
+ var pkey = principal_f.values[0];
+
+ IPA.command({
+ entity: that.entity.name,
+ method: 'disable',
+ args: [pkey],
+ on_success: function(data, text_status, xhr) {
+ that.facet.refresh();
+ that.close();
+ },
+ on_error: function(xhr, text_status, error_thrown) {
+ that.close();
+ }
+ }).execute();
};
- function set_status(status) {
- that.status_valid.css('display', status == 'valid' ? 'inline' : 'none');
- that.status_missing.css('display', status == 'missing' ? 'inline' : 'none');
- }
+ that.create_buttons();
return that;
};
-IPA.service_provisioning_status_field = function (spec) {
+IPA.service.unprovision_action = function(spec) {
spec = spec || {};
+ spec.name = spec.name || 'unprovision';
+ spec.label = spec.label || IPA.messages.objects.service.delete_key_unprovision;
+ spec.enable_cond = spec.enable_cond || ['has_keytab', 'krbprincipalkey_w'];
- var that = IPA.field(spec);
+ var that = IPA.action(spec);
- that.load = function(record) {
-
- that.values = {
- value: record[that.param],
- pkey: record['krbprincipalname'][0]
- };
+ that.execute_action = function(facet) {
- that.load_writable(record);
+ var dialog = IPA.service.unprovision_dialog({
+ entity: facet.entity,
+ facet: facet
+ });
- that.reset();
+ dialog.open();
};
return that;
};
-IPA.field_factories['service_provisioning_status'] = IPA.service_provisioning_status_field;
-IPA.widget_factories['service_provisioning_status'] = IPA.service_provisioning_status_widget;
+IPA.service.krbprincipalkey_acl_evaluator = function(spec) {
+
+ spec.name = spec.name || 'unprovision_acl_evaluator';
+ spec.attribute = spec.attribute || 'krbprincipalkey';
+
+ var that = IPA.acl_state_evaluator(spec);
+ return that;
+};
+
+IPA.service.has_keytab_evaluator = function(spec) {
+
+ spec.name = spec.name || 'has_keytab_evaluator';
+ spec.attribute = spec.attribute || 'has_keytab';
+ spec.value = spec.value || [true];
+ spec.representation = spec.representation || 'has_keytab';
+
+ var that = IPA.value_state_evaluator(spec);
+ return that;
+};
IPA.service.certificate_status_field = function(spec) {