64 lines
3.9 KiB
PHP
64 lines
3.9 KiB
PHP
<div class="space-y-6">
|
|||
|
|
<div>
|
||
|
|
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Alert Name</label>
|
||
|
|
<input type="text" name="name" id="name" value="{{ old('name', $alert->name ?? '') }}" required
|
||
|
|
placeholder="e.g. Traffic spike alert"
|
||
|
|
class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
@error('name') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||
|
|
<div>
|
||
|
|
<label for="metric" class="block text-sm font-medium text-gray-700 mb-1">Metric</label>
|
||
|
|
<select name="metric" id="metric" class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
@foreach (\App\Models\Alert::$metrics as $value => $label)
|
||
|
|
<option value="{{ $value }}" @selected(old('metric', $alert->metric ?? '') === $value)>{{ $label }}</option>
|
||
|
|
@endforeach
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<label for="condition" class="block text-sm font-medium text-gray-700 mb-1">Condition</label>
|
||
|
|
<select name="condition" id="condition" class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
@foreach (\App\Models\Alert::$conditions as $value => $label)
|
||
|
|
<option value="{{ $value }}" @selected(old('condition', $alert->condition ?? '') === $value)>{{ $label }}</option>
|
||
|
|
@endforeach
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<label for="threshold" class="block text-sm font-medium text-gray-700 mb-1">Threshold</label>
|
||
|
|
<input type="number" name="threshold" id="threshold" value="{{ old('threshold', $alert->threshold ?? '') }}" required step="0.01" min="0"
|
||
|
|
class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||
|
|
placeholder="e.g. 1000">
|
||
|
|
@error('threshold') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||
|
|
<div>
|
||
|
|
<label for="period" class="block text-sm font-medium text-gray-700 mb-1">Check Period</label>
|
||
|
|
<select name="period" id="period" class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
<option value="daily" @selected(old('period', $alert->period ?? 'daily') === 'daily')>Daily</option>
|
||
|
|
<option value="hourly" @selected(old('period', $alert->period ?? '') === 'hourly')>Hourly</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div>
|
||
|
|
<label for="channel" class="block text-sm font-medium text-gray-700 mb-1">Notification Channel</label>
|
||
|
|
<select name="channel" id="channel" class="block w-full rounded-lg border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||
|
|
<option value="email" @selected(old('channel', $alert->channel ?? 'email') === 'email')>Email</option>
|
||
|
|
<option value="in_app" @selected(old('channel', $alert->channel ?? '') === 'in_app')>In-App Only</option>
|
||
|
|
<option value="both" @selected(old('channel', $alert->channel ?? '') === 'both')>Both</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="flex items-center gap-3 pt-2">
|
||
|
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-indigo-600 rounded-lg text-sm font-medium text-white hover:bg-indigo-500 transition">
|
||
|
|
{{ isset($alert->id) ? 'Update Alert' : 'Create Alert' }}
|
||
|
|
</button>
|
||
|
|
<a href="{{ route('alerts.index', $website) }}" class="text-sm text-gray-500 hover:text-gray-700 transition">Cancel</a>
|
||
|
|
</div>
|
||
|
|
</div>
|