refresh cache button plugin : add last cache update date and time on button title
This commit is contained in:
parent
a1f0701630
commit
b1f7854510
5 changed files with 37 additions and 17 deletions
|
|
@ -1,26 +1,34 @@
|
|||
<template>
|
||||
<k-button
|
||||
v-if="pageStatus !== 'draft'"
|
||||
:theme="theme"
|
||||
variant="dimmed"
|
||||
:icon="icon"
|
||||
title="Rafraîchir le cache front"
|
||||
@click="refreshCache()"
|
||||
>{{ text }}</k-button
|
||||
>
|
||||
<div id="refresh-cache-button">
|
||||
<k-button
|
||||
v-if="pageStatus !== 'draft'"
|
||||
:theme="theme"
|
||||
variant="dimmed"
|
||||
:icon="icon"
|
||||
:title="title"
|
||||
@click="refreshCache()"
|
||||
>{{ text }}</k-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
const { pageUri, pageStatus } = defineProps({
|
||||
const { pageUri, pageStatus, lastCacheUpdate } = defineProps({
|
||||
pageUri: String,
|
||||
pageStatus: String,
|
||||
lastCacheUpdate: String,
|
||||
});
|
||||
|
||||
const text = ref("Rafraîchir");
|
||||
const icon = ref("refresh");
|
||||
const theme = ref("aqua-icon");
|
||||
const title = computed(() => {
|
||||
return lastCacheUpdate?.length > 0
|
||||
? "Dernière mise à jour : " + lastCacheUpdate
|
||||
: "Mettre à jour le cache front";
|
||||
});
|
||||
|
||||
async function refreshCache() {
|
||||
text.value = "En cours…";
|
||||
|
|
@ -48,10 +56,8 @@ async function refreshCache() {
|
|||
theme.value = "green-icon";
|
||||
|
||||
setTimeout(() => {
|
||||
text.value = "Rafraîchir";
|
||||
icon.value = "refresh";
|
||||
theme.value = "aqua-icon";
|
||||
}, 2000);
|
||||
location.href = location.href;
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue