diff --git a/ccp/js/executionmonitorcontroller.js b/ccp/js/executionmonitorcontroller.js
index 2f34711..fd412ec 100644
--- a/ccp/js/executionmonitorcontroller.js
+++ b/ccp/js/executionmonitorcontroller.js
@@ -49,7 +49,7 @@ class CCPExecutionMonitor extends HTMLElement {
refreshExecution(execution){
this.#boot.secureFetch(execution.self).then(reply =>{
if(reply.status === 200) return reply.json();
- else throw "Unable to load job links" + reply.text
+ else throw "Unable to load job links"
}).then(data=>{
execution.links = data
BSS.apply(this.execution_list_bss, this.#rootdoc)
@@ -70,6 +70,26 @@ class CCPExecutionMonitor extends HTMLElement {
window.setInterval( ()=>this.#socket.send("ping"), 30000)
}
+ download(url, name) {
+ this.#boot.secureFetch(url).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 = name
+ tmplnk.href = objectURL
+ //tmplnk.target="_blank"
+ document.body.appendChild(tmplnk)
+ tmplnk.click()
+ document.body.removeChild(tmplnk)
+
+ }).catch(err => console.error(err))
+ }
+
execution_list_bss = {
template : "#EXECUTIOM_LIST_TEMPLATE",
target : "ol[name=ccp_execution_list]",
@@ -117,9 +137,13 @@ class CCPExecutionMonitor extends HTMLElement {
{
target : "li",
"in" : (e,d)=>{return d.links.map(l=>{ return { href : d.self + "/" + l.path, path : l.path} })},
+ on_click : ev=>{
+ const href = ev.currentTarget.bss_input.data.href
+ const name = ev.currentTarget.bss_input.data.path
+ this.download(href, name)
+ },
apply : (e,d)=>{
- console.log("applying", e, d)
- e.innerHTML = `${d.path}`
+ e.innerHTML = `${d.path}`
}
}
]