Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Endi Sukma Dewata

On 10/29/2010 12:13 PM, Adam Young wrote:

On 10/29/2010 12:45 PM, Endi Sukma Dewata wrote:


still using the old parameter.

Fixed.


ACKed and pushed to master.

--
Endi S. Dewata

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


Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Adam Young

On 10/29/2010 12:45 PM, Endi Sukma Dewata wrote:


  still using the old parameter. 

Fixed.
From 1b3c7c58e83fc9060923f107fec68a85bbcbf81f Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Thu, 28 Oct 2010 17:20:12 -0400
Subject: [PATCH] delete associations

Uses code very similar to the search code for deleting associations
Had to modify how we were configuring for bulk so that the logic for delete matched the logic for enroll

Fixed unit test and removed the 'new' from the associator call
---
 install/static/associate.js  |  247 --
 install/static/group.js  |6 +-
 install/static/host.js   |4 +-
 install/static/serverconfig.js   |4 +-
 install/static/test/association_tests.js |   10 +-
 install/static/user.js   |8 +-
 6 files changed, 213 insertions(+), 66 deletions(-)

diff --git a/install/static/associate.js b/install/static/associate.js
index 7daa0cf..e91288a 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -25,14 +25,14 @@
 /**
 *This associator is built for the case where each association requires a separate rpc
 */
-function SerialAssociator(form, manyObjPkeys, on_success)
+function serial_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
 this.manyObjPkeys =  manyObjPkeys;
 this.on_success = on_success;
 
-this.associateNext = function(){
+this.associate_next = function(){
 var form = this.form;
 //TODO assert pre-conditions
 var  manyObjPkey =  manyObjPkeys.shift();
@@ -46,7 +46,7 @@ function SerialAssociator(form, manyObjPkeys, on_success)
  if (data.error){
  alert('error adding member: '+data.error.message);
  }else{
- associator.associateNext();
+ associator.associate_next();
  }
  },
  function(xhr, text_status, error_thrown) {
@@ -57,53 +57,117 @@ function SerialAssociator(form, manyObjPkeys, on_success)
 associator.on_success();
 }
 }
+this.associate_next();
 }
 
+
+function serial_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+   many_entity_pkeys, on_success){
+var that = {};
+that.one_entity = one_entity;
+that.on_success = on_success;
+that.many_entity_pkeys = many_entity_pkeys;
+that.delete_next = function(){
+var  many_entity_pkey =  this.many_entity_pkeys.shift();
+if (many_entity_pkey){
+var options = {};
+options[one_entity] = one_entity_pkey;
+var args = [many_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert("error deleting member: "
+   +data.error.message);
+ }else{
+ that.delete_next();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert("associateFailure");
+ },
+ many_entity );
+}else{
+this.on_success();
+}
+}
+
+that.delete_next();
+}
+
+function bulk_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+ many_entity_pkeys, on_success){
+if (many_entity_pkeys.length){
+var options = {};
+options[one_entity] = one_entity_pkey;
+var option = many_entity_pkeys.shift();
+while(many_entity_pkeys.length > 0) {
+option += ',' + many_entity_pkeys.shift();
+}
+
+var options = {
+'all':true
+};
+options[many_entity] = option;
+var args = [one_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert("error deleting member: "
+   +data.error.message);
+ }else{
+ on_success();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert("associateFailure");
+ },
+ one_entity );
+}else{
+on_success();
+}
+}
+
+
 /**
 *This associator is for the common case where all the asociations can be sent
 in a single rpc
 */
-function BulkAssociator(form, manyObjPkeys, on_success)
+function bulk_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
 this.manyObjPkeys = manyObjP

Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Endi Sukma Dewata

On 10/29/2010 10:33 AM, Adam Young wrote:

On 10/28/2010 05:30 PM, Adam Young wrote:

On 10/28/2010 05:22 PM, Adam Young wrote:

delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion. While this works for all
deletes,
it is slower than bulk.



Found one problem myself: the '*_remove_member' approach only works
one way, not both for removing associations.



