diff --git a/src/components/log.vue b/src/components/log.vue index 915ba37..d394211 100644 --- a/src/components/log.vue +++ b/src/components/log.vue @@ -36,7 +36,7 @@ export default { }; }, methods: { - fetch: function() { + fetch() { if (this.fetching) { return; } @@ -49,7 +49,7 @@ export default { this.getLogs(); } }, - streamLogs: function() { + streamLogs() { let path = "/logs?runID=" + this.runid + "&taskID=" + this.taskid; if (this.setup) { path += "&setup"; @@ -69,14 +69,14 @@ export default { this.es.close(); }; }, - getLogs: function() { + async getLogs() { let path = "/logs?runID=" + this.runid + "&taskID=" + this.taskid; if (this.setup) { path += "&setup"; } else { path += "&step=" + this.step; } - fetch(apiurl(path)) + let res = await fetch(apiurl(path)) .then(r => { if (r.status == 200) { return r.text(); diff --git a/src/components/projects.vue b/src/components/projects.vue index da24a52..aa2c679 100644 --- a/src/components/projects.vue +++ b/src/components/projects.vue @@ -38,17 +38,14 @@ export default { }; } }, - fetchProjects(ownertype, ownername) { + async fetchProjects(ownertype, ownername) { let path = "/projectgroups/" + encodeURIComponent(ownertype + "/" + ownername); path += "/projects"; - fetch(apiurl(path)) - .then(res => res.json()) - .then(res => { - console.log(res); - this.projects = res; - console.log("projects", this.projects); - }); + let res = await (await fetch(apiurl(path))).json(); + console.log(res); + this.projects = res; + console.log("projects", this.projects); } }, created: function() { diff --git a/src/components/rundetail.vue b/src/components/rundetail.vue index b7ab6eb..9a68e70 100644 --- a/src/components/rundetail.vue +++ b/src/components/rundetail.vue @@ -134,34 +134,32 @@ export default { if (task.status == "running") return "running"; return "unknown"; }, - restartRun(run, fromStart) { - fetch(apiurl("/run/" + run.id + "/actions"), { + async restartRun(run, fromStart) { + let res = await fetch(apiurl("/run/" + run.id + "/actions"), { method: "POST", body: JSON.stringify({ action_type: "restart", from_start: fromStart }) - }).then(r => { - console.log("r: " + r); - if (r.status == 200) { - return r.json(); - } - throw Error(r.statusText); }); + console.log("r: " + r); + if (r.status == 200) { + return r.json(); + } + throw Error(r.statusText); }, - stopRun(run) { - fetch(apiurl("/run/" + run.id + "/actions"), { + async stopRun(run) { + let res = fetch(apiurl("/run/" + run.id + "/actions"), { method: "POST", body: JSON.stringify({ action_type: "stop" }) - }).then(r => { - console.log("r: " + r); - if (r.status == 200) { - return r.json(); - } - throw Error(r.statusText); }); + console.log("r: " + r); + if (r.status == 200) { + return r.json(); + } + throw Error(r.statusText); } } }; diff --git a/src/components/runs.vue b/src/components/runs.vue index 30c7ac4..6f6c863 100644 --- a/src/components/runs.vue +++ b/src/components/runs.vue @@ -119,32 +119,26 @@ export default { } this.pollData(); }, - fetchProject() { + async fetchProject() { let path = "/projects/" + encodeURIComponent( this.ownertype + "/" + this.ownername + "/" + this.projectname ); - fetch(apiurl(path)) - .then(res => res.json()) - .then(res => { - console.log(res); - this.project = res; - console.log("project", this.project); + let res = await (await fetch(apiurl(path))).json(); + console.log(res); + this.project = res; + console.log("project", this.project); - this.fetchRuns(); - }); + this.fetchRuns(); }, - fetchUser() { - fetch(apiurl("/users/" + this.username)) - .then(res => res.json()) - .then(res => { - console.log(res); - this.user = res; - console.log("user", this.user); + async fetchUser() { + let res = await (await fetch(apiurl("/users/" + this.username))).json(); + console.log(res); + this.user = res; + console.log("user", this.user); - this.fetchRuns(); - }); + this.fetchRuns(); }, async fetchRuns() { let group;