Commit a2aaf6a1 authored by Romain Courteaud's avatar Romain Courteaud

[HARDCODED] [officejs_olapy_demo] Demo of an offline XMLA server usage

Thanks to Vincent Bechu for his work on this topic.
parent e183a1e7
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_web_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_web_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>web_view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>0.9</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Web View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:object is not None and object.isWebMode() and not object.isEditableMode()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
.main-content > div {
width: 50vw;
height: 100vh;
}
.main-content iframe {
width: 50vw;
height: 98vh;
}
.main-content {
display: flex;
}
button {
padding: 10px 50px;
background-color: coral;
color: white;
border-radius: 5px;
}
button:hover {
background-color: #ff7f50cf;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="gadget_erp5_nojqm.css">
<link rel="stylesheet" type="text/css" href="gadget_onlyoffice_iodide.css">
<title>Onlyoffice Iodide Gadget</title>
<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="gadget_onlyoffice_iodide.js"></script>
</head>
<body>
<div class="main-content">
<div data-gadget-url="onlyoffice.gadget.html"
data-gadget-scope="onlyoffice"
data-gadget-sandbox="iframe"></div>
<div data-gadget-url="gadget_notebook.html"
data-gadget-scope="iodide"
data-gadget-sandbox="iframe"></div>
</div>
</body>
</html>
/*jslint indent: 2, unparam: true*/
/*global rJS, window, RSVP, jIO, Promise, console, DOMParser */
(function (rJS, window, RSVP, jIO, Promise) {
"use strict";
var SW = "gadget_onlyoffice_iodide_sw.js";
function makeRequestOnIodide(gadget, xml) {
return gadget.getDeclaredGadget('iodide')
.push(function (iodide) {
return iodide.evalCode(
'callFunction(' +
JSON.stringify({
fun: "requestOlapy",
argument_list: [xml]
}) +
')'
);
})
.push(function (result) {
// console.log('eval result', result);
return result;
}, function (error) {
console.warn('eval error', error);
throw error;
});
}
function waitForServiceWorkerActive(gadget, registration) {
var serviceWorker;
if (registration.installing) {
serviceWorker = registration.installing;
} else if (registration.waiting) {
serviceWorker = registration.waiting;
} else if (registration.active) {
serviceWorker = registration.active;
}
if (serviceWorker.state !== "activated") {
return RSVP.Promise(function (resolve, reject) {
serviceWorker.addEventListener('statechange', function (e) {
if (e.target.state === "activated") {
resolve();
}
});
RSVP.delay(500).then(function () {
reject(new Error("Timeout service worker install"));
});
});
}
}
rJS(window)
.ready(function (gadget) {
return new RSVP.Queue()
.push(function () {
return window.navigator.serviceWorker.register(SW);
})
.push(function (registration) {
window.navigator.serviceWorker.addEventListener('message', function (event) {
return makeRequestOnIodide(gadget, event.data)
.push(function (result) {
event.ports[0].postMessage(result);
}, function (error) {
event.ports[0].postMessage(error);
});
});
return waitForServiceWorkerActive(gadget, registration);
});
})
.allowPublicAcquisition('notifyChange', function (options) {
window.console.warn(options);
})
.allowPublicAcquisition('notifyInvalid', function (options) {
window.console.error(options);
})
.allowPublicAcquisition('notifyValid', function (options) {
window.console.log(options);
})
.allowPublicAcquisition('submitContent', function () {
window.console.warn(arguments);
})
.allowPublicAcquisition('getSetting', function (param) {
if (param[0] === 'portal_type') {
return 'Spreadsheet';
}
throw new Error("get Setting undefined for : " + param[0]);
})
.ready(function (gadget) {
return gadget.render();
})
.declareMethod("render", function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('iodide'),
jIO.util.ajax({
url: "olapy_notebook.jsmd"
}),
gadget.getDeclaredGadget('onlyoffice'),
jIO.util.ajax({
url: "onlyoffice_iodide_test_2.xlsy",
dataType: "blob"
})
]);
})
.push(function (result) {
console.log(result);
return result[0].render({
key: 'script',
value: result[1].target.response
})
.push(function () {
return jIO.util.readBlobAsDataURL(result[3].target.response);
})
.push(function (event) {
return result[2].render({
key: 'content',
value: event.target.result
});
});
});
});
}(rJS, window, RSVP, jIO, Promise));
/*jslint indent: 2*/
/*global self, Response, MessageChannel, console */
var global = self, window = self;
(function (self, Response, Promise, MessageChannel) {
"use strict";
self.importScripts('rsvp.js');
// http://craig-russell.co.uk/2016/01/29/service-worker-messaging.html#.XC8oy82JK3A
function send_message_to_client(client, msg) {
return new Promise(function (resolve, reject) {
var msg_chan = new MessageChannel();
msg_chan.port1.onmessage = function (event) {
if (event.data.error) {
reject(event.data.error);
} else {
resolve(event.data);
}
};
msg_chan.port1.onmessageerror = reject;
client.postMessage(msg, [msg_chan.port2]);
});
}
function getMainClient() {
if (self.main_client !== undefined) {
return self.main_client;
}
return self.clients.matchAll()
.then(function (client_list) {
var i;
for (i = 0; i < client_list.length; i += 1) {
if (client_list[i].url === self.registration.scope) {
self.main_client = client_list[i];
return self.main_client;
}
}
});
}
self.addEventListener('install', function (event) {
event.waitUntil(self.skipWaiting());
});
self.addEventListener('activate', function (event) {
event.waitUntil(self.clients.claim());
});
console.warn("I m the SW");
self.addEventListener("fetch", function (event) {
var relative_url = event.request.url.split("#")[0]
.replace(self.registration.scope, "");
if (relative_url === "local_iodide") {
event.respondWith(
new self.RSVP.Queue()
.push(function () {
return self.RSVP.all([
event.request.text(),
getMainClient()
]);
})
.push(function (result) {
return send_message_to_client(result[1], result[0]);
})
.push(function (result) {
return new Response(result, {headers: {'Content-Type': 'text/xml'}});
}, function (error) {
return new Response(error, {status: "500"});
})
);
} else {
return;
}
});
}(self, Response, Promise, MessageChannel));
\ No newline at end of file
erp5_officejs_ooffice
\ No newline at end of file
Provide a demo using olapy inside notebook with spreadsheet
\ No newline at end of file
Vincent Bechu
\ No newline at end of file
Notebook | web_view
\ No newline at end of file
web_page_module/gadget_onlyoffice_iodide*
web_site_module/onlyoffice_iodide
web_site_module/onlyoffice_iodide/**
document_module/onlyoffice_iodide*
notebook_module/olapy_notebook
\ No newline at end of file
web_page_module/gadget_onlyoffice_iodide*
web_site_module/onlyoffice_iodide
web_site_module/onlyoffice_iodide/**
document_module/onlyoffice_iodide*
notebook_module/olapy_notebook
\ No newline at end of file
document_module/onlyoffice_iodide*
notebook_module/olapy_notebook
web_page_module/gadget_onlyoffice_iodide*
web_site_module/onlyoffice_iodide
web_site_module/onlyoffice_iodide/**
\ No newline at end of file
officejs_olapy_demo
\ 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