mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 21:33:18 +01:00
fix: unfound fields are shown by default instead of hidden (#3342)
This commit is contained in:
@@ -48,7 +48,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="w-60">Field</th>
|
<th class="w-60">Field</th>
|
||||||
<th class="mobile-hidden">Value</th>
|
<th class="mobile-hidden">Value</th>
|
||||||
<th class="w-20"><input type="checkbox" class="toggle toggle-primary" @change="toggleAll($event)" /></th>
|
<th class="w-20">
|
||||||
|
<input type="checkbox" class="toggle toggle-primary" v-model="toggleAllFields" title="Toggle all" />
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody ref="list">
|
<tbody ref="list">
|
||||||
@@ -85,21 +87,11 @@ function toggleField(key: string[]) {
|
|||||||
visibleKeys.value = new Map<string[], boolean>(fields.value.map(({ key }) => [key, true]));
|
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);
|
visibleKeys.value.set(key, !enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleAll(e: Event) {
|
|
||||||
if (visibleKeys.value.size === 0) {
|
|
||||||
visibleKeys.value = new Map<string[], boolean>(fields.value.map(({ key }) => [key, true]));
|
|
||||||
}
|
|
||||||
|
|
||||||
const enabled = e.target instanceof HTMLInputElement && e.target.checked;
|
|
||||||
for (const key of visibleKeys.value.keys()) {
|
|
||||||
visibleKeys.value.set(key, enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const fields = computed({
|
const fields = computed({
|
||||||
get() {
|
get() {
|
||||||
const fieldsWithValue: { key: string[]; value: any; enabled: boolean }[] = [];
|
const fieldsWithValue: { key: string[]; value: any; enabled: boolean }[] = [];
|
||||||
@@ -116,7 +108,7 @@ const fields = computed({
|
|||||||
|
|
||||||
for (const [key, value] of allFields) {
|
for (const [key, value] of allFields) {
|
||||||
if ([...visibleKeys.value.keys()].findIndex((k) => arrayEquals(k, key)) === -1) {
|
if ([...visibleKeys.value.keys()].findIndex((k) => arrayEquals(k, key)) === -1) {
|
||||||
fieldsWithValue.push({ key, value, enabled: false });
|
fieldsWithValue.push({ key, value, enabled: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +124,18 @@ const fields = computed({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const toggleAllFields = computed({
|
||||||
|
get: () => fields.value.every(({ enabled }) => enabled),
|
||||||
|
set(value) {
|
||||||
|
if (visibleKeys.value.size === 0) {
|
||||||
|
visibleKeys.value = new Map<string[], boolean>(fields.value.map(({ key }) => [key, true]));
|
||||||
|
}
|
||||||
|
for (const key of visibleKeys.value.keys()) {
|
||||||
|
visibleKeys.value.set(key, value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
function syntaxHighlight(json: any) {
|
function syntaxHighlight(json: any) {
|
||||||
json = JSON.stringify(json, null, 2);
|
json = JSON.stringify(json, null, 2);
|
||||||
return json.replace(
|
return json.replace(
|
||||||
@@ -149,7 +153,7 @@ function syntaxHighlight(json: any) {
|
|||||||
} else if (/null/.test(match)) {
|
} else if (/null/.test(match)) {
|
||||||
cls = "json-null";
|
cls = "json-null";
|
||||||
}
|
}
|
||||||
return '<span class="' + cls + '">' + match + "</span>";
|
return `<span class="${cls}">${match}</span>`;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, ComputedRef, Ref } from "vue";
|
import { Component, ComputedRef, Ref } from "vue";
|
||||||
import { flattenJSON, getDeep } from "@/utils";
|
import { flattenJSON } from "@/utils";
|
||||||
import ComplexLogItem from "@/components/LogViewer/ComplexLogItem.vue";
|
import ComplexLogItem from "@/components/LogViewer/ComplexLogItem.vue";
|
||||||
import SimpleLogItem from "@/components/LogViewer/SimpleLogItem.vue";
|
import SimpleLogItem from "@/components/LogViewer/SimpleLogItem.vue";
|
||||||
import ContainerEventLogItem from "@/components/LogViewer/ContainerEventLogItem.vue";
|
import ContainerEventLogItem from "@/components/LogViewer/ContainerEventLogItem.vue";
|
||||||
@@ -85,10 +85,14 @@ export class ComplexLogEntry extends LogEntry<JSONObject> {
|
|||||||
if (visibleKeys.value.size === 0) {
|
if (visibleKeys.value.size === 0) {
|
||||||
return flattenJSON(message);
|
return flattenJSON(message);
|
||||||
} else {
|
} else {
|
||||||
const keys = Array.from(visibleKeys.value.entries())
|
const flatJSON = flattenJSON(message);
|
||||||
.filter(([, value]) => value)
|
for (const [keys, enabled] of visibleKeys.value.entries()) {
|
||||||
.map(([key]) => key);
|
const key = keys.join(".");
|
||||||
return keys.reduce((acc, attr) => ({ ...acc, [attr.join(".")]: getDeep(message, attr) }), {});
|
if (!enabled) {
|
||||||
|
delete flatJSON[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flatJSON;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user