Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ function isLogElementInViewport(el: Element, {extraViewPortHeight}={extraViewPor
type LocaleStorageOptions = {
autoScroll: boolean;
expandRunning: boolean;
actionsLogShowSeconds: boolean;
actionsLogShowTimestamps: boolean;
};

export default defineComponent({
Expand Down Expand Up @@ -135,8 +137,8 @@ export default defineComponent({
},

data() {
const defaultViewOptions: LocaleStorageOptions = {autoScroll: true, expandRunning: false};
const {autoScroll, expandRunning} = localUserSettings.getJsonObject('actions-view-options', defaultViewOptions);
const defaultViewOptions: LocaleStorageOptions = {autoScroll: true, expandRunning: false, actionsLogShowSeconds: false, actionsLogShowTimestamps: false};
const {autoScroll, expandRunning, actionsLogShowSeconds, actionsLogShowTimestamps} = localUserSettings.getJsonObject('actions-view-options', defaultViewOptions);
return {
// internal state
loadingAbortController: null as AbortController | null,
Expand All @@ -146,11 +148,11 @@ export default defineComponent({
menuVisible: false,
isFullScreen: false,
timeVisible: {
'log-time-stamp': false,
'log-time-seconds': false,
'log-time-stamp': actionsLogShowTimestamps,
'log-time-seconds': actionsLogShowSeconds,
},
optionAlwaysAutoScroll: autoScroll ?? false,
optionAlwaysExpandRunning: expandRunning ?? false,
optionAlwaysAutoScroll: autoScroll,
optionAlwaysExpandRunning: expandRunning,

// provided by backend
run: {
Expand Down Expand Up @@ -253,7 +255,12 @@ export default defineComponent({

methods: {
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);
},

Expand Down Expand Up @@ -470,6 +477,7 @@ export default defineComponent({
for (const el of this.elStepsContainer().querySelectorAll(`.log-time-${type}`)) {
toggleElem(el, this.timeVisible[`log-time-${type}`]);
}
this.saveLocaleStorageOptions();
},

toggleFullScreen() {
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/modules/user-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export const localUserSettings = {
getJsonObject: <T extends Record<string, any>>(key: string, def: T): T => {
const value = getLocalStorageUserSetting(key);
try {
const decoded = value !== null ? JSON.parse(value) : def;
return decoded ?? def;
const decoded = value !== null ? JSON.parse(value) : null;
return {...def, ...decoded};
} catch (e) {
console.error(`Unable to parse JSON value for local user settings ${key}=${value}`, e);
}
Expand Down