mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
- 2.x - sites (wip)
- improved ssh error handling - database soft deletes
This commit is contained in:
@ -2,24 +2,16 @@
|
||||
|
||||
namespace App\Web\Pages\Servers\Logs;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerLog;
|
||||
use App\Web\Components\Page;
|
||||
use App\Web\Pages\Servers\Logs\Widgets\LogsList;
|
||||
use App\Web\Traits\PageHasServer;
|
||||
use App\Web\Pages\Servers\Page;
|
||||
|
||||
class Index extends Page
|
||||
{
|
||||
use PageHasServer;
|
||||
|
||||
protected static ?string $slug = 'servers/{server}/logs';
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $title = 'Logs';
|
||||
|
||||
public Server $server;
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('viewAny', [ServerLog::class, static::getServerFromRoute()]) ?? false;
|
||||
|
@ -4,9 +4,13 @@
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerLog;
|
||||
use App\Models\Site;
|
||||
use Exception;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
@ -18,13 +22,21 @@ class LogsList extends Widget
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public ?Site $site = null;
|
||||
|
||||
public ?string $label = '';
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return ServerLog::query()->where('server_id', $this->server->id);
|
||||
return ServerLog::query()
|
||||
->where('server_id', $this->server->id)
|
||||
->where(function (Builder $query) {
|
||||
if ($this->site) {
|
||||
$query->where('site_id', $this->site->id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected static ?string $heading = '';
|
||||
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
@ -68,6 +80,7 @@ public function getTable(): Table
|
||||
);
|
||||
}),
|
||||
])
|
||||
->heading($this->label)
|
||||
->actions([
|
||||
Action::make('view')
|
||||
->hiddenLabel()
|
||||
@ -90,6 +103,19 @@ public function getTable(): Table
|
||||
->icon('heroicon-o-archive-box-arrow-down')
|
||||
->authorize(fn ($record) => auth()->user()->can('view', $record))
|
||||
->action(fn (ServerLog $record) => $record->download()),
|
||||
]);
|
||||
DeleteAction::make()
|
||||
->hiddenLabel()
|
||||
->tooltip('Delete')
|
||||
->icon('heroicon-o-trash')
|
||||
->color('danger')
|
||||
->authorize(fn ($record) => auth()->user()->can('delete', $record)),
|
||||
])
|
||||
->bulkActions(
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make()
|
||||
->requiresConfirmation()
|
||||
->authorize(auth()->user()->can('deleteMany', [ServerLog::class, $this->server])),
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user