From de4349342fa639ef5048c94e80f6b4471acacb13 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Mon, 13 May 2024 16:30:31 +0300 Subject: [PATCH] update --- web/app/Livewire/FileManager.php | 24 +++++- .../livewire/file-manager/index.blade.php | 74 ++++++++++++++++--- 2 files changed, 85 insertions(+), 13 deletions(-) diff --git a/web/app/Livewire/FileManager.php b/web/app/Livewire/FileManager.php index ca5b511..768b743 100644 --- a/web/app/Livewire/FileManager.php +++ b/web/app/Livewire/FileManager.php @@ -4,6 +4,7 @@ namespace App\Livewire; use App\Models\Domain; use App\Models\HostingSubscription; +use Carbon\Carbon; use Illuminate\Support\Str; use Livewire\Component; @@ -19,6 +20,10 @@ class FileManager extends Component public $currentPath; + public $folderName; + + public $canIBack = false; + public function mount($hostingSubscriptionId) { $this->hostingSubscriptionId = $hostingSubscriptionId; @@ -52,6 +57,8 @@ class FileManager extends Component if (Str::startsWith($newRealPath, $this->domainHomeRoot)) { $this->currentRealPath = $newRealPath; + } else { + $this->canIBack = false; } } @@ -67,6 +74,17 @@ class FileManager extends Component } + public function createFolder() + { + $this->folderName = Str::slug($this->folderName); + $newPath = $this->currentRealPath . '/' . $this->folderName; + if (!is_dir($newPath)) { + mkdir($newPath); + $this->folderName = ''; + $this->dispatch('close-modal', id: 'create-folder'); + } + } + public function render() { if (!$this->currentRealPath) { @@ -78,6 +96,10 @@ class FileManager extends Component $folders = []; if ($this->currentRealPath) { + if (Str::startsWith(dirname($this->currentRealPath), $this->domainHomeRoot)) { + $this->canIBack = true; + } + $scanFiles = scandir($this->currentRealPath); foreach ($scanFiles as $scanFile) { if ($scanFile == '.' || $scanFile == '..') { @@ -93,7 +115,7 @@ class FileManager extends Component 'owner' => posix_getpwuid(fileowner($this->currentRealPath . '/' . $scanFile))['name'], 'group' => posix_getgrgid(filegroup($this->currentRealPath . '/' . $scanFile))['name'], 'size' => filesize($this->currentRealPath . '/' . $scanFile), - 'last_modified' => filemtime($this->currentRealPath . '/' . $scanFile), + 'last_modified' => date('Y-m-d H:i:s', filemtime($this->currentRealPath . '/' . $scanFile)), 'type' => filetype($this->currentRealPath . '/' . $scanFile), ]; if ($append['is_dir']) { diff --git a/web/resources/views/livewire/file-manager/index.blade.php b/web/resources/views/livewire/file-manager/index.blade.php index ef5c9dc..898fe0d 100644 --- a/web/resources/views/livewire/file-manager/index.blade.php +++ b/web/resources/views/livewire/file-manager/index.blade.php @@ -1,31 +1,65 @@ -
- -
- Path: {{$currentRealPath}} -
+
- + Back - + Refresh - - Create Folder - - + + + + Create Folder + + + + Create Folder + + +
+ + + +
+ + Create + +
+
+ + + + + Create File + + + + Create File + + +
+ +
+ + Create + +
+
+ + Upload +
@if(!empty($files)) - +
@@ -36,6 +70,21 @@ + + + @if($canIBack) + + + + @endif + @foreach($files as $file) @endforeach +
#Permission
+
+ + + + Back to parent folder +
+
@@ -108,6 +157,7 @@
@else

No files found