Show enable status on front page

This commit is contained in:
myrmidex 2025-07-10 11:06:17 +02:00
parent 8f7dbf993d
commit 2d981081f2
3 changed files with 217 additions and 1 deletions

View file

@ -6,6 +6,7 @@
use App\Models\PlatformAccount; use App\Models\PlatformAccount;
use App\Models\PlatformChannel; use App\Models\PlatformChannel;
use App\Models\PlatformInstance; use App\Models\PlatformInstance;
use App\Services\SystemStatusService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\View; use Illuminate\View\View;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@ -16,7 +17,9 @@ public function index(): View|RedirectResponse
{ {
// Check if user needs onboarding // Check if user needs onboarding
if (!$this->needsOnboarding()) { if (!$this->needsOnboarding()) {
return redirect()->route('feeds.index'); $systemStatus = resolve(SystemStatusService::class)->getSystemStatus();
return view('pages.dashboard', compact('systemStatus'));
} }
return view('onboarding.welcome'); return view('onboarding.welcome');

View file

@ -0,0 +1,49 @@
<?php
namespace App\Services;
use App\Models\Feed;
use App\Models\FeedPlatformChannel;
use App\Models\PlatformChannel;
use App\Models\Setting;
class SystemStatusService
{
public function getSystemStatus(): array
{
$reasons = [];
$isEnabled = true;
if (!Setting::isArticleProcessingEnabled()) {
$isEnabled = false;
$reasons[] = 'Manually disabled by user';
}
if (!Feed::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active feeds configured';
}
if (!PlatformChannel::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active platform channels configured';
}
if (!FeedPlatformChannel::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active feed-to-channel routes configured';
}
return [
'is_enabled' => $isEnabled,
'status' => $isEnabled ? 'Enabled' : 'Disabled',
'status_class' => $isEnabled ? 'text-green-600' : 'text-red-600',
'reasons' => $reasons,
];
}
public function canProcessArticles(): bool
{
return $this->getSystemStatus()['is_enabled'];
}
}

View file

@ -0,0 +1,164 @@
@extends('layouts.app')
@section('content')
<div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
<div class="px-4 py-6 sm:px-0">
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-gray-900">Dashboard</h1>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- System Status Card -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
@if($systemStatus['is_enabled'])
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
<x-heroicon-o-check-circle class="w-5 h-5 text-green-600" />
</div>
@else
<div class="w-8 h-8 bg-red-100 rounded-full flex items-center justify-center">
<x-heroicon-o-x-circle class="w-5 h-5 text-red-600" />
</div>
@endif
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">System Status</dt>
<dd class="text-lg font-medium {{ $systemStatus['status_class'] }}">
{{ $systemStatus['status'] }}
</dd>
</dl>
</div>
</div>
@if(!$systemStatus['is_enabled'] && count($systemStatus['reasons']) > 0)
<div class="mt-4 pt-4 border-t border-gray-200">
<h4 class="text-sm font-medium text-gray-700 mb-2">Reasons for being disabled:</h4>
<ul class="text-sm text-gray-600 space-y-1">
@foreach($systemStatus['reasons'] as $reason)
<li class="flex items-center">
<x-heroicon-o-exclamation-triangle class="w-4 h-4 text-yellow-500 mr-2 flex-shrink-0" />
{{ $reason }}
</li>
@endforeach
</ul>
</div>
@endif
@if(!$systemStatus['is_enabled'])
<div class="mt-4 pt-4 border-t border-gray-200">
<div class="flex space-x-3">
<a href="{{ route('settings.index') }}" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">
<x-heroicon-o-cog-6-tooth class="w-4 h-4 mr-1" />
Settings
</a>
<a href="{{ route('feeds.index') }}" class="inline-flex items-center px-3 py-2 border border-gray-300 text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
<x-heroicon-o-rss class="w-4 h-4 mr-1" />
Feeds
</a>
</div>
</div>
@endif
</div>
</div>
<!-- Quick Stats -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-chart-bar class="w-6 h-6 text-gray-400" />
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Quick Stats</dt>
<dd class="text-lg font-medium text-gray-900">Coming Soon</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Recent Activity -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-clock class="w-6 h-6 text-gray-400" />
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Recent Activity</dt>
<dd class="text-lg font-medium text-gray-900">
<a href="{{ route('logs') }}" class="text-blue-600 hover:text-blue-800">View Logs</a>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<!-- Navigation Cards -->
<div class="mt-8 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<a href="{{ route('feeds.index') }}" class="bg-white overflow-hidden shadow rounded-lg hover:shadow-md transition-shadow">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-rss class="w-8 h-8 text-orange-500" />
</div>
<div class="ml-5">
<h3 class="text-lg font-medium text-gray-900">Feeds</h3>
<p class="text-sm text-gray-500">Manage content sources</p>
</div>
</div>
</div>
</a>
<a href="{{ route('platforms.index') }}" class="bg-white overflow-hidden shadow rounded-lg hover:shadow-md transition-shadow">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-share class="w-8 h-8 text-blue-500" />
</div>
<div class="ml-5">
<h3 class="text-lg font-medium text-gray-900">Platforms</h3>
<p class="text-sm text-gray-500">Manage platform accounts</p>
</div>
</div>
</div>
</a>
<a href="{{ route('channels.index') }}" class="bg-white overflow-hidden shadow rounded-lg hover:shadow-md transition-shadow">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-hashtag class="w-8 h-8 text-purple-500" />
</div>
<div class="ml-5">
<h3 class="text-lg font-medium text-gray-900">Channels</h3>
<p class="text-sm text-gray-500">Manage publishing channels</p>
</div>
</div>
</div>
</a>
<a href="{{ route('routing.index') }}" class="bg-white overflow-hidden shadow rounded-lg hover:shadow-md transition-shadow">
<div class="px-4 py-5 sm:p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
<x-heroicon-o-arrow-path class="w-8 h-8 text-green-500" />
</div>
<div class="ml-5">
<h3 class="text-lg font-medium text-gray-900">Routing</h3>
<p class="text-sm text-gray-500">Configure feed routing</p>
</div>
</div>
</div>
</a>
</div>
</div>
</div>
@endsection