refactor: format markdown files using prettier, fix spelling concerns, reduce Taskfile bloat
This commit is contained in:
608 files changed
+63317
-10219
No files matched your search
@@ -2,7 +2,14 @@
|
||||
import { computed, onUnmounted, ref, watch } from "vue";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { LOG_LEVELS } from "@/lib/log";
|
||||
import { componentOptions, filters } from "./state";
|
||||
|
||||
@@ -22,7 +29,10 @@ const ALL = "__all__";
|
||||
|
||||
// LOG_LEVELS' values are a wire contract: the server matches that CSV
|
||||
// server-side, so the labels are paired with them here and never rewritten.
|
||||
const levelOptions = LOG_LEVELS.map((option) => ({ value: option.value || ALL, label: option.label }));
|
||||
const levelOptions = LOG_LEVELS.map((option) => ({
|
||||
value: option.value || ALL,
|
||||
label: option.label,
|
||||
}));
|
||||
const componentSelectOptions = computed(() => [
|
||||
{ value: ALL, label: "All components" },
|
||||
...componentOptions.value.map((name) => ({ value: name, label: name })),
|
||||
@@ -63,7 +73,11 @@ onUnmounted(() => clearTimeout(searchTimer));
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="option in levelOptions" :key="option.value" :value="option.value">
|
||||
<SelectItem
|
||||
v-for="option in levelOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
@@ -76,7 +90,11 @@ onUnmounted(() => clearTimeout(searchTimer));
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="option in componentSelectOptions" :key="option.value" :value="option.value">
|
||||
<SelectItem
|
||||
v-for="option in componentSelectOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
|
||||
+25
-4
@@ -17,7 +17,16 @@ import { emptyDetail, emptyTitle, entries, loading, readError } from "./state";
|
||||
|
||||
// Varied widths, so the placeholder reads as lines of a log rather than a
|
||||
// table waiting to be filled.
|
||||
const SKELETON_ROWS = ["w-11/12", "w-3/4", "w-5/6", "w-2/3", "w-11/12", "w-1/2", "w-5/6", "w-3/4"];
|
||||
const SKELETON_ROWS = [
|
||||
"w-11/12",
|
||||
"w-3/4",
|
||||
"w-5/6",
|
||||
"w-2/3",
|
||||
"w-11/12",
|
||||
"w-1/2",
|
||||
"w-5/6",
|
||||
"w-3/4",
|
||||
];
|
||||
|
||||
const scroller = ref<HTMLElement | null>(null);
|
||||
|
||||
@@ -39,10 +48,22 @@ watch(
|
||||
<!-- A failed read is about this page's request, not about the log, so it
|
||||
says what the server said rather than borrowing an empty state. -->
|
||||
<LogsEmpty v-if="readError" title="Cannot read logs" :detail="readError" />
|
||||
<div v-else-if="loading && !entries.length" class="flex flex-col gap-3 px-3 py-4">
|
||||
<Skeleton v-for="(width, i) in SKELETON_ROWS" :key="i" class="h-3" :class="width" />
|
||||
<div
|
||||
v-else-if="loading && !entries.length"
|
||||
class="flex flex-col gap-3 px-3 py-4"
|
||||
>
|
||||
<Skeleton
|
||||
v-for="(width, i) in SKELETON_ROWS"
|
||||
:key="i"
|
||||
class="h-3"
|
||||
:class="width"
|
||||
/>
|
||||
</div>
|
||||
<LogsEmpty v-else-if="!entries.length" :title="emptyTitle" :detail="emptyDetail" />
|
||||
<LogsEmpty
|
||||
v-else-if="!entries.length"
|
||||
:title="emptyTitle"
|
||||
:detail="emptyDetail"
|
||||
/>
|
||||
<template v-else>
|
||||
<LogRow v-for="entry in entries" :key="entryKey(entry)" :entry="entry" />
|
||||
</template>
|
||||
|
||||
@@ -11,7 +11,9 @@ import { meta, streamKind, streamState } from "./state";
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<span class="min-w-0 break-words font-mono text-xs text-fg-subtle">{{ meta }}</span>
|
||||
<span class="min-w-0 break-words font-mono text-xs text-fg-subtle">{{
|
||||
meta
|
||||
}}</span>
|
||||
<Badge :variant="streamKind">{{ streamState }}</Badge>
|
||||
</div>
|
||||
</template>
|
||||
@@ -12,7 +12,9 @@ import LogStatus from "./LogStatus.vue";
|
||||
<!-- gap-0 so the header's rule sits on the list rather than a card gap above
|
||||
it; the rows carry their own separators. -->
|
||||
<Card class="gap-0">
|
||||
<CardHeader class="flex flex-wrap items-center justify-between gap-3 border-b">
|
||||
<CardHeader
|
||||
class="flex flex-wrap items-center justify-between gap-3 border-b"
|
||||
>
|
||||
<LogFilters />
|
||||
<LogStatus />
|
||||
</CardHeader>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import {
|
||||
Empty,
|
||||
EmptyDescription,
|
||||
EmptyHeader,
|
||||
EmptyTitle,
|
||||
} from "@/components/ui/empty";
|
||||
|
||||
/**
|
||||
* The list's nothing-to-show state: a title that names the situation and a
|
||||
|
||||
@@ -30,13 +30,18 @@ export function entryKey(entry: LogEntry): string {
|
||||
* internal/webui/api_tasks_logs.go).
|
||||
*/
|
||||
export function matchesFilters(entry: LogEntry, filters: LogFilters): boolean {
|
||||
if (filters.level && !filters.level.split(",").includes((entry.level || "").toUpperCase())) {
|
||||
if (
|
||||
filters.level &&
|
||||
!filters.level.split(",").includes((entry.level || "").toUpperCase())
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (filters.component && entry.fields?.component !== filters.component) return false;
|
||||
if (filters.component && entry.fields?.component !== filters.component)
|
||||
return false;
|
||||
if (filters.q) {
|
||||
const needle = filters.q.toLowerCase();
|
||||
const hay = `${entry.message || entry.msg || ""} ${JSON.stringify(entry.fields || {})}`.toLowerCase();
|
||||
const hay =
|
||||
`${entry.message || entry.msg || ""} ${JSON.stringify(entry.fields || {})}`.toLowerCase();
|
||||
if (!hay.includes(needle)) return false;
|
||||
}
|
||||
return true;
|
||||
@@ -58,5 +63,7 @@ export function mergeEntries(
|
||||
const byID = new Map<string, LogEntry>();
|
||||
for (const entry of history) byID.set(entryKey(entry), entry);
|
||||
for (const [id, entry] of live) byID.set(id, entry);
|
||||
return [...byID.values()].filter((entry) => matchesFilters(entry, filters)).slice(-1000);
|
||||
return [...byID.values()]
|
||||
.filter((entry) => matchesFilters(entry, filters))
|
||||
.slice(-1000);
|
||||
}
|
||||
@@ -8,7 +8,10 @@
|
||||
* logsEmptyTitle names the situation: a dead stream, a deployment with no
|
||||
* durable history, or filters that match nothing.
|
||||
*/
|
||||
export function logsEmptyTitle(durableUnavailable: boolean, streamState: string): string {
|
||||
export function logsEmptyTitle(
|
||||
durableUnavailable: boolean,
|
||||
streamState: string,
|
||||
): string {
|
||||
if (streamState === "unavailable") return "Log stream unavailable";
|
||||
if (durableUnavailable) return "No logs yet";
|
||||
return "Nothing matches";
|
||||
@@ -18,7 +21,10 @@ export function logsEmptyTitle(durableUnavailable: boolean, streamState: string)
|
||||
* logsEmptyDetail says what to expect next, and never promises live logs from
|
||||
* a stream that has stopped.
|
||||
*/
|
||||
export function logsEmptyDetail(durableUnavailable: boolean, streamState: string): string {
|
||||
export function logsEmptyDetail(
|
||||
durableUnavailable: boolean,
|
||||
streamState: string,
|
||||
): string {
|
||||
if (streamState === "unavailable") {
|
||||
return "The log stream will reconnect automatically.";
|
||||
}
|
||||
|
||||
+24
-6
@@ -4,7 +4,12 @@ import { api, subscribeLogs } from "@/lib/api";
|
||||
import type { LogEntry } from "@/lib/log";
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
import type { StreamState } from "@/lib/stream-state";
|
||||
import { entryKey, matchesFilters, mergeEntries, type LogFilters } from "./log-entries";
|
||||
import {
|
||||
entryKey,
|
||||
matchesFilters,
|
||||
mergeEntries,
|
||||
type LogFilters,
|
||||
} from "./log-entries";
|
||||
import { logsEmptyDetail, logsEmptyTitle } from "./logs-empty";
|
||||
|
||||
/**
|
||||
@@ -25,7 +30,11 @@ interface LogHistory {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export const filters = reactive<LogFilters>({ level: "", component: "", q: "" });
|
||||
export const filters = reactive<LogFilters>({
|
||||
level: "",
|
||||
component: "",
|
||||
q: "",
|
||||
});
|
||||
|
||||
/** The components the filter can name: those the server found, plus any the
|
||||
* live stream has shown since. */
|
||||
@@ -58,7 +67,8 @@ export const meta = computed(() => {
|
||||
if (readError.value) return "Cannot read logs";
|
||||
if (loading.value) return "Refreshing…";
|
||||
if (durableUnavailable.value) return "Live only";
|
||||
if (truncated.value) return `showing the most recent matches from ${logFile.value}`;
|
||||
if (truncated.value)
|
||||
return `showing the most recent matches from ${logFile.value}`;
|
||||
return logFile.value;
|
||||
});
|
||||
|
||||
@@ -71,8 +81,12 @@ export const streamKind = computed<StatusKind>(() => {
|
||||
});
|
||||
|
||||
/** Which of the nothing-to-show situations the list is in. */
|
||||
export const emptyTitle = computed(() => logsEmptyTitle(durableUnavailable.value, streamState.value));
|
||||
export const emptyDetail = computed(() => logsEmptyDetail(durableUnavailable.value, streamState.value));
|
||||
export const emptyTitle = computed(() =>
|
||||
logsEmptyTitle(durableUnavailable.value, streamState.value),
|
||||
);
|
||||
export const emptyDetail = computed(() =>
|
||||
logsEmptyDetail(durableUnavailable.value, streamState.value),
|
||||
);
|
||||
|
||||
export async function loadLogs(): Promise<void> {
|
||||
loading.value = true;
|
||||
@@ -109,7 +123,11 @@ function handleEntry(raw: unknown): void {
|
||||
|
||||
liveEntries.set(entryKey(entry), entry);
|
||||
const component = entry.fields?.component;
|
||||
if (typeof component === "string" && component && !componentOptions.value.includes(component)) {
|
||||
if (
|
||||
typeof component === "string" &&
|
||||
component &&
|
||||
!componentOptions.value.includes(component)
|
||||
) {
|
||||
componentOptions.value = [...componentOptions.value, component];
|
||||
}
|
||||
liveTick.value += 1;
|
||||
|
||||
Reference in new issue
Block a user