Skip to content

Commit

Permalink
add gallery purge button if admin
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jun 27, 2024
1 parent c993366 commit 26ae549
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pages/gallery/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
max="16"
/>
</v-col>
<v-col cols="12" sm="6">
<v-col cols="12" :sm="$root.isAdmin ? 3 : 6">
<v-switch :label="$root.lang('gallery.stretched_switcher')" v-model="stretched" />
</v-col>
<v-col cols="12" sm="3" v-if="$root.isAdmin">
<v-btn block @click="clearCache">{{ $root.lang().gallery.clear_cache }}</v-btn>
</v-col>
</v-row>

<div class="my-2 text-h5">{{ $root.lang().gallery.category.search }}</div>
Expand Down Expand Up @@ -325,13 +328,22 @@ export default {
behavior: "smooth",
});
},
clearCache() {
axios
.get(`${this.$root.apiURL}/gallery/cache/purge`, this.$root.apiOptions)
.then(() => this.$root.showSnackBar(this.$root.lang().global.ends_success, "success"))
.catch((err) => {
console.error(err);
this.$root.showSnackBar(err, "error");
});
},
},
computed: {
requestTime() {
if (!this.timer.end || !this.timer.start);
const seconds = (this.timer.end - this.timer.start) / 1000;
// cast to number again to remove unnecessary zeros
return Number(seconds.toFixed(1));
return Number(seconds.toFixed(2));
},
resultMessage() {
const replacePlaceholders = (msg) =>
Expand Down
1 change: 1 addition & 0 deletions resources/strings/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export default {
},
all: "All",
latest: "Latest",
clear_cache: "Clear Gallery Cache",
result_stats_singular: "%COUNT% texture found in %SECONDS% seconds",
result_stats_plural: "%COUNT% textures found in %SECONDS% seconds",
modal: {
Expand Down

0 comments on commit 26ae549

Please sign in to comment.