Vue event bus, uploading files handles from file service.
This commit is contained in:
@@ -47,7 +47,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
search: function () {
|
||||
console.info(this.searchTerm);
|
||||
axios.get('/book/search/' + this.searchTerm).then(response => {
|
||||
this.books = response.data;
|
||||
});
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
<td class="text-end">{{ formatSize(file.fileSize) }}</td>
|
||||
<td>{{ file.extension }}</td>
|
||||
<td><a :href="'/file/'+ file.id" class="link-secondary">download</a></td>
|
||||
<td><a :href="'/file/delete/'+file.id" class="link-danger">remove</a></td>
|
||||
<td><a :href="'/file/delete/'+file.id" @click.prevent="deleteFile(file.id)" class="link-danger">remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -31,9 +32,13 @@
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import {EventBus} from "../event-bus";
|
||||
|
||||
export default {
|
||||
name: 'Files',
|
||||
components: {
|
||||
EventBus
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
files: []
|
||||
@@ -42,9 +47,15 @@ export default {
|
||||
mounted() {
|
||||
this.getFiles();
|
||||
},
|
||||
created() {
|
||||
window.EventBus.$on('fileUploaded', this.getFiles);
|
||||
},
|
||||
methods: {
|
||||
deleteFile: function (fileId) {
|
||||
axios.get(window.location.origin + '/file/delete/' + fileId).then(() => this.getFiles())
|
||||
},
|
||||
formatSize: function (bytes) {
|
||||
if (bytes == 0) {
|
||||
if (bytes === 0) {
|
||||
return "0.00 B";
|
||||
}
|
||||
var e = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
|
||||
Reference in New Issue
Block a user