This version matches the serial and bulk associators with the deleter


NACK. The enrollment & deletion work, but there are some issues:
- The unit test failed because it's still referring to the old
  associator names.
- The ipa_entity_set_association_definition() invocation in aci.js is
  still using the old parameter.
- The variable 'that' in serial_delete() is defined as global variable.
- The members in the association list are clickable but it brings you
  to an empty page. I see the note in the code saying that this is not
  working yet, I think the link should be disabled for now.
- Deleter's method name is hardcoded, but this can be fixed later when
  needed.
- There are some trailing white spaces in the patch.

--
Endi S. Dewata

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


Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Adam Young

On 10/28/2010 05:30 PM, Adam Young wrote:

On 10/28/2010 05:22 PM, Adam Young wrote:

 delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion.  While this works for all 
deletes,

it is slower than bulk.


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


Found one problem myself:  the '*_remove_member'  approach only works 
one way, not both for removing associations.



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

This version matches the serial and bulk associators with the deleter
From f9b4d2723c1087652d03d2a2af850b65d1f04a3c Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Thu, 28 Oct 2010 17:20:12 -0400
Subject: [PATCH] delete associations

Uses code very similar to the search code for deleting associations
Had to modify how we were configuring for bulk so that the logic for delete matched the logic for enroll
---
 install/static/associate.js|  199 
 install/static/group.js|6 +-
 install/static/host.js |4 +-
 install/static/serverconfig.js |4 +-
 install/static/user.js |8 +-
 5 files changed, 190 insertions(+), 31 deletions(-)

diff --git a/install/static/associate.js b/install/static/associate.js
index 7daa0cf..e538e3d 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -25,7 +25,7 @@
 /**
 *This associator is built for the case where each association requires a separate rpc
 */
-function SerialAssociator(form, manyObjPkeys, on_success)
+function serial_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
@@ -59,11 +59,80 @@ function SerialAssociator(form, manyObjPkeys, on_success)
 }
 }
 
+
+function serial_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+   many_entity_pkeys, on_success){
+that = {};
+that.one_entity = one_entity;
+that.on_success = on_success;
+that.many_entity_pkeys = many_entity_pkeys;
+that.delete_next = function(){
+var  many_entity_pkey =  this.many_entity_pkeys.shift();
+if (many_entity_pkey){
+var options = {};
+options[one_entity] = one_entity_pkey;
+var args = [many_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert("error deleting member: "
+   +data.error.message);
+ }else{
+ that.delete_next();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert("associateFailure");
+ },
+ many_entity );
+}else{
+this.on_success();
+}
+}
+
+that.delete_next();
+}
+
+function bulk_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+ many_entity_pkeys, on_success){
+if (many_entity_pkeys.length){
+var options = {};
+options[one_entity] = one_entity_pkey;
+
+var option = many_entity_pkeys.shift();
+while(many_entity_pkeys.length > 0) {
+option += ',' + many_entity_pkeys.shift();
+}
+
+var options = {
+'all':true
+};
+options[many_entity] = option;
+var args = [one_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert("error deleting member: "
+   +data.error.message);
+ }else{
+ on_success();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert("associateFailure");
+ },
+ one_entity );
+}else{
+on_success();
+}
+}
+
+
 /**
 *This associator is for the common case where all the asociations can be sent
 in a single rpc
 */
-function BulkAssociator(form, manyObjPkeys, on_success)
+function bulk_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
@@ -103,7 +172,7 @@ function BulkAssociator(form, manyObjPkeys, on_success)
  *  Create a form for a one to many association.
  *
  */
-function AssociationForm(oneObj, pkey, manyObj, on_success, associatorConstructor, method)
+function AssociationForm(oneObj, pkey, manyObj, on_success, associator, method)

Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-28 Thread Adam Young

On 10/28/2010 05:22 PM, Adam Young wrote:

 delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion.  While this works for all 
deletes,

it is slower than bulk.


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


