On 11/21/2011 7:31 PM, Endi Sukma Dewata wrote:
The Back, Next, and New Test buttons in HBAC Test have been fixed
to work properly.
Ticket #388
Updated patch attached.
--
Endi S. Dewata
From f61c2c2967cefeed7ff5d0ab0319cd4b1944ba31 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <[email protected]>
Date: Mon, 21 Nov 2011 16:43:52 -0600
Subject: [PATCH] Fixed navigation buttons for HBAC Test.
The Back, Next, and New Test buttons in HBAC Test have been fixed
to work properly.
Ticket #388
---
install/ui/facet.js | 12 +++++
install/ui/hbactest.js | 97 +++++++++++++++++++++++++++++++++----
install/ui/ipa.css | 26 ++++++----
install/ui/jquery.ordered-map.js | 18 +++++++-
install/ui/widget.js | 2 +-
5 files changed, 131 insertions(+), 24 deletions(-)
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 65ac71ee0ac92a1cbb2d8893fe6c013a0cca9b19..4ffd43dcdbd61553ed8d010019b7942ecd577d55 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -702,6 +702,18 @@ IPA.facet_group = function(spec) {
return that.facets.get(name);
};
+ that.get_facet_index = function(name) {
+ return that.facets.get_key_index(name);
+ };
+
+ that.get_facet_by_index = function(index) {
+ return that.facets.get_value_by_index(index);
+ };
+
+ that.get_facet_count = function(index) {
+ return that.facets.length;
+ };
+
return that;
};
diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js
index b5bf3de2cd4ee5cf1bd0f9a83378853e1bfd04c5..715c0449c56b75c55883518ab4128f8c83671152 100644
--- a/install/ui/hbactest.js
+++ b/install/ui/hbactest.js
@@ -204,22 +204,31 @@ IPA.hbac.test_facet = function(spec) {
style: 'float: right'
}).appendTo(container);
- that.back_button = IPA.button({
- name: 'back',
- label: 'Back',
- click: function() {
- if (!that.back_button.hasClass('action-button-disabled')) {
- that.back();
+ var facet_group = that.entity.get_facet_group('default');
+ var index = facet_group.get_facet_index(that.name);
+
+ if (index > 0) {
+ that.back_button = IPA.button({
+ name: 'back',
+ label: 'Back',
+ icon: 'ui-icon ui-icon-triangle-1-w',
+ click: function() {
+ if (!that.back_button.hasClass('action-button-disabled')) {
+ that.back();
+ }
+ return false;
}
- return false;
- }
- }).appendTo(buttons);
+ }).appendTo(buttons);
+
+ buttons.append(' ');
+ }
that.next_button = IPA.button({
name: 'next',
label: 'Next',
+ icon: 'ui-icon ui-icon-triangle-1-e',
click: function() {
- if (!that.add_button.hasClass('action-button-disabled')) {
+ if (!that.next_button.hasClass('action-button-disabled')) {
that.next();
}
return false;
@@ -227,6 +236,30 @@ IPA.hbac.test_facet = function(spec) {
}).appendTo(buttons);
};
+ that.back = function() {
+ var facet_group = that.entity.get_facet_group('default');
+ var index = facet_group.get_facet_index(that.name);
+ if (index <= 0) return;
+
+ var facet = facet_group.get_facet_by_index(index - 1);
+
+ var state = {};
+ state[that.entity.name+'-facet'] = facet.name;
+ IPA.nav.push_state(state);
+ };
+
+ that.next = function() {
+ var facet_group = that.entity.get_facet_group('default');
+ var index = facet_group.get_facet_index(that.name);
+ if (index >= facet_group.get_facet_count() - 1) return;
+
+ var facet = facet_group.get_facet_by_index(index + 1);
+
+ var state = {};
+ state[that.entity.name+'-facet'] = facet.name;
+ IPA.nav.push_state(state);
+ };
+
that.get_pkeys = function(data) {
var result = data.result.result;
var pkey_name = that.managed_entity.metadata.primary_key;
@@ -261,7 +294,7 @@ IPA.hbac.test_facet = function(spec) {
command.on_success = function(data, text_status, xhr) {
if (that.filter) that.filter.focus();
- that.load(data); // table_facet.load()
+ that.load(data);
};
command.on_error = function(xhr, text_status, error_thrown) {
@@ -271,6 +304,10 @@ IPA.hbac.test_facet = function(spec) {
command.execute();
};
+ that.reset = function() {
+ that.table.set_values([]);
+ };
+
that.save = function(record) {
if (that.selected_values && that.selected_values.length) {
record[that.name] = that.selected_values[0];
@@ -336,6 +373,11 @@ IPA.hbac.test_rules_facet = function(spec) {
that.create_buttons(container);
};
+ that.reset = function() {
+ that.table.set_values([]);
+ if (that.enabled) that.enabled.attr('checked', false);
+ if (that.disabled) that.enabled.attr('checked', false);
+ };
that.save = function(record) {
if (that.selected_values && that.selected_values.length) {
@@ -409,6 +451,7 @@ IPA.hbac.test_run_facet = function(spec) {
that.back_button = IPA.button({
name: 'back',
label: 'Back',
+ icon: 'ui-icon ui-icon-triangle-1-w',
click: function() {
if (!that.back_button.hasClass('action-button-disabled')) {
that.back();
@@ -417,6 +460,8 @@ IPA.hbac.test_run_facet = function(spec) {
}
}).appendTo(buttons);
+ buttons.append(' ');
+
that.new_test_button = IPA.button({
name: 'new_test',
label: 'New Test',
@@ -429,6 +474,36 @@ IPA.hbac.test_run_facet = function(spec) {
}).appendTo(buttons);
};
+ that.new_test = function() {
+ var facet = that.entity.get_facet('user');
+ facet.reset();
+
+ facet = that.entity.get_facet('targethost');
+ facet.reset();
+
+ facet = that.entity.get_facet('service');
+ facet.reset();
+
+ facet = that.entity.get_facet('sourcehost');
+ facet.reset();
+
+ facet = that.entity.get_facet('rules');
+ facet.reset();
+
+ facet = that.entity.get_facet('run');
+ facet.reset();
+
+ var state = {};
+ state[that.entity.name+'-facet'] = 'user';
+ IPA.nav.push_state(state);
+ };
+
+ that.reset = function() {
+ that.test_result.text('');
+ that.table.empty();
+ that.table.set_values([]);
+ };
+
that.refresh = function() {
};
diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index 76d90166bfa222212ba4f2e98739ece15c57fd49..7a69b2960e6a10f6e3b8a05f5517b3259456119b 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -126,12 +126,6 @@ body {
font-size: 11px;
}
-.input_link {
- text-decoration: none;
- position: relative;
- cursor: pointer;
-}
-
.icon {
display: inline-block;
height: 16px;
@@ -967,17 +961,27 @@ span.main-separator{
padding:0.1em;
}
+.button {
+ text-decoration: none;
+ position: relative;
+ cursor: pointer;
+ display: inline-block;
+}
+
+.button-label {
+ padding: 0 0.2em;
+ display: inline-block;
+ height: 16px;
+ line-height: 16px;
+}
+
.action-button {
background: none;
- background-image:none;
+ background-image: none;
font-family: "Liberation Sans", Arial, sans-serif;
font-size: 0.9em;
}
-.action-button .button-label {
- padding: 0 0.2em;
-}
-
.action-button-disabled {
color: gray;
cursor: default;
diff --git a/install/ui/jquery.ordered-map.js b/install/ui/jquery.ordered-map.js
index ea61b954d09c93970aa48a49b1cecafa249fce71..df772f60d92f6df9d85424d5592edaa62dde467f 100755
--- a/install/ui/jquery.ordered-map.js
+++ b/install/ui/jquery.ordered-map.js
@@ -44,7 +44,7 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() {
that.remove = function(key) {
- var i = that.keys.indexOf(key);
+ var i = that.get_key_index(key);
if (i<0) return null;
that.keys.splice(i, 1);
@@ -63,5 +63,21 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() {
that.length = that.keys.length;
};
+ that.get_key_index = function(key) {
+ return that.keys.indexOf(key);
+ };
+
+ that.get_key_by_index = function(index) {
+ return that.keys[index];
+ };
+
+ that.get_key_index = function(key) {
+ return that.keys.indexOf(key);
+ };
+
+ that.get_value_by_index = function(index) {
+ return that.values[index];
+ };
+
return that;
};
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 63b2c5495c9398d3598b3234b7ab276e2021caa2..0b3581569017ad34476e0f34f4347022ab2e4e93 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1792,7 +1792,7 @@ IPA.button = function(spec) {
name: spec.name,
href: spec.href || '#' + (spec.name || 'button'),
title: spec.title || spec.label,
- 'class': 'ui-state-default ui-corner-all input_link',
+ 'class': 'ui-state-default ui-corner-all button',
style: spec.style,
click: spec.click,
blur: spec.blur
--
1.7.5.1
_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel