mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
add filament dashboard
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Custom\Widgets;
|
||||
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Filament\Widgets\Widget;
|
||||
|
||||
class StatTable extends Widget
|
||||
{
|
||||
protected static string $view = 'filament.widgets.stat-table';
|
||||
|
||||
protected function getHeader(): string
|
||||
{
|
||||
return nulll;
|
||||
}
|
||||
|
||||
protected function getTableRows(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'header' => $this->getHeader(),
|
||||
'data' => $this->getTableRows(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,8 @@ class UserResource extends Resource
|
||||
'index' => Pages\ListUsers::route('/'),
|
||||
'create' => Pages\CreateUser::route('/create'),
|
||||
// 'edit' => Pages\EditUser::route('/{record}/edit'),
|
||||
'view' => Pages\ViewUser::route('/{record}'),
|
||||
// 'view' => Pages\ViewUser::route('/{record}'),
|
||||
'view' => Pages\UserProfile::route('/{record}'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\User\UserResource\Pages;
|
||||
|
||||
use App\Filament\Resources\User\UserResource;
|
||||
use Filament\Resources\Pages\Page;
|
||||
|
||||
class UserProfile extends Page
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.user.user-resource.pages.user-profile';
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class LatestTorrents extends BaseWidget
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
Tables\Columns\TextColumn::make('name')->limit(40),
|
||||
Tables\Columns\TextColumn::make('name')->limit(30),
|
||||
Tables\Columns\TextColumn::make('user.username'),
|
||||
Tables\Columns\TextColumn::make('size')->formatStateUsing(fn ($state) => mksize($state)),
|
||||
Tables\Columns\TextColumn::make('added')->dateTime(),
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Custom\Widgets\StatTable;
|
||||
use App\Repositories\DashboardRepository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class SystemInfo extends StatTable
|
||||
{
|
||||
protected static ?int $sort = 1000;
|
||||
|
||||
protected function getHeader(): string
|
||||
{
|
||||
return nexus_trans('dashboard.system_info.page_title');
|
||||
}
|
||||
|
||||
protected function getTableRows(): array
|
||||
{
|
||||
$dashboardRep = new DashboardRepository();
|
||||
|
||||
return $dashboardRep->getSystemInfo();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Custom\Widgets\StatTable;
|
||||
use App\Repositories\DashboardRepository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentStat extends StatTable
|
||||
{
|
||||
protected static ?int $sort = 102;
|
||||
|
||||
protected function getHeader(): string
|
||||
{
|
||||
return nexus_trans('dashboard.torrent.page_title');
|
||||
}
|
||||
|
||||
protected function getTableRows(): array
|
||||
{
|
||||
$dashboardRep = new DashboardRepository();
|
||||
|
||||
return $dashboardRep->statTorrents();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Custom\Widgets\StatTable;
|
||||
use App\Repositories\DashboardRepository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class UserClassStat extends StatTable
|
||||
{
|
||||
protected static ?int $sort = 101;
|
||||
|
||||
protected function getHeader(): string
|
||||
{
|
||||
return nexus_trans('dashboard.user_class.page_title');
|
||||
}
|
||||
|
||||
protected function getTableRows(): array
|
||||
{
|
||||
$dashboardRep = new DashboardRepository();
|
||||
|
||||
return $dashboardRep->statUserClass();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Filament\Custom\Widgets\StatTable;
|
||||
use App\Repositories\DashboardRepository;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class UserStat extends StatTable
|
||||
{
|
||||
protected static ?int $sort = 100;
|
||||
|
||||
protected function getHeader(): string
|
||||
{
|
||||
return nexus_trans('dashboard.user.page_title');
|
||||
}
|
||||
|
||||
protected function getTableRows(): array
|
||||
{
|
||||
$dashboardRep = new DashboardRepository();
|
||||
|
||||
return $dashboardRep->statUsers();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user