Skip to content

Commit

Permalink
Merge pull request #1007 from chakflying/feat/save-chart-period
Browse files Browse the repository at this point in the history
Feat: Save and restore chart period
  • Loading branch information
louislam authored Apr 15, 2022
2 parents fb00640 + 6f99d75 commit 0c40e32
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/PingChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export default {
if (newPeriod == "0") {
newPeriod = null;
this.heartbeatList = null;
this.$root.storage().removeItem(`chart-period-${this.monitorId}`);
} else {
this.loading = true;
Expand All @@ -228,6 +229,7 @@ export default {
toast.error(res.msg);
} else {
this.heartbeatList = res.data;
this.$root.storage()[`chart-period-${this.monitorId}`] = newPeriod;
}
this.loading = false;
});
Expand All @@ -248,6 +250,12 @@ export default {
},
{ deep: true }
);
// Load chart period from storage if saved
let period = this.$root.storage()[`chart-period-${this.monitorId}`];
if (period != null) {
this.chartPeriodHrs = Math.min(period, 6);
}
}
};
</script>
Expand Down

0 comments on commit 0c40e32

Please sign in to comment.