Skip to content

Commit

Permalink
feat: add loadingMessage() to show different loadingMsg
Browse files Browse the repository at this point in the history
Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
  • Loading branch information
Rash419 authored and juliushaertl committed Dec 29, 2023
1 parent 1622e7d commit a89a48f
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div v-if="showLoadingIndicator"
class="office-viewer__loading-overlay"
:class="{ debug: debug }">
<NcEmptyContent v-if="!error" :name="t('richdocuments', 'Loading {filename} …', { filename: basename }, 1, {escape: false})">
<NcEmptyContent v-if="!error" :name="loadingMessage">
<template #icon>
<NcLoadingIcon />
</template>
Expand All @@ -39,6 +39,21 @@
<template #icon>
<AlertOctagonOutline />
</template>
<template #description>
<p>{{ errorMessage }}</p>
<p v-if="showAdminStorageFailure">
{{ t('richdocuments', 'Please check the Collabora Online server log for more details and make sure that Nextcloud can be reached from there.') }}
</p>
<p v-if="showAdminWebsocketFailure">
{{ t('richdocuments', 'Socket connection closed unexpectedly. The reverse proxy might be misconfigured, please contact the administrator.') }}
<a href="https://docs.nextcloud.com/server/latest/admin_manual/office/proxy.html"
target="_blank"
rel="noreferrer noopener"
class="external">
{{ t('richdocuments', 'More information can be found in the reverse proxy documentation') }}
</a>
</p>
</template>
<template #action>
<NcButton @click="close">
{{ t('richdocuments', 'Close') }}
Expand Down Expand Up @@ -104,6 +119,7 @@ import pickLink from '../mixins/pickLink.js'
import saveAs from '../mixins/saveAs.js'
import uiMention from '../mixins/uiMention.js'
import version from '../mixins/version.js'
import { getCurrentUser } from '@nextcloud/auth'
const FRAME_DOCUMENT = 'FRAME_DOCUMENT'
Expand Down Expand Up @@ -153,6 +169,8 @@ export default {
loading: LOADING_STATE.LOADING,
loadingTimeout: null,
error: null,
errorType: null,
loadingMsg: null,
views: [],
showLinkPicker: false,
Expand Down Expand Up @@ -186,6 +204,13 @@ export default {
return this.error
}
},
loadingMessage() {
if (this.loadingMsg) {
return this.loadingMsg
}
return t('richdocuments', 'Loading {filename} …', { filename: basename(this.filename) }, 1, { escape: false })
},
debug() {
return !!window.TESTING
},
Expand All @@ -195,6 +220,12 @@ export default {
shareToken() {
return document.getElementById('sharingToken')?.value
},
showAdminStorageFailure() {
return getCurrentUser()?.isAdmin && this.errorType === 'websocketloadfailed'
},
showAdminWebsocketFailure() {
return getCurrentUser()?.isAdmin && this.errorType === 'websocketconnectionfailed'
},
},
async mounted() {
this.postMessage = new PostMessageService({
Expand Down Expand Up @@ -321,8 +352,14 @@ export default {
if (args.success) {
this.documentReady()
} else {
this.error = args.errorMsg
this.loading = LOADING_STATE.FAILED
if (args.errorType === 'clusterscaling') {
this.loadingMsg = t('richdocuments', 'Cluster is scaling …')
} else {
this.error = args.errorMsg
this.errorType = args.errorType
this.loading = LOADING_STATE.FAILED
clearTimeout(this.loadingTimeout)
}
}
break
case 'UI_Close':
Expand Down

0 comments on commit a89a48f

Please sign in to comment.