Persist actions log time display settings in localStorage (#36623)
Persist the two boolean settings in the actions log into `localStorage` so that they are remembered across page reloads. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,8 @@ function isLogElementInViewport(el: Element, {extraViewPortHeight}={extraViewPor
|
|||||||
type LocaleStorageOptions = {
|
type LocaleStorageOptions = {
|
||||||
autoScroll: boolean;
|
autoScroll: boolean;
|
||||||
expandRunning: boolean;
|
expandRunning: boolean;
|
||||||
|
actionsLogShowSeconds: boolean;
|
||||||
|
actionsLogShowTimestamps: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -135,8 +137,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const defaultViewOptions: LocaleStorageOptions = {autoScroll: true, expandRunning: false};
|
const defaultViewOptions: LocaleStorageOptions = {autoScroll: true, expandRunning: false, actionsLogShowSeconds: false, actionsLogShowTimestamps: false};
|
||||||
const {autoScroll, expandRunning} = localUserSettings.getJsonObject('actions-view-options', defaultViewOptions);
|
const {autoScroll, expandRunning, actionsLogShowSeconds, actionsLogShowTimestamps} = localUserSettings.getJsonObject('actions-view-options', defaultViewOptions);
|
||||||
return {
|
return {
|
||||||
// internal state
|
// internal state
|
||||||
loadingAbortController: null as AbortController | null,
|
loadingAbortController: null as AbortController | null,
|
||||||
@@ -146,11 +148,11 @@ export default defineComponent({
|
|||||||
menuVisible: false,
|
menuVisible: false,
|
||||||
isFullScreen: false,
|
isFullScreen: false,
|
||||||
timeVisible: {
|
timeVisible: {
|
||||||
'log-time-stamp': false,
|
'log-time-stamp': actionsLogShowTimestamps,
|
||||||
'log-time-seconds': false,
|
'log-time-seconds': actionsLogShowSeconds,
|
||||||
},
|
},
|
||||||
optionAlwaysAutoScroll: autoScroll ?? false,
|
optionAlwaysAutoScroll: autoScroll,
|
||||||
optionAlwaysExpandRunning: expandRunning ?? false,
|
optionAlwaysExpandRunning: expandRunning,
|
||||||
|
|
||||||
// provided by backend
|
// provided by backend
|
||||||
run: {
|
run: {
|
||||||
@@ -253,7 +255,12 @@ export default defineComponent({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
saveLocaleStorageOptions() {
|
saveLocaleStorageOptions() {
|
||||||
const opts: LocaleStorageOptions = {autoScroll: this.optionAlwaysAutoScroll, expandRunning: this.optionAlwaysExpandRunning};
|
const opts: LocaleStorageOptions = {
|
||||||
|
autoScroll: this.optionAlwaysAutoScroll,
|
||||||
|
expandRunning: this.optionAlwaysExpandRunning,
|
||||||
|
actionsLogShowSeconds: this.timeVisible['log-time-seconds'],
|
||||||
|
actionsLogShowTimestamps: this.timeVisible['log-time-stamp'],
|
||||||
|
};
|
||||||
localUserSettings.setJsonObject('actions-view-options', opts);
|
localUserSettings.setJsonObject('actions-view-options', opts);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -470,6 +477,7 @@ export default defineComponent({
|
|||||||
for (const el of this.elStepsContainer().querySelectorAll(`.log-time-${type}`)) {
|
for (const el of this.elStepsContainer().querySelectorAll(`.log-time-${type}`)) {
|
||||||
toggleElem(el, this.timeVisible[`log-time-${type}`]);
|
toggleElem(el, this.timeVisible[`log-time-${type}`]);
|
||||||
}
|
}
|
||||||
|
this.saveLocaleStorageOptions();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleFullScreen() {
|
toggleFullScreen() {
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ export const localUserSettings = {
|
|||||||
getJsonObject: <T extends Record<string, any>>(key: string, def: T): T => {
|
getJsonObject: <T extends Record<string, any>>(key: string, def: T): T => {
|
||||||
const value = getLocalStorageUserSetting(key);
|
const value = getLocalStorageUserSetting(key);
|
||||||
try {
|
try {
|
||||||
const decoded = value !== null ? JSON.parse(value) : def;
|
const decoded = value !== null ? JSON.parse(value) : null;
|
||||||
return decoded ?? def;
|
return {...def, ...decoded};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Unable to parse JSON value for local user settings ${key}=${value}`, e);
|
console.error(`Unable to parse JSON value for local user settings ${key}=${value}`, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user