log uploaded files

This commit is contained in:
notCharles 2025-11-03 21:56:44 -05:00
parent 6cec5da76d
commit 339efc754d
3 changed files with 45 additions and 2 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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;