File uploads
This commit is contained in:
parent
8a3970645f
commit
86cedf9531
6 changed files with 139 additions and 15 deletions
|
|
@ -226,7 +226,7 @@ class NodeFiles extends Component {
|
|||
})
|
||||
.map(file=>
|
||||
html`
|
||||
<div class="filename">${file.Filename}</div>
|
||||
<div class="filename" onclick=${()=>node.download(file.ID)}>${file.Filename}</div>
|
||||
<div class="size">${this.formatSize(file.Size)}</div>
|
||||
`
|
||||
)
|
||||
|
|
@ -308,6 +308,37 @@ class Node {
|
|||
.then(callback)
|
||||
.catch(this.app.responseError)
|
||||
}//}}}
|
||||
download(fileID) {//{{{
|
||||
let headers = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
if(this.app.session.UUID !== '')
|
||||
headers['X-Session-Id'] = this.app.session.UUID
|
||||
|
||||
let fname = ""
|
||||
fetch("/node/download", {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
NodeID: this.ID,
|
||||
FileID: fileID,
|
||||
}),
|
||||
})
|
||||
.then(response=>{
|
||||
console.log(...response.headers);
|
||||
return response.blob()
|
||||
})
|
||||
.then(blob=>{
|
||||
let url = window.URL.createObjectURL(blob)
|
||||
let a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = "filename.xlsx";
|
||||
document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox
|
||||
a.click();
|
||||
a.remove(); //afterwards we remove the element again
|
||||
})
|
||||
}//}}}
|
||||
children(callback) {//{{{
|
||||
this.app.request('/node/tree', { StartNodeID: this.ID })
|
||||
.then(res=>{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue