Commit 06e11f97 authored by Roque's avatar Roque

erp5_officejs: restoring old ojs jio gadget

- new approach uses a new ojs jio gadget
- old one is kept for backward compatibility (not migrated apps)
parent f3f3df01
...@@ -204,8 +204,6 @@ gadget_button_maximize.js\n ...@@ -204,8 +204,6 @@ gadget_button_maximize.js\n
gadget_erp5_configure_editor.html\n gadget_erp5_configure_editor.html\n
gadget_erp5_configure_editor.js\n gadget_erp5_configure_editor.js\n
\n \n
jio_appcachestorage.js\n
\n
#setting\n #setting\n
gadget_officejs_setting.js\n gadget_officejs_setting.js\n
gadget_officejs_setting.html\n gadget_officejs_setting.html\n
...@@ -400,7 +398,7 @@ NETWORK:\n ...@@ -400,7 +398,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.65224.6078.42154</string> </value> <value> <string>975.65395.52374.56473</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -418,7 +416,7 @@ NETWORK:\n ...@@ -418,7 +416,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558970026.48</float> <float>1558985553.36</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -150,8 +150,8 @@ gadget_erp5_ojs_panel.html\n ...@@ -150,8 +150,8 @@ gadget_erp5_ojs_panel.html\n
gadget_erp5_ojs_panel.js\n gadget_erp5_ojs_panel.js\n
gadget_erp5_header.html\n gadget_erp5_header.html\n
gadget_erp5_header.js\n gadget_erp5_header.js\n
gadget_ojs_jio.html\n gadget_ojs_local_jio.html\n
gadget_ojs_jio.js\n gadget_ojs_local_jio.js\n
\n \n
gadget_erp5_page_ojs_configurator.html\n gadget_erp5_page_ojs_configurator.html\n
gadget_erp5_page_ojs_configurator.js\n gadget_erp5_page_ojs_configurator.js\n
...@@ -760,7 +760,7 @@ NETWORK:\n ...@@ -760,7 +760,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.59928.32228.31914</string> </value> <value> <string>975.65264.897.7441</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -778,7 +778,7 @@ NETWORK:\n ...@@ -778,7 +778,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558971840.81</float> <float>1558984889.91</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script src="jiodev.js" type="text/javascript"></script> <script src="jiodev.js" type="text/javascript"></script>
<script src="jio_ojs_storage.js" type="text/javascript"></script> <script src="jio_ojs_storage.js" type="text/javascript"></script>
<script src="jio_appcachestorage.js"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_ojs_jio.js" type="text/javascript"></script> <script src="gadget_ojs_jio.js" type="text/javascript"></script>
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.23054.45008.28006</string> </value> <value> <string>975.50798.33418.15411</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>1552654559.7</float> <float>1558984646.18</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate, console */ /*global window, rJS, jIO, FormData, UriTemplate */
/*jslint indent: 2, maxerr: 3 */ /*jslint indent: 2, maxerr: 3 */
(function (window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate, console) { (function (window, rJS, jIO) {
"use strict"; "use strict";
// jIO call wrapper for redirection to authentication page if needed // jIO call wrapper for redirection to authentication page if needed
...@@ -60,39 +60,6 @@ ...@@ -60,39 +60,6 @@
}); });
} }
function processHateoasDict(raw_dict) {
var raw_fields, type, parent, field_key, field_id, return_dict = {};
return_dict.raw_dict = raw_dict;
/*jslint nomen: true*/
if (raw_dict.hasOwnProperty("_embedded") && raw_dict._embedded.hasOwnProperty("_view")) {
raw_fields = raw_dict._embedded._view;
type = raw_dict._links.type.name;
parent = raw_dict._links.parent.name;
/*jslint nomen: false*/
return_dict.parent_relative_url = "portal_types/" + parent;
return_dict.portal_type = type;
for (field_key in raw_fields) {
if (raw_fields.hasOwnProperty(field_key)) {
field_id = "";
if (raw_fields[field_key]["default"] !== undefined && raw_fields[field_key]["default"] !== "") {
if (field_key.startsWith("my_")) {
field_id = field_key.replace("my_", "");
} else if (field_key.startsWith("your_")) {
field_id = field_key.replace("your_", "");
} else {
field_id = field_key;
}
return_dict[field_id] = raw_fields[field_key]["default"];
}
}
}
} else {
// raw_dict is a blob
return raw_dict;
}
return return_dict;
}
rJS(window) rJS(window)
.ready(function (gadget) { .ready(function (gadget) {
...@@ -107,42 +74,10 @@ ...@@ -107,42 +74,10 @@
.declareAcquiredMethod('getUrlFor', 'getUrlFor') .declareAcquiredMethod('getUrlFor', 'getUrlFor')
.declareMethod('createJio', function (jio_options) { .declareMethod('createJio', function (jio_options) {
var appcache_storage, var gadget = this;
origin_url = window.location.href,
hateoas_script = "hateoas/ERP5Document_getHateoas",
// TODO manifest should come from gadget.props.cache_file -add script in html body
manifest = "gadget_officejs_discussion_tool.configuration",
jio_appchache_options = {
type: "replicate",
parallel_operation_attachment_amount: 10,
parallel_operation_amount: 1,
conflict_handling: 2,
signature_hash_key: 'hash',
check_remote_attachment_modification: true,
check_remote_attachment_creation: true,
check_remote_attachment_deletion: true,
check_remote_deletion: true,
check_local_creation: false,
check_local_deletion: false,
check_local_modification: false,
signature_sub_storage: {
type: "query",
sub_storage: {
type: "memory"
}
},
local_sub_storage: {},
remote_sub_storage: {
type: "appcache",
manifest: manifest
}
},
sync_flag = "appcache-stored",
configuration_ids_list = [];
if (jio_options === undefined) { if (jio_options === undefined) {
return; return;
} }
jio_appchache_options.local_sub_storage = JSON.parse(JSON.stringify(jio_options));
jio_options = { jio_options = {
type: 'dateupdater', type: 'dateupdater',
sub_storage: jio_options, sub_storage: jio_options,
...@@ -155,63 +90,7 @@ ...@@ -155,63 +90,7 @@
} }
return this.getSetting("jio_storage_name") return this.getSetting("jio_storage_name")
.push(function (jio_storage_name) { .push(function (jio_storage_name) {
if (jio_storage_name === undefined) { return; } gadget.state_parameter_dict.jio_storage_name = jio_storage_name;
appcache_storage = jIO.createJIO(jio_appchache_options);
// verify if appcache-local sync needs to be done
return appcache_storage.get(sync_flag)
.push(undefined, function (error) {
if (error && String(error.status_code) !== "404") {
throw error;
}
return appcache_storage.repair()
.push(function () {
return appcache_storage.allAttachments(origin_url)
.push(function (attachment_dict) {
var id, promise_list = [], i = 0;
for (id in attachment_dict) {
if (attachment_dict.hasOwnProperty(id)) {
if (id.indexOf(hateoas_script) === -1) {
promise_list.push(appcache_storage.getAttachment(origin_url, id));
} else {
promise_list.push(appcache_storage.getAttachment(origin_url, id, {"format": "json"}));
}
configuration_ids_list[i] = id;
i += 1;
}
}
return RSVP.all(promise_list);
})
.push(function (content_list) {
var i, id, parser, urlParams, content, promise_list = [];
for (i = 0; i < content_list.length; i += 1) {
id = configuration_ids_list[i];
parser = document.createElement('a');
parser.href = id;
urlParams = new URLSearchParams(parser.search);
id = urlParams.get("relative_url");
if (id !== null) { // ignore non configuration elements
content = processHateoasDict(content_list[i]);
promise_list.push(appcache_storage.put(id, content));
}
}
return RSVP.all(promise_list);
})
.push(function () {
return appcache_storage.put(sync_flag, {})
.push(undefined);
});
}, function (error) {
console.log("Error while appcache-local storage synchronization");
if (error && error.currentTarget && error.currentTarget.status === "401") {
console.log("Unauthorized access to storage, sync cancelled");
return;
}
//TODO: ignore sync error to make other officejs apps work
//until configuration manifest file name is get from app-settings
return;
throw error;
});
});
}); });
}) })
.declareMethod('allDocs', function () { .declareMethod('allDocs', function () {
...@@ -245,4 +124,4 @@ ...@@ -245,4 +124,4 @@
return wrapJioCall(this, 'repair', arguments); return wrapJioCall(this, 'repair', arguments);
}); });
}(window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate, console)); }(window, rJS, jIO));
\ No newline at end of file \ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.65235.3327.40977</string> </value> <value> <string>975.65475.50182.26112</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558970119.51</float> <float>1558984734.0</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Local Jio Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="jio_ojs_storage.js" type="text/javascript"></script>
<script src="jio_appcachestorage.js"></script>
<!-- custom script -->
<script src="gadget_ojs_local_jio.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<!-- renderjs --> <!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script> <script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="jio_appcachestorage.js"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_erp5_page_ojs_controller.js" type="text/javascript"></script> <script src="gadget_erp5_page_ojs_controller.js" type="text/javascript"></script>
......
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.28762.23822.37188</string> </value> <value> <string>975.50798.33418.15411</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1552954277.64</float> <float>1558979314.08</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -385,7 +385,7 @@ ...@@ -385,7 +385,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_jio_gadget_url</string> </key> <key> <string>configuration_jio_gadget_url</string> </key>
<value> <string>gadget_ojs_jio.html</string> </value> <value> <string>gadget_ojs_local_jio.html</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_manifest_url</string> </key> <key> <string>configuration_manifest_url</string> </key>
...@@ -680,7 +680,7 @@ ...@@ -680,7 +680,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.50798.33418.15411</string> </value> <value> <string>975.65245.13101.57361</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -698,7 +698,7 @@ ...@@ -698,7 +698,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558970711.99</float> <float>1558984800.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -385,7 +385,7 @@ ...@@ -385,7 +385,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_jio_gadget_url</string> </key> <key> <string>configuration_jio_gadget_url</string> </key>
<value> <string>gadget_ojs_jio.html</string> </value> <value> <string>gadget_ojs_local_jio.html</string> </value>
</item> </item>
<item> <item>
<key> <string>configuration_manifest_url</string> </key> <key> <string>configuration_manifest_url</string> </key>
...@@ -680,7 +680,7 @@ ...@@ -680,7 +680,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.59928.32228.31914</string> </value> <value> <string>975.65245.14433.33911</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -698,7 +698,7 @@ ...@@ -698,7 +698,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558970713.21</float> <float>1558984804.96</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