Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-14 Thread Endi Sukma Dewata

On 4/14/2011 12:17 AM, Endi Sukma Dewata wrote:

Attached is an updated version. There are a few more patches in the
pipeline. After that I'll address the I18n labels, integer validation
and builder cleanup.


ACKed on IRC. Replaced integer constants with string. Pushed to master.

--
Endi S. Dewata
From a3d79ad1b2492880f46bcc80f0fb40911cc7aa8b Mon Sep 17 00:00:00 2001
From: Endi S. Dewata 
Date: Mon, 11 Apr 2011 20:22:38 -0500
Subject: [PATCH] Entitlement registration.

The entitlement facet will show buttons according to the entitlement
status. If it's unregistered, the facet will show a Register button.
If it's registered, the facet will show a Consume button.
---
 install/ui/dialog.js   |3 +
 install/ui/entitle.js  |  211 ---
 install/ui/entity.js   |   16 +-
 install/ui/ipa.css |4 +
 install/ui/ipa.js  |   15 +-
 install/ui/test/data/entitle_get_unregistered.json |   11 +
 install/ui/test/data/entitle_register.json |   26 ++
 install/ui/test/data/ipa_init.json |  401 
 install/ui/widget.js   |3 +-
 ipalib/plugins/baseldap.py |   22 +-
 10 files changed, 659 insertions(+), 53 deletions(-)
 create mode 100644 install/ui/test/data/entitle_get_unregistered.json
 create mode 100644 install/ui/test/data/entitle_register.json

diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 964d5f5fcdd4a6012954ac4bdc1098af7d5e7b52..08fba45801abf7419ba7f8309ad10b468eea26f0 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -105,6 +105,9 @@ IPA.dialog = function(spec) {
 };
 
 that.init = function() {
+
+that.entity = IPA.get_entity(that.entity_name);
+
 for (var i=0; i', {
 type: 'button',
+name: 'register',
+value: 'Register'
+}).appendTo(buttons);
+
+$('', {
+type: 'button',
 name: 'consume',
 value: 'Consume'
 }).appendTo(buttons);
@@ -108,15 +197,29 @@ IPA.entitle.search_facet = function(spec) {
 
 var action_panel = that.get_action_panel();
 
-var button = $('input[name=consume]', action_panel);
+var button = $('input[name=register]', action_panel);
+that.register_button = IPA.action_button({
+label: 'Register',
+icon: 'ui-icon-plus',
+click: function() {
+var dialog = that.entity.get_dialog('register');
+dialog.open(that.container);
+}
+});
+that.register_button.css('display', 'none');
+button.replaceWith(that.register_button);
+
+button = $('input[name=consume]', action_panel);
 that.consume_button = IPA.action_button({
 label: 'Consume',
 icon: 'ui-icon-plus',
+style: 'display: none;',
 click: function() {
-var dialog = that.get_dialog('consume');
+var dialog = that.entity.get_dialog('consume');
 dialog.open(that.container);
 }
 });
+that.consume_button.css('display', 'none');
 button.replaceWith(that.consume_button);
 };
 
