diff --git a/repositories.go b/repositories.go index 652ea42..3e35003 100644 --- a/repositories.go +++ b/repositories.go @@ -222,7 +222,6 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) { client := drone.NewClient(droneEndpoint, droneConfig) result, err := client.Logs(tmp[0], tmp[1], nbuild, 1, 3) if err != nil { - log.Printf("An error occurs when retrieving logs from Drone (%s/%s/%d/1/3): %s", tmp[0], tmp[1], nbuild, err.Error()) c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Unable to retrieve logs."}) return } diff --git a/ui/src/lib/repositories.js b/ui/src/lib/repositories.js index 0b2ac2c..d3d5275 100644 --- a/ui/src/lib/repositories.js +++ b/ui/src/lib/repositories.js @@ -37,14 +37,8 @@ export class WorkRepository { } } - async getBuildLogs(userid) { - let url = this.id_work?`works/${this.id_work}/repositories/${this.id}/state-logs`:`repositories/${this.id}/state-logs`; - - if (userid) { - url = `users/${userid}/` + url; - } - - const res = await fetch("api/" + url, { + async getBuildLogs() { + const res = await fetch(this.id_work?`api/works/${this.id_work}/repositories/${this.id}/state-logs`:`api/repositories/${this.id}/state-logs`, { headers: {'Accept': 'application/json'} }); if (res.status == 200) { @@ -102,12 +96,7 @@ export async function getRemoteRepositories(userid) { export async function getRepositories(wid, userid) { const res = await fetch(userid?`api/users/${userid}/works/${wid}/repositories`:`api/works/${wid}/repositories`, {headers: {'Accept': 'application/json'}}) if (res.status == 200) { - const data = await res.json() - if (data) { - return data.map((r) => new WorkRepository(r)); - } else { - return []; - } + return (await res.json()).map((r) => new WorkRepository(r)); } else { throw new Error((await res.json()).errmsg); } diff --git a/ui/src/routes/works/[wid]/rendus.svelte b/ui/src/routes/works/[wid]/rendus.svelte index 16b0d58..55ebb28 100644 --- a/ui/src/routes/works/[wid]/rendus.svelte +++ b/ui/src/routes/works/[wid]/rendus.svelte @@ -23,19 +23,13 @@ export let work = null; let usersP = null; - let show_dl_btn = { }; work.then((w) => { usersP = getUsers(w.promo, w.group); - usersP.then((users) => { - nb_users = users.length; - show_dl_btn = { }; - }); + usersP.then((users) => { nb_users = users.length; }); }); let nb_rendus = 0; let nb_users = 0; - - let show_logs = null; {#await work then w} @@ -62,7 +56,7 @@ {user.login} - { nb_rendus += 1; show_dl_btn[user.id] = true; }} /> + { nb_rendus += 1; user.show_dl_btn = true; }} /> {#await getRepositories(w.id, user.id) then repos} @@ -75,10 +69,7 @@
{#if repo.last_check} - { show_logs = repo.getBuildLogs(user.id); (new bootstrap.Modal(document.getElementById('logsModal'))).show(); }} - /> + {:else} - {/if} @@ -99,7 +90,7 @@ @@ -111,25 +102,3 @@ {/await} {/await} - -