[Libreoffice-commits] online.git: 4 commits - loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Dec 18 16:41:24 UTC 2018
loleaflet/src/control/Signing.js | 36 +++++++++++++++++++++--------
loleaflet/src/vcl.js | 48 ++++++++++++++++++++++++++++++---------
2 files changed, 64 insertions(+), 20 deletions(-)
New commits:
commit be9346ddf6c015e59c8829efd0ec8d29b817dd5f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 18 17:36:47 2018 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 18 17:39:21 2018 +0100
on auth. event check session and list of idents., log known events
Change-Id: Ie668defffa6f3450571df708db27f163789aa848
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 53c0cf770..0f0a8036f 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -413,10 +413,26 @@ L.Map.include({
onEvent: function(event) {
switch (event.type) {
case 'ActionConfirmedAndExecuted':
- console.log('ActionConfirmedAndExecuted');
+ console.log('event ActionConfirmedAndExecuted');
break;
case 'Authenticated':
- vereignRestoreIdentity();
+ console.log('event Authenticated');
+ library.hasSession().then(function(result) {
+ if (isSuccess(result)) {
+ library.listIdentities().then(function(result) {
+ if (isSuccess(result)) {
+ vereignRestoreIdentity();
+ }
+ });
+ }
+ });
+ break;
+ case 'Logout':
+ console.log('event Logout');
+ _map.signingLogout();
+ break;
+ case 'QRCodeUpdated':
+ console.log('event QRCodeUpdated');
break;
default:
console.log('UNKNOWN EVENT: ' + event.type);
commit 0c28b32069e1bdae508d80d8706cbe1eb965a3a0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 18 17:34:40 2018 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 18 17:39:21 2018 +0100
additional WOPI endpoint parameter for vereign client library
Change-Id: Iddae25824ca00dcfca8e602c02a72cc60d03431a
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 53c0ec894..53c0cf770 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -425,7 +425,8 @@ L.Map.include({
}
},
vereignURL + '/vcl/js/iframe',
- vereignURL + '/api/'
+ vereignURL + '/api/',
+ vereignURL + '/wopi/'
).then(function(lib) {
library = lib;
adjustUIState();
diff --git a/loleaflet/src/vcl.js b/loleaflet/src/vcl.js
index fd413846c..f3a492073 100644
--- a/loleaflet/src/vcl.js
+++ b/loleaflet/src/vcl.js
@@ -8,14 +8,20 @@
* @param methods - list of methods to be used in iframe
* @param iframeUrl - iframe URL to connect
* @param apiUrl - API URL used to access API endpoints
+ * @param wopiUrl - WOPI URL used to acces WopiAPI
* @returns {*}
*/
-function setupViamAPI(divId, methods, iframeUrl, apiUrl) {
+function setupViamAPI(divId, methods, iframeUrl, apiUrl, wopiUrl) {
if (!apiUrl) {
apiUrl = `${window.location.origin}/api/`;
console.warn(`API host URL not specified. Fall back to ${apiUrl}`); // eslint-disable-line no-console
}
+ if (!wopiUrl) {
+ wopiUrl = `${window.location.origin}/wopi/`;
+ console.warn(`WOPI host URL not specified. Fall back to ${wopiUrl}`); // eslint-disable-line no-console
+ }
+
if (!iframeUrl) {
iframeUrl = `${window.location.origin}/vcl/js/iframe`;
console.warn(`Iframe URL not specified. Fall back to ${iframeUrl}`); // eslint-disable-line no-console
@@ -31,9 +37,10 @@ function setupViamAPI(divId, methods, iframeUrl, apiUrl) {
});
return connection.promise
- .then((child) => child.initializeApiHost(apiUrl).then(() => child));
+ .then((child) => child.initialize(apiUrl, wopiUrl).then(() => child));
}
window.setupViamAPI = setupViamAPI;
+
/* jshint ignore:end */
/* eslint-enable no-alert, no-console */
commit 1187d5800b912ec114b4f934a19f40b9c58b789e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 18 14:07:08 2018 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 18 17:39:21 2018 +0100
Logout even if logout command doesn't return success
It is possible the user is already logged out and the logout
command doesn't return success.
Change-Id: I3f164ad96a388d5c94126540aceaf078082fb9a4
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index a0287ca88..53c0ec894 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -338,13 +338,11 @@ L.Map.include({
},
signingLogout: function() {
if (library) {
- library.logout().then(function(result) {
- if (isSuccess(result)) {
- identity = null;
- currentPassport = null;
- updateIndentity();
- adjustUIState();
- }
+ library.logout().then(function() {
+ identity = null;
+ currentPassport = null;
+ updateIndentity();
+ adjustUIState();
});
}
},
commit ad1abaaa67eca585591974e98794b45543193d3a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Dec 18 12:54:05 2018 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Tue Dec 18 17:39:21 2018 +0100
update vereign client library: additional parameter
Change-Id: I1a0dca92ec5b46ce942a68f947cc318f83fd10c5
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 0e2b9f9c8..a0287ca88 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -426,7 +426,8 @@ L.Map.include({
}
}
},
- vereignURL + '/vcl/js/iframe'
+ vereignURL + '/vcl/js/iframe',
+ vereignURL + '/api/'
).then(function(lib) {
library = lib;
adjustUIState();
diff --git a/loleaflet/src/vcl.js b/loleaflet/src/vcl.js
index 2a136efcb..fd413846c 100644
--- a/loleaflet/src/vcl.js
+++ b/loleaflet/src/vcl.js
@@ -2,17 +2,38 @@
/* jshint ignore:start*/
!function(e,n){var r={};!function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=e.ERR_CONNECTION_DESTROYED="ConnectionDestroyed",r=e.ERR_CONNECTION_TIMEOUT="ConnectionTimeout",t=e.ERR_NOT_IN_IFRAME="NotInIframe",o={"http:":"80","https:":"443"},a=/^(https?:)?\/\/([^\/:]+)(:(\d+))?/,i={ERR_CONNECTION_DESTROYED:n,ERR_CONNECTION_TIMEOUT:r,ERR_NOT_IN_IFRAME:t,Promise:function(){try{return window?window.Promise:null}catch(e){return null}}(),debug:!1},d=function(){var e=0;return function(){return++e}}(),c=function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(i.debug){var t;(t=console).log.apply(t,["[Penpal]"].concat(n))}},u=function(e){var n=document.location,r=a.exec(e),t=void 0,i=void 0,d=void 0;return r?(t=r[1]?r[1]:n.protocol,i=r[2],d=r[4]):(t=n.protocol,i=n.hostname,d=n.port),t+"//"+i+(d&&d!==o[t]?":"+d:"")},s=function(e){var n=[];return e(function(){n.forEach(function(e){e()})}),{then:function(e){n.push(e)}}},l=function(e){return{n
ame:e.name,message:e.message,stack:e.stack}},m=function(e){var n=new Error;return Object.keys(e).forEach(function(r){return n[r]=e[r]}),n},f=function(e,r,t,o){var a=r.localName,u=r.local,s=r.remote,l=r.remoteOrigin,f=!1;c(a+": Connecting call sender");var v=function(e){return function(){for(var r=arguments.length,t=Array(r),o=0;o<r;o++)t[o]=arguments[o];if(c(a+": Sending "+e+"() call"),f){var v=new Error("Unable to send "+e+"() call due to destroyed connection");throw v.code=n,v}return new i.Promise(function(n,r){var o=d(),i=function t(i){if(i.source===s&&i.origin===l&&"reply"===i.data.penpal&&i.data.id===o){c(a+": Received "+e+"() reply"),u.removeEventListener("message",t);var d=i.data.returnValue;i.data.returnValueIsError&&(d=m(d)),("fulfilled"===i.data.resolution?n:r)(d)}};u.addEventListener("message",i),s.postMessage({penpal:"call",id:o,methodName:e,args:t},l)})}};o.then(function(){f=!0}),t.reduce(function(e,n){return e[n]=v(n),e},e)},v=function(e,n,r){var t=e.localName,o=e.loca
l,a=e.remote,d=e.remoteOrigin,u=!1;c(t+": Connecting call receiver");var s=function(e){if(e.source===a&&e.origin===d&&"call"===e.data.penpal){var r=e.data,o=r.methodName,s=r.args,m=r.id;if(c(t+": Received "+o+"() call"),o in n){var f=function(e){return function(n){if(c(t+": Sending "+o+"() reply"),u)return void c(t+": Unable to send "+o+"() reply due to destroyed connection");var r={penpal:"reply",id:m,resolution:e,returnValue:n};"rejected"===e&&n instanceof Error&&(r.returnValue=l(n),r.returnValueIsError=!0);try{a.postMessage(r,d)}catch(e){throw"DataCloneError"===e.name&&a.postMessage({penpal:"reply",id:m,resolution:"rejected",returnValue:l(e),returnValueIsError:!0},d),e}}};new i.Promise(function(e){return e(n[o].apply(n,s))}).then(f("fulfilled"),f("rejected"))}}};o.addEventListener("message",s),r.then(function(){u=!0,o.removeEventListener("message",s)})};i.connectToChild=function(e){var t=e.url,o=e.appendTo,a=e.methods,d=void 0===a?{}:a,l=e.timeout,m=void 0,p=new s(function(e){m=e
}),h=window,g=document.createElement("iframe");g.setAttribute('style','display:none;');(o||document.body).appendChild(g),p.then(function(){g.parentNode&&g.parentNode.removeChild(g)});var E=g.contentWindow||g.contentDocument.parentWindow,w=u(t);return{promise:new i.Promise(function(e,o){var a=void 0;void 0!==l&&(a=setTimeout(function(){var e=new Error("Connection to child timed out after "+l+"ms");e.code=r,o(e),m()},l));var i={},u=void 0,y=void 0,N=function(n){if(n.source===E&&n.origin===w&&"handshake"===n.data.penpal){c("Parent: Received handshake, sending reply"),n.source.postMessage({penpal:"handshake-reply",methodNames:Object.keys(d)},n.origin);var r={localName:"Parent",local:h,remote:E,remoteOrigin:n.origin};y&&y();var t=new s(function(e){p.then(e),y=e});v(r,d,t),u&&u.forEach(function(e){delete i[e]}),u=n.data.methodNames,f(i,r,u,p),clearTimeout(a),e(i)}};h.addEventListener("message",N),p.then(function(){h.removeEventListener("message",N);var e=new Error("Connection destroyed");
e.code=n,o(e)}),c("Parent: Loading iframe"),g.src=t}),iframe:g,destroy:m}},i.connectToParent=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=e.parentOrigin,a=void 0===o?"*":o,d=e.methods,u=void 0===d?{}:d,l=e.timeout;if(window===window.top){var m=new Error("connectToParent() must be called within an iframe");throw m.code=t,m}var p=void 0,h=new s(function(e){p=e}),g=window,E=g.parent;return{promise:new i.Promise(function(e,t){var o=void 0;void 0!==l&&(o=setTimeout(function(){var e=new Error("Connection to parent timed out after "+l+"ms");e.code=r,t(e),p()},l));var i=function n(r){if(("*"===a||a===r.origin)&&r.source===E&&"handshake-reply"===r.data.penpal){c("Child: Received handshake reply"),g.removeEventListener("message",n);var t={localName:"Child",local:g,remote:E,remoteOrigin:r.origin},i={};v(t,u,h),f(i,t,r.data.methodNames,h),clearTimeout(o),e(i)}};g.addEventListener("message",i),h.then(function(){g.removeEventListener("message",i);var e=new Error("C
onnection destroyed");e.code=n,t(e)}),c("Child: Sending handshake"),E.postMessage({penpal:"handshake",methodNames:Object.keys(u)},a)}),destroy:p}},e.default=i}(r),"function"==typeof define&&define.amd?define("Penpal",r.default):e.Penpal=r.default}(this);
-function setupViamAPI(divId, methodsArg, envUrl) {
- const connection = Penpal.connectToChild({
- // URL of page to load into iframe.
- url: envUrl,
- // Container to which the iframe should be appended.
- appendTo: document.getElementById(divId),
- // Methods parent is exposing to child
- methods: methodsArg
- });
+/**
+ * Sets up interaction with Vereign Restful API
+ * @param divId - target container to append iframe via Penpal
+ * @param methods - list of methods to be used in iframe
+ * @param iframeUrl - iframe URL to connect
+ * @param apiUrl - API URL used to access API endpoints
+ * @returns {*}
+ */
+function setupViamAPI(divId, methods, iframeUrl, apiUrl) {
+ if (!apiUrl) {
+ apiUrl = `${window.location.origin}/api/`;
+ console.warn(`API host URL not specified. Fall back to ${apiUrl}`); // eslint-disable-line no-console
+ }
- return connection.promise
+ if (!iframeUrl) {
+ iframeUrl = `${window.location.origin}/vcl/js/iframe`;
+ console.warn(`Iframe URL not specified. Fall back to ${iframeUrl}`); // eslint-disable-line no-console
+ }
+
+ const connection = Penpal.connectToChild({
+ // URL of page to load into iframe.
+ url: iframeUrl,
+ // Container to which the iframe should be appended.
+ appendTo: document.getElementById(divId),
+ // Methods parent is exposing to child
+ methods
+ });
+
+ return connection.promise
+ .then((child) => child.initializeApiHost(apiUrl).then(() => child));
}
+
+window.setupViamAPI = setupViamAPI;
/* jshint ignore:end */
/* eslint-enable no-alert, no-console */
More information about the Libreoffice-commits
mailing list