Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/File/Info.vue
<template> | <template> | ||||
<div class="container"> | <div class="container"> | ||||
<div class="card" id="file-info"> | <div class="card" id="file-info"> | ||||
<div class="card-body"> | <div class="card-body" v-if="fileId === 'newCollection'"> | ||||
<div class="card-title" >{{ $t('collection.new') }}</div> | |||||
<div class="card-text"> | |||||
<form @submit.prevent="submit" class="card-body"> | |||||
<div class="row mb-3"> | |||||
<label for="name" class="col-sm-4 col-form-label">{{ $t('collection.name') }}</label> | |||||
<div class="col-sm-8"> | |||||
<input type="text" class="form-control" id="name" v-model="file.name" :disabled="file.id"> | |||||
</div> | |||||
</div> | |||||
<btn v-if="!file.id" class="btn-primary mt-3" type="submit" icon="check">{{ $t('btn.submit') }}</btn> | |||||
</form> | |||||
</div> | |||||
</div> | |||||
<div class="card-body" v-else> | |||||
<div class="card-title"> | <div class="card-title"> | ||||
{{ file.name }} | {{ file.name }} | ||||
<btn v-if="file.canDelete" class="btn-outline-danger button-delete float-end" @click="fileDelete" icon="trash-can">{{ $t('file.delete') }}</btn> | <btn v-if="file.canDelete" class="btn-outline-danger button-delete float-end" @click="fileDelete" icon="trash-can">{{ $t('file.delete') }}</btn> | ||||
</div> | </div> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<tabs class="mt-3" :tabs="file.isOwner ? ['form.general','file.sharing'] : ['form.general']"></tabs> | <tabs class="mt-3" :tabs="file.isOwner ? ['form.general','file.sharing'] : ['form.general']"></tabs> | ||||
<div class="tab-content"> | <div class="tab-content"> | ||||
<form class="tab-pane show active card-body read-only short" id="general" role="tabpanel" aria-labelledby="tab-general"> | <form class="tab-pane show active card-body read-only short" id="general" role="tabpanel" aria-labelledby="tab-general"> | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | library.add( | ||||
require('@fortawesome/free-solid-svg-icons/faDownload').definition, | require('@fortawesome/free-solid-svg-icons/faDownload').definition, | ||||
) | ) | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
file: {}, | file: {}, | ||||
fileId: null, | fileId: null, | ||||
collectionId: null, | |||||
shares: [] | shares: [] | ||||
} | } | ||||
}, | }, | ||||
created() { | created() { | ||||
this.api = new FileAPI({}) | this.api = new FileAPI({}) | ||||
this.fileId = this.$route.params.file | this.fileId = this.$route.params.file | ||||
this.collectionId = this.$route.query.parent | |||||
axios.get('/api/v4/files/' + this.fileId, { loader: true }) | if (this.fileId != 'newCollection') { | ||||
axios.get('/api/v4/fs/' + this.fileId, { loader: true }) | |||||
machniak: files -> fs | |||||
.then(response => { | .then(response => { | ||||
this.file = response.data | this.file = response.data | ||||
if (this.file.isOwner) { | if (this.file.isOwner) { | ||||
axios.get('api/v4/files/' + this.fileId + '/permissions') | axios.get('api/v4/fs/' + this.fileId + '/permissions') | ||||
Done Inline Actionsfiles -> fs machniak: files -> fs | |||||
.then(response => { | .then(response => { | ||||
if (response.data.list) { | if (response.data.list) { | ||||
this.shares = response.data.list | this.shares = response.data.list | ||||
} | } | ||||
}) | }) | ||||
} | } | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
} | |||||
}, | }, | ||||
methods: { | methods: { | ||||
copyLink(link) { | copyLink(link) { | ||||
navigator.clipboard.writeText(link); | navigator.clipboard.writeText(link); | ||||
}, | }, | ||||
fileDelete() { | fileDelete() { | ||||
axios.delete('api/v4/files/' + this.fileId) | axios.delete('api/v4/fs/' + this.fileId) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.$router.push({ name: 'files' }) | this.$router.push({ name: 'files' }) | ||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
fileDownload() { | fileDownload() { | ||||
this.api.fileDownload(this.fileId) | this.api.fileDownload(this.fileId) | ||||
}, | }, | ||||
shareAdd() { | shareAdd() { | ||||
let post = { permissions: 'read-only', user: $('#user').val() } | let post = { permissions: 'read-only', user: $('#user').val() } | ||||
if (!post.user) { | if (!post.user) { | ||||
return | return | ||||
} | } | ||||
axios.post('api/v4/files/' + this.fileId + '/permissions', post) | axios.post('api/v4/fs/' + this.fileId + '/permissions', post) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.shares.push(response.data) | this.shares.push(response.data) | ||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
shareDelete(id) { | shareDelete(id) { | ||||
axios.delete('api/v4/files/' + this.fileId + '/permissions/' + id) | axios.delete('api/v4/fs/' + this.fileId + '/permissions/' + id) | ||||
.then(response => { | .then(response => { | ||||
if (response.data.status == 'success') { | if (response.data.status == 'success') { | ||||
this.$toast.success(response.data.message) | this.$toast.success(response.data.message) | ||||
this.$delete(this.shares, this.shares.findIndex(element => element.id == id)) | this.$delete(this.shares, this.shares.findIndex(element => element.id == id)) | ||||
} | } | ||||
}) | }) | ||||
}, | |||||
submit() { | |||||
this.$root.clearFormValidation($('#general form')) | |||||
let post = this.$root.pick(this.file, ['name']) | |||||
axios.post('/api/v4/fs', post, { params: { | |||||
type: 'collection', | |||||
parent: this.collectionId | |||||
}}) | |||||
.then(response => { | |||||
this.$toast.success(response.data.message) | |||||
this.$router.replace({ name: 'files', params: { parent: this.collectionId }}) | |||||
}) | |||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |
files -> fs