Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Dec 6, 2024
1 parent aec8aa8 commit 887dbc2
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 18 deletions.
39 changes: 39 additions & 0 deletions web/Modules/Email/App/Filament/Pages/EmailHealthStatusPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Modules\Email\App\Filament\Pages;

use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Modules\Email\App\Models\EmailHealthStatus;

class EmailHealthStatusPage extends Page implements HasForms, HasTable
{

use InteractsWithTable;
use InteractsWithForms;

protected static ?string $navigationIcon = 'heroicon-o-heart';
protected static string $view = 'email::filament.pages.email-health-status';
protected static ?string $navigationGroup = 'Email';
protected static ?string $navigationLabel = 'Email Health Status';

public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('service')
->label('Service')
->sortable(),
TextColumn::make('status')
->label('Status')
->badge()
->sortable(),
])
->query(fn () => EmailHealthStatus::query());
}
}
41 changes: 41 additions & 0 deletions web/Modules/Email/App/Models/EmailHealthStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Modules\Email\App\Models;

use Illuminate\Database\Eloquent\Model;
use Modules\Email\App\Services\EmailHealthService;
use Sushi\Sushi;

class EmailHealthStatus extends Model
{
use Sushi;

protected $schema = [
'service' => 'string',
'status' => 'string',
];

public function getRows()
{
$service = new EmailHealthService();

return [
[
'service' => 'Dovecot',
'status' => $service->checkDovecotStatus(),
],
[
'service' => 'Postfix',
'status' => $service->checkPostfixStatus(),
],
[
'service' => 'OpenDKIM',
'status' => $service->checkOpenDkimStatus(),
],
[
'service' => 'Firewall',
'status' => $service->checkFirewallStatus(),
],
];
}
}
32 changes: 32 additions & 0 deletions web/Modules/Email/App/Services/EmailHealthService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Modules\Email\App\Services;

class EmailHealthService
{
public function checkDovecotStatus(): string
{
return $this->checkServiceStatus('dovecot');
}

public function checkPostfixStatus(): string
{
return $this->checkServiceStatus('postfix');
}

public function checkOpenDkimStatus(): string
{
return $this->checkServiceStatus('opendkim');
}

public function checkFirewallStatus(): string
{
return shell_exec('sudo ufw status');
}

private function checkServiceStatus(string $serviceName): string
{
$status = shell_exec("systemctl is-active $serviceName");
return trim($status) === 'active' ? 'Running' : 'Not Running';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<x-filament-panels::page>
<div>
{{ $this->table }}
</div>
</x-filament-panels::page>
2 changes: 1 addition & 1 deletion web/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/public/css/filament/filament/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/public/css/filament/forms/forms.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions web/public/js/filament/forms/components/file-upload.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/public/js/filament/forms/components/markdown-editor.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions web/public/js/filament/support/support.js

Large diffs are not rendered by default.

0 comments on commit 887dbc2

Please sign in to comment.