mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 20:19:26 +01:00
should fix our issues?
This commit is contained in:
parent
339efc754d
commit
227521b7bb
@ -78,7 +78,10 @@
|
||||
try {
|
||||
const uploadSizeLimit = await $wire.getUploadSizeLimit();
|
||||
|
||||
for (const { file } of filesWithPaths) {
|
||||
for (const {
|
||||
file
|
||||
}
|
||||
of filesWithPaths) {
|
||||
if (file.size > uploadSizeLimit) {
|
||||
new window.FilamentNotification()
|
||||
.title(`File ${file.name} exceeds the upload size limit of ${this.formatBytes(uploadSizeLimit)}`)
|
||||
@ -90,7 +93,10 @@
|
||||
}
|
||||
|
||||
const folderPaths = new Set();
|
||||
for (const { path } of filesWithPaths) {
|
||||
for (const {
|
||||
path
|
||||
}
|
||||
of filesWithPaths) {
|
||||
if (path) {
|
||||
const parts = path.split('/').filter(Boolean);
|
||||
let currentPath = '';
|
||||
@ -129,12 +135,17 @@
|
||||
|
||||
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; });
|
||||
.catch(() => {
|
||||
completedCount++;
|
||||
this.currentFileIndex = completedCount;
|
||||
});
|
||||
|
||||
activeUploads.push(uploadPromise);
|
||||
|
||||
@ -150,19 +161,32 @@
|
||||
await $wire.$refresh();
|
||||
|
||||
if (failed.length === 0) {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.success') }}').success().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.success') }}')
|
||||
.success()
|
||||
.send();
|
||||
} else if (failed.length === this.totalFiles) {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.error_all') }}').danger().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.failed') }}')
|
||||
.danger()
|
||||
.send();
|
||||
} else {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.error_partial') }}').warning().send();
|
||||
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) {
|
||||
if (typeof $wire !== 'undefined' && $wire && typeof $wire.call === 'function') {
|
||||
$wire.call('logUploadedFiles', uploadedFiles);
|
||||
} else if (typeof window.livewire !== 'undefined' && typeof window.livewire.call === 'function') {
|
||||
window.livewire.call('logUploadedFiles', uploadedFiles);
|
||||
} else if (typeof Livewire !== 'undefined' && typeof Livewire.call === 'function') {
|
||||
Livewire.call('logUploadedFiles', uploadedFiles);
|
||||
} else {
|
||||
console.warn('Could not call Livewire method logUploadedFiles; Livewire not found.');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -174,7 +198,10 @@
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.error('Upload error:', error);
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.error') }}').danger().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.error') }}')
|
||||
.danger()
|
||||
.send();
|
||||
this.isUploading = false;
|
||||
}
|
||||
},
|
||||
@ -264,7 +291,10 @@
|
||||
async handleFileSelect(e) {
|
||||
const files = Array.from(e.target.files);
|
||||
if (files.length > 0) {
|
||||
const filesWithPaths = files.map(f => ({ file: f, path: '' }));
|
||||
const filesWithPaths = files.map(f => ({
|
||||
file: f,
|
||||
path: ''
|
||||
}));
|
||||
await this.uploadFilesWithFolders(filesWithPaths);
|
||||
}
|
||||
},
|
||||
@ -272,8 +302,7 @@
|
||||
this.$refs.fileInput.click();
|
||||
},
|
||||
}"
|
||||
class="relative"
|
||||
>
|
||||
class="relative">
|
||||
<div class="p-4">
|
||||
<input type="file" x-ref="fileInput" class="hidden" multiple @change="handleFileSelect">
|
||||
|
||||
|
||||
@ -44,7 +44,10 @@
|
||||
}
|
||||
|
||||
if (files && files.length > 0 && filesWithPaths.length === 0) {
|
||||
filesWithPaths = Array.from(files).map(f => ({ file: f, path: '' }));
|
||||
filesWithPaths = Array.from(files).map(f => ({
|
||||
file: f,
|
||||
path: ''
|
||||
}));
|
||||
}
|
||||
|
||||
if (filesWithPaths.length > 0) {
|
||||
@ -124,7 +127,10 @@
|
||||
try {
|
||||
const uploadSizeLimit = await $wire.getUploadSizeLimit();
|
||||
|
||||
for (const { file } of filesWithPaths) {
|
||||
for (const {
|
||||
file
|
||||
}
|
||||
of filesWithPaths) {
|
||||
if (file.size > uploadSizeLimit) {
|
||||
new window.FilamentNotification()
|
||||
.title(`File ${file.name} exceeds the upload limit.`)
|
||||
@ -136,7 +142,10 @@
|
||||
}
|
||||
|
||||
const folderPaths = new Set();
|
||||
for (const { path } of filesWithPaths) {
|
||||
for (const {
|
||||
path
|
||||
}
|
||||
of filesWithPaths) {
|
||||
if (path) {
|
||||
const parts = path.split('/').filter(Boolean);
|
||||
let currentPath = '';
|
||||
@ -175,12 +184,17 @@
|
||||
|
||||
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; });
|
||||
.catch(() => {
|
||||
completedCount++;
|
||||
this.currentFileIndex = completedCount;
|
||||
});
|
||||
|
||||
activeUploads.push(uploadPromise);
|
||||
|
||||
@ -196,19 +210,32 @@
|
||||
await $wire.$refresh();
|
||||
|
||||
if (failed.length === 0) {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.success') }}').success().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.success') }}')
|
||||
.success()
|
||||
.send();
|
||||
} else if (failed.length === this.totalFiles) {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.failed') }}').danger().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.failed') }}')
|
||||
.danger()
|
||||
.send();
|
||||
} else {
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.failed') }}').danger().send();
|
||||
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) {
|
||||
if (typeof $wire !== 'undefined' && $wire && typeof $wire.call === 'function') {
|
||||
$wire.call('logUploadedFiles', uploadedFiles);
|
||||
} else if (typeof window.livewire !== 'undefined' && typeof window.livewire.call === 'function') {
|
||||
window.livewire.call('logUploadedFiles', uploadedFiles);
|
||||
} else if (typeof Livewire !== 'undefined' && typeof Livewire.call === 'function') {
|
||||
Livewire.call('logUploadedFiles', uploadedFiles);
|
||||
} else {
|
||||
console.warn('Could not call Livewire method logUploadedFiles; Livewire not found.');
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -220,7 +247,10 @@
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.error('Upload error:', error);
|
||||
new window.FilamentNotification().title('{{ trans('server/file.actions.upload.error') }}').danger().send();
|
||||
new window.FilamentNotification()
|
||||
.title('{{ trans('server/file.actions.upload.error') }}')
|
||||
.danger()
|
||||
.send();
|
||||
this.isUploading = false;
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user