Commit 287b4434 authored by Anton's avatar Anton
Browse files

Add documents source tab to mosys, fix access control in image cell

parent ad1e95aa
<template lang="pug">
q-list.default-source-container
q-list-header
q-item
small Documents
q-item-separator
template(v-for="(file, i) in images")
template(v-if="i > 0")
q-item-separator
q-item
q-item-side
q-icon(
draggable="true",
@dragstart.native="event => {handleItemDragStart(event, file)}",
:name="typeToIconName(getSimpleType(file.metaData['content-type']))", style="font-size: 1.8rem")
q-item-main {{ file.name }}
</template>
<script>
import { mapGetters } from 'vuex'
const typeToIconName = {
'image': 'photo',
'video': 'local movies'
}
export default {
data () {
return {
files: []
}
},
async mounted () {
this.files = await this.$store.dispatch('files/list', this.bucketName)
},
computed: {
...mapGetters({
user: 'auth/getUserState'
}),
bucketName () {
return `user-${this.user.uuid}`
},
images () {
return this.files.filter(file => this.getSimpleType(file.metaData['content-type']) === 'image')
},
types () {
const _this = this
return this.files.reduce((types, file) => {
const mimetype = file.metaData && file.metaData['content-type'] ? file.metaData['content-type'] : undefined
if (mimetype) {
const type = _this.getSimpleType(mimetype)
if (types.indexOf(type) === -1) types.push(type)
}
return types
}, [])
}
},
methods: {
typeToIconName (type) {
let iconName = typeToIconName[type.toLowerCase()]
if (!iconName) {
iconName = 'broken image'
}
return iconName
},
getSimpleType (mimetype) {
if (mimetype.indexOf('/') !== -1) return mimetype.split('/')[0]
return mimetype
},
handleItemDragStart (event, item) {
const resourceCell = {
uuid: null,
type: this.getSimpleType(item.metaData['content-type']),
x: 1,
y: 1,
width: 1,
height: 1,
content: `${process.env.STORAGE_HOST}/files/${this.bucketName}/${item.name}`
}
event.dataTransfer.setData('text/plain', JSON.stringify(resourceCell))
}
}
}
</script>
<style scoped lang="stylus">
.q-list-header
padding-left 0
.q-input
padding-left 1em
padding-right 1em
.q-input:before
.q-input:after
display none
.q-input
padding-left 0
</style>
......@@ -4,6 +4,7 @@
q-tab(slot="title", name="tab-default-cells", default, icon="add")
<!--q-tab(slot="title", name="tab-magic-box", icon="wb iridescent")-->
q-tab(slot="title", name="tab-piecemaker") Piecemaker
q-tab(slot="title", name="tab-documents", v-if="userHasDocuments") Documents
q-tab(slot="title", name="tab-vimeo") Vimeo
q-tab(slot="title", name="tab-youtube") YouTube
q-btn(slot="title", icon="close",
......@@ -22,6 +23,9 @@
q-tab-pane(name="tab-piecemaker")
grid-editor-source-piece-maker
q-tab-pane(name="tab-documents", v-if="userHasDocuments")
grid-editor-source-documents
q-tab-pane(name="tab-vimeo")
grid-editor-source-vimeo
......@@ -34,15 +38,20 @@
import CellEditor from './CellEditor'
import GridEditorDefaultSource from './GridEditorDefaultSource'
import GridEditorMagicSource from './GridEditorMagicSource'
import GridEditorSourceDocuments from './GridEditorSourceDocuments'
import GridEditorSourcePieceMaker from './GridEditorSourcePieceMaker'
import GridEditorSourceVimeo from './GridEditorSourceVimeo'
import GridEditorSourceYouTube from './GridEditorSourceYouTube'
import { mapGetters } from 'vuex'
import { userHasFeature } from 'mbjs-quasar/src/lib'
export default {
components: {
CellEditor,
GridEditorDefaultSource,
GridEditorMagicSource,
GridEditorSourceDocuments,
GridEditorSourcePieceMaker,
GridEditorSourceVimeo,
GridEditorSourceYouTube
......@@ -53,6 +62,12 @@
}
},
computed: {
...mapGetters({
user: 'auth/getUserState'
}),
userHasDocuments () {
return userHasFeature(this.user, 'documents')
},
currentStoreTab () {
return this.$store.state.mosysGridEditorStore.sourcesTabName
},
......
......@@ -29,7 +29,7 @@
if (process.env.STORAGE_HOST && src.indexOf(process.env.STORAGE_HOST) === 0) {
if (this.user && localStorage.getItem('access_token')) {
src += src.indexOf('?') === -1 ? '?' : '&'
src += `access_token=${encodeURIComponent(localStorage.getItem('access_token'))}`
src += `token=${encodeURIComponent(localStorage.getItem('access_token'))}`
}
}
return src
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment