mirror of
https://github.com/rajnandan1/kener.git
synced 2026-08-07 07:14:56 +00:00
Add monitoring status dropdown
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
name: string;
|
||||
}
|
||||
|
||||
type StatusFilter = "ALL" | "UP" | "DOWN" | "DEGRADED";
|
||||
|
||||
// Helper to format datetime as YYYY-MM-DDTHH:mm for datetime-local input
|
||||
function formatDateTimeForInput(date: Date): string {
|
||||
return format(date, "yyyy-MM-dd'T'HH:mm");
|
||||
@@ -68,12 +70,14 @@
|
||||
let pageNo = $state(1);
|
||||
let showFilters = $state(false);
|
||||
let monitorTagFilter = $state("ALL");
|
||||
let statusFilter = $state<StatusFilter>("ALL");
|
||||
let startDateTime = $state(formatDateTimeForInput(yesterday));
|
||||
let endDateTime = $state(formatDateTimeForInput(now));
|
||||
const limit = 50;
|
||||
|
||||
const hasActiveFilters = $derived(
|
||||
monitorTagFilter !== "ALL" ||
|
||||
statusFilter !== "ALL" ||
|
||||
startDateTime !== formatDateTimeForInput(yesterday) ||
|
||||
endDateTime !== formatDateTimeForInput(now)
|
||||
);
|
||||
@@ -113,6 +117,7 @@
|
||||
|
||||
function clearFilters() {
|
||||
monitorTagFilter = "ALL";
|
||||
statusFilter = "ALL";
|
||||
startDateTime = formatDateTimeForInput(yesterday);
|
||||
endDateTime = formatDateTimeForInput(now);
|
||||
pageNo = 1;
|
||||
@@ -189,12 +194,14 @@
|
||||
page: number;
|
||||
limit: number;
|
||||
monitor_tag: string;
|
||||
status: StatusFilter;
|
||||
start_time?: number;
|
||||
end_time?: number;
|
||||
} = {
|
||||
page: pageNo,
|
||||
limit,
|
||||
monitor_tag: monitorTagFilter
|
||||
monitor_tag: monitorTagFilter,
|
||||
status: statusFilter
|
||||
};
|
||||
|
||||
if (startDateTime) {
|
||||
@@ -241,6 +248,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleStatusChange(value: string | undefined) {
|
||||
if (value) {
|
||||
statusFilter = value as StatusFilter;
|
||||
}
|
||||
}
|
||||
|
||||
// Pagination
|
||||
function goToPage(page: number) {
|
||||
pageNo = page;
|
||||
@@ -304,6 +317,20 @@
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-muted-foreground text-xs font-medium">Status</span>
|
||||
<Select.Root type="single" value={statusFilter} onValueChange={handleStatusChange}>
|
||||
<Select.Trigger class="w-36">
|
||||
{statusFilter === "ALL" ? "All Statuses" : statusFilter}
|
||||
</Select.Trigger>
|
||||
<Select.Content>
|
||||
<Select.Item value="ALL">All Statuses</Select.Item>
|
||||
<Select.Item value="UP">UP</Select.Item>
|
||||
<Select.Item value="DOWN">DOWN</Select.Item>
|
||||
<Select.Item value="DEGRADED">DEGRADED</Select.Item>
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
</div>
|
||||
<Button size="sm" onclick={applyFilters}>
|
||||
<SearchIcon class="size-4" />
|
||||
Search
|
||||
|
||||
Reference in New Issue
Block a user