Found one problem myself:  the '*_remove_member'  approach only works 
one way, not both for removing associations.
___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

[Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-28 Thread Adam Young

 delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion.  While this works for all 
deletes,

it is slower than bulk.

From 8620779c9bbfe7f39653da03aeeb20ae0ff5be45 Mon Sep 17 00:00:00 2001
From: Adam Young 
Date: Thu, 28 Oct 2010 17:20:12 -0400
Subject: [PATCH] delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of dletion.  While this works for all deletes,
it is slower than bulk.
---
 install/static/associate.js |  116 ---
 1 files changed, 109 insertions(+), 7 deletions(-)

diff --git a/install/static/associate.js b/install/static/associate.js
index 7daa0cf..7b4960e 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -59,6 +59,41 @@ function SerialAssociator(form, manyObjPkeys, on_success)
 }
 }
 
+
+function serial_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+   many_entity_pkeys, on_success){
+that = {};
+that.one_entity = one_entity;
+that.on_success = on_success;
+that.many_entity_pkeys = many_entity_pkeys;
+that.delete_next = function(){
+var  many_entity_pkey =  this.many_entity_pkeys.shift();
+if (many_entity_pkey){
+var options = {};
+options[one_entity] = one_entity_pkey;
+var args = [many_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert("error deleting member: "
+   +data.error.message);
+ }else{
+ that.delete_next();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert("associateFailure");
+ },
+ many_entity );
+}else{
+this.on_success();
+}
+}
+
+that.delete_next();
+}
+
+
 /**
 *This associator is for the common case where all the asociations can be sent
 in a single rpc
@@ -221,6 +256,11 @@ function ipa_association_config(spec) {
 return that;
 }
 
+
+
+
+
+
 function ipa_association_facet(spec) {
 
 spec = spec || {};
@@ -284,15 +324,21 @@ function ipa_association_facet(spec) {
 container.find('.search-filter').css('display', 'none');
 container.find('.search-buttons').html('');
 
-$('', {
-type:  'button',
-value: 'enroll',
-click: function() {
+var ctrls = container.find('.search-buttons');
+
+ipa_make_button( 'ui-icon-plus',IPA.messages.button.enroll).
+click(function() {
 that.show_enrollment_dialog();
-}
-}).appendTo(container.find('.search-buttons'));
+}).appendTo(ctrls);
 
-var header = $('').appendTo(container.find('.search-table thead:last'));
+ipa_make_button('ui-icon-trash',IPA.messages.button.delete).
+click(function(){
+that.delete_on_click(container);
+}).appendTo(ctrls);
+
+
+
+var header = container.find('.search-table thead:last').find("tr");;
 for (var i =0 ; i != that.columns.length ;i++){
 $('',{
 html: that.columns[i].title
@@ -301,14 +347,70 @@ function ipa_association_facet(spec) {
 that.refresh(container);
 };
 
+that.delete_on_click = function(container) {
+var delete_list = [];
+var delete_dialog = $('', {
+title: IPA.messages.button.delete,
+'class': 'search-dialog-delete'
+});
+
+function delete_on_click() {
+serial_delete('remove_member', that.entity_name,
+  that.pkey, that.other_entity, delete_list,
+  function(){ that.refresh(container)});
+delete_dialog.dialog('close');
+}
+function delete_on_win() {
+delete_dialog.dialog('close');
+}
+function cancel_on_click() {
+delete_dialog.dialog('close');
+}
+var confirm_list = $('');
+var delete_list = [];
+container.find('.search-selector').each(function () {
+if (this.checked){
+delete_list.push(this.title);
+confirm_list.append($('',{text: this.title}));
+}
+});
+if (delete_list.length == 0){
+return;
+}
+delete_dialog.append(confirm_list);
+delete_dialog.append(
+$('',
+  {text:IPA.messages.search.delete_confirm}));
+
+
+delete_dialog.dialog({
+modal: true,
+buttons: {
+'Delete': delete_on_click,
+'Cancel': cancel_on_click