From e05e1834ccd5a393fe3d8095c7d730e658677c2d Mon Sep 17 00:00:00 2001 From: dieriba Date: Thu, 15 May 2025 11:03:16 +0200 Subject: [PATCH] nit queue metrics drawer (#5745) --- backend/windmill-api/openapi.yaml | 36 ++++++++++++++++++- .../lib/components/QueueMetricsDrawer.svelte | 36 ++++++++----------- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index b1a90bafb1..11def94a0a 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -11028,7 +11028,11 @@ paths: description: a config content: application/json: - schema: {} + type: object + schema: + oneOf: + - $ref: "#/components/schemas/Configs" + - type: "null" /configs/update/{name}: post: @@ -13183,6 +13187,36 @@ components: code_completion_model: $ref: "#/components/schemas/AIProviderModel" + Alert: + type: object + properties: + name: + type: string + tags_to_monitor: + type: array + items: + type: string + jobs_num_threshold: + type: integer + alert_cooldown_seconds: + type: integer + alert_time_threshold_seconds: + type: integer + required: + - name + - tags_to_monitor + - jobs_num_threshold + - alert_cooldown_seconds + - alert_time_threshold_seconds + + Configs: + type: object + properties: + alerts: + type: array + items: + $ref: '#/components/schemas/Alert' + Script: type: object properties: diff --git a/frontend/src/lib/components/QueueMetricsDrawer.svelte b/frontend/src/lib/components/QueueMetricsDrawer.svelte index d7ed0c6866..dd4ad426fa 100644 --- a/frontend/src/lib/components/QueueMetricsDrawer.svelte +++ b/frontend/src/lib/components/QueueMetricsDrawer.svelte @@ -2,7 +2,7 @@ import { onMount } from 'svelte' import { Drawer, DrawerContent, Button } from './common' import QueueMetricsDrawerInner from './QueueMetricsDrawerInner.svelte' - import { ConfigService } from '$lib/gen' + import { ConfigService, type Alert } from '$lib/gen' import Section from './Section.svelte' import { sendUserToast } from '$lib/toast' import { Pencil, Trash, Check, PlusCircle, SaveIcon } from 'lucide-svelte' @@ -21,14 +21,6 @@ } } - type Alert = { - name: string - tags_to_monitor: string[] - jobs_num_threshold: number - alert_cooldown_seconds: number - alert_time_threshold_seconds: number - } - let drawer: Drawer export function openDrawer() { drawer?.openDrawer() @@ -55,8 +47,8 @@ async function fetchConfig() { try { - const response = (await ConfigService.getConfig({ name: configName })) as { alerts: Alert[] } - alerts = response.alerts || [] + const response = await ConfigService.getConfig({ name: configName }) + alerts = response?.alerts || [] originalAlerts = JSON.parse(JSON.stringify(alerts)) } catch (error) { console.error('Failed to fetch config:', error) @@ -298,7 +290,9 @@ filterTags(e)} disabled={workerTags.length === alert.tags_to_monitor.length} class="p-1 flex-grow mr-1" @@ -321,15 +315,15 @@ > {#each filteredTags as tag} {#if !alert.tags_to_monitor.includes(tag)} -
  • - -
  • +
  • + +
  • {/if} {/each}