diff --git a/ccp/js/methodlistcontroller2.js b/ccp/js/methodlistcontroller2.js index b60c8bf..3cf8b06 100644 --- a/ccp/js/methodlistcontroller2.js +++ b/ccp/js/methodlistcontroller2.js @@ -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(){