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 fb32352 commit 57f144d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions web/Modules/Email/App/Filament/Pages/EmailHealthStatusPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\BadgeColumn;
use Modules\Email\App\Services\EmailService;
use Filament\Tables\Columns\TextColumn;
Expand Down Expand Up @@ -70,6 +71,18 @@ public function table(Table $table): Table
->requiresConfirmation()
->color('danger')
->visible(fn (EmailHealthStatus $record) => $record->status === ServiceStatus::RUNNING),
ViewAction::make('viewLogs')
->label('View Logs')
->icon('heroicon-o-document')
->modalContent(function (EmailHealthStatus $record){
$serviceName = strtolower($record->service);
$emailService = new EmailService();
$logContents = $emailService->getLog($serviceName);
return view('email::filament.pages.view-log',[
'logContents' => $logContents
]);
})
->color('info'),
]);
}
}
5 changes: 5 additions & 0 deletions web/Modules/Email/App/Services/EmailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ public function startService(string $serviceName): string
$output = shell_exec("sudo systemctl start $serviceName");
return $output ? trim($output) : "$serviceName started successfully.";
}
public function getLog(string $serviceName): string
{
$logFilePath = "/var/log/{$serviceName}.log"; // Adjust the path as needed
return file_exists($logFilePath) ? file_get_contents($logFilePath) : 'Log file not found.';
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<x-filament-panels::page>

<div>
<h1>Service Log</h1>
<pre>{{ $logContents }}</pre>
</div>
</x-filament-panels::page>

0 comments on commit 57f144d

Please sign in to comment.