diff --git a/app/Filament/Server/Resources/Files/Pages/ListFiles.php b/app/Filament/Server/Resources/Files/Pages/ListFiles.php index c58b87557..582da08f4 100644 --- a/app/Filament/Server/Resources/Files/Pages/ListFiles.php +++ b/app/Filament/Server/Resources/Files/Pages/ListFiles.php @@ -676,6 +676,19 @@ class ListFiles extends ListRecords } } + /** + * @param string[] $files + */ + public function logUploadedFiles(array $files): void + { + $filesCollection = collect($files); + + Activity::event('server:files.uploaded') + ->property('directory', $this->path) + ->property('files', $filesCollection) + ->log(); + } + private function getDaemonFileRepository(): DaemonFileRepository { /** @var Server $server */ diff --git a/resources/views/filament/server/pages/file-upload.blade.php b/resources/views/filament/server/pages/file-upload.blade.php index 666d273cf..920a0ea5d 100644 --- a/resources/views/filament/server/pages/file-upload.blade.php +++ b/resources/views/filament/server/pages/file-upload.blade.php @@ -73,6 +73,7 @@ this.uploadQueue = []; this.totalFiles = filesWithPaths.length; this.currentFileIndex = 0; + const uploadedFiles = []; try { const uploadSizeLimit = await $wire.getUploadSizeLimit(); @@ -128,7 +129,11 @@ for (let i = 0; i < this.uploadQueue.length; i++) { const uploadPromise = this.uploadFile(i) - .then(() => { completedCount++; this.currentFileIndex = completedCount; }) + .then(() => { completedCount++; this.currentFileIndex = completedCount; + const item = this.uploadQueue[i]; + const relativePath = (item.path ? item.path.replace(/^\/+/, '') + '/' : '') + item.name; + uploadedFiles.push(relativePath); + }) .catch(() => { completedCount++; this.currentFileIndex = completedCount; }); activeUploads.push(uploadPromise); @@ -152,6 +157,16 @@ new window.FilamentNotification().title('{{ trans('server/file.actions.upload.error_partial') }}').warning().send(); } + if (uploadedFiles.length > 0) { + this.$nextTick(() => { + try { + @this.call('logUploadedFiles', uploadedFiles); + } catch (e) { + $wire.call('logUploadedFiles', uploadedFiles); + } + }); + } + if (this.autoCloseTimer) clearTimeout(this.autoCloseTimer); this.autoCloseTimer = setTimeout(() => { this.isUploading = false; diff --git a/resources/views/filament/server/pages/list-files.blade.php b/resources/views/filament/server/pages/list-files.blade.php index cde3b0fb7..e864d0ee9 100644 --- a/resources/views/filament/server/pages/list-files.blade.php +++ b/resources/views/filament/server/pages/list-files.blade.php @@ -119,6 +119,7 @@ this.uploadQueue = []; this.totalFiles = filesWithPaths.length; this.currentFileIndex = 0; + const uploadedFiles = []; try { const uploadSizeLimit = await $wire.getUploadSizeLimit(); @@ -174,7 +175,11 @@ for (let i = 0; i < this.uploadQueue.length; i++) { const uploadPromise = this.uploadFile(i) - .then(() => { completedCount++; this.currentFileIndex = completedCount; }) + .then(() => { completedCount++; this.currentFileIndex = completedCount; + const item = this.uploadQueue[i]; + const relativePath = (item.path ? item.path.replace(/^\/+/, '') + '/' : '') + item.name; + uploadedFiles.push(relativePath); + }) .catch(() => { completedCount++; this.currentFileIndex = completedCount; }); activeUploads.push(uploadPromise); @@ -198,6 +203,16 @@ new window.FilamentNotification().title('{{ trans('server/file.actions.upload.failed') }}').danger().send(); } + if (uploadedFiles.length > 0) { + this.$nextTick(() => { + try { + @this.call('logUploadedFiles', uploadedFiles); + } catch (e) { + $wire.call('logUploadedFiles', uploadedFiles); + } + }); + } + if (this.autoCloseTimer) clearTimeout(this.autoCloseTimer); this.autoCloseTimer = setTimeout(() => { this.isUploading = false;