Skip to content

Commit

Permalink
Load the application after checking the file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualEvan committed Dec 7, 2020
1 parent 12e3683 commit 7b750a1
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions apps/draw-io/src/DrawIoEditor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<template>
<iframe id="drawio-editor" ref="drawIoEditor" :src="iframeSource"></iframe>
<div>
<oc-spinner
v-if="loading"
:aria-label="this.$gettext('Loading media')"
class="uk-position-center"
size="xlarge"
/>
<iframe v-else id="drawio-editor" ref="drawIoEditor" :src="iframeSource" />
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
Expand All @@ -10,16 +18,14 @@ import moment from 'moment'
export default {
name: 'DrawIoEditor',
data: () => ({
loading: true,
filePath: '',
fileExtension: '',
isReadOnly: null,
currentETag: null
}),
computed: {
...mapGetters(['getToken']),
loading() {
return this.content === ''
},
config() {
const { url = 'https://embed.diagrams.net', theme = 'minimal', autosave = false } =
this.$store.state.apps.fileEditors.find(editor => editor.app === 'draw-io').config || {}
Expand All @@ -42,9 +48,7 @@ export default {
created() {
this.filePath = this.$route.params.filePath
this.fileExtension = this.filePath.split('.').pop()
this.$client.files.fileInfo(this.filePath, ['{http://owncloud.org/ns}permissions']).then(v => {
this.isReadOnly = v.fileInfo['{http://owncloud.org/ns}permissions'].indexOf('W') === -1
})
this.checkPermissions()
window.addEventListener('message', event => {
if (event.data.length > 0) {
var payload = JSON.parse(event.data)
Expand Down Expand Up @@ -75,6 +79,17 @@ export default {
}
})
},
checkPermissions() {
this.$client.files
.fileInfo(this.filePath, ['{http://owncloud.org/ns}permissions'])
.then(v => {
this.isReadOnly = v.fileInfo['{http://owncloud.org/ns}permissions'].indexOf('W') === -1
this.loading = false
})
.catch(error => {
this.error(error)
})
},
load() {
this.$client.files
.getFileContents(this.filePath, { resolveWithResponseObject: true })
Expand Down

0 comments on commit 7b750a1

Please sign in to comment.