Filemanager: Fix some weirdness with Et2File upload

This commit is contained in:
nathan 2025-02-26 17:33:44 -07:00
parent 69789d0a17
commit 8a8f283bc6
3 changed files with 21 additions and 6 deletions

View File

@ -362,13 +362,14 @@ export class Et2File extends Et2InputWidget(LitElement)
else
{
const ev = new CustomEvent("et2-load", {bubbles: true, detail: file});
this.dispatchEvent(ev);
Object.keys(response).forEach((tempName) =>
{
if(fileItem)
{
fileItem.variant = "success";
}
file['tempName'] = tempName;
this.dispatchEvent(ev);
// Add file into value
if (typeof this.value !== 'object' || !this.value)
@ -625,7 +626,14 @@ export class Et2File extends Et2InputWidget(LitElement)
// so we check if it is actually a file
if(!icon && fileInfo.file instanceof File && type?.startsWith("image/"))
{
thumbnail = URL.createObjectURL(fileInfo.file);
try
{
thumbnail = URL.createObjectURL(fileInfo.file);
}
catch(e)
{
// Thumbnail creation failed, but we don't really care
}
}
const variant = !fileInfo.warning ? "default" : "warning";
const closable = !this.readonly && (fileInfo.accepted || Object.values(this.value).indexOf(fileInfo) !== -1)

View File

@ -465,6 +465,10 @@ export class filemanagerAPP extends EgwApp
uploadOnOne(_event)
{
this.upload(_event,1);
// Stop nm from refreshing, we'll get it on the push
_event.stopPropagation();
return false;
}
/**
@ -487,15 +491,18 @@ export class filemanagerAPP extends EgwApp
let widget = _event.target;
widget.loading = true;
_event.detail.accepted = false; // Turn off removable, it's too late now
let value = widget.getValue();
value.conflict = _conflict;
const widgetValue = widget.getValue();
const value = {};
value[_event.detail.tempName] = {...widgetValue[_event.detail.tempName]};
delete widgetValue[_event.detail.tempName];
widget.value = widgetValue;
value["conflict"] = _conflict;
widget.requestUpdate("loading");
egw.json(_target, ['upload', value, _path, {ui_path: this.egw.window.location.pathname}],
this._upload_callback, this, true, this
).sendRequest().finally(() =>
{
widget.loading = false;
widget.value = {};
widget.requestUpdate("loading", true);
});
}

View File

@ -57,7 +57,7 @@
disabled="!@show_refresh" hideOnReadonly="true" image="reload" noSubmit="true"></et2-button>
<et2-file label="Upload" statustext="Select file to upload in current directory" id="upload" class="et2_toolbar_hasCaption"
dropTarget="filemanager-index" multiple="true"
onFinishOne="app.filemanager.uploadOnOne"/>
onFinishOne="app.filemanager.uploadOnOne" onchange="widget.value={}; return false;"/>
</template>
<template id="filemanager.index.header_row" template="" lang="" group="0" version="1.9.002">
<et2-button id="home" statustext="Go to your home directory" image="gohome" onclick="app.filemanager.change_dir('~',widget);" noSubmit="true"></et2-button>