added export button for methods
This commit is contained in:
parent
b06f29312f
commit
79a1b0b5ac
|
@ -78,6 +78,7 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
fill: white;
|
fill: white;
|
||||||
width:24px;
|
width:24px;
|
||||||
height:24px;
|
height:24px;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ccp-option {
|
.ccp-option {
|
||||||
|
@ -150,10 +151,13 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
</svg>
|
</svg>
|
||||||
`
|
`
|
||||||
#delete_icon = `
|
#delete_icon = `
|
||||||
<svg style="width:24px;height:24px;pointer-events: none;" 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 d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" />
|
||||||
</svg>
|
</svg>
|
||||||
`
|
`
|
||||||
|
#download_icon = `
|
||||||
|
<svg viewBox="0 0 24 24"><g><rect fill="none" height="24" width="24"/></g><g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g></svg>
|
||||||
|
`
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
super();
|
super();
|
||||||
|
@ -291,6 +295,31 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadMethod(method){
|
||||||
|
if(this.#locked) return;
|
||||||
|
this.lockRender()
|
||||||
|
var filename = this.#current.title + "-" + this.#current.version + ".json"
|
||||||
|
this.#boot.secureFetch(this.#serviceurl + "/methods/" + method + "/shareable").then(
|
||||||
|
(resp)=>{
|
||||||
|
if(resp.status === 200){
|
||||||
|
return resp.json()
|
||||||
|
}else throw "Error retrieving sharable process: " + resp.status
|
||||||
|
}
|
||||||
|
).then(data=>{
|
||||||
|
const objectURL = URL.createObjectURL(data)
|
||||||
|
var tmplnk = document.createElement("a")
|
||||||
|
tmplnk.download = filename
|
||||||
|
tmplnk.href = objectURL
|
||||||
|
document.body.appendChild(tmplnk)
|
||||||
|
tmplnk.click()
|
||||||
|
document.body.removeChild(tmplnk)
|
||||||
|
this.unlockRender()
|
||||||
|
}).catch(err=>{
|
||||||
|
alert(err)
|
||||||
|
this.unlockRender()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
editMethod(method){
|
editMethod(method){
|
||||||
if(this.#locked) return;
|
if(this.#locked) return;
|
||||||
this.lockRender()
|
this.lockRender()
|
||||||
|
@ -378,6 +407,7 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
<div class="ccp-toolbar-right">
|
<div class="ccp-toolbar-right">
|
||||||
${this.renderSaveButton()}
|
${this.renderSaveButton()}
|
||||||
${this.renderResetButton()}
|
${this.renderResetButton()}
|
||||||
|
${this.renderDownloadButton()}
|
||||||
${ this.#isupdate ? this.renderDeleteButton() : "" }
|
${ this.#isupdate ? this.renderDeleteButton() : "" }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -532,6 +562,12 @@ class CCPMethodEditorController extends HTMLElement{
|
||||||
this.saveMethod()
|
this.saveMethod()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.#rootdoc.querySelector("button[name=download]").addEventListener("click", ev=>{
|
||||||
|
ev.preventDefault()
|
||||||
|
ev.stopPropagation()
|
||||||
|
this.downloadMethod()
|
||||||
|
})
|
||||||
|
|
||||||
if(this.#isupdate){
|
if(this.#isupdate){
|
||||||
this.#rootdoc.querySelector("button[name=delete]").addEventListener("click", ev=>{
|
this.#rootdoc.querySelector("button[name=delete]").addEventListener("click", ev=>{
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
|
Loading…
Reference in New Issue