Skip to content

Commit

Permalink
fix(ui): auto-refresh button is now animated for better feedback
Browse files Browse the repository at this point in the history
closes #1802
  • Loading branch information
brian-mulier-p committed Jul 31, 2023
1 parent 56dec7e commit 9ce70f7
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions ui/src/components/layout/RefreshButton.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<el-button-group>
<el-button @click="toggleAutoRefresh" :pressed="autoRefresh">
<el-button :active="autoRefresh" @click="toggleAutoRefresh">
<kicon :tooltip="$t('toggle periodic refresh each 10 seconds')" placement="bottom">
<clock />
<component :is="autoRefresh ? 'auto-renew' : 'auto-renew-off'" class="auto-refresh-icon" />
</kicon>
</el-button>
<el-button @click="triggerRefresh">
Expand All @@ -14,10 +14,11 @@
</template>
<script>
import Refresh from "vue-material-design-icons/Refresh.vue";
import Clock from "vue-material-design-icons/Clock.vue";
import AutoRenew from "vue-material-design-icons/Autorenew.vue";
import AutoRenewOff from "vue-material-design-icons/AutorenewOff.vue";
import Kicon from "../Kicon.vue"
export default {
components: {Refresh, Clock, Kicon},
components: {Refresh, AutoRenew, AutoRenewOff, Kicon},
emits: ["refresh"],
data() {
return {
Expand All @@ -32,12 +33,6 @@
toggleAutoRefresh() {
this.autoRefresh = !this.autoRefresh;
localStorage.setItem("autoRefresh", this.autoRefresh ? "1" : "0");
if (this.autoRefresh) {
this.refreshHandler = setInterval(this.triggerRefresh, 10000);
this.triggerRefresh()
} else {
this.stopRefresh();
}
},
triggerRefresh() {
this.$emit("refresh");
Expand All @@ -51,7 +46,29 @@
},
beforeUnmount() {
this.stopRefresh();
},
watch: {
autoRefresh(newValue) {
if (newValue) {
this.refreshHandler = setInterval(this.triggerRefresh, 10000);
this.triggerRefresh()
} else {
this.stopRefresh();
}
}
}
};
</script>

<style scoped lang="scss">
button[active=true] .auto-refresh-icon {
animation: rotate 10s linear infinite;
}
@keyframes rotate {
0% {
rotate: 0deg;
}
100% {
rotate: 360deg;
}
}
</style>

0 comments on commit 9ce70f7

Please sign in to comment.