|
26 | 26 | :autoload="false"
|
27 | 27 | :dense="true"
|
28 | 28 | ref="table"
|
| 29 | + :headers="headers" |
29 | 30 | >
|
30 | 31 |
|
31 |
| - <b-table-column field="name" label="Name" v-slot="props"> |
32 |
| - {{ props.row.filename }} |
| 32 | + <b-table-column field="name" label="Name" searchable> |
| 33 | + <template |
| 34 | + slot="searchable" |
| 35 | + slot-scope="props"> |
| 36 | + <b-input |
| 37 | + v-model="props.filters[props.column.field]" |
| 38 | + placeholder="Search..." |
| 39 | + icon="magnify" |
| 40 | + size="is-small" /> |
| 41 | + </template> |
| 42 | + <template v-slot="props"> |
| 43 | + {{ props.row.name }} |
| 44 | + </template> |
| 45 | + </b-table-column> |
| 46 | + |
| 47 | + <b-table-column field="type" label="Type" searchable> |
| 48 | + <template |
| 49 | + slot="searchable" |
| 50 | + slot-scope="props"> |
| 51 | + <b-input |
| 52 | + v-model="props.filters[props.column.field]" |
| 53 | + placeholder="Search..." |
| 54 | + icon="magnify" |
| 55 | + size="is-small" /> |
| 56 | + </template> |
| 57 | + <template v-slot="props"> |
| 58 | + {{ props.row.type }} |
| 59 | + </template> |
33 | 60 | </b-table-column>
|
34 | 61 |
|
35 | 62 | <b-table-column field="size" label="File size" v-slot="props">
|
36 | 63 | {{ props.row.size }} bytes
|
37 | 64 | </b-table-column>
|
38 | 65 |
|
39 |
| - <b-table-column field="size" label="Mod time" v-slot="props"> |
40 |
| - {{ props.row.mod_time }} |
| 66 | + <b-table-column field="created_at" label="Upload time" v-slot="props"> |
| 67 | + {{ props.row.created_at | moment }} |
41 | 68 | </b-table-column>
|
42 | 69 |
|
43 | 70 | <b-table-column field="actions" label="Actions" v-slot="props">
|
44 |
| - <b-button tag="a" type="is-primary" :href="generateFileUri(props.row.filename)"> |
| 71 | + <b-button tag="a" type="is-primary" @click="download(props.row)"> |
45 | 72 | <b-icon icon="download"></b-icon>
|
46 | 73 | </b-button>
|
47 | 74 | </b-table-column>
|
|
51 | 78 | </template>
|
52 | 79 |
|
53 | 80 | <script>
|
| 81 | + import { saveAs } from 'file-saver'; |
54 | 82 | import PaginatedTable from "../../components/PaginatedTable";
|
55 | 83 | import UploadFile from "./UploadFile";
|
56 | 84 | export default {
|
57 | 85 | name: "FileList",
|
58 | 86 | components: {UploadFile, PaginatedTable},
|
59 | 87 | data() {
|
60 | 88 | return {
|
61 |
| - uploadDialog: false, |
| 89 | + headers: [ |
| 90 | + { |
| 91 | + text: 'Name', |
| 92 | + value: 'name', |
| 93 | + searchable: true, |
| 94 | + }, |
| 95 | + { |
| 96 | + text: 'Type', |
| 97 | + value: 'type', |
| 98 | + searchable: true, |
| 99 | + }, |
| 100 | + { |
| 101 | + text: 'Size', |
| 102 | + value: 'size', |
| 103 | + searchable: true, |
| 104 | + }, |
| 105 | + ], |
| 106 | + uploadDialog: false, |
62 | 107 | }
|
63 | 108 | },
|
64 | 109 | methods: {
|
65 |
| - generateFileUri(filename) { |
66 |
| - return `${process.env.VUE_APP_API_URL}../file/${filename}` |
| 110 | + download(file) { |
| 111 | + const response = this.$store.dispatch('file/download', file.id) |
| 112 | + saveAs(response.data, file.name) |
67 | 113 | },
|
68 | 114 | refreshList() {
|
69 | 115 | this.$refs.table.fetchItems()
|
|
0 commit comments