refresh cache button plugin : add last cache update date and time on button title

This commit is contained in:
isUnknown 2025-09-24 09:13:04 +02:00
parent a1f0701630
commit b1f7854510
5 changed files with 37 additions and 17 deletions

View file

@ -1 +1 @@
(function(){"use strict";function f(n,e,c,t,r,o,i,u){var a=typeof n=="function"?n.options:n;return e&&(a.render=e,a.staticRenderFns=c,a._compiled=!0),{exports:n,options:a}}const l={__name:"RefreshCacheButton",props:{pageUri:String,pageStatus:String},setup(n){const{pageUri:e,pageStatus:c}=n,t=Vue.ref("Rafraîchir"),r=Vue.ref("refresh"),o=Vue.ref("aqua-icon");async function i(){t.value="En cours…",r.value="loader",o.value="orange-icon";const u={method:"POST","Content-Type":"application/json",body:JSON.stringify({pageUri:e})},s=await(await fetch("/refresh-cache.json",u)).json();s.status==="error"?(console.error(s),t.value="Erreur",r.value="alert",o.value="red-icon"):(console.log(s),t.value="Terminé",r.value="check",o.value="green-icon",setTimeout(()=>{t.value="Rafraîchir",r.value="refresh",o.value="aqua-icon"},2e3))}return{__sfc:!0,text:t,icon:r,theme:o,refreshCache:i}}};var h=function(){var e=this,c=e._self._c,t=e._self._setupProxy;return e.pageStatus!=="draft"?c("k-button",{attrs:{theme:t.theme,variant:"dimmed",icon:t.icon,title:"Rafraîchir le cache front"},on:{click:function(r){return t.refreshCache()}}},[e._v(e._s(t.text))]):e._e()},_=[],p=f(l,h,_);const v=p.exports;window.panel.plugin("adrienpayet/refresh-cache-button",{components:{"refresh-cache-button":v}})})();
(function(){"use strict";function f(n,e,a,t,r,c,s,u){var o=typeof n=="function"?n.options:n;return e&&(o.render=e,o.staticRenderFns=a,o._compiled=!0),{exports:n,options:o}}const l={__name:"RefreshCacheButton",props:{pageUri:String,pageStatus:String,lastCacheUpdate:String},setup(n){const{pageUri:e,pageStatus:a,lastCacheUpdate:t}=n,r=Vue.ref("Rafraîchir"),c=Vue.ref("refresh"),s=Vue.ref("aqua-icon"),u=Vue.computed(()=>(t==null?void 0:t.length)>0?"Dernière mise à jour : "+t:"Mettre à jour le cache front");async function o(){r.value="En cours…",c.value="loader",s.value="orange-icon";const m={method:"POST","Content-Type":"application/json",body:JSON.stringify({pageUri:e})},i=await(await fetch("/refresh-cache.json",m)).json();i.status==="error"?(console.error(i),r.value="Erreur",c.value="alert",s.value="red-icon"):(console.log(i),r.value="Terminé",c.value="check",s.value="green-icon",setTimeout(()=>{location.href=location.href},1500))}return{__sfc:!0,text:r,icon:c,theme:s,title:u,refreshCache:o}}};var h=function(){var e=this,a=e._self._c,t=e._self._setupProxy;return a("div",{attrs:{id:"refresh-cache-button"}},[e.pageStatus!=="draft"?a("k-button",{attrs:{theme:t.theme,variant:"dimmed",icon:t.icon,title:t.title},on:{click:function(r){return t.refreshCache()}}},[e._v(e._s(t.text))]):e._e()],1)},_=[],p=f(l,h,_);const d=p.exports;window.panel.plugin("adrienpayet/refresh-cache-button",{components:{"refresh-cache-button":d}})})();