This commit is contained in:
Bozhidar 2024-05-13 13:55:41 +03:00
parent 06ede145c2
commit b582154626
5 changed files with 160 additions and 0 deletions

View file

@ -167,6 +167,7 @@ class HostingSubscriptionResource extends Resource
->options(fn (): array => HostingSubscription::query()->pluck('system_username', 'id')->all())
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('visit')
->label('Open website')
->icon('heroicon-m-arrow-top-right-on-square')
@ -207,6 +208,7 @@ class HostingSubscriptionResource extends Resource
'index' => Pages\ListHostingSubscriptions::route('/'),
'create' => Pages\CreateHostingSubscription::route('/create'),
'edit' => Pages\EditHostingSubscription::route('/{record}/edit'),
'view' => Pages\ViewHostingSubscription::route('/{record}'),
'databases' => Pages\ManageHostingSubscriptionDatabases::route('/{record}/databases'),
'backups' => Pages\ManageHostingSubscriptionBackups::route('/{record}/backups'),
'ftp-accounts' => Pages\ManageHostingSubscriptionFtpAccounts::route('/{record}/ftp-accounts'),

View file

@ -0,0 +1,28 @@
<?php
namespace App\Filament\Resources\HostingSubscriptionResource\Pages;
use App\Filament\Resources\HostingSubscriptionResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Filament\Resources\Pages\ViewRecord;
class ViewHostingSubscription extends ViewRecord
{
protected static string $resource = HostingSubscriptionResource::class;
protected static string $view = 'filament.pages.view-hosting-subscription';
public static function getPages(): array
{
return [
];
}
protected function getHeaderActions(): array
{
return [
];
}
}

View file

@ -0,0 +1,60 @@
<?php
namespace App\Livewire;
use App\Models\Domain;
use Livewire\Component;
class FileManager extends Component
{
public $hostingSubscriptionId;
public $currentRealPath;
public $currentPath;
public function mount($hostingSubscriptionId)
{
$this->hostingSubscriptionId = $hostingSubscriptionId;
}
public function render()
{
$findDomain = Domain::where('hosting_subscription_id', $this->hostingSubscriptionId)
->where('is_main', 1)
->first();
if ($findDomain) {
if (!$this->currentRealPath) {
$this->currentRealPath = $findDomain->home_root;
}
}
$all = [];
$files = [];
$folders = [];
if ($this->currentRealPath) {
$scanFiles = scandir($this->currentRealPath);
foreach ($scanFiles as $scanFile) {
if ($scanFile == '.' || $scanFile == '..') {
continue;
}
$append = [
'name' => $scanFile,
'path' => $this->currentRealPath . '/' . $scanFile,
'is_dir' => is_dir($this->currentRealPath . '/' . $scanFile)
];
if ($append['is_dir']) {
$folders[] = $append;
} else {
$files[] = $append;
}
}
}
$all = array_merge($folders, $files);
return view('livewire.file-manager.index', [
'files'=>$all
]);
}
}

View file

@ -0,0 +1,7 @@
<x-filament-panels::page>
<div>
<livewire:file-manager hostingSubscriptionId="{{$this->data['id']}}" />
</div>
</x-filament-panels::page>

View file

