mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
from django import forms
|
|
from .models import NginxSettings, NginxAlertProfile
|
|
|
|
|
|
class NginxSettingsForm(forms.ModelForm):
|
|
class Meta:
|
|
model = NginxSettings
|
|
fields = [
|
|
'namespace',
|
|
'pod_label',
|
|
'container',
|
|
'fetch_interval_seconds',
|
|
'log_file_path',
|
|
'enabled',
|
|
'excluded_ips',
|
|
]
|
|
widgets = {
|
|
'excluded_ips': forms.Textarea(attrs={
|
|
'rows': 4,
|
|
'placeholder': '192.168.1.218\n192.168.1.x\n192.168.1.0/24',
|
|
'class': 'font-mono text-xs',
|
|
}),
|
|
}
|
|
|
|
|
|
class NginxAlertProfileForm(forms.ModelForm):
|
|
class Meta:
|
|
model = NginxAlertProfile
|
|
fields = [
|
|
'name',
|
|
'alert_window_seconds',
|
|
'alert_max_requests',
|
|
'alert_max_error_rate',
|
|
'alert_min_requests',
|
|
'telegram_bot_token',
|
|
'telegram_chat_id',
|
|
'enabled',
|
|
]
|
|
widgets = {
|
|
'telegram_bot_token': forms.PasswordInput(render_value=True),
|
|
}
|
|
help_texts = {
|
|
'alert_max_error_rate': 'Value between 0 and 1, e.g. 0.6 = 60% errors.',
|
|
}
|
|
|
|
|
|
class PasteLogsForm(forms.Form):
|
|
log_text = forms.CharField(
|
|
widget=forms.Textarea(attrs={
|
|
'rows': 10,
|
|
'placeholder': 'Paste raw nginx ingress log lines here…',
|
|
'class': 'font-mono text-xs',
|
|
}),
|
|
label='Raw log lines',
|
|
)
|