mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 12:39:30 +01:00
log uploaded files
This commit is contained in:
parent
6cec5da76d
commit
339efc754d
@ -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 */
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user