diff --git a/repositories.go b/repositories.go index 3e35003..652ea42 100644 --- a/repositories.go +++ b/repositories.go @@ -222,6 +222,7 @@ 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 d3d5275..0b2ac2c 100644 --- a/ui/src/lib/repositories.js +++ b/ui/src/lib/repositories.js @@ -37,8 +37,14 @@ export class WorkRepository { } } - 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`, { + 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, { headers: {'Accept': 'application/json'} }); if (res.status == 200) { @@ -96,7 +102,12 @@ 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) { - return (await res.json()).map((r) => new WorkRepository(r)); + const data = await res.json() + if (data) { + return data.map((r) => new WorkRepository(r)); + } else { + return []; + } } 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 55ebb28..16b0d58 100644 --- a/ui/src/routes/works/[wid]/rendus.svelte +++ b/ui/src/routes/works/[wid]/rendus.svelte @@ -23,13 +23,19 @@ 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; }); + usersP.then((users) => { + nb_users = users.length; + show_dl_btn = { }; + }); }); let nb_rendus = 0; let nb_users = 0; + + let show_logs = null; {#await work then w} @@ -56,7 +62,7 @@ {user.login} - { nb_rendus += 1; user.show_dl_btn = true; }} /> + { nb_rendus += 1; show_dl_btn[user.id] = true; }} /> {#await getRepositories(w.id, user.id) then repos} @@ -69,7 +75,10 @@
{#if repo.last_check} - + { show_logs = repo.getBuildLogs(user.id); (new bootstrap.Modal(document.getElementById('logsModal'))).show(); }} + /> {:else} - {/if} @@ -90,7 +99,7 @@ @@ -102,3 +111,25 @@ {/await} {/await} + +