added support for zip export

This commit is contained in:
dcore94 2023-01-31 13:13:43 +01:00
parent 5449890dae
commit feaea1c48c
1 changed files with 25 additions and 1 deletions

View File

@ -61,6 +61,9 @@ class CCPExecutionHistory extends HTMLElement {
<span name="runtime" class="badge"></span> <span name="runtime" class="badge"></span>
<h5 style="display:inline"></h5> <h5 style="display:inline"></h5>
<span name="status" class="badge"></span> <span name="status" class="badge"></span>
<button data-index="0" name="zip" title="Download as zip archive" class="btn btn-primary ccp-toolbar-button">
<svg viewBox="0 0 48 48"><path d="M7 40q-1.15 0-2.075-.925Q4 38.15 4 37V11q0-1.15.925-2.075Q5.85 8 7 8h14l3 3h17q1.15 0 2.075.925Q44 12.85 44 14v23q0 1.15-.925 2.075Q42.15 40 41 40Zm25-3h9V14h-9v4.6h4.6v4.6H32v4.6h4.6v4.6H32ZM7 37h20.4v-4.6H32v-4.6h-4.6v-4.6H32v-4.6h-4.6V14h-4.65l-3-3H7v26Zm0-23v-3 26-23Z"/></svg>
</button>
<button data-index="0" name="delete" title="Delete" class="btn btn-danger ccp-toolbar-button"> <button data-index="0" name="delete" title="Delete" class="btn btn-danger ccp-toolbar-button">
<svg viewBox="0 0 24 24"> <svg viewBox="0 0 24 24">
<path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"></path> <path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"></path>
@ -149,7 +152,6 @@ class CCPExecutionHistory extends HTMLElement {
var tmplnk = document.createElement("a") var tmplnk = document.createElement("a")
tmplnk.download = name tmplnk.download = name
tmplnk.href = objectURL tmplnk.href = objectURL
//tmplnk.target="_blank"
document.body.appendChild(tmplnk) document.body.appendChild(tmplnk)
tmplnk.click() tmplnk.click()
document.body.removeChild(tmplnk) document.body.removeChild(tmplnk)
@ -157,6 +159,24 @@ class CCPExecutionHistory extends HTMLElement {
}).catch(err => console.error(err)) }).catch(err => console.error(err))
} }
downloadZIP(id){
this.#boot.secureFetch(`${this.#serviceurl}/executions/${id}`,
{ method: "GET", headers : { "Accept" : "application/zip"} }).then(reply =>{
if (reply.status !== 200) {
throw "Unable to download"
}
return reply.blob()
}).then(blob => {
const objectURL = URL.createObjectURL(blob)
var tmplnk = document.createElement("a")
tmplnk.download = id + ".zip"
tmplnk.href = objectURL
document.body.appendChild(tmplnk)
tmplnk.click()
document.body.removeChild(tmplnk)
}).catch(err=>{ console.error(err)})
}
execution_list_bss = { execution_list_bss = {
template : "#EXECUTIOM_LIST_TEMPLATE", template : "#EXECUTIOM_LIST_TEMPLATE",
target : "ol[name=ccp_execution_list]", target : "ol[name=ccp_execution_list]",
@ -173,6 +193,10 @@ class CCPExecutionHistory extends HTMLElement {
this.deleteExecution(this.#executions[index].id) this.deleteExecution(this.#executions[index].id)
} }
} }
if(ev.target.getAttribute("name") === "zip"){
const index = Number(ev.target.getAttribute("data-index"))
this.downloadZIP(this.#executions[index].id)
}
}, },
recurse : [ recurse : [
{ {