Replaces maryUI and daisyUI with nonameweb/livewire-material: the Vibrant indigo scheme, a system/light/dark theme under sealshare-theme, one top app bar with the account menu, the upload drop zone and link-ready moments, M3 fields, dialogs instead of wire:confirm, snackbars instead of flashed messages, a sortable admin table, and the starter-kit cleanup. Docker builds assets after Composer; CI drops the Flux step. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Models\Share;
|
|
use App\Models\ShareFile;
|
|
use App\Services\ShareService;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
#[Layout('layouts.app')]
|
|
class AdminDashboard extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
/**
|
|
* The columns the table can be sorted by.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
public const SORTABLE = ['token', 'files_count', 'total_size', 'download_count', 'expires_at', 'created_at'];
|
|
|
|
/** @var array{column: string, direction: string} */
|
|
public array $sortBy = ['column' => 'created_at', 'direction' => 'desc'];
|
|
|
|
/** The share the delete dialog is asking about, while it is open. */
|
|
public ?int $deletingShareId = null;
|
|
|
|
public function deleteShare(int $shareId, ShareService $shareService): void
|
|
{
|
|
$share = Share::query()->findOrFail($shareId);
|
|
$shareService->deleteShare($share);
|
|
|
|
$this->deletingShareId = null;
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
$shareService = app(ShareService::class);
|
|
|
|
// The sort comes from the browser: only a known column and direction reach the query.
|
|
$column = in_array($this->sortBy['column'] ?? null, self::SORTABLE, true) ? $this->sortBy['column'] : 'created_at';
|
|
$direction = ($this->sortBy['direction'] ?? null) === 'asc' ? 'asc' : 'desc';
|
|
|
|
$shares = Share::query()
|
|
->withCount('files')
|
|
->orderBy($column, $direction)
|
|
->paginate(15);
|
|
|
|
return view('livewire.admin.admin-dashboard', [
|
|
'shares' => $shares,
|
|
'totalShares' => Share::query()->count(),
|
|
'activeShares' => Share::query()->where(function ($q) {
|
|
$q->whereNull('expires_at')->orWhere('expires_at', '>', now());
|
|
})->count(),
|
|
'totalFiles' => ShareFile::query()->count(),
|
|
'usedSpace' => $shareService->getTotalUsedSpace(),
|
|
'maxQuota' => $shareService->getMaxStorageQuota(),
|
|
]);
|
|
}
|
|
}
|