Re: [Freeipa-devel] [PATCH] Splitting service principal into service name and hostname.
On 09/10/2010 12:49 PM, Endi Sukma Dewata wrote: Splitting service principal into service name and hostname. The EntityBuilder has been modified to obtain the pkey value by invoking getPKey(). This function can be overriden for different entities. The addOptionsFunction() has been renamed to getOptions() and it can be overriden for different entities. Each entity that uses this function has been modified accordingly. The addEdit(), addAnother(), add_fail() has been moved into the EntityBuilder class. The global builders is no longer needed because a reference to the builder object can be obtained via enclosure. The ServiceForms has been modified to take service name and hostname and combine them to generate the service principal by overriding the getPKey(). pushed to master ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
Re: [Freeipa-devel] [PATCH] Splitting service principal into service name and hostname.
- "Adam Young" wrote: > ACK, although > please add the following error check in add.js line 67ish > if (response.error){ > if (response.error.message){ > alert(response.error.message); > }else{ > alert("error adding entry"); > } > return; > } OK, fixed in the new attachment. Thanks! -- Endi S. Dewata >From cee21193e33900c2abaab6a581bc70baacfc1d83 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 9 Sep 2010 22:21:29 -0400 Subject: [PATCH] Splitting service principal into service name and hostname. The EntityBuilder has been modified to obtain the pkey value by invoking getPKey(). This function can be overriden for different entities. The addOptionsFunction() has been renamed to getOptions() and it can be overriden for different entities. Each entity that uses this function has been modified accordingly. The addEdit(), addAnother(), add_fail() has been moved into the EntityBuilder class. The global builders is no longer needed because a reference to the builder object can be obtained via enclosure. The ServiceForms has been modified to take service name and hostname and combine them to generate the service principal by overriding the getPKey(). --- install/static/add.js | 112 ++- install/static/hostgroup.js | 18 install/static/netgroup.js | 20 install/static/service.js | 17 +++ install/static/user.js | 14 +++-- 5 files changed, 92 insertions(+), 89 deletions(-) diff --git a/install/static/add.js b/install/static/add.js index 97f7666..fcbcc52 100644 --- a/install/static/add.js +++ b/install/static/add.js @@ -22,34 +22,31 @@ /* REQUIRES: ipa.js */ -/* - * An associatev array between entity names and their builders - */ -var builders = {} ; - -function add_fail(desc){ -alert(desc); -} +//Process for managing the 'add' functionality +function EntityBuilder(obj,addProperties){ +var builder = this; -//Process for managing the 'add' functionality -function EntityBuilder(obj,addProperties,addOptionsFunction ){ this.obj = obj; this.addProperties = addProperties; -if (addOptionsFunction){ -this.addOptionsFunction = addOptionsFunction; -}else{ -this.addOptionsFunction = function(){ -var options = { }; -return options; -} + +this.getPKey = function(){ +return $("#pkey").val(); +} + +this.getOptions = function(){ +return {}; +} + +this.add_fail = function(desc){ +alert(desc); } -this.add = function(on_success){ -var options = this.addOptionsFunction(); -var params = [$("#pkey").val()]; -ipa_cmd( 'add', params, options, on_success, add_fail, this.obj ); +this.add = function(pkey, on_success){ +var params = [pkey]; +var options = this.getOptions(); +ipa_cmd( 'add', params, options, on_success, this.add_fail, this.obj ); } this.setup = function(){ @@ -58,24 +55,53 @@ function EntityBuilder(obj,addProperties,addOptionsFunction ){ $(" ") .appendTo("#content"); var label =$("Add and ").appendTo("#addForm") -$("", - {id:'addEdit', - type:'button', - value:'Edit', - click: function(){ - var params = ipa_parse_qs(); - builders[params["tab"]].add (addEdit) - } - }).appendTo(label); + +$("", { +id:'addEdit', +type:'button', +value:'Edit', +click: function(){ +var params = ipa_parse_qs(); +var pkey = builder.getPKey(); +builder.add(pkey, function(response){ +if (response.error){ +if (response.error.message) { +alert(response.error.message); +} else { +alert("error adding entry"); +} +return; +} +var hash= "tab=" ++params["tab"] ++"&facet=details&pkey=" ++pkey; +window.location.hash = hash; +}); +} +}).appendTo(label); + $("", { id:'addAnother', type:'button', value:'Add Another', click: function(){ - var params = ipa_parse_qs(); -builders[params["tab"]].add (addAnother) +var params = ipa_parse_qs(); +var pkey = builder.getPKey(); +builder.add(pkey, function(response){ +if (response.error){ +if (response.error.message) { +alert(response.error.message); +} else { +alert("error adding entry"); +
Re: [Freeipa-devel] [PATCH] Splitting service principal into service name and hostname.
On 09/09/2010 07:00 PM, Endi Sukma Dewata wrote: Hi, Please review the attached patch. Thanks! The EntityBuilder has been modified to obtain the pkey value by invoking getPKey(). This function can be overriden for different entities. The addOptionsFunction() has been renamed to getOptions() and it can be overriden for different entities. Each entity that uses this function has been modified accordingly. The addEdit(), addAnother(), add_fail() has been moved into the EntityBuilder class. The global builders is no longer needed because a reference to the builder object can be obtained via enclosure. The ServiceForms has been modified to take service name and hostname and combine them to generate the service principal by overriding the getPKey(). -- Endi S. Dewata ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel ACK, although please add the following error check in add.js line 67ish if (response.error){ if (response.error.message){ alert(response.error.message); }else{ alert("error adding entry"); } return; } ___ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel
[Freeipa-devel] [PATCH] Splitting service principal into service name and hostname.
Hi, Please review the attached patch. Thanks! The EntityBuilder has been modified to obtain the pkey value by invoking getPKey(). This function can be overriden for different entities. The addOptionsFunction() has been renamed to getOptions() and it can be overriden for different entities. Each entity that uses this function has been modified accordingly. The addEdit(), addAnother(), add_fail() has been moved into the EntityBuilder class. The global builders is no longer needed because a reference to the builder object can be obtained via enclosure. The ServiceForms has been modified to take service name and hostname and combine them to generate the service principal by overriding the getPKey(). -- Endi S. Dewata >From cb6ee37caa2790ed2f7b6eca1158ec5c146e1ef8 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Thu, 9 Sep 2010 22:21:29 -0400 Subject: [PATCH] Splitting service principal into service name and hostname. The EntityBuilder has been modified to obtain the pkey value by invoking getPKey(). This function can be overriden for different entities. The addOptionsFunction() has been renamed to getOptions() and it can be overriden for different entities. Each entity that uses this function has been modified accordingly. The addEdit(), addAnother(), add_fail() has been moved into the EntityBuilder class. The global builders is no longer needed because a reference to the builder object can be obtained via enclosure. The ServiceForms has been modified to take service name and hostname and combine them to generate the service principal by overriding the getPKey(). --- install/static/add.js | 104 -- install/static/hostgroup.js | 18 install/static/netgroup.js | 20 install/static/service.js | 17 +++ install/static/user.js | 14 +++--- 5 files changed, 84 insertions(+), 89 deletions(-) diff --git a/install/static/add.js b/install/static/add.js index 97f7666..d40fdbc 100644 --- a/install/static/add.js +++ b/install/static/add.js @@ -22,34 +22,31 @@ /* REQUIRES: ipa.js */ -/* - * An associatev array between entity names and their builders - */ -var builders = {} ; - -function add_fail(desc){ -alert(desc); -} +//Process for managing the 'add' functionality +function EntityBuilder(obj,addProperties){ +var builder = this; -//Process for managing the 'add' functionality -function EntityBuilder(obj,addProperties,addOptionsFunction ){ this.obj = obj; this.addProperties = addProperties; -if (addOptionsFunction){ -this.addOptionsFunction = addOptionsFunction; -}else{ -this.addOptionsFunction = function(){ -var options = { }; -return options; -} + +this.getPKey = function(){ +return $("#pkey").val(); +} + +this.getOptions = function(){ +return {}; +} + +this.add_fail = function(desc){ +alert(desc); } -this.add = function(on_success){ -var options = this.addOptionsFunction(); -var params = [$("#pkey").val()]; -ipa_cmd( 'add', params, options, on_success, add_fail, this.obj ); +this.add = function(pkey, on_success){ +var params = [pkey]; +var options = this.getOptions(); +ipa_cmd( 'add', params, options, on_success, this.add_fail, this.obj ); } this.setup = function(){ @@ -58,24 +55,45 @@ function EntityBuilder(obj,addProperties,addOptionsFunction ){ $(" ") .appendTo("#content"); var label =$("Add and ").appendTo("#addForm") -$("", - {id:'addEdit', - type:'button', - value:'Edit', - click: function(){ - var params = ipa_parse_qs(); - builders[params["tab"]].add (addEdit) - } - }).appendTo(label); + +$("", { +id:'addEdit', +type:'button', +value:'Edit', +click: function(){ +var params = ipa_parse_qs(); +var pkey = builder.getPKey(); +builder.add(pkey, function(response){ +if (response.error){ +alert("error adding entry"); +return; +} +var hash= "tab=" ++params["tab"] ++"&facet=details&pkey=" ++pkey; +window.location.hash = hash; +}); +} +}).appendTo(label); + $("", { id:'addAnother', type:'button', value:'Add Another', click: function(){ - var params = ipa_parse_qs(); -builders[params["tab"]].add (addAnother) +var params = ipa_parse_qs(); +var pkey = builder.getPKey(); +builder.add(pkey, function(response){ +if