Commit 401260d9 authored by preetwinder's avatar preetwinder Committed by preetwinder

[erp5_officejs] Fix sync, header in login and list results.

parent 0efc3990
...@@ -85,9 +85,11 @@ ...@@ -85,9 +85,11 @@
FBStorage.prototype.buildQuery = function (query) { FBStorage.prototype.buildQuery = function (query) {
console.log('QueryRecieved', query); console.log('QueryRecieved', query);
var that = this, template_argument = {user_id: this._user_id, limit: 100, var that = this, fields = [], limit = this._default_limit,
access_token: this._access_token}, fields = [], template_argument = {
limit = this._default_limit; user_id: this._user_id,
limit: limit,
access_token: this._access_token};
if (query.include_docs) { if (query.include_docs) {
fields = fields.concat(that._default_field_list); fields = fields.concat(that._default_field_list);
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16463.42275.10052</string> </value> <value> <string>961.20894.37088.58897</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502116781.14</float> <float>1502382636.2</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<body> <body>
<section class="ui-content-header-plain"> <section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">&nbsp; <h3 class="ui-content-title ui-body-c">&nbsp;
<span id="status" class="ui-icon ui-icon-custom ui-icon-file-text-o">Please Log into the app</span> <span id="status" class="ui-icon ui-icon-custom ui-icon-file-text-o"> Please Log into the app</span>
</h3> </h3>
</section> </section>
<section class="ui-body-c ui-content-section"> <section class="ui-body-c ui-content-section">
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16470.22894.2645</string> </value> <value> <string>961.20845.44804.55534</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502117181.46</float> <float>1502379704.19</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -79,20 +79,16 @@ gadget_klass ...@@ -79,20 +79,16 @@ gadget_klass
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this;
return gadget.updateHeader({ return gadget.updateHeader({page_title: "Facebook Login"})
title: "Connect To Facebook Storage",
back_url: "#page=document_list",
panel_action: false
})
}) })
.declareService(function () { .declareService(function () {
var gadget = this; var gadget = this;
FB.init({ FB.init({
appId : '1917551475189095', appId : '1917551475189095',
cookie : true, cookie : true,
xfbml : true, xfbml : true,
version : 'v2.8' version : 'v2.8'
}); });
FB.getLoginStatus(function(response) { FB.getLoginStatus(function(response) {
if (response.status == 'connected') { if (response.status == 'connected') {
...@@ -117,7 +113,7 @@ gadget_klass ...@@ -117,7 +113,7 @@ gadget_klass
} }
} }
}) })
.onEvent("click", function (event) { .onEvent("click", function (event) {
var gadget = this; var gadget = this;
if (event.target.id == 'login') { if (event.target.id == 'login') {
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16472.57754.53162</string> </value> <value> <string>961.20848.25415.9847</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502117334.01</float> <float>1502381591.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -20,13 +20,16 @@ ...@@ -20,13 +20,16 @@
.allowPublicAcquisition("jio_allDocs", function (param_list) { .allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this; var gadget = this;
console.log(param_list);
param_list[0].select_list.push('story');
param_list[0].select_list.push('link');
return gadget.jio_allDocs(param_list[0]) return gadget.jio_allDocs(param_list[0])
.push(function (result) { .push(function (result) {
var i, date, len = result.data.total_rows; var i, date, message, len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("modification_date")) { if (result.data.rows[i].value.hasOwnProperty("created_time")) {
date = new Date(result.data.rows[i].value.modification_date); date = new Date(result.data.rows[i].value.created_time);
result.data.rows[i].value.modification_date = { result.data.rows[i].value.created_time = {
allow_empty_time: 0, allow_empty_time: 0,
ampm_time_style: 0, ampm_time_style: 0,
css_class: "date_field", css_class: "date_field",
...@@ -36,10 +39,10 @@ ...@@ -36,10 +39,10 @@
hidden: 0, hidden: 0,
hidden_day_is_last_day: 0, hidden_day_is_last_day: 0,
default: date.toUTCString(), default: date.toUTCString(),
key: "modification_date", key: "created_time",
required: 0, required: 0,
timezone_style: 0, timezone_style: 0,
title: "Modification Date", title: "Creation Time",
type: "DateTimeField" type: "DateTimeField"
}; };
result.data.rows[i].value["listbox_uid:list"] = { result.data.rows[i].value["listbox_uid:list"] = {
...@@ -47,6 +50,22 @@ ...@@ -47,6 +50,22 @@
value: 2713 value: 2713
}; };
} }
if (!result.data.rows[i].value.message) {
message = '';
}
else {
message = result.data.rows[i].value.message;
}
if (result.data.rows[i].value.story) {
message += ' ' + result.data.rows[i].value.story;
}
var link = result.data.rows[i].value.link;
if (link) {
if (!(message == link.slice(0, -1) || message == link)) {
message += ' ' + result.data.rows[i].value.link.slice(0, 100) + '...';
}
}
result.data.rows[i].value.message = message;
} }
return result; return result;
}); });
......
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16167.19263.24251</string> </value> <value> <string>961.20726.1023.7560</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502202691.66</float> <float>1502372527.27</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -342,7 +342,7 @@ NETWORK:\n ...@@ -342,7 +342,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.17876.53189.13602</string> </value> <value> <string>961.20841.15763.31249</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -360,7 +360,7 @@ NETWORK:\n ...@@ -360,7 +360,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502286664.9</float> <float>1502440236.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -11,43 +11,8 @@ ...@@ -11,43 +11,8 @@
} }
return storage[method_name].apply(storage, argument_list) return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) { .push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 401)) { if (error.status_code === 400) {
var regexp, return gadget.redirect({command: "display", options: {page: 'ojs_facebook_configurator'}});
site,
login_page;
if (gadget.state_parameter_dict.jio_storage_name === "ERP5") {
regexp = /^X-Delegate uri=\"(http[s]?:\/\/[\/\-\[\]{}()*+=:?&.,\\\^$|#\s\w%]+)\"$/;
login_page = error.target.getResponseHeader('WWW-Authenticate');
if (regexp.test(login_page)) {
return gadget.getUrlFor({
command: 'login',
absolute_url: true
})
.push(function (came_from) {
return gadget.redirect({
command: 'raw',
options: {
url: UriTemplate.parse(regexp.exec(login_page)[1]).expand({came_from: came_from})
}
});
});
}
}
if (gadget.state_parameter_dict.jio_storage_name === "DAV") {
regexp = /^Nayookie login_url=(http[s]?:\/\/[\/\-\[\]{}()*+=:?&.,\\\^$|#\s\w%]+)$/;
login_page = error.target.getResponseHeader('WWW-Authenticate');
if (regexp.test(login_page)) {
site = UriTemplate.parse(
regexp.exec(login_page)[1]
).expand({
back_url: window.location.href,
origin: window.location.origin
});
}
}
if (site) {
return gadget.redirect({ command: "row", url: site});
}
} }
throw error; throw error;
}); });
......
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.19289.52390.7048</string> </value> <value> <string>961.20900.38898.22289</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502286412.26</float> <float>1502382996.38</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
}) })
.push(function (data) { .push(function (data) {
var options = { var options = {
page: "ojs_document_list" page: "ojs_fb_posts_document_list"
}; };
if (data.search) { if (data.search) {
options.extended_search = data.search; options.extended_search = data.search;
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16408.6890.18005</string> </value> <value> <string>961.19389.35931.31061</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502113976.19</float> <float>1502292333.77</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment