Skip to content

Commit

Permalink
ms error
Browse files Browse the repository at this point in the history
  • Loading branch information
elizavetaRa committed Dec 2, 2022
1 parent d2a87b0 commit 5c0e1c0
Showing 1 changed file with 125 additions and 41 deletions.
166 changes: 125 additions & 41 deletions packages/web-app-external/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@
'oc-flex oc-flex-center oc-flex-middle': loading || loadingError
}"
>
<oc-modal
v-if="modal"
:icon="'alarm-warning'"
:title="'Microsoft debug'"
:button-cancel-text="'Cancel'"
:button-confirm-text="'Force reload'"
@cancel="
() => {
this.modal = false
}
"
@confirm="
() => {
this.debugMicrosoft = true
this.modal = false
}
"
>
<template #content>
<p>
If you are facing problems with editing the document, please force
reload
</p>
<p>
OTG:
<a href="https://cern.service-now.com/service-portal?id=outage&n=OTG0074523"
>OTG0074523</a
>
</p>
</template>
</oc-modal>
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<loading-screen v-if="loading" />
<error-screen v-else-if="loadingError" :message="errorMessage" />
Expand Down Expand Up @@ -33,7 +64,7 @@
</template>

<script lang="ts">
import { mapGetters } from 'vuex'
import { mapActions, mapGetters } from 'vuex'
import ErrorScreen from './components/ErrorScreen.vue'
import LoadingScreen from './components/LoadingScreen.vue'
import { computed, unref } from '@vue/composition-api'
Expand Down Expand Up @@ -65,7 +96,10 @@ export default defineComponent({
errorMessage: '',
appUrl: '',
method: '',
formParameters: {}
formParameters: {},
debugMicrosoft: false,
modal: false,
viewmodeWrite: false
}),
computed: {
...mapGetters(['capabilities', 'configuration']),
Expand All @@ -86,54 +120,104 @@ export default defineComponent({
return this.$route.query.fileId
}
},
watch: {
debugMicrosoft(n, o) {
if (n === true) {
this.onCreate()
}
}
},
async created() {
this.loading = true
try {
const filePath = this.currentFileContext.path
const fileId = this.fileId || (await this.getFileResource(filePath)).fileId
await this.onCreate()
this.catchMicrosoftError()
},
methods: {
...mapActions([
'createModal',
'hideModal'
]),
catchMicrosoftError() {
const events = []
this.func = (event) => {events.push(JSON.parse(event.data))}
if (window.location.href.includes('app=MS') ){ //&& this.viewmodeWrite) {
window.addEventListener('message', this.func)
setTimeout(() => {
if (
!events.some((e) => {
return e.MessageId === 'App_LoadingStatus'
})
) {
this.modal = true
setTimeout(()=>{
if (
!events.some((e) => {
return e.MessageId === 'App_LoadingStatus'
})
)
window.removeEventListener('message', this.func)
// fetch iframe params for app and file
const configUrl = this.configuration.server
const appOpenUrl = this.capabilities.files.app_providers[0].open_url.replace(/^\/+/, '')
const url =
configUrl +
appOpenUrl +
`?file_id=${fileId}` +
`&lang=${this.$language.current}` +
(this.applicationName ? `&app_name=${this.applicationName}` : '')
}, 10*1000)
}
}, 10 * 1000)
}
},
async onCreate() {
this.loading = true
try {
const filePath = this.currentFileContext.path
const fileId = this.fileId || (await this.getFileResource(filePath)).fileId
const response = await this.makeRequest('POST', url)
// fetch iframe params for app and file
const configUrl = this.configuration.server
const appOpenUrl = this.capabilities.files.app_providers[0].open_url.replace(/^\/+/, '')
const url =
configUrl +
appOpenUrl +
`?file_id=${fileId}` +
`&lang=${this.$language.current}` +
(this.applicationName ? `&app_name=${this.applicationName}` : '') +
(this.debugMicrosoft ? '&forcelock=1' : '')
if (response.status !== 200) {
this.errorMessage = response.message
this.loading = false
this.loadingError = true
console.error('Error fetching app information', response.status, this.errorMessage)
return
}
const response = await this.makeRequest('POST', url)
if (!response.data.app_url || !response.data.method) {
this.errorMessage = this.$gettext('Error in app server response')
this.loading = false
this.loadingError = true
console.error('Error in app server response')
return
}
if (response.status !== 200) {
this.errorMessage = response.message
this.loading = false
this.loadingError = true
console.error('Error fetching app information', response.status, this.errorMessage)
return
}
this.appUrl = response.data.app_url
this.method = response.data.method
if (response.data.form_parameters) this.formParameters = response.data.form_parameters
if (!response.data.app_url || !response.data.method) {
this.errorMessage = this.$gettext('Error in app server response')
this.loading = false
this.loadingError = true
console.error('Error in app server response')
return
}
//
//if (JSON.parse(atob(response["form_parameters"]?.accessToken?.split(".")[1]))?.viewmode ==="VIEW_MODE_READ_WRITE")
this.viewmodeWrite = true
this.appUrl = response.data.app_url
this.method = response.data.method
if (response.data.form_parameters) this.formParameters = response.data.form_parameters
if (this.method === 'POST' && this.formParameters) {
this.$nextTick(() => this.$refs.subm.click())
if (this.method === 'POST' && this.formParameters) {
this.$nextTick(() => this.$refs.subm.click())
}
this.loading = false
} catch (error) {
this.errorMessage = this.$gettext('Error retrieving file information')
console.error('Error retrieving file information', error)
this.loading = false
this.loadingError = true
}
this.loading = false
} catch (error) {
this.errorMessage = this.$gettext('Error retrieving file information')
console.error('Error retrieving file information', error)
this.loading = false
this.loadingError = true
}
}
})
</script>

0 comments on commit 5c0e1c0

Please sign in to comment.