@ -0,0 +1,63 @@
<div class="rounded-xl bg-white p-4 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
<div>
Path: {{$currentRealPath}}
</div>
@if(!empty($files))
<table class="w-full rounded mt-2 border border-slate-200">
<thead>
<tr>
<th class="p-4">#</th>
<th class="p-4 text-left">Name</th>
<th class="p-4 text-left">Size</th>
<th class="p-4 text-left">Last modified</th>
<th class="p-4 text-left">Type</th>
<th class="p-4 text-left">Permission</th>
</tr>
</thead>
@foreach($files as $file)
<tr class="border border-slate-200 cursor-pointer hover:bg-gray-50 p-4">
<td class="w-6 p-4">
<div>
@if($file['name'] == 'public_html')
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 text-blue-500" viewBox="0 0 2048 2048">
<path fill="currentColor" d="M496 883q13 0 29 4t32 11t32 13t29 12l-16 2q-8 1-17 1q-17 0-31-5t-26-13t-24-12t-22-6q-10 0-18 4t-16 9q0-4-7-4q7-7 26-11t29-5m135 45q41 0 75 14q-14 5-28 8t-29 4q-20 0-36-4q5-8 10-10t8-12M1024 0q141 0 271 37t244 103t208 161t160 207t104 244t37 272q0 141-37 271t-103 244t-161 208t-207 160t-244 104t-272 37q-141 0-271-37t-244-103t-208-161t-160-207t-104-244t-37-272q0-141 37-271t103-244t161-208t207-160T752 37t272-37m762 555q-14-22-28-42t-29-41q-2 9-5 13t-4 18q0 9 7 17t18 16t22 12t19 7m-69-98q0 8-3 11h6q4 0 6 1zm-693 1463q114 0 223-29t206-82t180-130t145-172q-13-30-25-61t-12-64q0-36 3-58t7-39t4-29t-3-31t-17-41t-37-62q1-7 3-19t4-25t1-24t-5-19q-26-3-54-11t-50-24l6-5q-13 3-26 8t-25 11t-26 8t-27 4l-16-2l3-7q-14 4-30 10t-31 6q-10 0-29-7t-38-17t-34-22t-15-23l2-3q-5-6-13-11t-15-10t-13-11t-5-14l11-9l-23-3l-8-30q2 5 9 4t11-4l-36-19l25-64q-14-52-7-80t27-46t44-36t49-49l-3-12l66-80l15-2q28 0 63-2t71-7t71-10t64-13q-32-38-67-72t-75-65q-11 4-27 11t-32 18t-25 24t-11 27l6 19q-18 29-40 36t-45 8t-48 0t-48 9l-16-34l15-58l-17-25l173-54q-11-28-36-42t-55-14v-10l56-9q-93-46-193-70t-205-24q-87 0-172 17t-164 49t-153 80t-135 108q26 0 40 13t26 29t25 29t35 14l16-12l-2-22l33-47l-26-74q5-3 15-10t17-7q30 0 46 3t28 11t21 23t28 38l36-28q10 4 32 13t45 22t39 27t17 26q0 15-11 24t-29 15t-37 9t-38 8t-29 10t-12 17l58 19q-20 17-43 31t-48 26l4 17l-92 36v28l-7 3l5-35l-4-1q-7 0-8 3t-1 7t2 8t1 6l-13-7l2 4q0 3 3 9t8 11t8 10t4 5q0 3-4 6t-10 4t-8 3t0 1q14 0 6 2t-25 10t-31 23t-16 44q0 17 1 33t-1 33q-14-38-42-58t-68-20l-43 4l21 14q-17-2-35-4t-37-1t-34 8t-30 21l-6 45q0 32 14 52t49 21q30 0 59-9t57-21q-9 22-20 42t-16 44l13 6q24-16 44-5t39 32t39 43t43 32l-34 18l-80-45q1 2 2 9t-1 3l-36-61q-32-1-68-10t-73-24t-69-33t-59-38l-7 107q0 122 33 238t93 218t147 186t193 143q-5-21-1-42t10-42t13-42t7-43q0-32-10-67t-24-71t-31-71t-27-66t-16-58t6-47l-15-7q6-14 16-27t21-26t17-28t7-30q0-10-4-21t-7-21l21 5q17-39 46-53t73-15q5 0 21 4t34 11t34 11t24 8q0 7 8 9t9 7l-2 8q3 1 14 7t24 15t23 16t14 11q18 0 49 12t68 30t73 43t68 50t49 50t20 44l-34 36q4 51-7 78t-34 45t-53 30t-65 34q0 20-10 43t-25 44t-36 35t-42 14l-42-32q2 2 0 7t-5 2q10 19 5 44t-17 51t-27 49t-27 39q54 14 108 21t109 7" />
</svg>
@elseif($file['is_dir'])
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 text-primary-500" viewBox="0 0 256 256">
<path fill="currentColor" d="M216 72h-84.69L104 44.69A15.88 15.88 0 0 0 92.69 40H40a16 16 0 0 0-16 16v144.62A15.41 15.41 0 0 0 39.39 216h177.5A15.13 15.13 0 0 0 232 200.89V88a16 16 0 0 0-16-16M40 56h52.69l16 16H40Z" />
</svg>
@else
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 text-purple-400" viewBox="0 0 256 256">
<path fill="currentColor" d="m213.66 82.34l-56-56A8 8 0 0 0 152 24H56a16 16 0 0 0-16 16v176a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16V88a8 8 0 0 0-2.34-5.66M152 88V44l44 44Z" />
</svg>
@endif
</div>
</td>
<td class="p-4">
{{ $file['name'] }}
</td>
<td class="p-4">
0.00 KB
</td>
<td class="p-4">
-
</td>
<td class="p-4">
@if($file['is_dir'])
Directory
@else
File
@endif
</td>
<td class="p-4">
700
</td>
</tr>
@endforeach
</table>
@else
<p>No files found</p>
@endif
</div>