Commit 21b239d9 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: OnlyOffice support binary replication of document files

thx  @cedric.leninivin
parent cbaf6487
......@@ -23,8 +23,8 @@
regexp.exec(auth_page)[1]
).expand({
came_from: window.location.href,
cors_origin: window.location.origin,
});
cors_origin: window.location.origin
});
}
}
if (gadget.state_parameter_dict.jio_storage_name === "DAV") {
......@@ -35,8 +35,8 @@
regexp.exec(auth_page)[1]
).expand({
back_url: window.location.href,
origin: window.location.origin,
});
origin: window.location.origin
});
}
}
if (site) {
......@@ -87,7 +87,7 @@
return wrapJioCall(this, 'remove', arguments);
})
.declareMethod('getAttachment', function () {
return wrapJioCall(this, 'gettAttachment', arguments);
return wrapJioCall(this, 'getAttachment', arguments);
})
.declareMethod('putAttachment', function () {
return wrapJioCall(this, 'putAttachment', arguments);
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>cedric.le.ninivin</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.59977.1025.50722</string> </value>
<value> <string>955.56950.51765.65211</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1458319358.64</float>
<float>1481385049.86</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals window, rJS, Handlebars, RSVP, loopEventListener, console, document*/
/*globals window, rJS, Handlebars, RSVP, loopEventListener, console, document, jIO*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, document, RSVP, rJS, Handlebars, loopEventListener) {
(function (window, document, RSVP, rJS, Handlebars, loopEventListener, jIO) {
"use strict";
function this_func_link(name) {
......@@ -26,8 +26,11 @@
.push(function (text_content_gadget) {
return text_content_gadget.getContent();
})
.push(function (data) {
doc.data = data.text_content;
.push(function(datauri) {
return gadget.jio_putAttachment(gadget.options.jio_key, 'data',
jIO.util.dataURItoBlob(datauri.text_content));
})
.push(function () {
return gadget.jio_put(gadget.options.jio_key, doc);
});
}
......@@ -107,6 +110,8 @@
.allowPublicAcquisition("getSetting", this_func_link("getSetting"))
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.allowPublicAcquisition('setFillStyle', function () {
return setFillStyle(this);
......@@ -139,9 +144,31 @@
var gadget = this;
gadget.options = options;
return gadget.jio_get(options.jio_key)
.push(function (doc) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.jio_get(options.jio_key),
gadget.jio_getAttachment(options.jio_key, "data")
.then(undefined, function (error) {
if (error.status_code === 404) {
return new Blob();
}
throw error;
})
]);
})
.push(function (result) {
return jIO.util.readBlobAsDataURL(result[1])
.then(function (evt) {
result[1] = evt.target.result;
return result;
});
})
.push(function (list) {
var doc = list[0],
data = list[1];
gadget.options.doc = doc;
gadget.options.data = data;
gadget.options.doc.title = gadget.options.doc.title || "";
return new RSVP.Queue()
.push(function () {
......@@ -194,7 +221,7 @@
return text_content_gadget.render({
//"jio_key": gadget.options.jio_key
"key": 'text_content',
"value": gadget.options.doc.data
"value": gadget.options.data
});
})
.push(function () {
......@@ -227,4 +254,4 @@
});
});
}(window, document, RSVP, rJS, Handlebars, loopEventListener));
\ No newline at end of file
}(window, document, RSVP, rJS, Handlebars, loopEventListener, jIO));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.11939.4774.12987</string> </value>
<value> <string>955.57136.52198.33194</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1478773249.86</float>
<float>1481396629.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,6 +16,7 @@
})
.declareAcquiredMethod("post", "jio_post")
.declareAcquiredMethod("put", "jio_put")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('getSetting', 'getSetting')
......@@ -28,12 +29,14 @@
return RSVP.all([
gadget.getSetting("portal_type"),
gadget.getSetting("document_title"),
gadget.getSetting("parent_relative_url")
gadget.getSetting("parent_relative_url"),
gadget.getSetting("filename_extension")
]);
}).push(function (answer_list) {
gadget.props.portal_type = answer_list[0];
gadget.props.document_title = answer_list[1];
gadget.props.parent_relative_url = answer_list[2];
gadget.props.filename_extension = answer_list[3];
return gadget.updateHeader({
title: "New " + gadget.props.document_title
});
......@@ -51,12 +54,18 @@
return gadget.props.deferred.promise;
})
.push(function () {
return gadget.post({});
})
.push(function (data) {
var doc = {
// XXX Hardcoded
parent_relative_url: gadget.props.parent_relative_url,
portal_type: gadget.props.portal_type
};
return gadget.post(doc);
if (gadget.props.filename_extension) {
doc.filename = data + '.' + gadget.props.filename_extension;
}
return gadget.put(data, doc).then(function () {return data; });
})
.push(function (data) {
return gadget.redirect({
......
......@@ -255,7 +255,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.28187.42881.35293</string> </value>
<value> <string>955.60105.11993.14284</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1464189839.22</float>
<float>1481576360.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -8,48 +8,53 @@
var erp5_url = gadget.props.element.querySelector("input[name='erp5_url']").value;
return gadget.getSetting("portal_type")
.push(function (portal_type) {
var old_date = new Date(),
configuration = {};
// We are looking for documents modified in the past 3 month
old_date = new Date(old_date.getFullYear(), old_date.getMonth(), old_date.getDate() - 15);
configuration = {
type: "replicate",
// XXX This drop the signature lists...
query: {
query: 'portal_type:"' + portal_type
// XX Synchonizing the whole module is too much, here is a way to start quietly
// Supsended until modification_date is handled for synchronization
+ '" AND modification_date:>="'
+ old_date.toISOString() + '" ',
limit: [0, 1234567890]
},
use_remote_post: true,
conflict_handling: 1,
check_local_modification: true,
check_local_creation: true,
check_local_deletion: false,
check_remote_modification: true,
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
return gadget.setSetting(
'jio_storage_description',
{
type: "replicate",
use_remote_post: true,
conflict_handling: 1,
check_local_modification: true,
check_local_creation: true,
check_local_deletion: false,
check_remote_modification: true,
check_remote_creation: true,
check_remote_deletion: true,
query: {
query: 'portal_type:"' + portal_type + '" '
},
attachment_list: ["data"],
local_sub_storage: {
type: "query",
sub_storage: {
type: "indexeddb",
database: "officejs-erp5"
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "officejs-erp5"
}
}
},
remote_sub_storage: {
type: "mapping",
attachment_mapping_dict: {
"data": {
"get": {
"uri_template": (new URI("hateoas"))
.absoluteTo(erp5_url)
.toString() + "/{+id}?format="
}
}
},
sub_storage: {
type: "erp5",
url: (new URI("hateoas"))
.absoluteTo(erp5_url)
.toString(),
default_view_reference: "jio_view"
}
}
},
remote_sub_storage: {
type: "erp5",
url: (new URI("hateoas"))
.absoluteTo(erp5_url)
.toString(),
default_view_reference: "jio_view"
}
};
return gadget.setSetting('jio_storage_description', configuration);
);
})
.push(function () {
return gadget.setSetting('jio_storage_name', "ERP5");
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.38591.30253.42973</string> </value>
<value> <string>955.59503.50809.11605</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1476438691.35</float>
<float>1481538235.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -18,6 +18,7 @@
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">document_module</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Presentation</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Presentations</script>
<script data-renderjs-configuration="filename_extension" type="text/x-renderjs-configuration">ppty</script>
<script data-renderjs-configuration="global_setting_gadget_url" type="text/x-renderjs-configuration">https://setting-gadget.app.officejs.com</script>
</body>
</html>
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.30719.44077.50978</string> </value>
<value> <string>955.60232.36630.13772</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1472140672.24</float>
<float>1481581966.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -18,6 +18,7 @@
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">document_module</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Spreadsheet</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Spreadsheets</script>
<script data-renderjs-configuration="filename_extension" type="text/x-renderjs-configuration">xlsy</script>
<script data-renderjs-configuration="global_setting_gadget_url" type="text/x-renderjs-configuration">https://setting-gadget.app.officejs.com</script>
</body>
</html>
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.30717.14538.34184</string> </value>
<value> <string>955.56775.45620.18517</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1472140702.02</float>
<float>1481582034.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -18,6 +18,7 @@
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">document_module</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Text</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Text documents</script>
<script data-renderjs-configuration="filename_extension" type="text/x-renderjs-configuration">docy</script>
<script data-renderjs-configuration="global_setting_gadget_url" type="text/x-renderjs-configuration">https://setting-gadget.app.officejs.com</script>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.30720.20594.2577</string> </value>
<value> <string>955.56775.45620.18517</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1472140729.45</float>
<float>1481574602.35</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -289,6 +289,16 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_x_frame_options</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -333,7 +343,7 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data:</string> </value>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data: https://setting-gadget.app.officejs.com</string> </value>
</item>
<item>
<key> <string>configuration_default_view_action_reference</string> </key>
......@@ -381,6 +391,10 @@
<none/>
</value>
</item>
<item>
<key> <string>configuration_x_frame_options</string> </key>
<value> <string>SAMEORIGIN</string> </value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>WebSection_renderDefaultPageAsGadget</string> </value>
......@@ -616,7 +630,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.26865.16887.45294</string> </value>
<value> <string>955.56775.45620.18517</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -634,7 +648,7 @@
</tuple>
<state>
<tuple>
<float>1471900178.78</float>
<float>1481584147.72</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -289,6 +289,16 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_x_frame_options</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -333,7 +343,7 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data:</string> </value>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data: https://setting-gadget.app.officejs.com</string> </value>
</item>
<item>
<key> <string>configuration_default_view_action_reference</string> </key>
......@@ -381,6 +391,10 @@
<none/>
</value>
</item>
<item>
<key> <string>configuration_x_frame_options</string> </key>
<value> <string>SAMEORIGIN</string> </value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>WebSection_renderDefaultPageAsGadget</string> </value>
......@@ -616,7 +630,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>952.23434.60810.22272</string> </value>
<value> <string>955.56775.45620.18517</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -634,7 +648,7 @@
</tuple>
<state>
<tuple>
<float>1467750427.13</float>
<float>1481384398.06</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -289,6 +289,16 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_x_frame_options</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -333,7 +343,7 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data:</string> </value>
<value> <string>img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\' https://netdna.bootstrapcdn.com data:; font-src \'self\' https://netdna.bootstrapcdn.com data:; frame-src \'self\' data: https://setting-gadget.app.officejs.com</string> </value>
</item>
<item>
<key> <string>configuration_default_view_action_reference</string> </key>
......@@ -381,6 +391,10 @@
<none/>
</value>
</item>
<item>
<key> <string>configuration_x_frame_options</string> </key>
<value> <string>SAMEORIGIN</string> </value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>WebSection_renderDefaultPageAsGadget</string> </value>
......@@ -616,7 +630,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>953.26865.33188.30890</string> </value>
<value> <string>955.56775.45620.18517</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -634,7 +648,7 @@
</tuple>
<state>
<tuple>
<float>1471900305.63</float>
<float>1481386184.71</float>
<string>UTC</string>
</tuple>
</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