Files
2026-01-17 16:42:43 +02:00

232 lines
10 KiB
PHP

@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