mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
@@ -57,10 +57,15 @@ IPA.service.entity = function(spec) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'provisioning',
|
name: 'provisioning',
|
||||||
|
action_panel: {
|
||||||
|
factory: IPA.action_panel,
|
||||||
|
name: 'provisioning_actions',
|
||||||
|
actions: ['unprovision']
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
type: 'service_provisioning_status',
|
type: 'service_provisioning_status',
|
||||||
name: 'krblastpwdchange',
|
name: 'has_keytab',
|
||||||
label: IPA.messages.objects.service.status
|
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({
|
association_facet({
|
||||||
name: 'managedby_host',
|
name: 'managedby_host',
|
||||||
@@ -227,7 +241,7 @@ IPA.service_provisioning_status_widget = function (spec) {
|
|||||||
|
|
||||||
that.widget_create(container);
|
that.widget_create(container);
|
||||||
|
|
||||||
var div = $('<div/>', {
|
that.status_valid = $('<div/>', {
|
||||||
name: 'kerberos-key-valid',
|
name: 'kerberos-key-valid',
|
||||||
style: 'display: none;'
|
style: 'display: none;'
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
@@ -236,23 +250,15 @@ IPA.service_provisioning_status_widget = function (spec) {
|
|||||||
src: 'images/check-icon.png',
|
src: 'images/check-icon.png',
|
||||||
style: 'float: left;',
|
style: 'float: left;',
|
||||||
'class': 'status-icon'
|
'class': 'status-icon'
|
||||||
}).appendTo(div);
|
}).appendTo(that.status_valid);
|
||||||
|
|
||||||
var content_div = $('<div/>', {
|
var content_div = $('<div/>', {
|
||||||
style: 'float: left;'
|
style: 'float: left;'
|
||||||
}).appendTo(div);
|
}).appendTo(that.status_valid);
|
||||||
|
|
||||||
content_div.append('<b>'+IPA.messages.objects.service.valid+':</b>');
|
content_div.append('<b>'+IPA.messages.objects.service.valid+'</b>');
|
||||||
|
|
||||||
content_div.append(' ');
|
that.status_missing = $('<div/>', {
|
||||||
|
|
||||||
$('<input/>', {
|
|
||||||
'type': 'button',
|
|
||||||
'name': 'unprovision',
|
|
||||||
'value': IPA.messages.objects.service.delete_key_unprovision
|
|
||||||
}).appendTo(content_div);
|
|
||||||
|
|
||||||
div = $('<div/>', {
|
|
||||||
name: 'kerberos-key-missing',
|
name: 'kerberos-key-missing',
|
||||||
style: 'display: none;'
|
style: 'display: none;'
|
||||||
}).appendTo(container);
|
}).appendTo(container);
|
||||||
@@ -261,76 +267,18 @@ IPA.service_provisioning_status_widget = function (spec) {
|
|||||||
src: 'images/caution-icon.png',
|
src: 'images/caution-icon.png',
|
||||||
style: 'float: left;',
|
style: 'float: left;',
|
||||||
'class': 'status-icon'
|
'class': 'status-icon'
|
||||||
}).appendTo(div);
|
}).appendTo(that.status_missing);
|
||||||
|
|
||||||
content_div = $('<div/>', {
|
content_div = $('<div/>', {
|
||||||
style: 'float: left;'
|
style: 'float: left;'
|
||||||
}).appendTo(div);
|
}).appendTo(that.status_missing);
|
||||||
|
|
||||||
content_div.append('<b>'+IPA.messages.objects.service.missing+'</b>');
|
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);
|
|
||||||
|
|
||||||
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.unprovision = function() {
|
|
||||||
|
|
||||||
var label = that.entity.metadata.label_singular;
|
|
||||||
var title = IPA.messages.objects.service.unprovision_title;
|
|
||||||
title = title.replace('${entity}', label);
|
|
||||||
|
|
||||||
var dialog = IPA.dialog({
|
|
||||||
'title': title
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.create = function() {
|
|
||||||
dialog.container.append(IPA.messages.objects.service.unprovision_confirmation);
|
|
||||||
};
|
|
||||||
|
|
||||||
dialog.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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.create_button({
|
|
||||||
name: 'cancel',
|
|
||||||
label: IPA.messages.buttons.cancel,
|
|
||||||
click: function() {
|
|
||||||
dialog.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.open(that.container);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.update = function(values) {
|
that.update = function(values) {
|
||||||
that.pkey = values.pkey;
|
that.status = values && values.length ? values[0] : false;
|
||||||
that.status = values.value;
|
set_status(that.status ? 'valid' : 'missing');
|
||||||
set_status(values.value ? 'valid' : 'missing');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
that.clear = function() {
|
that.clear = function() {
|
||||||
@@ -346,29 +294,109 @@ IPA.service_provisioning_status_widget = function (spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
IPA.service_provisioning_status_field = function (spec) {
|
IPA.field_factories['service_provisioning_status'] = IPA.field;
|
||||||
|
IPA.widget_factories['service_provisioning_status'] = IPA.service_provisioning_status_widget;
|
||||||
|
|
||||||
|
|
||||||
|
IPA.service.unprovision_dialog = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
spec.title = spec.title || IPA.messages.objects.service.unprovision_title;
|
||||||
|
|
||||||
var that = IPA.field(spec);
|
var that = IPA.dialog(spec);
|
||||||
|
that.facet = spec.facet;
|
||||||
|
|
||||||
that.load = function(record) {
|
var entity_singular = that.entity.metadata.label_singular;
|
||||||
|
that.title = that.title.replace('${entity}', entity_singular);
|
||||||
|
|
||||||
that.values = {
|
that.create = function() {
|
||||||
value: record[that.param],
|
that.container.append(IPA.messages.objects.service.unprovision_confirmation);
|
||||||
pkey: record['krbprincipalname'][0]
|
};
|
||||||
};
|
|
||||||
|
|
||||||
that.load_writable(record);
|
that.create_buttons = function() {
|
||||||
|
|
||||||
that.reset();
|
that.create_button({
|
||||||
|
name: 'unprovision',
|
||||||
|
label: IPA.messages.objects.service.unprovision,
|
||||||
|
click: function() {
|
||||||
|
that.unprovision();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
that.create_button({
|
||||||
|
name: 'cancel',
|
||||||
|
label: IPA.messages.buttons.cancel,
|
||||||
|
click: function() {
|
||||||
|
that.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
that.unprovision = function() {
|
||||||
|
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
|
||||||
|
that.create_buttons();
|
||||||
|
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
|
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.action(spec);
|
||||||
|
|
||||||
|
that.execute_action = function(facet) {
|
||||||
|
|
||||||
|
var dialog = IPA.service.unprovision_dialog({
|
||||||
|
entity: facet.entity,
|
||||||
|
facet: facet
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
IPA.field_factories['service_provisioning_status'] = IPA.service_provisioning_status_field;
|
IPA.service.krbprincipalkey_acl_evaluator = function(spec) {
|
||||||
IPA.widget_factories['service_provisioning_status'] = IPA.service_provisioning_status_widget;
|
|
||||||
|
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) {
|
IPA.service.certificate_status_field = function(spec) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user