support also dropping of execution objects
This commit is contained in:
parent
c243983942
commit
be2f797d38
|
@ -65,19 +65,6 @@ class CCPExecutionForm extends HTMLElement{
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Runtimes <span alt="refresh" title="refresh" style="cursor:pointer" name="refresh-runtimes" class="text-info">↺</span></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="ccp-runtimes">
|
||||
<div class="form-row">
|
||||
<select class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div-->
|
||||
<button id="execute_method_button" class="btn btn-info">Execute</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -93,7 +80,7 @@ class CCPExecutionForm extends HTMLElement{
|
|||
}
|
||||
|
||||
loadMethod(){
|
||||
this.#boot.secureFetch(this.#serviceurl + "/processes/" + this.#method).then(
|
||||
return this.#boot.secureFetch(this.#serviceurl + "/processes/" + this.#method).then(
|
||||
(resp)=>{
|
||||
if(resp.status === 200){
|
||||
return resp.json()
|
||||
|
@ -122,7 +109,6 @@ class CCPExecutionForm extends HTMLElement{
|
|||
showMethod(){
|
||||
if(this.#method == null) this.showEmpty();
|
||||
else{
|
||||
console.log(this.#data)
|
||||
BSS.apply(this.#executionform_bss, this.#rootdoc)
|
||||
}
|
||||
}
|
||||
|
@ -176,16 +162,70 @@ class CCPExecutionForm extends HTMLElement{
|
|||
return Array.prototype.slice.call(this.#rootdoc.querySelectorAll("d4s-ccp-output"))
|
||||
}
|
||||
|
||||
initValues(inputs){
|
||||
Object.keys(inputs).forEach(k=>{
|
||||
const w = this.#rootdoc.querySelector(`d4s-ccp-input[name=${k}]`)
|
||||
if(w){
|
||||
w.value = (inputs[k])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
prepareFromExecution(exec){
|
||||
let f1 =
|
||||
this.#boot.secureFetch(this.#serviceurl + `/executions/${exec.id}/metadata/method.json`)
|
||||
.then(resp=>{
|
||||
if(resp.status === 200){
|
||||
return resp.json()
|
||||
}else throw "Error retrieving process"
|
||||
}
|
||||
).then(data=>data)
|
||||
|
||||
let f2 =
|
||||
this.#boot.secureFetch(this.#serviceurl + `/executions/${exec.id}/metadata/request.json`)
|
||||
.then(resp=>{
|
||||
if(resp.status === 200){
|
||||
return resp.json()
|
||||
}else throw "Error retrieving process"
|
||||
}
|
||||
).then(data=>data)
|
||||
|
||||
var requestdata = null
|
||||
Promise.all([f1, f2]).then(m_and_r => {
|
||||
this.#data = m_and_r[0]
|
||||
requestdata = m_and_r[1]
|
||||
this.#method = this.#data.id
|
||||
const rts =
|
||||
this.#data.links
|
||||
.filter(l => l.rel === "compatibleWith")
|
||||
.map(l=>l.href.replace("runtimes/",""))
|
||||
.join(" ")
|
||||
return this.#boot.secureFetch(this.#serviceurl + "/infrastructures/runtimes?runtimes=" + rts)
|
||||
}).then(resp=>{
|
||||
this.#data.executable = resp.status === 200
|
||||
}).then(()=>{
|
||||
this.showMethod()
|
||||
this.initValues(requestdata.inputs)
|
||||
}).catch(err=>alert(err))
|
||||
}
|
||||
|
||||
#empty_executionform_bss = {
|
||||
template : "#EXECUTION_FORM_EMPTY_TEMPLATE",
|
||||
target : "div[name=execution_form]",
|
||||
on_drop : ev=>{
|
||||
if(ev.dataTransfer && ev.dataTransfer.getData('text/plain+ccpmethod')){
|
||||
if(ev.dataTransfer){
|
||||
if(ev.dataTransfer.getData('text/plain+ccpmethod')){
|
||||
const id = ev.dataTransfer.getData('text/plain+ccpmethod')
|
||||
this.setAttribute("method", id);
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
ev.currentTarget.style.backgroundColor = "white"
|
||||
}else if(ev.dataTransfer.getData('text/plain+ccpexecution')){
|
||||
this.prepareFromExecution(JSON.parse(ev.dataTransfer.getData('application/json+ccpexecution')))
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
ev.currentTarget.style.backgroundColor = "white"
|
||||
}
|
||||
}
|
||||
},
|
||||
on_dragover : ev=>{
|
||||
|
@ -198,11 +238,18 @@ class CCPExecutionForm extends HTMLElement{
|
|||
target : "div[name=execution_form]",
|
||||
in : ()=>this.#data,
|
||||
on_drop : ev=>{
|
||||
if(ev.dataTransfer && ev.dataTransfer.getData('text/plain+ccpmethod')){
|
||||
if(ev.dataTransfer){
|
||||
if(ev.dataTransfer.getData('text/plain+ccpmethod')){
|
||||
const id = ev.dataTransfer.getData('text/plain+ccpmethod');
|
||||
this.setAttribute("method", id);
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
}else if(ev.dataTransfer.getData('text/plain+ccpexecution')){
|
||||
this.prepareFromExecution(JSON.parse(ev.dataTransfer.getData('application/json+ccpexecution')))
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
ev.currentTarget.style.backgroundColor = "white"
|
||||
}
|
||||
}
|
||||
},
|
||||
on_dragover : ev=>{
|
||||
|
@ -225,7 +272,7 @@ class CCPExecutionForm extends HTMLElement{
|
|||
"in" : (e,d)=>{ return Object.values(d.inputs) },
|
||||
target : "div",
|
||||
apply : (e,d)=>{
|
||||
e.innerHTML = `<d4s-ccp-input input='${JSON.stringify(d)}'></d4s-ccp-input>`
|
||||
e.innerHTML = `<d4s-ccp-input name="${d.id}" input='${JSON.stringify(d)}'></d4s-ccp-input>`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -238,7 +285,7 @@ class CCPExecutionForm extends HTMLElement{
|
|||
"in" : (e,d)=>{ return Object.values(d.outputs) },
|
||||
target : "div",
|
||||
apply : (e,d)=>{
|
||||
e.innerHTML = `<d4s-ccp-output output='${JSON.stringify(d)}'></d4s-ccp-output>`
|
||||
e.innerHTML = `<d4s-ccp-output name="${d.id}" output='${JSON.stringify(d)}'></d4s-ccp-output>`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue