Commit 09c9ae60 authored by Hardik Juneja's avatar Hardik Juneja Committed by hardikj

gadget_officejs : Add support for Webrtc share configuration

parent f1caf11c
......@@ -37,6 +37,7 @@
<ul data-role="listview" class="ui-listview">
<li><a href="#page=document_list" data-i18n="Document List">Document List</a></li>
<li><a href="#page=jio_configurator" data-i18n="Storage Configuration">Storage Configuration</a></li>
<li><a href="#page=share_configurator" data-i18n="Share Configuration">Share Configuration</a></li>
<li><a href="#page=sync" data-i18n="Synchronization">Synchronization</a></li>
<li class="ui-last-child"><a href="#page=logout" data-i18n="Logout">Logout</a></li>
</ul>
......
......@@ -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.28216.64976.63368</string> </value>
<value> <string>954.5775.37069.56541</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1464191586.4</float>
<float>1474555175.01</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -15,8 +15,7 @@
<div class="center">
<div class="ui-field-contain">
<label data-i18n="Public Link:"> Public Link: </label>
<button type="submit" id="generatelink" name="generatelink" data-i18n="Jio Link" style="display: inline-block; width: 34%;"> Jio Link </button>
<button type="submit" id="generatelink1" name="generatelink1" data-i18n="Websocket Link" style="display: inline-block; width: 34%;"> Websocket Link </button>
<button type="submit" id="generatelink" name="generatelink" data-i18n="Generate Link" style="display: inline-block;"> Generate Link </button>
<input type="text" id="sharelink" name="share" style="display:none" value=""/>
</div>
</div>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.5706.38367.28381</string> </value>
<value> <string>954.5829.6234.43417</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1474551059.28</float>
<float>1474558386.14</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -29,57 +29,57 @@
});
}
function shareDoc (gadget, type) {
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;
if (type === "jio") {
config = {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
"type": "dav",
"url": "https://softinst67513.host.vifib.net/share/",
"basic_login": btoa("admin:vowhkida")
}
function shareDoc (gadget) {
return gadget.getSetting('webrtc_share_name')
.push(function(webrtc_share_name){
gadget.props.webrtc_share_name = webrtc_share_name;
return gadget.getSetting('webrtc_share_description')
})
.push(function(webrtc_share_description){
if(window.location.hash) {
var index = window.location.hash.indexOf('room='),
type;
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")
}
};
} else {
config = {url: "ws://192.168.242.146:9999/"};
}
var sharelink = window.location.origin + window.location.pathname + '#page=webrtc_viewer&room='+room+'&type='+type+'&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();
gadget.props.element.querySelector('#generatelink1').remove();
if(config) {
return g.initiate(room, gadget, type, config);
} else {
throw new Error("Share config is missing");
}
})
);
})
.push(function(g){
var config;
if (gadget.props.webrtc_share_name === "DAV") {
type = "jio";
config = webrtc_share_description.remote_sub_storage;
} else {
type = gadget.props.webrtc_share_name.toLowerCase();
config = {url: webrtc_share_description.url};
}
var sharelink = window.location.origin + window.location.pathname +
'#page=webrtc_viewer&room='+room+'&type='+type+'&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, type, config);
} else {
throw new Error("Share config is missing");
}
})
}
}
}
});
}
......@@ -125,6 +125,7 @@
.declareAcquiredMethod("put", "jio_put")
.declareAcquiredMethod('allDocs', 'jio_allDocs')
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.allowPublicAcquisition('triggerMaximize', function () {
var gadget = this;
......@@ -142,7 +143,7 @@
})
.declareMethod('triggerSubmit', function () {
return this.props.element.querySelector('button').click();
return this.props.element.querySelector('form.view-web-page-form').getElementsByTagName('button')[0].click();
})
.declareMethod("render", function (options) {
......@@ -213,7 +214,7 @@
.push(function () {
return gadget.props.deferred.promise;
})
.push(function () {
.push(function () {
return RSVP.all([
loopEventListener(
gadget.props.element.querySelector('form.select-share-type'),
......@@ -221,9 +222,7 @@
true,
function (event) {
if (document.activeElement.name === "generatelink") {
return shareDoc(gadget, "jio");
} else if (document.activeElement.name === "generatelink1") {
return shareDoc(gadget, "websocket");
return shareDoc(gadget);
}
}
),
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.5702.26020.8277</string> </value>
<value> <string>954.15487.18741.41096</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1474550862.46</float>
<float>1475137884.03</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -101,7 +101,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS jIO DAV Configurator Page JS</string> </value>
<value> <string>OfficeJS jiO DAV Configurator Page JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>947.53845.25131.55500</string> </value>
<value> <string>954.5849.14852.49954</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1450259852.52</float>
<float>1474559647.83</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Router Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_page_share_configurator.js" type="text/javascript"></script>
</head>
<body>
<article class="ui-content ui-body-c message" style="display: none;">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c" style="color: #085078;">
<span class="ui-icon ui-icon-custom ui-icon-info-circle">&nbsp;</span>
</3>
</section>
</article>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your Webrtc Page Share Choice
</h3>
</section>
<section class="ui-body-c ui-content-section">
<p>Select a storage for Webrtc handshake</p>
<!--div class="select-storage ui-controlgroup ui-controlgroup-horizontal"-->
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a">
<form class="select-dav-form" style="margin-right: .3125em; margin-left: .3125em;">
<button class="ui-btn ui-btn-b" type="submit" data-i18n="DAV Storage">DAV Storage</button>
</form>
</div>
<div class="ui-block-b">
<form class="select-erp5-form" style="margin-right: .3125em; margin-left: .3125em;">
<button class="ui-btn ui-btn-b" type="submit" data-i18n="ERP5">ERP5</button>
</form>
</div>
<div class="ui-block-c">
<form class="select-websocket-form" style="margin-right: .3125em; margin-left: .3125em;">
<button class="ui-btn ui-btn-b" type="submit" data-i18n="Websocket">Websocket</button>
</form>
</div>
</div>
<!--/div-->
</section>
</article>
<article class="ui-content ui-body-c document-access">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-file-text-o">&nbsp;</span>
Your Documents
</h3>
</section>
<section class="ui-body-c ui-content-section">
<div class="ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-a ui-responsive">
<div class="ui-block-b">
<a class="ui-btn" href="#page=document_list" data-i18n="Go to document List">Access document List</a>
</div>
</div>
</div>
</section>
</article>
</body>
</html>
\ No newline at end of file
/*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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS jIO DAV Configurator Page</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_officejs_page_share_dav_configurator.js"></script>
</head>
<body>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your WebDAV Connection parameters
</h3>
</section>
<section class="ui-body-c ui-content-section">
<form class="dav-configuration-form">
<div class="ui-form">
<div class="ui-field-contain">
<label data-i18n="Connection URL:">Connection URL:</label>
<input type="url" name="dav_url" required value=""/>
</div>
<div class="ui-field-contain">
<label data-i18n="Username:">Username:</label>
<input type="text" name="dav_username" value=""/>
</div>
<div class="ui-field-contain">
<label data-i18n="Password:">Password:</label>
<input type="password" name="dav_password" value=""/>
</div>
</div>
<div class="select-storage ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b"></div>
<div class="ui-block-c">
<button type="submit" data-i18n="Connect" class="ui-btn-btn-right">Save</button>
</div>
</div>
</div>
</form>
</section>
</article>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-file-text-o">&nbsp;</span>
Your Text Documents
</h3>
</section>
<section class="ui-body-c ui-content-section">
<div class="ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-a ui-responsive">
<div class="ui-block">
<a class="ui-btn" href="#page=document_list">Go to document List</a>
</div>
</div>
</div>
</section>
</article>
</body>
</html>
/*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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Share Websocket Configurator Page</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_officejs_page_share_websocket_configurator.js"></script>
</head>
<body>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your Websocket Connection parameters
</h3>
</section>
<section class="ui-body-c ui-content-section">
<form class="websocket-configuration-form">
<div class="ui-form">
<div class="ui-field-contain">
<label data-i18n="Connection URL:">Connection URL:</label>
<input type="url" name="websocket_url" required value=""/>
</div>
</div>
<div class="select-storage ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b"></div>
<div class="ui-block-c">
<button type="submit" data-i18n="Connect" class="ui-btn-btn-right">Save</button>
</div>
</div>
</div>
</form>
</section>
</article>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-file-text-o">&nbsp;</span>
Your Text Documents
</h3>
</section>
<section class="ui-body-c ui-content-section">
<div class="ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-a ui-responsive">
<div class="ui-block">
<a class="ui-btn" href="#page=document_list">Go to document List</a>
</div>
</div>
</div>
</section>
</article>
</body>
</html>
/*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
......@@ -4,7 +4,7 @@
"use strict";
var timeout = 60000,
websocket_timeout = 500000;
websocket_timeout = 5000;
function S4() {
return ('0000' + Math.floor(
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.5720.33596.8260</string> </value>
<value> <string>954.14471.14332.60706</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1474551874.29</float>
<float>1475077244.9</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