some progress

This commit is contained in:
Doar Mihai
2026-01-17 16:42:43 +02:00
parent 030a105992
commit 3665a1d5a3
57 changed files with 5804 additions and 3 deletions
@@ -0,0 +1,141 @@
@extends('layouts.app')
@section('title', 'Add Health Check - ' . $site->name)
@section('content')
<div class="mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('sites.index') }}">Sites</a></li>
<li class="breadcrumb-item"><a href="{{ route('dashboard.show', $site) }}">{{ $site->name }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('health-checks.index', $site) }}">Health Checks</a></li>
<li class="breadcrumb-item active">Add Health Check</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-8">
<h1 class="mb-4"><i class="bi bi-plus-circle"></i> Add Health Check</h1>
<div class="card">
<div class="card-body">
<form action="{{ route('health-checks.store', $site) }}" method="POST">
@csrf
<div class="mb-3">
<label for="endpoint" class="form-label">Health Endpoint Path</label>
<div class="input-group">
<span class="input-group-text">{{ rtrim($site->url, '/') }}/</span>
<input type="text"
class="form-control @error('endpoint') is-invalid @enderror"
id="endpoint"
name="endpoint"
value="{{ old('endpoint') }}"
placeholder="health"
required>
@error('endpoint')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="form-text">Enter the path to your health check endpoint (e.g., "health", "api/health", "status").</div>
</div>
<div class="mb-3">
<label for="expected_json_keys" class="form-label">Expected JSON Keys (Optional)</label>
<input type="text"
class="form-control @error('expected_json_keys') is-invalid @enderror"
id="expected_json_keys"
name="expected_json_keys"
value="{{ old('expected_json_keys') }}"
placeholder="status, database, cache">
@error('expected_json_keys')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
<div class="form-text">
Comma-separated list of JSON keys that must be present in the response. Supports dot notation for nested keys (e.g., "data.status, meta.version").
</div>
</div>
<div class="mb-3">
<label for="performance_threshold" class="form-label">Performance Threshold (Optional)</label>
<div class="input-group">
<input type="number"
class="form-control @error('performance_threshold') is-invalid @enderror"
id="performance_threshold"
name="performance_threshold"
value="{{ old('performance_threshold') }}"
min="1"
max="60000"
placeholder="1000">
<span class="input-group-text">ms</span>
@error('performance_threshold')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="form-text">
Alert when response time exceeds this threshold in milliseconds. Leave empty to disable performance alerts.
</div>
</div>
<div class="mb-3">
<div class="form-check">
<input type="checkbox"
class="form-check-input"
id="is_active"
name="is_active"
value="1"
{{ old('is_active', true) ? 'checked' : '' }}>
<label class="form-check-label" for="is_active">
Enable monitoring for this health check
</label>
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-circle"></i> Add Health Check
</button>
<a href="{{ route('health-checks.index', $site) }}" class="btn btn-secondary">
Cancel
</a>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h5 class="mb-0"><i class="bi bi-info-circle"></i> Health Check Guide</h5>
</div>
<div class="card-body">
<h6>What is a Health Check?</h6>
<p class="small">
A health check endpoint is a URL that returns information about your application's status, including database connectivity, cache availability, and other critical services.
</p>
<h6 class="mt-3">Common Endpoints</h6>
<ul class="small mb-0">
<li><code>/health</code></li>
<li><code>/api/health</code></li>
<li><code>/status</code></li>
<li><code>/healthz</code></li>
<li><code>/.well-known/health</code></li>
</ul>
<h6 class="mt-3">Response Format</h6>
<p class="small mb-0">
Your endpoint should return JSON with a 2xx status code when healthy. Example:
</p>
<pre class="small bg-light p-2 mt-2"><code>{
"status": "healthy",
"database": "ok",
"cache": "ok"
}</code></pre>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,149 @@
@extends('layouts.app')
@section('title', 'Edit Health Check - ' . $site->name)
@section('content')
<div class="mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('sites.index') }}">Sites</a></li>
<li class="breadcrumb-item"><a href="{{ route('dashboard.show', $site) }}">{{ $site->name }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('health-checks.index', $site) }}">Health Checks</a></li>
<li class="breadcrumb-item active">Edit</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-md-8">
<h1 class="mb-4"><i class="bi bi-pencil"></i> Edit Health Check</h1>
<div class="card">
<div class="card-body">
<form action="{{ route('health-checks.update', [$site, $healthCheck]) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-3">
<label for="endpoint" class="form-label">Health Endpoint Path</label>
<div class="input-group">
<span class="input-group-text">{{ rtrim($site->url, '/') }}/</span>
<input type="text"
class="form-control @error('endpoint') is-invalid @enderror"
id="endpoint"
name="endpoint"
value="{{ old('endpoint', $healthCheck->endpoint) }}"
required>
@error('endpoint')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="form-text">Enter the path to your health check endpoint.</div>
</div>
<div class="mb-3">
<label for="expected_json_keys" class="form-label">Expected JSON Keys (Optional)</label>
<input type="text"
class="form-control @error('expected_json_keys') is-invalid @enderror"
id="expected_json_keys"
name="expected_json_keys"
value="{{ old('expected_json_keys', $healthCheck->expected_json_keys ? implode(', ', $healthCheck->expected_json_keys) : '') }}"
placeholder="status, database, cache">
@error('expected_json_keys')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
<div class="form-text">
Comma-separated list of JSON keys that must be present in the response. Supports dot notation for nested keys.
</div>
</div>
<div class="mb-3">
<label for="performance_threshold" class="form-label">Performance Threshold (Optional)</label>
<div class="input-group">
<input type="number"
class="form-control @error('performance_threshold') is-invalid @enderror"
id="performance_threshold"
name="performance_threshold"
value="{{ old('performance_threshold', $healthCheck->performance_threshold) }}"
min="1"
max="60000"
placeholder="1000">
<span class="input-group-text">ms</span>
@error('performance_threshold')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="form-text">
Alert when response time exceeds this threshold in milliseconds. Leave empty to disable performance alerts.
</div>
</div>
<div class="mb-3">
<div class="form-check">
<input type="checkbox"
class="form-check-input"
id="is_active"
name="is_active"
value="1"
{{ old('is_active', $healthCheck->is_active) ? 'checked' : '' }}>
<label class="form-check-label" for="is_active">
Enable monitoring for this health check
</label>
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-circle"></i> Update Health Check
</button>
<a href="{{ route('health-checks.show', [$site, $healthCheck]) }}" class="btn btn-secondary">
Cancel
</a>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h5 class="mb-0"><i class="bi bi-activity"></i> Current Status</h5>
</div>
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-5">Status:</dt>
<dd class="col-sm-7">
<span class="badge bg-{{ $healthCheck->status_color }}">
{{ $healthCheck->status_text }}
</span>
</dd>
<dt class="col-sm-5">Last Checked:</dt>
<dd class="col-sm-7">
@if($healthCheck->last_checked_at)
{{ $healthCheck->last_checked_at->diffForHumans() }}
@else
<span class="text-muted">Never</span>
@endif
</dd>
@if($healthCheck->status_code)
<dt class="col-sm-5">Status Code:</dt>
<dd class="col-sm-7">
<span class="badge bg-{{ $healthCheck->status_code < 300 ? 'success' : 'danger' }}">
{{ $healthCheck->status_code }}
</span>
</dd>
@endif
@if($healthCheck->response_time_ms)
<dt class="col-sm-5">Response Time:</dt>
<dd class="col-sm-7">{{ $healthCheck->response_time_ms }}ms</dd>
@endif
</dl>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,123 @@
@extends('layouts.app')
@section('title', 'Health Checks - ' . $site->name)
@section('content')
<div class="mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('sites.index') }}">Sites</a></li>
<li class="breadcrumb-item"><a href="{{ route('dashboard.show', $site) }}">{{ $site->name }}</a></li>
<li class="breadcrumb-item active">Health Checks</li>
</ol>
</nav>
</div>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1><i class="bi bi-heart-pulse"></i> Health Check Monitoring</h1>
<a href="{{ route('health-checks.create', $site) }}" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> Add Health Check
</a>
</div>
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
@endif
@if($healthChecks->isEmpty())
<div class="alert alert-info">
<i class="bi bi-info-circle"></i> No health check endpoints are being monitored for this site yet. Click "Add Health Check" to start monitoring.
</div>
@else
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Endpoint</th>
<th>Status</th>
<th>Status Code</th>
<th>Response Time</th>
<th>Last Checked</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($healthChecks as $healthCheck)
<tr>
<td>
<strong>{{ $healthCheck->endpoint }}</strong>
@if($healthCheck->expected_json_keys)
<br>
<small class="text-muted">
<i class="bi bi-key"></i> Validates: {{ implode(', ', $healthCheck->expected_json_keys) }}
</small>
@endif
</td>
<td>
<span class="badge bg-{{ $healthCheck->status_color }}">
{{ $healthCheck->status_text }}
</span>
</td>
<td>
@if($healthCheck->status_code)
<span class="badge bg-{{ $healthCheck->status_code < 300 ? 'success' : 'danger' }}">
{{ $healthCheck->status_code }}
</span>
@else
<span class="text-muted">—</span>
@endif
</td>
<td>
@if($healthCheck->response_time_ms)
{{ $healthCheck->response_time_ms }}ms
@else
<span class="text-muted">—</span>
@endif
</td>
<td>
@if($healthCheck->last_checked_at)
{{ $healthCheck->last_checked_at->diffForHumans() }}
@else
<span class="text-muted">Never</span>
@endif
</td>
<td>
@if($healthCheck->is_active)
<span class="badge bg-success">Active</span>
@else
<span class="badge bg-secondary">Inactive</span>
@endif
</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ route('health-checks.show', [$site, $healthCheck]) }}"
class="btn btn-outline-primary" title="View">
<i class="bi bi-eye"></i>
</a>
<a href="{{ route('health-checks.edit', [$site, $healthCheck]) }}"
class="btn btn-outline-secondary" title="Edit">
<i class="bi bi-pencil"></i>
</a>
<form action="{{ route('health-checks.destroy', [$site, $healthCheck]) }}"
method="POST"
class="d-inline"
onsubmit="return confirm('Are you sure you want to delete this health check?');">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-outline-danger" title="Delete">
<i class="bi bi-trash"></i>
</button>
</form>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
@endsection
@@ -0,0 +1,231 @@
@extends('layouts.app')
@section('title', 'Health Check - ' . $healthCheck->endpoint . ' - ' . $site->name)
@section('content')
<div class="mb-3">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('sites.index') }}">Sites</a></li>
<li class="breadcrumb-item"><a href="{{ route('dashboard.show', $site) }}">{{ $site->name }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('health-checks.index', $site) }}">Health Checks</a></li>
<li class="breadcrumb-item active">{{ $healthCheck->endpoint }}</li>
</ol>
</nav>
</div>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1><i class="bi bi-heart-pulse"></i> {{ $healthCheck->endpoint }}</h1>
<div class="btn-group">
<a href="{{ route('health-checks.edit', [$site, $healthCheck]) }}" class="btn btn-outline-secondary">
<i class="bi bi-pencil"></i> Edit
</a>
<form action="{{ route('health-checks.destroy', [$site, $healthCheck]) }}"
method="POST"
class="d-inline"
onsubmit="return confirm('Are you sure you want to delete this health check?');">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-outline-danger">
<i class="bi bi-trash"></i> Delete
</button>
</form>
</div>
</div>
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
@endif
<div class="row">
<div class="col-md-8">
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">Health Check Details</h5>
</div>
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-3">Site</dt>
<dd class="col-sm-9">
<a href="{{ route('dashboard.show', $site) }}">{{ $site->name }}</a>
<br>
<small class="text-muted">{{ $site->url }}</small>
</dd>
<dt class="col-sm-3">Endpoint URL</dt>
<dd class="col-sm-9">
<a href="{{ $healthCheck->full_url }}" target="_blank" rel="noopener">
{{ $healthCheck->full_url }}
<i class="bi bi-box-arrow-up-right"></i>
</a>
</dd>
<dt class="col-sm-3">Status</dt>
<dd class="col-sm-9">
<span class="badge bg-{{ $healthCheck->status_color }}">
{{ $healthCheck->status_text }}
</span>
</dd>
<dt class="col-sm-3">Monitoring</dt>
<dd class="col-sm-9">
@if($healthCheck->is_active)
<span class="badge bg-success">Active</span>
@else
<span class="badge bg-secondary">Inactive</span>
@endif
</dd>
<dt class="col-sm-3">Last Checked</dt>
<dd class="col-sm-9">
@if($healthCheck->last_checked_at)
{{ $healthCheck->last_checked_at->format('Y-m-d H:i:s') }}
<br>
<small class="text-muted">{{ $healthCheck->last_checked_at->diffForHumans() }}</small>
@else
<span class="text-muted">Never</span>
@endif
</dd>
@if($healthCheck->status_code)
<dt class="col-sm-3">Status Code</dt>
<dd class="col-sm-9">
<span class="badge bg-{{ $healthCheck->status_code < 300 ? 'success' : 'danger' }}">
{{ $healthCheck->status_code }}
</span>
</dd>
@endif
@if($healthCheck->response_time_ms)
<dt class="col-sm-3">Response Time</dt>
<dd class="col-sm-9">{{ $healthCheck->response_time_ms }}ms</dd>
@endif
<dt class="col-sm-3">Expected Keys</dt>
<dd class="col-sm-9">
@if($healthCheck->expected_json_keys && count($healthCheck->expected_json_keys) > 0)
@foreach($healthCheck->expected_json_keys as $key)
<span class="badge bg-info text-dark me-1">{{ $key }}</span>
@endforeach
@else
<span class="text-muted">None specified</span>
@endif
</dd>
<dt class="col-sm-3">Performance Threshold</dt>
<dd class="col-sm-9">
@if($healthCheck->performance_threshold)
<span class="badge bg-warning text-dark">{{ $healthCheck->performance_threshold }}ms</span>
@if($healthCheck->response_time_ms && $healthCheck->response_time_ms > $healthCheck->performance_threshold)
<br><small class="text-danger"><i class="bi bi-exclamation-triangle"></i> Currently exceeding threshold</small>
@endif
@else
<span class="text-muted">Not set</span>
@endif
</dd>
<dt class="col-sm-3">Created</dt>
<dd class="col-sm-9">
{{ $healthCheck->created_at->format('Y-m-d H:i:s') }}
<br>
<small class="text-muted">{{ $healthCheck->created_at->diffForHumans() }}</small>
</dd>
</dl>
</div>
</div>
@if($healthCheck->response_data)
<div class="card">
<div class="card-header">
<h5 class="mb-0">Latest Response Data</h5>
</div>
<div class="card-body">
@if(isset($healthCheck->response_data['error']))
<div class="alert alert-danger mb-0">
<i class="bi bi-exclamation-triangle"></i>
<strong>Error:</strong> {{ $healthCheck->response_data['error'] }}
</div>
@else
<pre class="bg-light p-3 rounded mb-0"><code>{{ json_encode($healthCheck->response_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}</code></pre>
@endif
</div>
</div>
@endif
</div>
<div class="col-md-4">
<div class="card mb-3">
<div class="card-header">
<h5 class="mb-0">Current Status</h5>
</div>
<div class="card-body text-center">
<div class="mb-3">
<span class="badge bg-{{ $healthCheck->status_color }} fs-5 px-4 py-2">
{{ $healthCheck->status_text }}
</span>
</div>
@if($healthCheck->is_healthy === true)
<p class="text-success mb-0">
<i class="bi bi-check-circle-fill"></i> All checks passed
</p>
@elseif($healthCheck->is_healthy === false)
<p class="text-danger mb-0">
<i class="bi bi-x-circle-fill"></i> Health check failed
</p>
@else
<p class="text-muted mb-0">
<i class="bi bi-question-circle"></i> Not yet checked
</p>
@endif
</div>
</div>
<div class="card mb-3">
<div class="card-header">
<h5 class="mb-0">Monitoring Info</h5>
</div>
<div class="card-body">
<p class="mb-2">
<i class="bi bi-clock"></i> <strong>Check Frequency:</strong> Every 5 minutes
</p>
<p class="mb-2">
<i class="bi bi-check2-square"></i> <strong>Requirements:</strong>
</p>
<ul class="small mb-0">
<li>2xx HTTP status code</li>
<li>Valid JSON response</li>
@if($healthCheck->expected_json_keys && count($healthCheck->expected_json_keys) > 0)
<li>Contains required keys: {{ implode(', ', $healthCheck->expected_json_keys) }}</li>
@endif
@if($healthCheck->performance_threshold)
<li class="text-warning">Performance alert if exceeds {{ $healthCheck->performance_threshold }}ms</li>
@endif
</ul>
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="mb-0">Quick Actions</h5>
</div>
<div class="card-body">
<div class="d-grid gap-2">
<a href="{{ route('health-checks.index', $site) }}" class="btn btn-outline-primary">
<i class="bi bi-list-ul"></i> View All Health Checks
</a>
<a href="{{ route('dashboard.show', $site) }}" class="btn btn-outline-secondary">
<i class="bi bi-bar-chart"></i> Site Dashboard
</a>
<a href="{{ $healthCheck->full_url }}" target="_blank" rel="noopener" class="btn btn-outline-info">
<i class="bi bi-box-arrow-up-right"></i> Open Endpoint
</a>
</div>
</div>
</div>
</div>
</div>
@endsection