Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unfound fields are shown by default instead of hidden #3342

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions assets/components/LogViewer/LogDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function toggleField(key: string[]) {
visibleKeys.value = new Map<string[], boolean>(fields.value.map(({ key }) => [key, true]));
}

const enabled = visibleKeys.value.get(key);
const enabled = visibleKeys.value.get(key) ?? true;

visibleKeys.value.set(key, !enabled);
}

Expand Down Expand Up @@ -116,7 +117,7 @@ const fields = computed({

for (const [key, value] of allFields) {
if ([...visibleKeys.value.keys()].findIndex((k) => arrayEquals(k, key)) === -1) {
fieldsWithValue.push({ key, value, enabled: false });
fieldsWithValue.push({ key, value, enabled: true });
}
}
}
Expand Down Expand Up @@ -149,7 +150,7 @@ function syntaxHighlight(json: any) {
} else if (/null/.test(match)) {
cls = "json-null";
}
return '<span class="' + cls + '">' + match + "</span>";
return `<span class="${cls}">${match}</span>`;
},
);
}
Expand Down
14 changes: 9 additions & 5 deletions assets/models/LogEntry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ComputedRef, Ref } from "vue";
import { flattenJSON, getDeep } from "@/utils";
import { flattenJSON } from "@/utils";
import ComplexLogItem from "@/components/LogViewer/ComplexLogItem.vue";
import SimpleLogItem from "@/components/LogViewer/SimpleLogItem.vue";
import ContainerEventLogItem from "@/components/LogViewer/ContainerEventLogItem.vue";
Expand Down Expand Up @@ -85,10 +85,14 @@ export class ComplexLogEntry extends LogEntry<JSONObject> {
if (visibleKeys.value.size === 0) {
return flattenJSON(message);
} else {
const keys = Array.from(visibleKeys.value.entries())
.filter(([, value]) => value)
.map(([key]) => key);
return keys.reduce((acc, attr) => ({ ...acc, [attr.join(".")]: getDeep(message, attr) }), {});
const flatJSON = flattenJSON(message);
for (const [keys, enabled] of visibleKeys.value.entries()) {
const key = keys.join(".");
if (!enabled) {
delete flatJSON[key];
}
}
return flatJSON;
}
});
} else {
Expand Down
Loading