From 637e205097dba8399b8ceaae673f623da68c8299 Mon Sep 17 00:00:00 2001 From: Hardik Juneja Date: Wed, 24 Aug 2016 14:58:55 +0000 Subject: [PATCH 1/4] Document Viewer using webrtc module --- .../gadget_officejs_header_js.js | 10 +- .../gadget_officejs_header_js.xml | 6 +- ...adget_officejs_jio_web_page_view_html.html | 24 +- ...gadget_officejs_jio_web_page_view_html.xml | 6 +- .../gadget_officejs_jio_web_page_view_js.js | 57 ++- .../gadget_officejs_jio_web_page_view_js.xml | 4 +- .../gadget_officejs_page_document_list_js.xml | 10 +- .../gadget_officejs_page_share_text_html.html | 17 + .../gadget_officejs_page_share_text_html.xml | 324 ++++++++++++++++ .../gadget_officejs_page_share_text_js.js | 260 +++++++++++++ .../gadget_officejs_page_share_text_js.xml | 332 ++++++++++++++++ ...dget_officejs_page_webrtc_viewer_html.html | 36 ++ ...adget_officejs_page_webrtc_viewer_html.xml | 361 ++++++++++++++++++ .../gadget_officejs_page_webrtc_viewer_js.js | 133 +++++++ .../gadget_officejs_page_webrtc_viewer_js.xml | 357 +++++++++++++++++ bt5/erp5_officejs/bt/dependency_list | 3 +- 16 files changed, 1911 insertions(+), 29 deletions(-) create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.html create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.xml create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.js create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.xml create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.html create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.xml create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.js create mode 100644 bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.xml diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.js index 6a0afc698d1..e5db02bdbf6 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.js @@ -103,13 +103,16 @@ this.stats.modified = true; return this.render(this.stats.options); } - }) + }) +*/ + .declareMethod('notifySubmitting', function () { if (this.stats.submitted) { this.stats.submitted = false; return this.render(this.stats.options); } }) + .declareMethod('notifySubmitted', function () { if (!this.stats.submitted) { this.stats.submitted = true; @@ -118,7 +121,7 @@ return this.render(this.stats.options); } }) -*/ + .declareMethod('render', function (options) { var gadget = this, possible_left_link_list = [ @@ -138,7 +141,8 @@ ], possible_right_button_list = [ ['save_action', 'Save', 'check', 'submit'], - ['submit_action', 'Proceed', 'check', 'submit'] + ['submit_action', 'Proceed', 'check', 'submit'], + ['refresh_action', 'Refresh', 'check', 'submit'] ], i, klass, diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.xml index 75bad9191c6..b435534bad8 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_header_js.xml @@ -210,7 +210,7 @@ actor - cedric.le.ninivin + zope comment @@ -224,7 +224,7 @@ serial - 945.58607.14824.6775 + 953.35411.21474.17817 state @@ -242,7 +242,7 @@ - 1442857960.12 + 1472401645.81 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html index e733b8489eb..14d81ebcf96 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html @@ -14,16 +14,21 @@
-
-
- +
+
- +
+ + +
+ +
+
-     
+
         Extra Properties
@@ -41,14 +46,15 @@
-
- - -
+
+ + +
+
diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.xml index 88fe7fedcf3..f20d8cc200f 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.xml @@ -218,7 +218,7 @@ actor - cedric.le.ninivin + zope comment @@ -232,7 +232,7 @@ serial - 945.58608.59350.33075 + 953.27768.8271.35532 state @@ -250,7 +250,7 @@ - 1442858061.15 + 1471964256.18 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js index 2a4919f95b4..ee1f0fba64d 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js @@ -100,7 +100,7 @@ return gadget.translateHtml(template(options.doc)); }) .push(function (html) { - gadget.props.element.innerHTML = html; + gadget.props.element.innerHTML += html; return gadget.updateHeader({ title: options.doc.title + " | Web Page", save_action: true @@ -110,6 +110,55 @@ return gadget.props.deferred.resolve(); }); }) + + .declareMethod("shareDoc", function () { + var gadget = this; + if(window.location.hash) { + var index = window.location.hash.indexOf('room='); + if (index === -1) { + var S4 = function() { + return (((1+Math.random())*0x10000)|0).toString(16).substring(1); + }; + var room = (S4()+S4()+"-"+S4()+S4()); + return new RSVP.Queue() + .push(function () { + return gadget.declareGadget( + "gadget_officejs_page_share_text.html", + { + scope: "share_text_via_webrtc", + element: gadget.props.element.querySelector(".webrtc-gadget") + } + ); + }) + .push(function(g){ + var config = { + type: "query", + sub_storage: { + type: "uuid", + sub_storage: { + //type: "indexeddb", + //"database": "handshake" + "type": "dav", + "url": "https://softinst67513.host.vifib.net/share/", + "basic_login": btoa("admin:vowhkida") + } + } + } + + var sharelink = window.location.origin + window.location.pathname + '#page=webrtc_viewer&room='+room+'&config='+encodeURIComponent(JSON.stringify(config)); + gadget.props.element.querySelector('#sharelink').value = sharelink; + gadget.props.element.querySelector('#sharelink').style.display = 'block'; + gadget.props.element.querySelector('#generatelink').remove(); + + if(config) { + return g.initiate(room, gadget, config); + } else { + return g.initiate(room, gadget); + } + }) + } + } + }) ///////////////////////////////////////// // Render text content gadget @@ -165,7 +214,11 @@ 'submit', true, function (event) { - return saveContent(gadget, event); + if (document.activeElement.name === "generatelink") { + return gadget.shareDoc(); + } else { + return saveContent(gadget, event); + } } ); }); diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml index 4711eef4f97..2b830c7b599 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml @@ -228,7 +228,7 @@ serial - 946.59099.34897.19985 + 953.38231.58110.12526 state @@ -246,7 +246,7 @@ - 1446740911.15 + 1472570624.98 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_document_list_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_document_list_js.xml index 38b1358212a..87d6a045ee6 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_document_list_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_document_list_js.xml @@ -66,9 +66,7 @@ categories - - contributor/person_module/1 - + @@ -249,7 +247,7 @@ actor - supercedriclen + zope comment @@ -263,7 +261,7 @@ serial - 951.28163.54980.41130 + 953.20991.57503.32870 state @@ -281,7 +279,7 @@ - 1464188897.32 + 1471536011.33 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.html new file mode 100644 index 00000000000..1c09d733401 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.html @@ -0,0 +1,17 @@ + + + + + + + Share jIO + + + + + + + +
+ + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.xml new file mode 100644 index 00000000000..f839ad963be --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_html.xml @@ -0,0 +1,324 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + content_type + text/html + + + default_reference + gadget_officejs_page_share_text.html + + + description + + + + + + id + gadget_officejs_page_share_text_html + + + language + en + + + portal_type + Web Page + + + short_title + + + + + + title + Document viewer using webrtc + + + version + 001 + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1471521952.46 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 953.38184.65477.60859 + + + state + current + + + time + + + + + + + + + + + 1472631749.27 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1471513520.74 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.js new file mode 100644 index 00000000000..d525aaef920 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.js @@ -0,0 +1,260 @@ +/*global window, rJS, document, RSVP, console, DOMException */ +/*jslint indent: 2, maxerr: 3 */ +(function (window, rJS, document, RSVP, console, DOMException) { + "use strict"; + + var timeout = 600000; + + function S4() { + return ('0000' + Math.floor( + Math.random() * 0x10000 /* 65536 */ + ).toString(16)).slice(-4); + } + + function UUID() { + return S4() + S4() + "-" + + S4() + "-" + + S4() + "-" + + S4() + "-" + + S4() + S4() + S4(); + } + + function declareSubGadget(gadget, url) { + var container_element = gadget.state_parameter_dict.element.querySelector("." + url.split(".")[0]), + element = document.createElement("div"); + + container_element.innerHTML = ""; + container_element.appendChild(element); + return gadget.declareGadget(url, { + element: element, + scope: url, + sandbox: "public" + }); + } + + function dropSubGadget(gadget, scope) { + return gadget.getDeclaredGadget(scope) + .push(function (result) { + return result.getElement(); + }) + .push(function (element) { + if (element.parentElement) { + element.parentElement.removeChild(element); + } + delete gadget.state_parameter_dict.scope_ip[scope]; + return gadget.dropGadget(scope); + }); + } + + function getWebRTCScopeList(gadget) { + var result_list = [], + element_list = gadget.state_parameter_dict.element.querySelector(".gadget_webrtc_jio_bridge") + .childNodes, + i; + for (i = 0; i < element_list.length; i += 1) { + result_list.push(element_list[i].getAttribute("data-gadget-scope")); + } + return result_list; + } + + function updateInfo(gadget) { + var scope_list = getWebRTCScopeList(gadget), + i, + result = ""; + for (i = 0; i < scope_list.length; i += 1) { + result += gadget.state_parameter_dict.scope_ip[scope_list[i]] + "\n"; + } + console.log(result); + console.log("peer count", i); + } + + function sendWebRTC(gadget, rtc_gadget, scope, message) { + return rtc_gadget.send(message) + .push(undefined, function (error) { + if ((error instanceof DOMException) && (error.name === 'InvalidStateError')) { + return dropSubGadget(gadget, scope) + .push(function () { + return updateInfo(gadget); + }, function (error) { + console.log("-- Can not drop remote subgadget " + scope); + console.log(error); + return; + }); + } + throw error; + }); + } + + rJS(window) + + .ready(function (gadget) { + // Initialize the gadget local parameters + gadget.state_parameter_dict = { + counter: 0, + connecting: false, + scope_ip: {} + }; + return gadget.getElement() + .push(function (element) { + gadget.state_parameter_dict.element = element; + }) + .push(function () { + return updateInfo(gadget); + }); + }) + .allowPublicAcquisition('notifyDataChannelClosed', function (argument_list, scope) { + /*jslint unparam:true*/ + var gadget = this; + return dropSubGadget(this, scope) + .push(function () { + return updateInfo(gadget); + }); + }) + + .declareMethod('connect', function(room_id, offer, parent_scope, config) { + var gadget = this, + scope, + rtc_gadget; + + return new RSVP.Queue() + .push(function(response) { + gadget.state_parameter_dict.connecting = true; + gadget.state_parameter_dict.counter += 1; + + var new_element = document.createElement("div"); + gadget.state_parameter_dict.element.querySelector(".gadget_webrtc_jio_bridge").appendChild(new_element); + scope = "webrtc" + gadget.state_parameter_dict.counter; + + return gadget.declareGadget("gadget_webrtc_jio_bridge.html", { + scope: scope, + element: new_element + }) + .push(function(gg){ + rtc_gadget = gg; + return rtc_gadget.register(room_id, 'master', config); + }) + .push(function(){ + // https://github.com/diafygi/webrtc-ips + var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/, + ip_list = [], + ip_dict = {}, + ip_addr, + line_list = JSON.parse(offer.data).sdp.split('\n'), + i; + + for (i = 0; i < line_list.length; i += 1) { + if (line_list[i].indexOf('a=candidate:') === 0) { + ip_addr = ip_regex.exec(line_list[i])[1]; + if (!ip_addr.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/)) { + // Hide ipv6 + if (!ip_dict[ip_addr]) { + ip_list.push(ip_addr); + ip_dict[ip_addr] = true; + } + } + } + } + gadget.state_parameter_dict.scope_ip[scope] = ip_list; + return rtc_gadget.connect({ + roomid: room_id, + peerid: 'master', + to: offer.from, + offer: JSON.stringify(offer.data) + }); + }) + .push(function () { + return RSVP.any([ + RSVP.Queue() + .push(function () { + return RSVP.delay(20000); + }) + .push(function () { + console.info('-- webrtc client disappears...'); + return dropSubGadget(gadget, scope); + }), + rtc_gadget.waitForConnection() + ]); + }) + .push(function () { + gadget.state_parameter_dict.connecting = false; + var ckeditor = window.frames[0].CKEDITOR; + + var data = {'content': ckeditor.instances.editor1.getData()}; + + // Get all the extra properties and send it with data + var extraprops = parent_scope.props.element.querySelector('.ui-collapsible').outerHTML; + data['extra_props'] = extraprops; + + // Get title + var title = parent_scope.props.element.querySelector('.ui-field-contain').childNodes[3].firstChild.value; + data['title'] = title; + + rtc_gadget.send(JSON.stringify(data)); + ckeditor.instances.editor1.on('key',function(e){ + rtc_gadget.send(JSON.stringify({'content':ckeditor.instances.editor1.getData()})); + }); + return updateInfo(gadget); + }); + }) + }) + .declareMethod('initiate', function (roomid, scope, config) { + var gadget = this, + rtc_gadget, + blob; + + return gadget.declareGadget("gadget_webrtc_jio_bridge.html") + .push(function (rg) { + // register peer + rtc_gadget = rg; + roomid = "/"+roomid+"/"; + return rtc_gadget.register(roomid, 'master', config); + }) + .push(function (r) { + var peerid = 'master'; + return rtc_gadget.wait_until_available(roomid, peerid+'_', function (offers) { + var connections = []; + for (var offer in offers) { + connections.push(gadget.connect(roomid, JSON.parse(offers[offer].target.result), scope, config)); + } + return RSVP.all(connections); + }); + }); + }) + .declareMethod('slaveInitiate', function(roomid, g, config) { + var context = this, + rtc_gadget, gadget; + + roomid = "/"+roomid+"/"; + + return g.notifySubmitting() + .push(function() { + return declareSubGadget(context, "gadget_webrtc_jio_bridge.html") + }) + .push(function (gadget) { + context.state_parameter_dict.uuid = UUID(); + context.state_parameter_dict.message_count = 0; + context.state_parameter_dict.message_dict = {}; + rtc_gadget = gadget; + + // register peer + if (config) { + config = JSON.parse(config) + } + return rtc_gadget.register(roomid, context.state_parameter_dict.uuid, config); + }) + .push(function(peers){ + var options = { roomid: roomid, + peerid: context.state_parameter_dict.uuid, + initiator: true, + to: 'master' } + return rtc_gadget.connect(options); + }) + .push(null, function(error){ + return g.notifySubmitted() + .push(function () { + throw error; + }); + }); + }) + +}(window, rJS, document, RSVP, console, DOMException)); \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.xml new file mode 100644 index 00000000000..c8bdc68c3f8 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_text_js.xml @@ -0,0 +1,332 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + categories + + + + + + content_md5 + + + + + + contributors + + + + + + default_reference + gadget_officejs_page_share_text.js + + + description + + + + + + id + gadget_officejs_page_share_text_js + + + language + en + + + portal_type + Web Script + + + short_title + + + + + + title + Document viewer using webrtc + + + version + 001 + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1471522253.26 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 953.29508.22380.37649 + + + state + current + + + time + + + + + + + + + + + 1472047040.89 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1471513430.76 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.html new file mode 100644 index 00000000000..f897a167ac5 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.html @@ -0,0 +1,36 @@ + + + + + + + + OfficeJS Editor Remote Viewer + + + + + + + + + +
+
+ + +
+
+ + + +
+
+
+
+
+
+ + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.xml new file mode 100644 index 00000000000..b888ab49bec --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_html.xml @@ -0,0 +1,361 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + categories + + + + + + content_md5 + + + + + + content_type + text/html + + + creators + + + cedric.le.ninivin + + + + + default_reference + gadget_officejs_page_webrtc_viewer.html + + + description + + + + + + id + gadget_officejs_page_webrtc_viewer_html + + + language + + + + + + modification_date + + + + + + + + + + + 1455284352.14 + UTC + + + + + + + portal_type + Web Page + + + short_title + + + + + + title + OfficeJS Webrtc Viewer + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1471511311.48 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 953.35402.46528.58316 + + + state + current + + + time + + + + + + + + + + + 1472400667.43 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1471510212.65 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.js new file mode 100644 index 00000000000..7126c856974 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.js @@ -0,0 +1,133 @@ +/*globals window, RSVP, rJS*/ +/*jslint indent: 2, nomen: true, maxlen: 80*/ +(function (window, RSVP, rJS) { + "use strict"; + + function getMaxHeight(wrap_obj) { + var height; + if (wrap_obj) { + height = window.innerHeight - wrap_obj.offsetTop; + } else { + height = window.innerHeight; + } + if (height < 400) { + height = 400; + } + return height + "px"; + } + + function setFillStyle(gadget) { + var iframe = gadget.props.element.querySelector('iframe'), + height = getMaxHeight(iframe), + width = "100%"; + iframe.setAttribute( + 'style', + 'width: ' + width + '; border: 2px solid; height: ' + height + ); + return {height: height, width: width}; + } + + rJS(window) + .ready(function (g) { + g.props = {}; + return g.getElement() + .push(function (element) { + g.props.element = element; + g.props.deferred = RSVP.defer(); + g.props.content = ''; + }); + }) + + .declareAcquiredMethod("updateHeader", "updateHeader") + .declareAcquiredMethod("notifySubmitting", "notifySubmitting") + .declareAcquiredMethod("notifySubmitted", "notifySubmitted") + + .allowPublicAcquisition("notifyDataChannelMessage", function (argument_list, scope) { + var data = JSON.parse(argument_list[0]); + if (data.extra_props) { + this.props.element.querySelector("#extra").innerHTML = data.extra_props; + $('#extra').find('[data-role=collapsible]').collapsible({ enhanced: true }); + } + if (data.title) { + this.props.element.querySelector(".viewer-content").firstChild.contentDocument.body.innerHTML = data.content; + this.props.element.querySelector(".ui-field-contain").childNodes[3].firstChild.value = data.title; + this.props.title = data.title; + } + + this.props.content = data.content; + + }) + + .allowPublicAcquisition('triggerSubmit', function () { + return this.props.element.querySelector('button').click(); + }) + + .declareMethod('triggerSubmit', function () { + return this.props.element.querySelector('button').click(); + }) + + .declareMethod("render", function(options) { + var gadget = this; + gadget.props.options = options; + return new RSVP.Queue() + .push(function () { + return gadget.updateHeader({ + title: "Document Viewer", + refresh_action: true + }); + }); + }) + + .declareService(function () { + var gadget = this; + if(window.location.hash) { + var room = gadget.props.options["room"]; + return gadget.notifySubmitting() + .push(function() { + return gadget.getDeclaredGadget('share_text_via_webrtc') + }) + .push(function(g){ + if(gadget.props.options['config']) { + return g.slaveInitiate(room, gadget, gadget.props.options['config']); + } else { + return g.slaveInitiate(room, gadget) + .push(null, function(error){ + return gadget.notifySubmitted() + .push(function () { + throw error; + }); + }); + } + }) + .push(function(){ + return gadget.notifySubmitted(); + }); + } + }) + + .declareService(function() { + var gadget = this; + var iframe = document.createElement("iframe"); + gadget.props.element.querySelector(".viewer-content").appendChild(iframe); + return setFillStyle(gadget); + }) + + ///////////////////////////////////////// + // Form submit + ///////////////////////////////////////// + .declareService(function () { + var gadget = this; + + return new RSVP.Queue() + .push(function () { + return loopEventListener( + gadget.props.element.querySelector('form'), + 'submit', + true, + function (event) { + gadget.props.element.querySelector(".viewer-content").firstChild.contentDocument.body.innerHTML = gadget.props.content; + } + ); + }); + }); +}(window, RSVP, rJS)); \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.xml new file mode 100644 index 00000000000..83d15150f17 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_webrtc_viewer_js.xml @@ -0,0 +1,357 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + categories + + + + + + content_md5 + + + + + + creators + + + cedric.le.ninivin + + + + + default_reference + gadget_officejs_page_webrtc_viewer.js + + + description + + + + + + id + gadget_officejs_page_webrtc_viewer_js + + + language + + + + + + modification_date + + + + + + + + + + + 1455284352.18 + UTC + + + + + + + portal_type + Web Script + + + short_title + + + + + + title + OfficeJS Webrtc Viewer JS + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1471537049.31 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 953.38233.8749.16844 + + + state + current + + + time + + + + + + + + + + + 1472570633.51 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1471535759.72 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/bt/dependency_list b/bt5/erp5_officejs/bt/dependency_list index 674fe978494..86eaeef8bbd 100644 --- a/bt5/erp5_officejs/bt/dependency_list +++ b/bt5/erp5_officejs/bt/dependency_list @@ -1,2 +1,3 @@ erp5_web_renderjs_ui -erp5_web_ung_core \ No newline at end of file +erp5_web_ung_core +erp5_webrtc_gadget \ No newline at end of file -- 2.30.9 From f1caf11c0f7f884fe54d1671caea1647d91177c3 Mon Sep 17 00:00:00 2001 From: Hardik Juneja Date: Tue, 20 Sep 2016 09:05:48 +0000 Subject: [PATCH 2/4] gadget_officejs: Add support for websocket --- ...adget_officejs_jio_web_page_view_html.html | 17 +- ...gadget_officejs_jio_web_page_view_html.xml | 4 +- .../gadget_officejs_jio_web_page_view_js.js | 135 +++++----- .../gadget_officejs_jio_web_page_view_js.xml | 4 +- .../gadget_officejs_page_share_text_html.html | 4 +- .../gadget_officejs_page_share_text_html.xml | 4 +- .../gadget_officejs_page_share_text_js.js | 234 +++++++----------- .../gadget_officejs_page_share_text_js.xml | 4 +- ...t_officejs_page_share_webrtc_jio_html.html | 10 +- ...et_officejs_page_share_webrtc_jio_html.xml | 8 +- ...adget_officejs_page_share_webrtc_jio_js.js | 169 ++++++------- ...dget_officejs_page_share_webrtc_jio_js.xml | 8 +- ...adget_officejs_page_webrtc_viewer_html.xml | 4 +- .../gadget_officejs_page_webrtc_viewer_js.js | 2 +- .../gadget_officejs_page_webrtc_viewer_js.xml | 4 +- .../gadget_officejs_webrtc_jio_html.html | 6 +- .../gadget_officejs_webrtc_jio_html.xml | 8 +- .../gadget_officejs_webrtc_jio_js.js | 90 +++---- .../gadget_officejs_webrtc_jio_js.xml | 8 +- 19 files changed, 325 insertions(+), 398 deletions(-) diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html index 14d81ebcf96..e25e2406096 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_html.html @@ -11,19 +11,22 @@ + + + + + + + + + +
+
+

+   + Your Webrtc Page Share Choice +

+
+
+

Select a storage for Webrtc handshake

+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+ + + \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_html.xml new file mode 100644 index 00000000000..09a024a2c89 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_html.xml @@ -0,0 +1,324 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + content_type + text/html + + + default_reference + gadget_officejs_page_share_configurator.html + + + description + + + + + + id + gadget_officejs_page_share_configurator_html + + + language + en + + + portal_type + Web Page + + + short_title + + + + + + title + OfficeJS Webrtc Share Configurator Gadget + + + version + 001 + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474555161.04 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.17181.1723.6468 + + + state + current + + + time + + + + + + + + + + + 1475239502.36 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474554776.94 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js new file mode 100644 index 00000000000..27fb3c5b9d6 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js @@ -0,0 +1,137 @@ +/*global window, document, rJS, RSVP, URI, location, + loopEventListener*/ +/*jslint nomen: true, indent: 2, maxerr: 3*/ +(function (window, rJS, RSVP) { + "use strict"; + + function setERP5Configuration(gadget) { + return gadget.getSetting("portal_type") + .push(function (portal_type) { + var configuration = { + local_sub_storage: { + type: "query", + sub_storage: { + type: "uuid", + sub_storage: { + type: "indexeddb", + database: "officejs-erp5" + } + } + }, + remote_sub_storage: { + type: "erp5", + url: (new URI("hateoas")) + .absoluteTo(location.href) + .toString(), + default_view_reference: "jio_view" + } + }; + return gadget.setSetting('jio_storage_description', configuration); + }) + .push(function () { + return gadget.setSetting('jio_storage_name', "ERP5"); + }) + .push(function () { + return gadget.reload(); + }); + } + + function setWebsocketConfiguration(gadget) { + return gadget.redirect({page: 'share_websocket_configurator'}); + } + + function setDAVConfiguration(gadget) { + return gadget.redirect({page: 'share_dav_configurator'}); + } + + var gadget_klass = rJS(window); + + gadget_klass + .ready(function (g) { + g.props = {}; + return g.getElement() + .push(function (element) { + g.props.element = element; + g.props.deferred = RSVP.defer(); + }); + }) + .declareAcquiredMethod("updateHeader", "updateHeader") + .declareAcquiredMethod("translateHtml", "translateHtml") + .declareAcquiredMethod("redirect", "redirect") + .declareAcquiredMethod("reload", "reload") + .declareAcquiredMethod("setSetting", "setSetting") + .declareAcquiredMethod("getSetting", "getSetting") + .declareMethod("render", function () { + var gadget = this; + return gadget.updateHeader({ + title: "Webrtc Page Share Configuration" + }).push(function () { + return RSVP.all([ + gadget.getSetting('webrtc_share_name'), + gadget.getSetting('application_title') + ]); + }).push(function (setting_list) { + switch (setting_list[0]) { + case "ERP5": + gadget.props.element.querySelector("form.select-erp5-form button").classList.add("ui-btn-active"); + break; + case "DAV": + gadget.props.element.querySelector("form.select-dav-form button").classList.add("ui-btn-active"); + break; + case "WEBSOCKET": + gadget.props.element.querySelector("form.select-websocket-form button").classList.add("ui-btn-active"); + break; + default: + gadget.props.element.querySelector(".message h3").appendChild(document.createTextNode("Welcome in OfficeJS " + setting_list[1] + ". Please start by choosing an option.")); + gadget.props.element.querySelector(".message").setAttribute("style", ""); + gadget.props.element.querySelector(".document-access").setAttribute("style", "display: none;"); + break; + } + return; + }).push(function () { + return gadget.props.deferred.resolve(); + }); + }) + + ///////////////////////////////////////// + // Form submit + ///////////////////////////////////////// + .declareService(function () { + var gadget = this; + + return new RSVP.Queue() + .push(function () { + return gadget.props.deferred.promise; + }) + .push(function () { + return RSVP.all([ + loopEventListener( + gadget.props.element.querySelector('form.select-erp5-form'), + 'submit', + true, + function () { + return setERP5Configuration(gadget); + } + ), + loopEventListener( + gadget.props.element.querySelector('form.select-websocket-form'), + 'submit', + true, + function () { + return setWebsocketConfiguration(gadget); + } + ), + loopEventListener( + gadget.props.element.querySelector('form.select-dav-form'), + 'submit', + true, + function () { + return setDAVConfiguration(gadget); + } + ) + ]); + }); + }); + + +}(window, rJS, RSVP)); \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml new file mode 100644 index 00000000000..cd89e15e2ac --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml @@ -0,0 +1,320 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + default_reference + gadget_officejs_page_share_configurator.js + + + description + + + + + + id + gadget_officejs_page_share_configurator_js + + + language + en + + + portal_type + Web Script + + + short_title + + + + + + title + OfficeJS Webrtc Share Configurator Gadget JS + + + version + 001 + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474555161.88 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.15508.28746.25412 + + + state + current + + + time + + + + + + + + + + + 1475139184.89 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474554650.05 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.html new file mode 100644 index 00000000000..e4e6584d953 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.html @@ -0,0 +1,71 @@ + + + + + + + OfficeJS jIO DAV Configurator Page + + + + + + + + + +
+
+

+   + Your WebDAV Connection parameters +

+
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.xml new file mode 100644 index 00000000000..1777de9d1f7 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_html.xml @@ -0,0 +1,328 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + content_type + text/html + + + default_reference + gadget_officejs_page_share_dav_configurator.html + + + description + + + + + + id + gadget_officejs_page_share_dav_configurator_html + + + language + + + + + + portal_type + Web Page + + + short_title + + + + + + title + OfficeJS Page Share DAV Configurator Page + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474560284.66 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.6881.61784.17937 + + + state + current + + + time + + + + + + + + + + + 1474621644.5 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474560021.82 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.js new file mode 100644 index 00000000000..2bb99dbc674 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.js @@ -0,0 +1,95 @@ +/*global window, rJS, RSVP, URI, location, + loopEventListener, btoa */ +/*jslint nomen: true, indent: 2, maxerr: 3*/ +(function (window, rJS, RSVP) { + "use strict"; + + function setPageShareDAVConfiguration(gadget) { + return gadget.getSetting("portal_type") + .push(function (portal_type) { + var configuration = { + remote_sub_storage: { + type: "query", + sub_storage: { + type: "uuid", + sub_storage: { + type: "dav", + url: gadget.props.element.querySelector("input[name='dav_url']").value, + basic_login: btoa(gadget.props.element.querySelector("input[name='dav_username']").value + + ':' + gadget.props.element.querySelector("input[name='dav_password']").value), + //with_credentials: true + } + } + } + }; + return gadget.setSetting('webrtc_share_description', configuration); + }) + .push(function () { + return gadget.setSetting('webrtc_share_name', "DAV"); + }) + .push(function () { + return gadget.reload(); + }); + } + + var gadget_klass = rJS(window); + + gadget_klass + .ready(function (g) { + g.props = {}; + return g.getElement() + .push(function (element) { + g.props.element = element; + g.props.deferred = RSVP.defer(); + return g.getSetting('webrtc_share_name'); + }) + .push(function (webrtc_share_name) { + if (webrtc_share_name === "DAV") { + return g.getSetting('webrtc_share_description') + .push(function (webrtc_share_description) { + g.props.element.querySelector("input[name='dav_url']").value = + webrtc_share_description.remote_sub_storage.sub_storage.sub_storage.url; + }); + } + }); + }) + .declareAcquiredMethod("updateHeader", "updateHeader") + .declareAcquiredMethod("redirect", "redirect") + .declareAcquiredMethod("reload", "reload") + .declareAcquiredMethod("getSetting", "getSetting") + .declareAcquiredMethod("setSetting", "setSetting") + .declareMethod("render", function () { + var gadget = this; + return gadget.updateHeader({ + title: "Configure DAV Storage", + back_url: "#page=share_configurator", + panel_action: false + }).push(function () { + return gadget.props.deferred.resolve(); + }); + }) + + ///////////////////////////////////////// + // Form submit + ///////////////////////////////////////// + .declareService(function () { + var gadget = this; + + return new RSVP.Queue() + .push(function () { + return gadget.props.deferred.promise; + }) + .push(function () { + return loopEventListener( + gadget.props.element.querySelector('form'), + 'submit', + true, + function () { + return setPageShareDAVConfiguration(gadget); + } + ); + }); + }); + + +}(window, rJS, RSVP)); \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.xml new file mode 100644 index 00000000000..45e44c8cb70 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_dav_configurator_js.xml @@ -0,0 +1,324 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + default_reference + gadget_officejs_page_share_dav_configurator.js + + + description + + + + + + id + gadget_officejs_page_share_dav_configurator_js + + + language + + + + + + portal_type + Web Script + + + short_title + + + + + + title + OfficeJS Page Share DAV Configurator Page JS + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474560008.96 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.15507.42714.29849 + + + state + current + + + time + + + + + + + + + + + 1475139117.07 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474559651.11 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.html b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.html new file mode 100644 index 00000000000..8a58fd8f886 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.html @@ -0,0 +1,63 @@ + + + + + + + OfficeJS Share Websocket Configurator Page + + + + + + + + + +
+
+

+   + Your Websocket Connection parameters +

+
+
+
+ +
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.xml new file mode 100644 index 00000000000..937c85a7112 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_html.xml @@ -0,0 +1,328 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + content_type + text/html + + + default_reference + gadget_officejs_page_share_websocket_configurator.html + + + description + + + + + + id + gadget_officejs_page_share_websocket_configurator_html + + + language + + + + + + portal_type + Web Page + + + short_title + + + + + + title + OfficeJS Page Share Websocket Configurator Page + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474556132.86 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.6882.11231.50705 + + + state + current + + + time + + + + + + + + + + + 1474621628.3 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474555855.94 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.js new file mode 100644 index 00000000000..9e87a8faef4 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.js @@ -0,0 +1,82 @@ +/*global window, rJS, RSVP, URI, location, + loopEventListener, btoa */ +/*jslint nomen: true, indent: 2, maxerr: 3*/ +(function (window, rJS, RSVP) { + "use strict"; + + function setPageShareConfiguration(gadget) { + return gadget.getSetting("portal_type") + .push(function (portal_type) { + var configuration = { + url: gadget.props.element.querySelector("input[name='websocket_url']").value + }; + return gadget.setSetting('webrtc_share_description', configuration); + }) + .push(function () { + return gadget.setSetting('webrtc_share_name', "WEBSOCKET"); + }) + .push(function () { + return gadget.reload(); + }); + } + + var gadget_klass = rJS(window); + + gadget_klass + .ready(function (g) { + g.props = {}; + return g.getElement() + .push(function (element) { + g.props.element = element; + g.props.deferred = RSVP.defer(); + return g.getSetting('webrtc_share_name'); + }) + .push(function (webrtc_share_name) { + if (webrtc_share_name === "WEBSOCKET") { + return g.getSetting('webrtc_share_description') + .push(function (webrtc_share_description) { + g.props.element.querySelector("input[name='websocket_url']").value = webrtc_share_description.url; + }); + } + }); + }) + .declareAcquiredMethod("updateHeader", "updateHeader") + .declareAcquiredMethod("redirect", "redirect") + .declareAcquiredMethod("reload", "reload") + .declareAcquiredMethod("getSetting", "getSetting") + .declareAcquiredMethod("setSetting", "setSetting") + .declareMethod("render", function () { + var gadget = this; + return gadget.updateHeader({ + title: "Handshake Using Websocket", + back_url: "#page=share_configurator", + panel_action: false + }).push(function () { + return gadget.props.deferred.resolve(); + }); + }) + + ///////////////////////////////////////// + // Form submit + ///////////////////////////////////////// + .declareService(function () { + var gadget = this; + + return new RSVP.Queue() + .push(function () { + return gadget.props.deferred.promise; + }) + .push(function () { + return loopEventListener( + gadget.props.element.querySelector('form'), + 'submit', + true, + function () { + return setPageShareConfiguration(gadget); + } + ); + }); + }); + + +}(window, rJS, RSVP)); \ No newline at end of file diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.xml new file mode 100644 index 00000000000..e36208b7226 --- /dev/null +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_websocket_configurator_js.xml @@ -0,0 +1,324 @@ + + + + + + + + + + _Access_contents_information_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + _Add_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _Change_local_roles_Permission + + + Assignor + Manager + + + + + _Modify_portal_content_Permission + + + Assignee + Assignor + Manager + + + + + _View_Permission + + + Anonymous + Assignee + Assignor + Associate + Auditor + Manager + Owner + + + + + content_md5 + + + + + + default_reference + gadget_officejs_page_share_websocket_configurator.js + + + description + + + + + + id + gadget_officejs_page_share_websocket_configurator_js + + + language + + + + + + portal_type + Web Script + + + short_title + + + + + + title + OfficeJS Page Share Websocket Configurator Page JS + + + version + + + + + + workflow_history + + AAAAAAAAAAI= + + + + + + + + + + + + + data + + + + document_publication_workflow + + AAAAAAAAAAM= + + + + edit_workflow + + AAAAAAAAAAQ= + + + + processing_status_workflow + + AAAAAAAAAAU= + + + + + + + + + + + + + + + + + + + action + publish_alive + + + actor + zope + + + comment + + + + error_message + + + + time + + + + + + + + + + + 1474557770.65 + UTC + + + + + + + validation_state + published_alive + + + + + + + + + + + + + + + + + action + edit + + + actor + zope + + + comment + + + + + + error_message + + + + serial + 954.15506.53785.58248 + + + state + current + + + time + + + + + + + + + + + 1475139052.2 + UTC + + + + + + + + + + + + + + + + + + + + + action + detect_converted_file + + + actor + zope + + + comment + + + + error_message + + + + external_processing_state + converted + + + serial + 0.0.0.0 + + + time + + + + + + + + + + + 1474556265.19 + UTC + + + + + + + + + + + diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.js index 71f42b79f18..51a5b6b4966 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.js @@ -4,7 +4,7 @@ "use strict"; var timeout = 60000, - websocket_timeout = 500000; + websocket_timeout = 5000; function S4() { return ('0000' + Math.floor( diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.xml index 552ce240610..2211b15cc7b 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_webrtc_jio_js.xml @@ -230,7 +230,7 @@
serial - 954.5720.33596.8260 + 954.14471.14332.60706 state @@ -248,7 +248,7 @@ - 1474551874.29 + 1475077244.9 UTC -- 2.30.9 From 674c23785b30d17eb26a2be187ad0511b0d2835a Mon Sep 17 00:00:00 2001 From: Hardik Juneja Date: Wed, 12 Oct 2016 16:06:05 +0000 Subject: [PATCH 4/4] erp5_officejs: Add support for ERP5 as handshake option for webrtc page share --- .../gadget_officejs_jio_web_page_view_js.js | 6 ++-- .../gadget_officejs_jio_web_page_view_js.xml | 4 +-- ...et_officejs_page_jio_configurator_html.xml | 6 ++-- ...adget_officejs_page_jio_configurator_js.js | 25 ++++++++++++- ...dget_officejs_page_jio_configurator_js.xml | 6 ++-- ..._officejs_page_jio_dav_configurator_js.xml | 4 +-- ...get_officejs_page_share_configurator_js.js | 36 +++++++------------ ...et_officejs_page_share_configurator_js.xml | 4 +-- 8 files changed, 51 insertions(+), 40 deletions(-) diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js index 4a756ec74f6..24936037d2e 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.js @@ -35,7 +35,7 @@ gadget.props.webrtc_share_name = webrtc_share_name; return gadget.getSetting('webrtc_share_description') }) - .push(function(webrtc_share_description){ + .push(function(webrtc_share_description) { if(window.location.hash) { var index = window.location.hash.indexOf('room='), type; @@ -54,9 +54,9 @@ } ); }) - .push(function(g){ + .push(function(g) { var config; - if (gadget.props.webrtc_share_name === "DAV") { + if (gadget.props.webrtc_share_name === "DAV" || gadget.props.webrtc_share_name === "ERP5" ) { type = "jio"; config = webrtc_share_description.remote_sub_storage; } else { diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml index f1c866788b0..c2d5b71a896 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_web_page_view_js.xml @@ -228,7 +228,7 @@ serial - 954.15487.18741.41096 + 954.35924.33648.64204 state @@ -246,7 +246,7 @@ - 1475137884.03 + 1476277769.81 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_html.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_html.xml index 54a03fee1e8..58ebdaeec00 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_html.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_html.xml @@ -220,7 +220,7 @@ actor - cedric.le.ninivin + zope comment @@ -234,7 +234,7 @@ serial - 947.12629.17894.55808 + 953.32434.36327.35225 state @@ -252,7 +252,7 @@ - 1448032104.14 + 1475239510.96 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.js index d34f86cee46..33e9db10e23 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.js @@ -77,6 +77,23 @@ return gadget.reload(); }); } + + function setWebrtcShareConfiguration(gadget) { + var configuration = { + remote_sub_storage: { + type: "erp5", + url: (new URI("hateoas")) + .absoluteTo(location.href) + .toString(), + default_view_reference: "view" + } + }; + + return gadget.setSetting('webrtc_share_description', configuration) + .push(function () { + return gadget.setSetting('webrtc_share_name', "ERP5"); + }) + } function setDAVConfiguration(gadget) { return gadget.redirect({page: 'jio_dav_configurator'}); @@ -104,9 +121,15 @@ return gadget.updateHeader({ title: "Storage Configuration" }).push(function () { + return gadget.getSetting("webrtc_share_name") + }).push(function (setting) { + if (!setting) { + return setWebrtcShareConfiguration(gadget); + } + }).push(function (setting) { return RSVP.all([ gadget.getSetting('jio_storage_name'), - gadget.getSetting('application_title') + gadget.getSetting('application_title'), ]); }).push(function (setting_list) { switch (setting_list[0]) { diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.xml index 2ddeb7bd11a..bdad081b4ac 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_configurator_js.xml @@ -216,7 +216,7 @@ actor - cedric.le.ninivin + zope comment @@ -230,7 +230,7 @@ serial - 947.12629.17894.55808 + 954.35989.13930.10461 state @@ -248,7 +248,7 @@ - 1447936126.33 + 1476281593.66 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_dav_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_dav_configurator_js.xml index a2023ed9bbe..3cc25cc4aad 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_dav_configurator_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_jio_dav_configurator_js.xml @@ -234,7 +234,7 @@ serial - 954.5849.14852.49954 + 954.14434.12379.58060 state @@ -252,7 +252,7 @@ - 1474559647.83 + 1475074692.17 UTC diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js index 27fb3c5b9d6..c74d826d75e 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.js @@ -5,31 +5,19 @@ "use strict"; function setERP5Configuration(gadget) { - return gadget.getSetting("portal_type") - .push(function (portal_type) { - var configuration = { - local_sub_storage: { - type: "query", - sub_storage: { - type: "uuid", - sub_storage: { - type: "indexeddb", - database: "officejs-erp5" - } - } - }, - remote_sub_storage: { - type: "erp5", - url: (new URI("hateoas")) - .absoluteTo(location.href) - .toString(), - default_view_reference: "jio_view" - } - }; - return gadget.setSetting('jio_storage_description', configuration); - }) + var configuration = { + remote_sub_storage: { + type: "erp5", + url: (new URI("hateoas")) + .absoluteTo(location.href) + .toString(), + default_view_reference: "view" + } + }; + + return gadget.setSetting('webrtc_share_description', configuration) .push(function () { - return gadget.setSetting('jio_storage_name', "ERP5"); + return gadget.setSetting('webrtc_share_name', "ERP5"); }) .push(function () { return gadget.reload(); diff --git a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml index cd89e15e2ac..a494435291f 100644 --- a/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml +++ b/bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_share_configurator_js.xml @@ -230,7 +230,7 @@ serial - 954.15508.28746.25412 + 954.35964.26780.28620 state @@ -248,7 +248,7 @@ - 1475139184.89 + 1476280104.88 UTC -- 2.30.9