[Feature] Add Alerts History page (#973)

* Add alert history

* refactor

* fix one colunm

* update migration

* add retention
This commit is contained in:
Sven van Ginkel
2025-07-21 01:20:51 +02:00
committed by GitHub
parent 3730a78e5a
commit 9d7fb8ab80
13 changed files with 762 additions and 213 deletions

View File

@@ -17,11 +17,16 @@ export default function SettingsProfilePage({ userSettings }: { userSettings: Us
const [isLoading, setIsLoading] = useState(false)
const { i18n } = useLingui()
// Add state for alert history retention
const [alertHistoryRetention, setAlertHistoryRetention] = useState(userSettings.alertHistoryRetention || "3m")
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault()
setIsLoading(true)
const formData = new FormData(e.target as HTMLFormElement)
const data = Object.fromEntries(formData) as Partial<UserSettings>
// Add alertHistoryRetention to data
data.alertHistoryRetention = alertHistoryRetention
await saveSettings(data)
setIsLoading(false)
}
@@ -182,6 +187,27 @@ export default function SettingsProfilePage({ userSettings }: { userSettings: Us
</div>
</div>
<Separator />
<div>
<Label htmlFor="alertHistoryRetention">
<Trans>Alert History Retention</Trans>
</Label>
<Select
name="alertHistoryRetention"
value={alertHistoryRetention}
onValueChange={setAlertHistoryRetention}
>
<SelectTrigger className="w-64 mt-1">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="1m">1 month</SelectItem>
<SelectItem value="3m">3 months</SelectItem>
<SelectItem value="6m">6 months</SelectItem>
<SelectItem value="1y">1 year</SelectItem>
</SelectContent>
</Select>
</div>
<Separator />
<Button type="submit" className="flex items-center gap-1.5 disabled:opacity-100" disabled={isLoading}>
{isLoading ? <LoaderCircleIcon className="h-4 w-4 animate-spin" /> : <SaveIcon className="h-4 w-4" />}
<Trans>Save Settings</Trans>