summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/ui/details.js56
-rw-r--r--install/ui/facet.js4
-rw-r--r--install/ui/host.js348
-rw-r--r--install/ui/ipa.css2
-rw-r--r--install/ui/widget.js2
5 files changed, 277 insertions, 135 deletions
diff --git a/install/ui/details.js b/install/ui/details.js
index d5f6bfc80..48c8adb60 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -1008,6 +1008,62 @@ IPA.acl_state_evaluator = function(spec) {
return that;
};
+IPA.value_state_evaluator = function(spec) {
+
+ spec.name = spec.name || 'value_state_evaluator';
+ spec.event = spec.event || 'post_load';
+
+ var that = IPA.state_evaluator(spec);
+ that.attribute = spec.attribute;
+ that.value = spec.value;
+ that.representation = spec.representation;
+
+ that.on_event = function(data) {
+
+ var old_state, record, state, value, loaded_value;
+
+ old_state = that.state;
+ record = data.result.result;
+ value = that.normalize_value(that.value);
+ loaded_value = record[that.attribute];
+ loaded_value = that.normalize_value(loaded_value);
+
+ that.state = [];
+
+ if (!IPA.array_diff(value, loaded_value)) {
+ that.state.push(that.get_state_text());
+ }
+
+ that.notify_on_change(old_state);
+ };
+
+ that.normalize_value = function(original) {
+
+ var value = original;
+
+ if (!(value instanceof Array)) {
+ value = [value];
+ }
+ return value;
+ };
+
+ that.get_state_text = function() {
+
+ var representation, value;
+
+ representation = that.representation;
+
+ if (!representation) {
+ value = that.normalize_value(that.value);
+ representation = that.attribute + '_' + value[0];
+ }
+
+ return representation;
+ };
+
+ return that;
+};
+
IPA.object_action = function(spec) {
spec = spec || {};
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 62950f6c4..550407bb7 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -1523,6 +1523,7 @@ IPA.state_evaluator = function(spec) {
//when state changes. Params: state, Context: this
that.changed = IPA.observer();
that.state = [];
+ that.first_pass = true;
that.init = function(facet) {
@@ -1536,8 +1537,9 @@ IPA.state_evaluator = function(spec) {
that.notify_on_change = function(old_state) {
- if (IPA.array_diff(that.state, old_state)) {
+ if (that.first_pass || IPA.array_diff(that.state, old_state)) {
that.changed.notify([that.state], that);
+ that.first_pass = false;
}
};
diff --git a/install/ui/host.js b/install/ui/host.js
index d07d63d95..e693f5f8e 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -77,6 +77,11 @@ IPA.host.entity = function(spec) {
},
{
name: 'enrollment',
+ action_panel: {
+ factory: IPA.action_panel,
+ name: 'enrollment_actions',
+ actions: ['unprovision', 'set_otp', 'reset_otp']
+ },
fields: [
{
factory: IPA.host_keytab_widget,
@@ -101,6 +106,31 @@ IPA.host.entity = function(spec) {
]
}
],
+ actions: [
+ IPA.host.unprovision_action,
+ {
+ factory: IPA.host.set_otp_action,
+ name: 'set_otp',
+ label: IPA.messages.objects.host.password_set_title,
+ status: 'missing',
+ hide_cond: ['has_password']
+ },
+ {
+ factory: IPA.host.set_otp_action,
+ name: 'reset_otp',
+ label: IPA.messages.objects.host.password_reset_title,
+ status: 'present',
+ show_cond: ['has_password']
+ }
+ ],
+ state: {
+ evaluators: [
+ IPA.host.has_password_evaluator,
+ IPA.host.has_keytab_evaluator,
+ IPA.host.userpassword_acl_evaluator,
+ IPA.host.krbprincipalkey_acl_evaluator
+ ]
+ },
policies: [
IPA.host_enrollment_policy()
]
@@ -530,58 +560,65 @@ IPA.host_keytab_widget = function(spec) {
that.present_span.append(' ');
that.present_span.append(IPA.messages.objects.host.keytab_present);
+ };
- that.present_span.append(': ');
+ that.update = function(values) {
+ set_status(values[0] ? 'present' : 'missing');
+ };
- IPA.button({
- name: 'unprovision',
- label: IPA.messages.objects.host.delete_key_unprovision,
- click: function() {
- that.show_unprovision_dialog();
- return false;
- }
- }).appendTo(that.present_span);
+ that.clear = function() {
+ that.present_span.css('display', 'none');
+ that.missing_span.css('display', 'none');
};
- that.show_unprovision_dialog = function() {
+ function set_status(status) {
+ that.present_span.css('display', status == 'present' ? 'inline' : 'none');
+ that.missing_span.css('display', status == 'missing' ? 'inline' : 'none');
+ }
- var label = that.entity.metadata.label_singular;
- var title = IPA.messages.objects.host.unprovision_title;
- title = title.replace('${entity}', label);
+ return that;
+};
- var dialog = IPA.dialog({
- 'title': title
- });
+IPA.host_unprovision_dialog = function(spec) {
- dialog.create = function() {
- dialog.container.append(IPA.messages.objects.host.unprovision_confirmation);
- };
+ spec.title = spec.title || IPA.messages.objects.host.unprovision_title;
+
+ spec = spec || {};
+
+ var that = IPA.dialog(spec);
+ that.facet = spec.facet;
+
+ that.title = that.title.replace('${entity}', that.entity.metadata.label_singular);
+
+ that.create = function() {
+ that.container.append(IPA.messages.objects.host.unprovision_confirmation);
+ };
- dialog.create_button({
+ that.create_buttons = function() {
+
+ that.create_button({
name: 'unprovision',
label: IPA.messages.objects.host.unprovision,
click: function() {
that.unprovision(
function(data, text_status, xhr) {
- set_status('missing');
- dialog.close();
+ that.facet.refresh();
+ that.close();
},
function(xhr, text_status, error_thrown) {
- dialog.close();
+ that.close();
}
);
}
});
- dialog.create_button({
+ that.create_button({
name: 'cancel',
label: IPA.messages.buttons.cancel,
click: function() {
- dialog.close();
+ that.close();
}
});
-
- dialog.open(that.container);
};
that.unprovision = function(on_success, on_error) {
@@ -601,20 +638,50 @@ IPA.host_keytab_widget = function(spec) {
command.execute();
};
- that.update = function(values) {
- set_status(values[0] ? 'present' : 'missing');
- };
+ that.create_buttons();
- that.clear = function() {
- that.present_span.css('display', 'none');
- that.missing_span.css('display', 'none');
+ return that;
+};
+
+IPA.host.unprovision_action = function(spec) {
+
+ spec = spec || {};
+ spec.name = spec.name || 'unprovision';
+ spec.label = spec.label || IPA.messages.objects.host.unprovision;
+ spec.enable_cond = spec.enable_cond || ['has_keytab', 'krbprincipalkey_w'];
+
+ var that = IPA.action(spec);
+
+ that.execute_action = function(facet) {
+
+ var dialog = IPA.host_unprovision_dialog({
+ entity: facet.entity,
+ facet: facet
+ });
+
+ dialog.open();
};
- function set_status(status) {
- that.present_span.css('display', status == 'present' ? 'inline' : 'none');
- that.missing_span.css('display', status == 'missing' ? 'inline' : 'none');
- }
+ return that;
+};
+IPA.host.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.host.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;
};
@@ -624,8 +691,6 @@ IPA.host_password_widget = function(spec) {
var that = IPA.input_widget(spec);
- that.password_change_request = IPA.observer();
-
that.create = function(container) {
that.widget_create(container);
@@ -656,62 +721,82 @@ IPA.host_password_widget = function(spec) {
that.present_span.append(' ');
that.present_span.append(IPA.messages.objects.host.password_present);
+ };
- container.append(': ');
+ that.update = function(values) {
+ set_status(values[0] ? 'present' : 'missing');
+ };
- that.set_password_button = IPA.button({
- name: 'set_password',
- label: IPA.messages.objects.host.password_set_button,
- click: function() {
- that.show_password_dialog();
- return false;
- }
- }).appendTo(container);
+ that.clear = function() {
+ that.missing_span.css('display', 'none');
+ that.present_span.css('display', 'none');
};
- that.show_password_dialog = function() {
+ function set_status(status) {
- var title;
- var label;
+ that.status = status;
- if (that.status == 'missing') {
- title = IPA.messages.objects.host.password_set_title;
- label = IPA.messages.objects.host.password_set_button;
+ if (status == 'missing') {
+ that.missing_span.css('display', 'inline');
+ that.present_span.css('display', 'none');
} else {
- title = IPA.messages.objects.host.password_reset_title;
- label = IPA.messages.objects.host.password_reset_button;
+ that.missing_span.css('display', 'none');
+ that.present_span.css('display', 'inline');
}
+ }
+
+ return that;
+};
+
+IPA.widget_factories['host_password'] = IPA.host_password_widget;
+IPA.field_factories['host_password'] = IPA.field;
+IPA.host.set_otp_dialog = function(spec) {
- var dialog = that.dialog = IPA.dialog({
- title: title,
- width: 400,
- sections: [
+ spec = spec || {};
+ spec.width = spec.width || 400;
+ spec.sections = spec.sections || [
+ {
+ fields: [
{
- fields: [
- {
- name: 'password1',
- label: IPA.messages.password.new_password,
- type: 'password'
- },
- {
- name: 'password2',
- label: IPA.messages.password.verify_password,
- type: 'password'
- }
- ]
+ name: 'password1',
+ label: IPA.messages.password.new_password,
+ type: 'password'
+ },
+ {
+ name: 'password2',
+ label: IPA.messages.password.verify_password,
+ type: 'password'
}
]
- });
+ }
+ ];
+
+ var that = IPA.dialog(spec);
+ that.facet = spec.facet;
+
+ that.set_status = function(status) {
+ var button = that.get_button('set_password');
- dialog.create_button({
+ if (status == 'missing') {
+ that.title = IPA.messages.objects.host.password_set_title;
+ button.label = IPA.messages.objects.host.password_set_button;
+ } else {
+ that.title = IPA.messages.objects.host.password_reset_title;
+ button.label = IPA.messages.objects.host.password_reset_button;
+ }
+ };
+
+ that.create_buttons = function() {
+
+ that.create_button({
name: 'set_password',
- label: label,
+ label: IPA.messages.objects.host.password_set_button,
click: function() {
var record = {};
- dialog.save(record);
+ that.save(record);
var new_password = record.password1[0];
var repeat_password = record.password2[0];
@@ -721,68 +806,22 @@ IPA.host_password_widget = function(spec) {
return;
}
- that.password_change_request.notify([new_password], that);
+ that.set_otp(new_password);
- dialog.close();
+ that.close();
}
});
- dialog.create_button({
+ that.create_button({
name: 'cancel',
label: IPA.messages.buttons.cancel,
click: function() {
- dialog.close();
+ that.close();
}
});
-
- dialog.open(that.container);
- };
-
- that.update = function(values) {
- set_status(values[0] ? 'present' : 'missing');
- };
-
- that.clear = function() {
- that.missing_span.css('display', 'none');
- that.present_span.css('display', 'none');
- var password_label = $('.button-label', that.set_password_button);
- password_label.text('');
- };
-
- function set_status(status) {
-
- that.status = status;
- var password_label = $('.button-label', that.set_password_button);
-
- if (status == 'missing') {
- that.missing_span.css('display', 'inline');
- that.present_span.css('display', 'none');
- password_label.text(IPA.messages.objects.host.password_set_button);
-
- } else {
- that.missing_span.css('display', 'none');
- that.present_span.css('display', 'inline');
- password_label.text(IPA.messages.objects.host.password_reset_button);
- }
- }
-
- return that;
-};
-
-IPA.host_password_field = function (spec) {
-
- spec = spec || {};
-
- var that = IPA.field(spec);
-
- that.widgets_created = function() {
-
- that.field_widgets_created();
- that.widget.password_change_request.attach(that.set_password);
- that.widget.search = that.search;
};
- that.set_password = function(password) {
+ that.set_otp = function(password) {
var pkey = that.entity.get_primary_key();
var command = IPA.command({
@@ -794,24 +833,67 @@ IPA.host_password_field = function (spec) {
rights: true,
userpassword: password
},
- on_success: function(result) {
- that.load(result.result.result);
- that.widget.dialog.close();
+ on_success: function(data) {
+ that.facet.load(data);
+ that.close();
},
on_error: function() {
- that.widget.dialog.close();
+ that.close();
}
});
command.execute();
};
+ that.create_buttons();
return that;
};
-IPA.widget_factories['host_password'] = IPA.host_password_widget;
-IPA.field_factories['host_password'] = IPA.host_password_field;
+IPA.host.set_otp_action = function(spec) {
+
+ spec = spec || {};
+ spec.name = spec.name || 'set_otp';
+ spec.label = spec.label || IPA.messages.objects.host.password_set_title;
+ spec.enable_cond = spec.enable_cond || ['userpassword_w'];
+
+ var that = IPA.action(spec);
+ that.status = spec.status || 'missing';
+
+ that.execute_action = function(facet) {
+
+ var dialog = IPA.host.set_otp_dialog({
+ entity: facet.entity,
+ facet: facet
+ });
+
+ dialog.set_status(that.status);
+
+ dialog.open();
+ };
+
+ return that;
+};
+
+IPA.host.userpassword_acl_evaluator = function(spec) {
+
+ spec.name = spec.name || 'userpassword_acl_evaluator';
+ spec.attribute = spec.attribute || 'userpassword';
+
+ var that = IPA.acl_state_evaluator(spec);
+ return that;
+};
+
+IPA.host.has_password_evaluator = function(spec) {
+
+ spec.name = spec.name || 'has_password_evaluator';
+ spec.attribute = spec.attribute || 'has_password';
+ spec.value = spec.value || [true];
+ spec.representation = spec.representation || 'has_password';
+
+ var that = IPA.value_state_evaluator(spec);
+ return that;
+};
IPA.host.certificate_status_field = function(spec) {
diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index 5371070a1..c69fc80de 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -1720,7 +1720,7 @@ form#login {
.action-panel {
position: absolute;
right: 0;
- top: 0;
+ top: -30px;
width: 150px;
diff --git a/install/ui/widget.js b/install/ui/widget.js
index d3dbd4c37..ccda2aef3 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -3238,6 +3238,8 @@ IPA.action_panel = function(spec) {
var classes, state, li, a;
+ if (!action.visible) return;
+
classes = ['action'];
state = action.enabled ? 'enabled' : 'disabled';
classes.push(state);