Commit 8a2559d3 authored by preetwinder's avatar preetwinder Committed by preetwinder

[erp5_officejs] Change default config page

parent 0a3d0837
...@@ -198,6 +198,7 @@ gadget_erp5_page_ojs_fb_posts_panel.html\n ...@@ -198,6 +198,7 @@ gadget_erp5_page_ojs_fb_posts_panel.html\n
gadget_erp5_page_ojs_fb_posts_panel.js\n gadget_erp5_page_ojs_fb_posts_panel.js\n
jio_fbstorage.js\n jio_fbstorage.js\n
gadget_erp5_page_ojs_fb_posts_jio.html\n gadget_erp5_page_ojs_fb_posts_jio.html\n
gadget_ojs_fb_posts_jio.js\n
GADGET:\n GADGET:\n
NETWORK:\n NETWORK:\n
*</string> </value> *</string> </value>
...@@ -359,7 +360,7 @@ NETWORK:\n ...@@ -359,7 +360,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502201569.89</float> <float>1502286664.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<!-- custom script --> <!-- custom script -->
<script src="gadget_ojs_jio.js" type="text/javascript"></script> <script src="gadget_ojs_fb_posts_jio.js" type="text/javascript"></script>
</head> </head>
<body> <body>
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16142.29893.22408</string> </value> <value> <string>961.16340.21976.59340</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502099015.21</float> <float>1502286442.68</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, jIO, FormData, UriTemplate */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, jIO) {
"use strict";
// jIO call wrapper for redirection to authentication page if needed
function wrapJioCall(gadget, method_name, argument_list) {
var storage = gadget.state_parameter_dict.jio_storage;
if (storage === undefined) {
return gadget.redirect({command: 'display', options: {page: 'ojs_facebook_configurator'}});
}
return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 401)) {
var regexp,
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;
});
}
rJS(window)
.ready(function (gadget) {
// Initialize the gadget local parameters
gadget.state_parameter_dict = {};
})
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod('getUrlFor', 'getUrlFor')
.declareMethod('createJio', function (jio_options) {
var gadget = this;
if (jio_options === undefined) {
return;
}
this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options);
return this.getSetting("jio_storage_name")
.push(function (jio_storage_name) {
gadget.state_parameter_dict.jio_storage_name = jio_storage_name;
});
})
.declareMethod('allDocs', function () {
return wrapJioCall(this, 'allDocs', arguments);
})
.declareMethod('allAttachments', function () {
return wrapJioCall(this, 'allAttachments', arguments);
})
.declareMethod('get', function () {
return wrapJioCall(this, 'get', arguments);
})
.declareMethod('put', function () {
return wrapJioCall(this, 'put', arguments);
})
.declareMethod('post', function () {
return wrapJioCall(this, 'post', arguments);
})
.declareMethod('remove', function () {
return wrapJioCall(this, 'remove', arguments);
})
.declareMethod('getAttachment', function () {
return wrapJioCall(this, 'getAttachment', arguments);
})
.declareMethod('putAttachment', function () {
return wrapJioCall(this, 'putAttachment', arguments);
})
.declareMethod('removeAttachment', function () {
return wrapJioCall(this, 'removeAttachment', arguments);
})
.declareMethod('repair', function () {
return wrapJioCall(this, 'repair', arguments);
});
}(window, rJS, jIO));
\ No newline at end of file
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