moved runnability check to infras instead of runtimes

This commit is contained in:
dcore94 2023-03-07 14:21:13 +01:00
parent 36f307b308
commit 92297a226a
1 changed files with 20 additions and 23 deletions

View File

@ -159,7 +159,7 @@ class CCPMethodList2 extends HTMLElement{
console.log("Processes parsed to json", data)
this.#data = data
this.updateList()
return Promise.all(this.fetchRuntimes())
return this.fetchInfrastructures()
}).then(d => {
this.updateList()
}).catch(err=>{
@ -168,28 +168,25 @@ class CCPMethodList2 extends HTMLElement{
})
}
fetchRuntimes(){
var promises = []
for(var d in this.#data ){
const m = this.#data[d]
if(!m.links || m.links.length === 0) continue;
const rts = m.links
.filter(l => l.rel === "compatibleWith")
.map( l => l.href.replace("runtimes/",""))
.join(" ")
const url = this.#serviceurl + "/infrastructures/runtimes?runtimes=" + rts
promises.push(
this.#boot.secureFetch(url).
then(resp=>{
m["executable"] = resp.status === 200
if(resp.status === 404) return null;
}).catch(err=>{
alert("Error while checking runtimes for method")
console.error("Error while checking runtimes for method: " + err)
})
)
}
return promises
fetchInfrastructures(){
const url = this.#serviceurl + "/infrastructures"
this.#boot.secureFetch(url).
then(resp=>{
if(resp.status !== 200) throw "Unable to fetch infrastructures " + resp.status;
else return resp.json()
}).then(infras=>{
for(let m=0; m < this.#data.length; m++){
const method = this.#data[m]
for(let i=0; i < infras.length; i++){
const infra = infras[i]
const matches = m.links.filter(l => return l.rel === "compatibleWith" && l.href === "infrastructures/" + infra.id
m["executable"] = matches.length > 0
}
}
}).catch(err=>{
alert("Error while checking runtimes for method")
console.error("Error while checking runtimes for method: " + err)
})
}
updateList(){