mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 18:56:17 +01:00
[Feature] Add Alerts History page (#973)
* Add alert history * refactor * fix one colunm * update migration * add retention
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user