fix(web): metric monitor edit keeps for_sec 0 and allows 0 minutes
This commit is contained in:
@@ -114,7 +114,9 @@ export function MonitorForm({
|
||||
const [metric, setMetric] = useState<MetricKind>(initial?.target.metric ?? "disk_pct");
|
||||
const [threshold, setThreshold] = useState<number>(initial?.target.threshold ?? 90);
|
||||
const [mount, setMount] = useState(initial?.target.mount ?? "");
|
||||
const [forMin, setForMin] = useState(Math.round((initial?.for_sec ?? 300) / 60));
|
||||
// for_sec 0 is omitted from JSON, so an existing monitor without it means
|
||||
// "alert immediately"; only a new monitor gets the 5 minute default.
|
||||
const [forMin, setForMin] = useState(Math.round((initial ? (initial.for_sec ?? 0) : 300) / 60));
|
||||
const [selector, setSelector] = useState<Record<string, string>>(initial?.target.selector ?? {});
|
||||
|
||||
const { data: servers } = useQuery({ queryKey: ["servers"], queryFn: () => api.listServers() });
|
||||
@@ -356,7 +358,7 @@ export function MonitorForm({
|
||||
className={`${inputClass} font-mono tabular-nums`}
|
||||
value={forMin}
|
||||
onChange={(e) => setForMin(Number(e.target.value))}
|
||||
min={1}
|
||||
min={0}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user