@@ -124,6 +227,9 @@ IPA.entitle.search_facet = function(spec) {
 
 function on_success(data, text_status, xhr) {
 
+that.register_button.css('display', 'none');
+that.consume_button.css('display', 'inline');
+
 that.table.empty();
 
 var result = data.result.result;
@@ -132,7 +238,7 @@ IPA.entitle.search_facet = function(spec) {
 that.table.add_record(record);
 }
 
-var summary = $('span[name=summary]', that.table.tfoot);
+var summary = $('span[name=summary]', that.table.tfoot).empty();
 if (data.result.truncated) {
 var message = IPA.messages.search.truncated;
 message = message.replace('${counter}', data.result.count);
@@ -143,28 +249,50 @@ IPA.entitle.search_facet = function(spec) {
 }
 
 function on_error(xhr, text_status, error_thrown) {
+
+that.register_button.css('display', 'inline');
+that.consume_button.css('display', 'none');
+
 var summary = $('span[name=summary]', that.table.tfoot).empty();
-summary.append('Error: '+error_thrown.name+'');
-summary.append(''+error_thrown.title+'');
-summary.append(''+error_thrown.message+'');
+summary.append(error_thrown.message);
 }
 
-var command = IPA.command({
-entity: 'entitle',
-method: 'get',
-options: {
-all: that.search_all
-},
-on_success: on_success,
-on_error: on_error
-});
-
-command.execu

Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Endi Sukma Dewata

On 4/13/2011 10:33 PM, Adam Young wrote:

BTW, are you planning on updating this patch, or do the validation work
in a follow on patch?


Attached is an updated version. There are a few more patches in the 
pipeline. After that I'll address the I18n labels, integer validation 
and builder cleanup.


--
Endi S. Dewata
From c561c581a6f46edce7d91e2a7f5d8c0eef0ae61a Mon Sep 17 00:00:00 2001
From: Endi S. Dewata 
Date: Mon, 11 Apr 2011 20:22:38 -0500
Subject: [PATCH] Entitlement registration.

The entitlement facet will show buttons according to the entitlement
status. If it's unregistered, the facet will show a Register button.
If it's registered, the facet will show a Consume button.
---
 install/ui/dialog.js   |3 +
 install/ui/entitle.js  |  211 ---
 install/ui/entity.js   |   16 +-
 install/ui/ipa.css |4 +
 install/ui/ipa.js  |   15 +-
 install/ui/test/data/entitle_get_unregistered.json |   11 +
 install/ui/test/data/entitle_register.json |   26 ++
 install/ui/test/data/ipa_init.json |  401 
 install/ui/widget.js   |3 +-
 ipalib/plugins/baseldap.py |   22 +-
 10 files changed, 659 insertions(+), 53 deletions(-)
 create mode 100644 install/ui/test/data/entitle_get_unregistered.json
 create mode 100644 install/ui/test/data/entitle_register.json

diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 964d5f5fcdd4a6012954ac4bdc1098af7d5e7b52..08fba45801abf7419ba7f8309ad10b468eea26f0 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -105,6 +105,9 @@ IPA.dialog = function(spec) {
 };
 
 that.init = function() {
+
+that.entity = IPA.get_entity(that.entity_name);
+
 for (var i=0; i', {
 type: 'button',
+name: 'register',
+value: 'Register'
+}).appendTo(buttons);
+
+$('', {
+type: 'button',
 name: 'consume',
 value: 'Consume'
 }).appendTo(buttons);
@@ -108,15 +197,29 @@ IPA.entitle.search_facet = function(spec) {
 
 var action_panel = that.get_action_panel();
 
-var button = $('input[name=consume]', action_panel);
+var button = $('input[name=register]', action_panel);
+that.register_button = IPA.action_button({
+label: 'Register',
+icon: 'ui-icon-plus',
+click: function() {
+var dialog = that.entity.get_dialog('register');
+dialog.open(that.container);
+}
+});
+that.register_button.css('display', 'none');
+button.replaceWith(that.register_button);
+
+button = $('input[name=consume]', action_panel);
 that.consume_button = IPA.action_button({
 label: 'Consume',
 icon: 'ui-icon-plus',
+style: 'display: none;',
 click: function() {
-var dialog = that.get_dialog('consume');
+var dialog = that.entity.get_dialog('consume');
 dialog.open(that.container);
 }
 });
+that.consume_button.css('display', 'none');
 button.replaceWith(that.consume_button);
 };
 
@@ -124,6 +227,9 @@ IPA.entitle.search_facet = function(spec) {
 
 function on_success(data, text_status, xhr) {
 
+that.register_button.css('display', 'none');
+that.consume_button.css('display', 'inline');
+
 that.table.empty();
 
 var result = data.result.result;
@@ -132,7 +238,7 @@ IPA.entitle.search_facet = function(spec) {
 that.table.add_record(record);
 }
 
-var summary = $('span[name=summary]', that.table.tfoot);
+var summary = $('span[name=summary]', that.table.tfoot).empty();
 if (data.result.truncated) {
 var message = IPA.messages.search.truncated;
 message = message.replace('${counter}', data.result.count);
@@ -143,28 +249,50 @@ IPA.entitle.search_facet = function(spec) {
 }
 
 function on_error(xhr, text_status, error_thrown) {
+
+that.register_button.css('display', 'inline');
+that.consume_button.css('display', 'none');
+
 var summary = $('span[name=summary]', that.table.tfoot).empty();
-summary.append('Error: '+error_thrown.name+'');
-summary.append(''+error_thrown.title+'');
-summary.append(''+error_thrown.message+'');
+summary.append(error_thrown.message);
 }
 
-var command = IPA.command({
-entity: 'entitle',
-method: 'get',
-options: {
-all: that.search_all
-},
-on_success: on_success,
-on_error: on_error
-});
-
-   

Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Adam Young

On 04/13/2011 11:30 AM, Endi Sukma Dewata wrote:

On 4/13/2011 10:13 AM, Adam Young wrote:

There's no pattern defined in the metadata for the quantity. There is
an 'int' type though. I think we can add a general purpose type
checking in addition to pattern validation. This can be done in a
separate patch.


We can add a validation rule [1..9][0..9]* to the entitlement plugin,
since it should be a positive integer.


It's kind of redundant since this pattern is implied by the int type 
and there are already min/max value params that limit the range to 
positive integers. I think it's better to validate the type and the 
min/max values in the widget because other parameters can benefit from 
it too.


BTW, are you planning on updating this patch, or do the validation work 
in a follow on patch?


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Adam Young

On 04/13/2011 11:30 AM, Endi Sukma Dewata wrote:

On 4/13/2011 10:13 AM, Adam Young wrote:

There's no pattern defined in the metadata for the quantity. There is
an 'int' type though. I think we can add a general purpose type
checking in addition to pattern validation. This can be done in a
separate patch.


We can add a validation rule [1..9][0..9]* to the entitlement plugin,
since it should be a positive integer.


It's kind of redundant since this pattern is implied by the int type 
and there are already min/max value params that limit the range to 
positive integers. I think it's better to validate the type and the 
min/max values in the widget because other parameters can benefit from 
it too.


Agreed.  Still, the Jascript regex  for int type can use that pattern.

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Endi Sukma Dewata

On 4/13/2011 10:13 AM, Adam Young wrote:

There's no pattern defined in the metadata for the quantity. There is
an 'int' type though. I think we can add a general purpose type
checking in addition to pattern validation. This can be done in a
separate patch.


We can add a validation rule [1..9][0..9]* to the entitlement plugin,
since it should be a positive integer.


It's kind of redundant since this pattern is implied by the int type and 
there are already min/max value params that limit the range to positive 
integers. I think it's better to validate the type and the min/max 
values in the widget because other parameters can benefit from it too.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Adam Young

On 04/13/2011 11:03 AM, Endi Sukma Dewata wrote:

On 4/13/2011 9:12 AM, Adam Young wrote:

Please make sure all String literals come from the interal.py messages
plugin. New button labels are defined in entitle.js for Consume and
Register.


I'm thinking to do that once we have all the entitlement 
functionalities implemented. There are also hard-coded button labels 
in ipa.css which I'm not sure how to remove. Any suggestion?


We'll catch the ipa.css changes in a separate patch.  I'll have to take 
a look.





The consume dialog should be limited to accepting only integer values:
pass the validation pattern in to the text widget. that.entity =
function(spec) {


There's no pattern defined in the metadata for the quantity. There is 
an 'int' type though. I think we can add a general purpose type 
checking in addition to pattern validation. This can be done in a 
separate patch.


We can add a validation rule [1..9][0..9]* to the entitlement plugin, 
since it should be a positive integer.






We are starting to see a proliferation of code like this:

if (spec instanceof Object){
var factory = spec.factory || IPA.entity;
entity = factory(spec);
} else {
var name = spec;
entity = IPA.entity({name: name});
}
return that;
};


Can we pull it into a helper function?


I checked the code, there are only 2 instances (in entity.js and 
search.js) where the structures appear to be identical. Other 
instances contain slight variation which is difficult to extract. I'd 
suggest we should try to standardize the invocations first then 
refactor them into a helper function.

Sounds good.




In dialog.js the code that.entity = IPA.get_entity(that.entity_name);
should happen before init, in the initial construction of the object.
The goal is to remove init functions; please don't put any more code
into them from here on out. Same thing with Facet in entity.js


See IPA.start_entities(). I don't think that's possible because the 
entity is only added into IPA.entities_by_name in add_entity() while 
the constructors are executed before that in the factory() invocation.


factory = that.entity_factories[name];
var entity = factory();
add_entity(entity);
entity.init();

The entity.init() is executed last, that's why IPA.get_entity() for 
now can only be invoked during the init() phase.


We could pass the entity object instead of entity name in the spec, 
but that will be a major change.




OK,we can punt on this.  We'll work on removing init in a dedicated patch.

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Endi Sukma Dewata

On 4/13/2011 9:12 AM, Adam Young wrote:

Please make sure all String literals come from the interal.py messages
plugin. New button labels are defined in entitle.js for Consume and
Register.


I'm thinking to do that once we have all the entitlement functionalities 
implemented. There are also hard-coded button labels in ipa.css which 
I'm not sure how to remove. Any suggestion?



The consume dialog should be limited to accepting only integer values:
pass the validation pattern in to the text widget. that.entity =
function(spec) {


There's no pattern defined in the metadata for the quantity. There is an 
'int' type though. I think we can add a general purpose type checking in 
addition to pattern validation. This can be done in a separate patch.



We are starting to see a proliferation of code like this:

if (spec instanceof Object){
var factory = spec.factory || IPA.entity;
entity = factory(spec);
} else {
var name = spec;
entity = IPA.entity({name: name});
}
return that;
};


Can we pull it into a helper function?


I checked the code, there are only 2 instances (in entity.js and 
search.js) where the structures appear to be identical. Other instances 
contain slight variation which is difficult to extract. I'd suggest we 
should try to standardize the invocations first then refactor them into 
a helper function.



In dialog.js the code that.entity = IPA.get_entity(that.entity_name);
should happen before init, in the initial construction of the object.
The goal is to remove init functions; please don't put any more code
into them from here on out. Same thing with Facet in entity.js


See IPA.start_entities(). I don't think that's possible because the 
entity is only added into IPA.entities_by_name in add_entity() while the 
constructors are executed before that in the factory() invocation.


factory = that.entity_factories[name];
var entity = factory();
add_entity(entity);
entity.init();

The entity.init() is executed last, that's why IPA.get_entity() for now 
can only be invoked during the init() phase.


We could pass the entity object instead of entity name in the spec, but 
that will be a major change.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-13 Thread Adam Young

On 04/12/2011 03:06 PM, Endi Sukma Dewata wrote:

The entitlement facet will show the appropriate buttons depending on
the entitlement status. If it's not registered, the facet will show
a Register button. If it's registered, the facet will show a Consume
button.


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel



Please make sure all String literals come from the interal.py messages 
plugin. New button labels are defined in entitle.js for Consume and 
Register.



The consume dialog should be limited to accepting only integer values: 
pass the validation pattern in to the text widget. that.entity = 
function(spec) {


We are starting to see a proliferation of code like this:

if (spec instanceof Object){
var factory = spec.factory || IPA.entity;
entity = factory(spec);
} else {
var name = spec;
entity = IPA.entity({name: name});
}
return that;
};


Can we pull it into a helper function?


In dialog.js   the code that.entity = IPA.get_entity(that.entity_name);  
should happen before init, in the initial construction of the object.  
The goal is to remove init functions; please don't put any more code 
into them from here on out.  Same thing with Facet in entity.js



___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

[Freeipa-devel] [PATCH] 137 Entitlement registration.

2011-04-12 Thread Endi Sukma Dewata

The entitlement facet will show the appropriate buttons depending on
the entitlement status. If it's not registered, the facet will show
a Register button. If it's registered, the facet will show a Consume
button.

--
Endi S. Dewata
From 16ce91b4c55ec8ca00421a818532a8ff8560ed6f Mon Sep 17 00:00:00 2001
From: Endi S. Dewata 
Date: Mon, 11 Apr 2011 20:22:38 -0500
Subject: [PATCH] Entitlement registration.

The entitlement facet will show the appropriate buttons depending on
the entitlement status. If it's not registered, the facet will show
a Register button. If it's registered, the facet will show a Consume
button.
---
 install/ui/dialog.js   |3 +
 install/ui/entitle.js  |  201 --
 install/ui/entity.js   |   16 +-
 install/ui/ipa.css |4 +
 install/ui/ipa.js  |   15 +-
 install/ui/test/data/entitle_get_unregistered.json |   11 +
 install/ui/test/data/entitle_register.json |   26 ++
 install/ui/test/data/ipa_init.json |  401 
 install/ui/widget.js   |3 +-
 ipalib/plugins/baseldap.py |   22 +-
 10 files changed, 651 insertions(+), 51 deletions(-)
 create mode 100644 install/ui/test/data/entitle_get_unregistered.json
 create mode 100644 install/ui/test/data/entitle_register.json

diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 964d5f5fcdd4a6012954ac4bdc1098af7d5e7b52..08fba45801abf7419ba7f8309ad10b468eea26f0 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -105,6 +105,9 @@ IPA.dialog = function(spec) {
 };
 
 that.init = function() {
+
+that.entity = IPA.get_entity(that.entity_name);
+
 for (var i=0; i', {
 type: 'button',
+name: 'register',
+value: 'Register'
+}).appendTo(buttons);
+
+$('', {
+type: 'button',
 name: 'consume',
 value: 'Consume'
 }).appendTo(buttons);
@@ -108,15 +189,29 @@ IPA.entitle.search_facet = function(spec) {
 
 var action_panel = that.get_action_panel();
 
-var button = $('input[name=consume]', action_panel);
+var button = $('input[name=register]', action_panel);
+that.register_button = IPA.action_button({
+label: 'Register',
+icon: 'ui-icon-plus',
+click: function() {
+var dialog = that.entity.get_dialog('register');
+dialog.open(that.container);
+}
+});
+that.register_button.css('display', 'none');
+button.replaceWith(that.register_button);
+
+button = $('input[name=consume]', action_panel);
 that.consume_button = IPA.action_button({
 label: 'Consume',
 icon: 'ui-icon-plus',
+style: 'display: none;',
 click: function() {
-var dialog = that.get_dialog('consume');
+var dialog = that.entity.get_dialog('consume');
 dialog.open(that.container);
 }
 });
+that.consume_button.css('display', 'none');
 button.replaceWith(that.consume_button);
 };
 
@@ -124,6 +219,9 @@ IPA.entitle.search_facet = function(spec) {
 
 function on_success(data, text_status, xhr) {
 
+that.register_button.css('display', 'none');
+that.consume_button.css('display', 'inline');
+
 that.table.empty();
 
 var result = data.result.result;
@@ -132,7 +230,7 @@ IPA.entitle.search_facet = function(spec) {
 that.table.add_record(record);
 }
 
-var summary = $('span[name=summary]', that.table.tfoot);
+var summary = $('span[name=summary]', that.table.tfoot).empty();
 if (data.result.truncated) {
 var message = IPA.messages.search.truncated;
 message = message.replace('${counter}', data.result.count);
@@ -143,27 +241,50 @@ IPA.entitle.search_facet = function(spec) {
 }
 
 function on_error(xhr, text_status, error_thrown) {
+
+that.register_button.css('display', 'inline');
+that.consume_button.css('display', 'none');
+
 var summary = $('span[name=summary]', that.table.tfoot).empty();
-summary.append('Error: '+error_thrown.name+'');
-summary.append(''+error_thrown.title+'');
-summary.append(''+error_thrown.message+'');
+summary.append(error_thrown.message);
 }
 
-var command = IPA.command({
-method: 'entitle_get',
-options: {
-all: that.search_all
-},
-on_success: on_success,
-on_error: on_error
-});
-
-command.execute();
+that.entity.get_certificates(
+on_success,
+