diff --git a/lib/www/client/source/src/views/Log.vue b/lib/www/client/source/src/views/Log.vue index a00695f..fab0641 100644 --- a/lib/www/client/source/src/views/Log.vue +++ b/lib/www/client/source/src/views/Log.vue @@ -548,6 +548,7 @@ export default { watch: { options: { async handler () { + this.savePrefs(), await this.fetchEvents(); }, deep: true @@ -566,16 +567,19 @@ export default { }, filter (newVal, oldVal) { + this.savePrefs(); if (newVal?.toLowerCase() != oldVal?.toLowerCase()) { this.fetchEvents(); } }, labelSearch () { + this.savePrefs(); this.fetchEvents(); }, filteredLabels () { + this.savePrefs() this.fetchEvents(); }, @@ -584,7 +588,7 @@ export default { }, user (newVal, oldVal) { - this.itemsPerPage = Number(localStorage.getItem(`dougal/prefs/${this.user?.name}/${this.$route.params.project}/${this.$options.name}/items-per-page`)) || 25; + this.loadPrefs(); } }, @@ -876,10 +880,36 @@ export default { */ }, + getPrefsKey () { + return `dougal/prefs/${this.user?.name}/${this.$route.params.project}/Log/v1`; + }, + + savePrefs () { + const prefs = { + shownLabels: this.shownLabels, + labelSearch: this.labelSearch, + filter: this.filter, + options: this.options + }; + localStorage.setItem(this.getPrefsKey(), JSON.stringify(prefs)); + }, + + loadPrefs () { + const stored = localStorage.getItem(this.getPrefsKey()); + if (stored) { + const prefs = JSON.parse(stored); + if (prefs.shownLabels !== undefined) this.shownLabels = prefs.shownLabels; + if (prefs.labelSearch !== undefined) this.labelSearch = prefs.labelSearch; + if (prefs.filter !== undefined) this.filter = prefs.filter; + if (prefs.options !== undefined) this.options = prefs.options; + } + }, + ...mapActions(["api", "showSnack", "refreshEvents", "getEvents"]) }, async mounted () { + this.loadPrefs(); this.fetchEvents(); window.addEventListener('keyup', this.handleKeyboardEvent);