summaryrefslogtreecommitdiffstats
path: root/install/ui/hbactest.js
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2011-12-09 17:22:37 +0200
committerAlexander Bokovoy <abokovoy@redhat.com>2011-12-09 17:22:37 +0200
commit0e45fb9ab1c639a43d0e50aadc5ff3bcaa096ba9 (patch)
treeb8e1724aa6cc911a6e899474a5f4a037a046f8f0 /install/ui/hbactest.js
parentd738b6e71808b1611bc67cb4764153977b444584 (diff)
parentc1baebe97990a65076da02b112fe139422c44e97 (diff)
downloadfreeipa.git-0e45fb9ab1c639a43d0e50aadc5ff3bcaa096ba9.tar.gz
freeipa.git-0e45fb9ab1c639a43d0e50aadc5ff3bcaa096ba9.tar.xz
freeipa.git-0e45fb9ab1c639a43d0e50aadc5ff3bcaa096ba9.zip
Merge branch 'master' of git+ssh://git.fedorahosted.org/git/freeipa
Diffstat (limited to 'install/ui/hbactest.js')
-rw-r--r--install/ui/hbactest.js110
1 files changed, 82 insertions, 28 deletions
diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js
index d9a854f1..f2256a31 100644
--- a/install/ui/hbactest.js
+++ b/install/ui/hbactest.js
@@ -117,7 +117,6 @@ IPA.hbac.test_entity = function(spec) {
label: IPA.messages.objects.hbactest.run_test,
managed_entity_name: 'hbacrule',
disable_breadcrumb: true,
- pagination: true,
facet_group: 'default',
columns: [
'cn',
@@ -198,13 +197,6 @@ IPA.hbac.test_facet = function(spec) {
}).appendTo(buttons);
};
- that.find = function() {
- var filter = that.filter.val();
- var state = {};
- state[that.entity.name+'-'+that.name+'-filter'] = filter;
- IPA.nav.push_state(state);
- };
-
that.prev = function() {
var facet_group = that.entity.get_facet_group('default');
var index = facet_group.get_facet_index(that.name);
@@ -262,7 +254,6 @@ IPA.hbac.test_facet = function(spec) {
}
command.on_success = function(data, text_status, xhr) {
- if (that.filter) that.filter.focus();
that.load(data);
};
@@ -368,7 +359,7 @@ IPA.hbac.test_select_facet = function(spec) {
td.append(' ');
that.external_text = $('<input/>', {
- name: 'external',
+ name: id,
focus: function() {
that.external_radio.click();
}
@@ -381,6 +372,13 @@ IPA.hbac.test_select_facet = function(spec) {
that.create_buttons(footer);
};
+ that.find = function() {
+ var filter = that.filter.val();
+ var state = {};
+ state[that.entity.name+'-'+that.name+'-filter'] = filter;
+ IPA.nav.push_state(state);
+ };
+
that.get_selected_values = function() {
var values = that.table.get_selected_values();
if (values && values.length) return values;
@@ -393,8 +391,9 @@ IPA.hbac.test_select_facet = function(spec) {
};
that.reset = function() {
- that.table.set_values([]);
+ delete that.selected_values;
if (that.external_radio) that.external_radio.attr('checked', false);
+ if (that.external_text) that.external_text.val('');
};
that.save = function(record) {
@@ -408,6 +407,25 @@ IPA.hbac.test_select_facet = function(spec) {
}
};
+ that.validate = function(record) {
+ if (record[that.name]) return true;
+
+ var dialog = IPA.message_dialog({
+ title: IPA.messages.dialogs.validation_title,
+ message: IPA.messages.dialogs.validation_message
+ });
+
+ dialog.on_ok = function() {
+ var state = {};
+ state[that.entity.name+'-facet'] = that.name;
+ IPA.nav.push_state(state);
+ };
+
+ dialog.open();
+
+ return false;
+ };
+
init();
return that;
@@ -475,9 +493,9 @@ IPA.hbac.test_rules_facet = function(spec) {
};
that.reset = function() {
- that.table.set_values([]);
+ delete that.selected_values;
if (that.enabled) that.enabled.attr('checked', false);
- if (that.disabled) that.enabled.attr('checked', false);
+ if (that.disabled) that.disabled.attr('checked', false);
};
that.save = function(record) {
@@ -505,6 +523,8 @@ IPA.hbac.test_run_facet = function(spec) {
var init = function() {
that.table.selectable = false;
+ that.show_matched = true;
+ that.show_unmatched = true;
};
that.create_content = function(container) {
@@ -547,10 +567,15 @@ IPA.hbac.test_run_facet = function(spec) {
header.append(' ');
- that.matched = $('<input/>', {
+ that.matched_checkbox = $('<input/>', {
id: 'hbactest-rules-matched',
type: 'checkbox',
- name: 'matched'
+ name: 'matched',
+ checked: true,
+ change: function() {
+ that.show_matched = that.matched_checkbox.is(':checked');
+ that.refresh();
+ }
}).appendTo(header);
$('<label/>', {
@@ -558,10 +583,15 @@ IPA.hbac.test_run_facet = function(spec) {
text: IPA.messages.objects.hbactest.matched
}).appendTo(header);
- that.unmatched = $('<input/>', {
+ that.unmatched_checkbox = $('<input/>', {
id: 'hbactest-rules-unmatched',
type: 'checkbox',
- name: 'disabled'
+ name: 'disabled',
+ checked: true,
+ change: function() {
+ that.show_unmatched = that.unmatched_checkbox.is(':checked');
+ that.refresh();
+ }
}).appendTo(header);
$('<label/>', {
@@ -634,12 +664,26 @@ IPA.hbac.test_run_facet = function(spec) {
};
that.reset = function() {
- that.test_result.text('');
- that.table.empty();
- that.table.set_values([]);
+ delete that.data;
+ that.show_matched = true;
+ that.show_unmatched = true;
+ if (that.matched_checkbox) that.matched_checkbox.attr('checked', true);
+ if (that.unmatched_checkbox) that.unmatched_checkbox.attr('checked', true);
+ that.refresh();
};
that.refresh = function() {
+ if (that.data) {
+ var message = that.data.result.value ?
+ IPA.messages.objects.hbactest.access_granted :
+ IPA.messages.objects.hbactest.access_denied;
+ that.test_result.text(message);
+
+ } else {
+ that.test_result.text('');
+ }
+
+ that.load(that.data);
};
that.run = function() {
@@ -650,15 +694,19 @@ IPA.hbac.test_run_facet = function(spec) {
var facet = that.entity.get_facet('user');
facet.save(options);
+ if (!facet.validate(options)) return;
facet = that.entity.get_facet('targethost');
facet.save(options);
+ if (!facet.validate(options)) return;
facet = that.entity.get_facet('service');
facet.save(options);
+ if (!facet.validate(options)) return;
facet = that.entity.get_facet('sourcehost');
facet.save(options);
+ if (!facet.validate(options)) return;
facet = that.entity.get_facet('rules');
facet.save(options);
@@ -666,12 +714,8 @@ IPA.hbac.test_run_facet = function(spec) {
command.set_options(options);
command.on_success = function(data, text_status, xhr) {
- var message = data.result.value ?
- IPA.messages.objects.hbactest.access_granted :
- IPA.messages.objects.hbactest.access_denied;
- that.test_result.text(message);
-
- that.load(data);
+ that.data = data;
+ that.refresh();
};
command.execute();
@@ -682,7 +726,7 @@ IPA.hbac.test_run_facet = function(spec) {
that.matched = {};
var matched = data.result.matched;
- if (matched) {
+ if (that.show_matched && matched) {
for (var i=0; i<matched.length; i++) {
var pkey = matched[i];
pkeys.push(pkey);
@@ -691,7 +735,7 @@ IPA.hbac.test_run_facet = function(spec) {
}
var notmatched = data.result.notmatched;
- if (notmatched) {
+ if (that.show_unmatched && notmatched) {
for (i=0; i<notmatched.length; i++) {
pkey = notmatched[i];
pkeys.push(pkey);
@@ -702,6 +746,16 @@ IPA.hbac.test_run_facet = function(spec) {
return pkeys;
};
+ that.get_records_command_name = function() {
+ if (that.show_matched && !that.show_unmatched) {
+ return 'hbactest_matched';
+ }
+ if (!that.show_matched && that.show_unmatched) {
+ return 'hbactest_unmatched';
+ }
+ return that.managed_entity_name+'_get_records';
+ };
+
that.load_records = function(records) {
var pkey_name = that.table.entity.metadata.primary_key;
that.table.empty();