Commit a4c398b6 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs_connector: OnlyOfficeGadget disable attachment synchronization

parent 48a84fbf
/*globals window, rJS, Handlebars, RSVP, loopEventListener, console, document, jIO*/
/*globals window, rJS, Handlebars, RSVP, loopEventListener, console, document*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, document, RSVP, rJS, Handlebars, loopEventListener, jIO) {
(function (window, document, RSVP, rJS, Handlebars, loopEventListener) {
"use strict";
function this_func_link(name) {
......@@ -26,11 +26,8 @@
.push(function (text_content_gadget) {
return text_content_gadget.getContent();
})
.push(function(datauri) {
return gadget.jio_putAttachment(gadget.options.jio_key, 'data',
jIO.util.dataURItoBlob(datauri.text_content));
})
.push(function () {
.push(function (data) {
doc.data = data.text_content;
return gadget.jio_put(gadget.options.jio_key, doc);
});
}
......@@ -110,8 +107,6 @@
.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);
......@@ -144,31 +139,9 @@
var gadget = this;
gadget.options = options;
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];
return gadget.jio_get(options.jio_key)
.push(function (doc) {
gadget.options.doc = doc;
gadget.options.data = data;
gadget.options.doc.title = gadget.options.doc.title || "";
return new RSVP.Queue()
.push(function () {
......@@ -221,7 +194,7 @@
return text_content_gadget.render({
//"jio_key": gadget.options.jio_key
"key": 'text_content',
"value": gadget.options.data
"value": gadget.options.doc.data
});
})
.push(function () {
......@@ -254,4 +227,4 @@
});
});
}(window, document, RSVP, rJS, Handlebars, loopEventListener, jIO));
\ No newline at end of file
}(window, document, RSVP, rJS, Handlebars, loopEventListener));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.57136.52198.33194</string> </value>
<value> <string>955.61083.47409.31300</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1481396629.42</float>
<float>1482250814.1</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -8,53 +8,48 @@
var erp5_url = gadget.props.element.querySelector("input[name='erp5_url']").value;
return gadget.getSetting("portal_type")
.push(function (portal_type) {
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",
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",
sub_storage: {
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"
type: "indexeddb",
database: "officejs-erp5"
}
}
},
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>955.59503.50809.11605</string> </value>
<value> <string>955.61083.47409.31300</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1481538235.2</float>
<float>1482250502.47</float>
<string>UTC</string>
</tuple>
</state>
......
from cStringIO import StringIO
value=value.split(",")[1]
file_name = context.getFilename()
# save document only if format is OnlyOffice
if file_name and file_name.split('.')[-1] in ('docy', 'xlsy', 'ppty'):
context.setData(StringIO(value.decode('base64')))
return True
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>value, request</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>OOoDocument_setDataAsDataUrlValidator</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -83,6 +83,7 @@ ooffice_view</string> </value>
<string>your_modification_date</string>
<string>my_content_type</string>
<string>my_filename</string>
<string>your_data</string>
</list>
</value>
</item>
......
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