Henrique Dias 8b98abedea Working better :)
Former-commit-id: 935ee3c7cceb4deb31965501a80c202a0034da52 [formerly 3a68553e1ac0af9dad51bd2b8eab1152959a4dc2] [formerly 596f9d6676cceafac0e9fe66a9137683482c2685 [formerly 191b31e9774be6e9a2a12a8336db40fe14eb94b5]]
Former-commit-id: f0179a58c53f057f1b6f0f19b40fc2308b0edd15 [formerly 5151c85d599e8b3772dabab24973004105c29881]
Former-commit-id: c28c7b95e5ea1b1d9ae2af046f49cc5ffa848385
2017-07-03 11:04:14 +01:00

62 lines
1.8 KiB
Vue

<template>
<div id="previewer">
<div class="bar">
<button @click="back" class="action" aria-label="Close Preview" id="close">
<i class="material-icons">close</i>
</button>
<rename-button v-if="allowEdit()"></rename-button>
<delete-button v-if="allowEdit()"></delete-button>
<download-button></download-button>
<info-button></info-button>
</div>
<div class="preview">
<img v-if="req.type == 'image'" :src="raw()">
<audio v-else-if="req.type == 'audio'" :src="raw()" controls></audio>
<video v-else-if="req.type == 'video'" :src="raw()" controls>
Sorry, your browser doesn't support embedded videos,
but don't worry, you can <a href="?download=true">download it</a>
and watch it with your favorite video player!
</video>
<object v-else-if="req.extension == '.pdf'" class="pdf" :data="raw()"></object>
<a v-else-if="req.type == 'blob'" href="?download=true">
<h2 class="message">Download <i class="material-icons">file_download</i></h2>
</a>
<pre v-else >{{ req.content }}</pre>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
import page from '../utils/page'
import InfoButton from './InfoButton'
import DeleteButton from './DeleteButton'
import RenameButton from './RenameButton'
import DownloadButton from './DownloadButton'
export default {
name: 'preview',
components: {
InfoButton,
DeleteButton,
RenameButton,
DownloadButton
},
computed: mapState(['req']),
methods: {
raw: function () {
return this.req.url + '?raw=true'
},
back: function (event) {
let url = page.removeLastDir(window.location.pathname) + '/'
page.open(url)
},
allowEdit: function (event) {
return this.$store.state.user.allowEdit
}
}
}
</script>