Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Endi Sukma Dewata

On 3/1/2011 8:30 PM, Adam Young wrote:

On 03/01/2011 09:23 PM, Adam Young wrote:

Not a 100% solution, but keeps the groups-user facet from exploding.
https://fedorahosted.org/freeipa/ticket/1011

Includes fixes for services


Some issues:

1. See these lines in associate.js:

604:that.relationship_filter = spec.relationship_filter;

899:var relationship_filter = 'in_' + that.entity_name;

The spec.relationship_filter is actually never used and the 
relationship_filter will always be in_entity name. For now this is not 
a problem because the only facet using this code is member_user, but I 
think 899 should be fixed to take that.relationship_filter if it's defined.


2. The description column has been removed from host's and service's 
enrollment dialogs, so the column widths for the remaining columns need 
to be adjusted (e.g. fqdn should be 200px now). Otherwise the column 
header will be too short (try adding a new managedby-host).


 that.create_adder_column({
 name: 'fqdn',
 primary_key: true,
 width: '100px'
 });

-that.create_adder_column({
-name: 'description',
-width: '100px'
-});


--
Endi S. Dewata

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


Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Adam Young

On 03/02/2011 10:14 AM, Endi Sukma Dewata wrote:

On 3/1/2011 8:30 PM, Adam Young wrote:

On 03/01/2011 09:23 PM, Adam Young wrote:

Not a 100% solution, but keeps the groups-user facet from exploding.
https://fedorahosted.org/freeipa/ticket/1011

Includes fixes for services


Some issues:

1. See these lines in associate.js:

604:that.relationship_filter = spec.relationship_filter;

Meant to remove that.



899:var relationship_filter = 'in_' + that.entity_name;

The spec.relationship_filter is actually never used and the 
relationship_filter will always be in_entity name. For now this is 
not a problem because the only facet using this code is member_user, 
but I think 899 should be fixed to take that.relationship_filter if 
it's defined.


We'll implement a complete solution next.  I don't want to add unused code.



2. The description column has been removed from host's and service's 
enrollment dialogs, so the column widths for the remaining columns 
need to be adjusted (e.g. fqdn should be 200px now). Otherwise the 
column header will be too short (try adding a new managedby-host).


 that.create_adder_column({
 name: 'fqdn',
 primary_key: true,
 width: '100px'
 });

-that.create_adder_column({
-name: 'description',
-width: '100px'
-});




We shouldn't be using px, either, but I'll adjust this way for now.  Or 
could I do something like 100%?


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


Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Adam Young
This version uses the search widget.  A little more intrusive than I 
wanted, but if fixes the issue with 
https://fedorahosted.org/freeipa/ticket/1011



On 03/02/2011 11:07 AM, Endi Sukma Dewata wrote:

On 3/2/2011 9:29 AM, Adam Young wrote:

Not a 100% solution, but keeps the groups-user facet from exploding.
https://fedorahosted.org/freeipa/ticket/1011

Includes fixes for services


Some issues:

1. See these lines in associate.js:

604: that.relationship_filter = spec.relationship_filter;

Meant to remove that.


899: var relationship_filter = 'in_' + that.entity_name;

The spec.relationship_filter is actually never used and the
relationship_filter will always be in_entity name. For now this is
not a problem because the only facet using this code is member_user,
but I think 899 should be fixed to take that.relationship_filter if
it's defined. so I'm going to punt 


We'll implement a complete solution next. I don't want to add unused 
code.


I don't see any harm fixing 899 instead of removing 604. It's just a 
simple fix which provides convenience, not a big chunk of useless 
code. As soon as someone needs a different relationship filter we'd 
have to add 604 back in and fix 899 anyway. We have a lot of 
convenience code which are probably not used anyway (e.g. default 
values), but the overall code is better with them there.


Removed the code at 604 for now.  We'll see what the right solution is 
when we start implementing the others.  I don't like how the code had to 
be split up due to the init function.





2. The description column has been removed from host's and service's
enrollment dialogs, so the column widths for the remaining columns
need to be adjusted (e.g. fqdn should be 200px now). Otherwise the
column header will be too short (try adding a new managedby-host).

