mirror of
https://github.com/amir20/dozzle.git
synced 2026-06-23 04:10:12 +00:00
f17b758fdf
Co-authored-by: lingfish <jason@lucid.net.au> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
28 lines
915 B
TypeScript
28 lines
915 B
TypeScript
import { ComplexLogEntry, type LogMessage, type LogEntry } from "@/models/LogEntry";
|
|
|
|
export function useVisibleFilter(visibleKeys: Ref<Map<string[], boolean>>) {
|
|
const { isSearching, inverseFilter } = useSearchFilter();
|
|
function filteredPayload(messages: Ref<LogEntry<LogMessage>[]>) {
|
|
return computed(() => {
|
|
return messages.value
|
|
.map((d) => {
|
|
if (d instanceof ComplexLogEntry) {
|
|
return ComplexLogEntry.fromLogEvent(d, visibleKeys);
|
|
} else {
|
|
return d;
|
|
}
|
|
})
|
|
.filter((d) => {
|
|
if (isSearching.value && d instanceof ComplexLogEntry) {
|
|
const hasMark = Object.values(d.message).some((v) => JSON.stringify(v)?.includes("<mark>"));
|
|
return inverseFilter.value ? !hasMark : hasMark;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
return { filteredPayload };
|
|
}
|