Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-12-02 10:48:28 +0300
committerSzymon Kłos <szymon.klos@collabora.com>2020-12-02 11:12:01 +0300
commit45ef4c67ddfaa7d989db61be1fe6095f0a449dbd (patch)
tree6b0095d5638bdc0264dda354826291d90e567bfb /src
parent59d1ae68acf47401fac9032853bfbbd7860f3eb8 (diff)
Check proxy status on timeout
richdocumentsframe iframe content is loaded only when appimage is fully started (if proxy is used). Check the proxy status and if is starting don't close on timeout but wait a bit more. Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'src')
-rw-r--r--src/files.js44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/files.js b/src/files.js
index 572ed863..dbeeecf2 100644
--- a/src/files.js
+++ b/src/files.js
@@ -21,6 +21,7 @@ const odfViewer = {
open: false,
receivedLoading: false,
+ isProxyStarting: false,
isCollaboraConfigured: (
(OC.getCapabilities().richdocuments.config.wopi_url.indexOf('proxy.php') !== -1)
|| (typeof OC.getCapabilities().richdocuments.collabora === 'object' && OC.getCapabilities().richdocuments.collabora.length !== 0)),
@@ -132,14 +133,15 @@ const odfViewer = {
$('head').append($('<link rel="stylesheet" type="text/css" href="' + OC.filePath('richdocuments', 'css', 'mobile.css') + '"/>'))
var $iframe = $('<iframe id="richdocumentsframe" nonce="' + btoa(OC.requestToken) + '" scrolling="no" allowfullscreen src="' + documentUrl + '" />')
- odfViewer.loadingTimeout = setTimeout(function() {
- if (!odfViewer.receivedLoading) {
- odfViewer.onClose()
- OC.Notification.showTemporary(t('richdocuments', 'Failed to load {productName} - please try again later', { productName: OC.getCapabilities().richdocuments.productName || 'Collabora Online' }))
- }
- }, (OC.getCapabilities().richdocuments.config.timeout * 1000 || 15000))
+ odfViewer.loadingTimeout = setTimeout(odfViewer.onTimeout,
+ (OC.getCapabilities().richdocuments.config.timeout * 1000 || 15000))
$iframe.src = documentUrl
+ if ((OC.appswebroots.richdocumentscode || OC.appswebroots.richdocumentscode_arm64)
+ && OC.getCapabilities().richdocuments.config.wopi_url.indexOf('proxy.php') >= 0) {
+ odfViewer.checkProxyStatus()
+ }
+
$('body').css('overscroll-behavior-y', 'none')
var viewport = document.querySelector('meta[name=viewport]')
viewport.setAttribute('content', 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no')
@@ -204,6 +206,36 @@ const odfViewer = {
OC.Util.History.replaceState()
FilesAppIntegration.close()
+ },
+
+ onTimeout: function() {
+ if (!odfViewer.receivedLoading && !odfViewer.isProxyStarting) {
+ odfViewer.onClose()
+ OC.Notification.showTemporary(t('richdocuments', 'Failed to load {productName} - please try again later', { productName: OC.getCapabilities().richdocuments.productName || 'Collabora Online' }))
+ } else if (!odfViewer.receivedLoading) {
+ odfViewer.loadingTimeout = setTimeout(odfViewer.onTimeout,
+ (OC.getCapabilities().richdocuments.config.timeout * 1000 || 15000))
+ }
+ },
+
+ checkProxyStatus: function() {
+ var wopiUrl = OC.getCapabilities().richdocuments.config.wopi_url
+ var url = wopiUrl.substr(0, wopiUrl.indexOf('proxy.php') + 'proxy.php'.length)
+ $.get(url + '?status').done(function(result) {
+ if (result && result.status) {
+ if (result.status === 'OK' || result.status === 'error') {
+ odfViewer.isProxyStarting = false
+ } else if (result.status === 'starting'
+ || result.status === 'stopped'
+ || result.status === 'restarting') {
+ odfViewer.isProxyStarting = true
+
+ setTimeout(function() {
+ odfViewer.checkProxyStatus()
+ }, 1000)
+ }
+ }
+ })
}
}