that.create_adder_column({
name: 'fqdn',
primary_key: true,
width: '100px'
});

- that.create_adder_column({
- name: 'description',
- width: '100px'
- });


We shouldn't be using px, either, but I'll adjust this way for now. Or
could I do something like 100%?


Try adding managedby-host with at least 6 hosts in the list (to make 
the scrollbar appear). If the column headers and the scrollbar appear 
fine then it's ok.




Fixed.

From ccf5f300ccd786c2f9491eefd1a6afb90fb180d7 Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Tue, 1 Mar 2011 21:21:19 -0500
Subject: [PATCH] Use modified entity find commands for associations

Using search widget for complex associations

https://fedorahosted.org/freeipa/ticket/1011
---
 install/ui/associate.js |  132 ++
 install/ui/host.js  |   10 +---
 install/ui/service.js   |8 +---
 3 files changed, 78 insertions(+), 72 deletions(-)

diff --git a/install/ui/associate.js b/install/ui/associate.js
index 600cd55c3abb99f810c8e322da83262c21b5e2c3..7339637459551340fc2188cad39e63a6816622a2 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -394,8 +394,12 @@ IPA.association_table_widget = function (spec) {
 'on_success': on_success,
 'on_error': on_error
 });
+var length = that.values.length;
+if (length  100){
+length = 100;
+}
 
