1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
<template>
<section class="section is-fullheight dashboard">
<div class="container">
<div class="columns ">
<div class="column is-narrow">
<Sidebar />
</div>
<div class="column">
<nav class="level">
<div class="level-left">
<div class="level-item">
<h2 class="subtitle">
Your uploaded files
</h2>
</div>
</div>
<div class="level-right">
<div class="level-item">
<Search @search="onSearch" />
</div>
</div>
</nav>
<hr>
<!-- <b-loading :active="images.isLoading" /> -->
<Grid
v-if="totalFiles && !isLoading"
:files="images.files"
:enable-search="false"
class="grid">
<template v-slot:pagination>
<b-pagination
v-if="shouldPaginate"
:total="totalFiles"
:per-page="limit"
:current.sync="current"
range-before="2"
range-after="2"
class="pagination-slot"
icon-prev="icon-interface-arrow-left"
icon-next="icon-interface-arrow-right"
icon-pack="icon"
aria-next-label="Next page"
aria-previous-label="Previous page"
aria-page-label="Page"
aria-current-label="Current page" />
</template>
</Grid>
</div>
</div>
</div>
</section>
</template>
<script>
import { mapState, mapGetters, mapActions } from 'vuex';
import Sidebar from '~/components/sidebar/Sidebar.vue';
import Grid from '~/components/grid/Grid.vue';
import Search from '~/components/search/Search.vue';
export default {
components: {
Sidebar,
Grid,
Search
},
middleware: ['auth', ({ store }) => {
store.commit('images/resetState');
}],
data() {
return {
current: 1,
isLoading: false,
search: ''
};
},
computed: {
...mapGetters({
totalFiles: 'images/getTotalFiles',
shouldPaginate: 'images/shouldPaginate',
limit: 'images/getLimit'
}),
...mapState(['images'])
},
watch: {
current: 'fetchPaginate'
},
async asyncData({ app }) {
await app.store.dispatch('images/fetch');
},
mounted() {
this.filteredHints = this.hints; // fixes the issue where on pageload, suggestions wont load
},
methods: {
...mapActions({
fetch: 'images/fetch'
}),
async fetchPaginate() {
this.isLoading = true;
// eslint-disable-next-line no-negated-condition
if (!this.search.length) {
await this.fetch(this.current);
} else {
this.$handler.executeAction('images/search', {
q: this.search,
page: this.current
});
}
this.isLoading = false;
},
sanitizeQuery(qry) {
// remove spaces between a search type selector `album:`
// and the value (ex `tag: 123` -> `tag:123`)
return (qry || '').replace(/(\w+):\s+/gi, '$1:');
},
async onSearch(query) {
this.search = this.sanitizeQuery(query);
// eslint-disable-next-line no-negated-condition
if (!this.search.length) {
this.current = 1;
await this.fetch(this.current);
} else {
this.$handler.executeAction('images/search', {
q: this.search,
page: this.current
});
}
}
},
head() {
return {
title: 'Dashboard'
};
}
};
</script>
<style lang="scss" scoped>
div.grid {
margin-bottom: 1rem;
}
.pagination-slot {
padding: 1rem 0;
}
</style>
<style lang="scss">
.pagination-slot > .pagination-previous, .pagination-slot > .pagination-next {
display: none !important;
}
</style>
|