added clear cache button to edit page

This commit is contained in:
BroodjeAap 2022-12-27 15:51:54 +00:00
parent 1a880edd74
commit f2996e90bd
5 changed files with 50 additions and 5 deletions

View file

@ -535,9 +535,8 @@ func (web *Web) cacheView(c *gin.Context) {
}
func (web *Web) cacheClear(c *gin.Context) {
url := c.PostForm("url")
delete(web.urlCache, url)
c.Redirect(http.StatusSeeOther, "/cache/view")
web.urlCache = make(map[string]string, 5)
c.JSON(http.StatusOK, gin.H{"status": "ok"})
}
func (web *Web) exportWatch(c *gin.Context) {

View file

@ -0,0 +1,22 @@
function clearCache() {
var confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed) {
return; // do nothing
}
var data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then(function (response) {
if (response.ok) {
window.location.reload();
}
else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit() {
var clearCacheButton = document.getElementById("clearCacheButton");
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -0,0 +1,21 @@
function clearCache(){
let confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed){
return // do nothing
}
let data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then((response) => {
if(response.ok){
window.location.reload()
} else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit(){
let clearCacheButton = document.getElementById("clearCacheButton") as HTMLElement;
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -43,6 +43,11 @@ GoWatch Edit {{ .Watch.Name }}
Import Watch
</button>
</td>
<td>
<button type="button" id="clearCacheButton" class="btn btn-info btn-sm">
Clear Cache
</button>
</td>
<td>
<a href="/watch/view/{{ .Watch.ID }}" class="btn btn-outline-secondary btn-sm">
View Watch
@ -226,6 +231,5 @@ function canvasInit() {
document.addEventListener('DOMContentLoaded', canvasInit, false);
var notifiers = {{ .Notifiers }};
</script>
{{ end }}

View file

@ -14,5 +14,4 @@
- walmart
- etsy
- aliexpress.com
- clear cache button on edit page
- add apprise/Shoutrrr ?