-for (var i=0; ithat.values.length; i++) {
+for (var i=0; i length; i++) {
 var value = that.values[i];
 
 var command = IPA.command({
@@ -638,17 +642,22 @@ IPA.association_facet = function (spec) {
 var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity;
 var pkey_name = IPA.metadata.objects[that.other_entity].primary_key;
 
-that.table = IPA.table_widget({
+
+var table_spec = {
 'id': that.entity_name+'-'+that.other_entity,
 'name': pkey_name,
 'label': label,
 'entity_name': that.entity_name,
 'other_entity': that.other_entity
-});
-
+};
+if (that.columns.length  1){
+table_spec.facet = that;
+that.table = IPA.search_widget(table_spec);
+}else{
+that.table = IPA.table_widget(table_spec);
+}
 if (that.columns.length) {
 that.table.set_columns(that.columns);
-
 } else {
 
 column = that.table.create_column({
@@ -734,18 +743,19 @@ IPA.association_facet = function (spec) {
 var action_panel = that.get_action_panel();
 var li = $('.action-controls', action_panel);
 
-// creating generic buttons for layout
-$('input/', {
-'type': 'button',
-'name': 'remove',
-'value': IPA.messages.buttons.remove
-}).appendTo(li);
-
-$('input/', {
-'type': 'button',
-'name': 'add',
-'value': IPA.messages.buttons.enroll
-}).appendTo(li);
+if (that.columns.length == 1){
+// creating generic 

Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Endi Sukma Dewata

On 3/2/2011 10:56 AM, Adam Young wrote:

This version uses the search widget. A little more intrusive than I
wanted, but if fixes the issue with
https://fedorahosted.org/freeipa/ticket/1011


I tested this with Group's Member User:

The Add button doesn't open a dialog box, but it tries to create the 
content of the dialog box under the search table.


The Delete button does open a dialog box, but it doesn't delete the 
member, then it goes back to group's search page.


Another thing, I was expecting the entire that.table = IPA.table_widget
to be replaced by that.table = IPA.search_widget so we don't have to do 
this:

  if (that.columns.length == 1) {
// do things with table widget
  } else {
// do things with search widget
  }
but it might be to complicated for this release.


604: that.relationship_filter = spec.relationship_filter;
899: var relationship_filter = 'in_' + that.entity_name;



Removed the code at 604 for now. We'll see what the right solution is
when we start implementing the others. I don't like how the code had to
be split up due to the init function.


Then I'd ask that you put a note above 899, something like this:
// TODO: fix hard-coded relationship filter

--
Endi S. Dewata

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


Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Adam Young
No search widget.  This will keep the UI from throwing an Error, but 
doesn't give a way to get results beyond the first 100



On 03/02/2011 01:20 PM, Endi Sukma Dewata wrote:

On 3/2/2011 10:56 AM, Adam Young wrote:

This version uses the search widget. A little more intrusive than I
wanted, but if fixes the issue with
https://fedorahosted.org/freeipa/ticket/1011


I tested this with Group's Member User:

The Add button doesn't open a dialog box, but it tries to create the 
content of the dialog box under the search table.


The Delete button does open a dialog box, but it doesn't delete the 
member, then it goes back to group's search page.


Another thing, I was expecting the entire that.table = IPA.table_widget
to be replaced by that.table = IPA.search_widget so we don't have to 
do this:

  if (that.columns.length == 1) {
// do things with table widget
  } else {
// do things with search widget
  }
but it might be to complicated for this release.


604: that.relationship_filter = spec.relationship_filter;
899: var relationship_filter = 'in_' + that.entity_name;



Removed the code at 604 for now. We'll see what the right solution is
when we start implementing the others. I don't like how the code had to
be split up due to the init function.


Then I'd ask that you put a note above 899, something like this:
// TODO: fix hard-coded relationship filter



From ae4b78e2a2708f4dc041018bc7fc0ddb11c1e51b Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Tue, 1 Mar 2011 21:21:19 -0500
Subject: [PATCH] Use modified entity find commands for associations

https://fedorahosted.org/freeipa/ticket/1011

Does not completely fix the problem in the ticket, but it does mitigate the failure.
---
 install/ui/associate.js |   45 +
 install/ui/host.js  |   10 ++
 install/ui/service.js   |8 +---
 3 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/install/ui/associate.js b/install/ui/associate.js
index 2f1a28d5a66e989d562c3605fa335763bcd00324..db3a9cd55ed5ccdc78e0c90b69c9e652139bed9f 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -430,8 +430,12 @@ IPA.association_table_widget = function (spec) {
 'on_success': on_success,
 'on_error': on_error
 });
+var length = that.values.length;
+if (length  100){
+length = 100;
+}
 
-for (var i=0; ithat.values.length; i++) {
+for (var i=0; i length; i++) {
 var value = that.values[i];
 
 var command = IPA.command({
@@ -917,28 +921,29 @@ IPA.association_facet = function (spec) {
 
 if (!pkeys.length) return;
 
-var batch = IPA.batch_command({
-'name': that.entity_name+'_'+that.name,
+
+var options = {
+'all': true,
+'rights': true
+};
+
+var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+var args =[];
+/* TODO: make a general solution to generate this value */
+var relationship_filter = 'in_' + that.entity_name;
+options[relationship_filter] = pkey;
+
+var command = IPA.command({
 'on_success': on_success,
-'on_error': on_error
+'on_error': on_error,
+'method': that.other_entity+'_find',
+'args': args,
+options: options
 });
 
-for (var i=0; ipkeys.length; i++) {
-var pkey = pkeys[i];
+command.execute();
 
-var command = IPA.command({
-'method': that.other_entity+'_show',
-'args': [pkey],
-'options': {
-'all': true,
-'rights': true
-}
-});
 
-batch.add_command(command);
-}
-
-batch.execute();
 };
 
 that.refresh = function() {
@@ -962,9 +967,9 @@ IPA.association_facet = function (spec) {
 that.get_records(
 pkeys,
 function(data, text_status, xhr) {
-var results = data.result.results;
+var results = data.result.result;
 for (var i=0; iresults.length; i++) {
-var record = results[i].result;
+var record = results[i];
 that.table.add_record(record);
 }
 }
diff --git a/install/ui/host.js b/install/ui/host.js
index 981bfc021924bc740379009e62ef5b8345b262d5..9ef7553e950d3cde5f22ca1a966067c445f6acd7 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -50,7 +50,7 @@ IPA.entity_factories.host = function () {
 that.add_facet(facet);
 
 facet = IPA.host_managedby_host_facet({
-'name': 'managedby_host'
+name: 'managedby_host'
 });
 that.add_facet(facet);
 
@@ 

Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-02 Thread Endi Sukma Dewata

On 3/2/2011 12:48 PM, Adam Young wrote:

No search widget. This will keep the UI from throwing an Error, but
doesn't give a way to get results beyond the first 100


ACK and pushed to master.

--
Endi S. Dewata

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


[Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-01 Thread Adam Young

Not a 100% solution, but keeps the groups-user facet from exploding.

https://fedorahosted.org/freeipa/ticket/1011
From 9b59bebceb79fd1f8101a4e08ed853c65784da9d Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Tue, 1 Mar 2011 21:21:19 -0500
Subject: [PATCH] Use modified entity find commands for associations

---
 install/ui/associate.js |   46 ++
 install/ui/host.js  |8 +---
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/install/ui/associate.js b/install/ui/associate.js
index 600cd55c3abb99f810c8e322da83262c21b5e2c3..47b5b968d6b14110016b435bbfd130c1d96cbf47 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -394,8 +394,12 @@ IPA.association_table_widget = function (spec) {
 'on_success': on_success,
 'on_error': on_error
 });
+var length = that.values.length;
+if (length  100){
+length = 100;
+}
 
-for (var i=0; ithat.values.length; i++) {
+for (var i=0; i length; i++) {
 var value = that.values[i];
 
 var command = IPA.command({
@@ -597,6 +601,8 @@ IPA.association_facet = function (spec) {
 that.adder_columns = [];
 that.adder_columns_by_name = {};
 
+that.relationship_filter = spec.relationship_filter;
+
 that.get_column = function(name) {
 return that.columns_by_name[name];
 };
@@ -881,28 +887,28 @@ IPA.association_facet = function (spec) {
 
 if (!pkeys.length) return;
 
-var batch = IPA.batch_command({
-'name': that.entity_name+'_'+that.name,
+
+var options = {
+'all': true,
+'rights': true
+};
+
+var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+var args =[];
+var relationship_filter = 'in_' + that.entity_name;
+options[relationship_filter] = pkey;
+
+var command = IPA.command({
 'on_success': on_success,
-'on_error': on_error
+'on_error': on_error,
+'method': that.other_entity+'_find',
+'args': args,
+options: options
 });
 
-for (var i=0; ipkeys.length; i++) {
-var pkey = pkeys[i];
+command.execute();
 
-var command = IPA.command({
-'method': that.other_entity+'_show',
-'args': [pkey],
-'options': {
-'all': true,
-'rights': true
-}
-});
 
-batch.add_command(command);
-}
-
-batch.execute();
 };
 
 that.refresh = function() {
@@ -926,9 +932,9 @@ IPA.association_facet = function (spec) {
 that.get_records(
 pkeys,
 function(data, text_status, xhr) {
-var results = data.result.results;
+var results = data.result.result;
 for (var i=0; iresults.length; i++) {
-var record = results[i].result;
+var record = results[i];
 that.table.add_record(record);
 }
 }
diff --git a/install/ui/host.js b/install/ui/host.js
index 981bfc021924bc740379009e62ef5b8345b262d5..adaf2c1cb003f1ff97d646eab236b8a8e9ff0025 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -50,7 +50,7 @@ IPA.entity_factories.host = function () {
 that.add_facet(facet);
 
 facet = IPA.host_managedby_host_facet({
-'name': 'managedby_host'
+name: 'managedby_host'
 });
 that.add_facet(facet);
 
@@ -503,18 +503,12 @@ IPA.host_managedby_host_facet = function (spec) {
 }).appendTo(container);
 };
 
-that.create_column({name: 'description'});
-
 that.create_adder_column({
 name: 'fqdn',
 primary_key: true,
 width: '100px'
 });
 
-that.create_adder_column({
-name: 'description',
-width: '100px'
-});
 
 that.association_facet_init();
 };
-- 
1.7.4

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

Re: [Freeipa-devel] [PATCH] admiyo-0206-2-Use-modified-entity-find-commands-for-associations

2011-03-01 Thread Adam Young

On 03/01/2011 09:23 PM, Adam Young wrote:

Not a 100% solution, but keeps the groups-user facet from exploding.

https://fedorahosted.org/freeipa/ticket/1011


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

Includes fixes for services
From c33490c208678520a587a0488dc5840d3368f58e Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Tue, 1 Mar 2011 21:21:19 -0500
Subject: [PATCH] Use modified entity find commands for associations

---
 install/ui/associate.js |   46 ++
 install/ui/host.js  |8 +---
 install/ui/service.js   |6 --
 3 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/install/ui/associate.js b/install/ui/associate.js
index 600cd55c3abb99f810c8e322da83262c21b5e2c3..47b5b968d6b14110016b435bbfd130c1d96cbf47 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -394,8 +394,12 @@ IPA.association_table_widget = function (spec) {
 'on_success': on_success,
 'on_error': on_error
 });
+var length = that.values.length;
+if (length  100){
+length = 100;
+}
 
-for (var i=0; ithat.values.length; i++) {
+for (var i=0; i length; i++) {
 var value = that.values[i];
 
 var command = IPA.command({
@@ -597,6 +601,8 @@ IPA.association_facet = function (spec) {
 that.adder_columns = [];
 that.adder_columns_by_name = {};
 
+that.relationship_filter = spec.relationship_filter;
+
 that.get_column = function(name) {
 return that.columns_by_name[name];
 };
@@ -881,28 +887,28 @@ IPA.association_facet = function (spec) {
 
 if (!pkeys.length) return;
 
-var batch = IPA.batch_command({
-'name': that.entity_name+'_'+that.name,
+
+var options = {
+'all': true,
+'rights': true
+};
+
+var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+var args =[];
+var relationship_filter = 'in_' + that.entity_name;
+options[relationship_filter] = pkey;
+
+var command = IPA.command({
 'on_success': on_success,
-'on_error': on_error
+'on_error': on_error,
+'method': that.other_entity+'_find',
+'args': args,
+options: options
 });
 
-for (var i=0; ipkeys.length; i++) {
-var pkey = pkeys[i];
+command.execute();
 
-var command = IPA.command({
-'method': that.other_entity+'_show',
-'args': [pkey],
-'options': {
-'all': true,
-'rights': true
-}
-});
 
-batch.add_command(command);
-}
-
-batch.execute();
 };
 
 that.refresh = function() {
@@ -926,9 +932,9 @@ IPA.association_facet = function (spec) {
 that.get_records(
 pkeys,
 function(data, text_status, xhr) {
-var results = data.result.results;
+var results = data.result.result;
 for (var i=0; iresults.length; i++) {
-var record = results[i].result;
+var record = results[i];
 that.table.add_record(record);
 }
 }
diff --git a/install/ui/host.js b/install/ui/host.js
index 981bfc021924bc740379009e62ef5b8345b262d5..adaf2c1cb003f1ff97d646eab236b8a8e9ff0025 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -50,7 +50,7 @@ IPA.entity_factories.host = function () {
 that.add_facet(facet);
 
 facet = IPA.host_managedby_host_facet({
-'name': 'managedby_host'
+name: 'managedby_host'
 });
 that.add_facet(facet);
 
@@ -503,18 +503,12 @@ IPA.host_managedby_host_facet = function (spec) {
 }).appendTo(container);
 };
 
-that.create_column({name: 'description'});
-
 that.create_adder_column({
 name: 'fqdn',
 primary_key: true,
 width: '100px'
 });
 
-that.create_adder_column({
-name: 'description',
-width: '100px'
-});
 
 that.association_facet_init();
 };
diff --git a/install/ui/service.js b/install/ui/service.js
index ff642a808b9d1c6aebf02d7c9385c7a245cba1aa..ee3a8b2718f82fcc56a5e01cf0f92732d3650b02 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -395,7 +395,6 @@ IPA.service_managedby_host_facet = function(spec) {
 }).appendTo(container);
 };
 
-that.create_column({name: 'description'});
 
 that.create_adder_column({
 name: 'fqdn',
@@ -403,11 +402,6 @@