Skip to content
Snippets Groups Projects
Commit c975bdfb authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Improve sendFinishedEvent (VPU/Middleware/API#40)

parent f1911a1e
No related branches found
No related tags found
No related merge requests found
......@@ -95,13 +95,17 @@ class VPUFileUpload extends VPULitElement {
([...files]).forEach(this.uploadFile.bind(this))
}
sendFinishedEvent(status, filename) {
const data = {
status: status,
filename: filename
};
const event = new CustomEvent("vpu-fileupload-finished", { "detail": data, bubbles: true, composed: true });
this.dispatchEvent(event);
sendFinishedEvent(response, file) {
response.json().then((json) => {
const data = {
status: response.status,
filename: file.name,
json: json
};
const event = new CustomEvent("vpu-fileupload-finished", { "detail": data, bubbles: true, composed: true });
this.dispatchEvent(event);
});
}
uploadFile(file) {
......@@ -120,12 +124,12 @@ class VPUFileUpload extends VPULitElement {
.then((response) => {
/* Done. Inform the user */
console.log(`Status: ${response.status} for file ${file.name}`);
this.sendFinishedEvent(response.status, file.name);
this.sendFinishedEvent(response, file);
})
.catch((response) => {
/* Error. Inform the user */
console.log(`Status: ${response.status} for file ${file.name}`);
this.sendFinishedEvent(response.status, file.name);
console.log(`Error status: ${response.status} for file ${file.name}`);
this.sendFinishedEvent(response, file);
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment