Re: [Freeipa-devel] [PATCH] 678-679 webui: send API version in RPC requests and adapt to new response format

2014-06-27 Thread Petr Vobornik

On 27.6.2014 06:34, Endi Sukma Dewata wrote:

On 6/25/2014 8:51 AM, Petr Vobornik wrote:

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

== [PATCH] 678 webui: send API version in RPC requests ==
Currently there is an incorrect behavior that server doesn't send
datetime
and dnsname data in new format.

This patch adds the version to each RPC request making the UI look as
the
latest client. Server then sends data in correct format. It also removes
the unknown version warning from each RPC response.


== [PATCH] 679 webui: extract rpc value from object envelope ==
adapt Web UI to a newer style of encapsulation object data


ACK.



pushed to master:
* 9aac0524c9adb714aa63113fa6b8436e7636e8c2 webui: send API version in 
RPC requests
* 5568e357d103bafaf9e2f7f1ba1fd507c89e0538 webui: extract rpc value from 
object envelope

--
Petr Vobornik

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


Re: [Freeipa-devel] [PATCH] 678-679 webui: send API version in RPC requests and adapt to new response format

2014-06-26 Thread Endi Sukma Dewata

On 6/25/2014 8:51 AM, Petr Vobornik wrote:

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

== [PATCH] 678 webui: send API version in RPC requests ==
Currently there is an incorrect behavior that server doesn't send datetime
and dnsname data in new format.

This patch adds the version to each RPC request making the UI look as  the
latest client. Server then sends data in correct format. It also removes
the unknown version warning from each RPC response.


== [PATCH] 679 webui: extract rpc value from object envelope ==
adapt Web UI to a newer style of encapsulation object data


ACK.

--
Endi S. Dewata

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


[Freeipa-devel] [PATCH] 678-679 webui: send API version in RPC requests and adapt to new response format

2014-06-25 Thread Petr Vobornik

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

== [PATCH] 678 webui: send API version in RPC requests ==
Currently there is an incorrect behavior that server doesn't send datetime
and dnsname data in new format.

This patch adds the version to each RPC request making the UI look as  the
latest client. Server then sends data in correct format. It also removes
the unknown version warning from each RPC response.


== [PATCH] 679 webui: extract rpc value from object envelope ==
adapt Web UI to a newer style of encapsulation object data
--
Petr Vobornik
From 457ed178131ae7520324b7fb2062658c185bed1b Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Wed, 18 Jun 2014 16:25:56 +0200
Subject: [PATCH] webui: extract rpc value from object envelope

adapt Web UI to a newer style of encapsulation object data

https://fedorahosted.org/freeipa/ticket/4394
---
 install/ui/src/freeipa/dns.js|  4 ++--
 install/ui/src/freeipa/facet.js  |  4 ++--
 install/ui/src/freeipa/field.js  |  1 +
 install/ui/src/freeipa/ipa.js|  2 +-
 install/ui/src/freeipa/rpc.js| 43 
 install/ui/src/freeipa/widget.js | 16 +++
 6 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js
index e59f6e5ad2f46febfa8d4935e549ab15892dada6..260b6f8720c8f725426be249c0a72bd72055d4e5 100644
--- a/install/ui/src/freeipa/dns.js
+++ b/install/ui/src/freeipa/dns.js
@@ -824,7 +824,7 @@ IPA.dns.record_search_facet = function(spec) {
 
 var original = records[i];
 var record = {
-idnsname: original.idnsname,
+idnsname: rpc.extract_objects(original.idnsname),
 values: []
 };
 
@@ -2280,7 +2280,7 @@ IPA.dns.ptr_redirection_dialog = function(spec) {
 
 for (var i=0; izones.length; i++) {
 
-var zone_name = zones[i].idnsname[0];
+var zone_name = rpc.extract_objects(zones[i].idnsname)[0];
 if (that.reverse_address.indexOf(zone_name)  -1) {
 var msg = text.get('@i18n:objects.dnsrecord.ptr_redir_zone');
 msg = msg.replace('${zone}', zone_name);
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 419011627d3f453e98837378f77f88eb6c622219..0bb697be0b606743279b661d2e901372d735f8c3 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -1710,11 +1710,11 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
 
 var result = data.result.result;
 var pkey_name = that.managed_entity.metadata.primary_key;
+var adapter = builder.build('adapter', 'adapter', {context: that});
 
 for (var i=0; iresult.length; i++) {
 var record = result[i];
-var pkey = record[pkey_name];
-if (pkey instanceof Array) pkey = pkey[0];
+var pkey = adapter.load(record, pkey_name)[0];
 records_map.put(pkey, record);
 }
 
diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js
index 0bc8c6f5eb633463ca829b0e46a0fbc0ffacefd7..c2e96b392bdba057828c3d5d465e7e17a52ee535 100644
--- a/install/ui/src/freeipa/field.js
+++ b/install/ui/src/freeipa/field.js
@@ -824,6 +824,7 @@ field.Adapter = declare(null, {
 if (util.is_empty(value)  !util.is_empty(def)) {
 value = util.normalize_value(def);
 }
+value = rpc.extract_objects(value);
 return value;
 },
 
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index 8a1ebaed76e1bd5bbecec7e80a35197191c55920..77ded3b8bbedd42472c74ca43d27e186f5c90466 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -583,7 +583,7 @@ IPA.update_password_expiration = function() {
 
 var now, expires, notify_days, diff, message, container, notify;
 
-expires = IPA.whoami.krbpasswordexpiration;
+expires = rpc.extract_objects(IPA.whoami.krbpasswordexpiration);
 expires = expires ? datetime.parse(expires[0]) : null;
 
 notify_days = IPA.server_config.ipapwdexpadvnotify;
diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js
index d49f60fee65711e0139d7dd70a92ca4168858017..756d4090fdb0d49d335191d4cf5020448dc8e207 100644
--- a/install/ui/src/freeipa/rpc.js
+++ b/install/ui/src/freeipa/rpc.js
@@ -923,5 +923,48 @@ rpc.create_4304_error_handler = function(adder_dialog) {
 };
 };
 
+/**
+ * Property names to identify objects and values to extract in
+ * `rpc.extract_objects(array)` method.
+ * @type {Array}
+ */
+rpc.extract_types = ['__base64__', '__datetime__', '__dns_name__'];
+
+/**
+ * Extract values from specially encoded objects
+ *
+ * '''
+ * // from
+ * [{__datetime__: 20140625103152Z}]
+ * // to
+ * [20140625103152Z]
+ * '''
+ *
+ * - in-place operations, modifies input array
+ * - object properties to extract are defined in `rpc.extract_types`
+ * -