Compare commits

..

No commits in common. "5b3bdb04297203d9f689d4006d96d777dee35373" and "99d58f69c2602c775665b8a4c3e501bbc1397a10" have entirely different histories.

3 changed files with 7 additions and 50 deletions

View File

@ -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
}

View File

@ -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);
}

View File

@ -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;
</script>
{#await work then w}
@ -62,7 +56,7 @@
<tr>
<td><a href="users/{user.login}">{user.login}</a></td>
<td>
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; show_dl_btn[user.id] = true; }} />
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; user.show_dl_btn = true; }} />
</td>
<td>
{#await getRepositories(w.id, user.id) then repos}
@ -75,10 +69,7 @@
<div class="mx-1">
{#if repo.last_check}
<DateFormat date={new Date(repo.last_check)} dateStyle="medium" timeStyle="medium" />
<BuildState
repo_pull_state={repo.getBuildState()}
on:show_logs={() => { show_logs = repo.getBuildLogs(user.id); (new bootstrap.Modal(document.getElementById('logsModal'))).show(); }}
/>
<BuildState repo_pull_state={repo.getBuildState()} />
{:else}
-
{/if}
@ -99,7 +90,7 @@
<a
href="/api/users/{user.id}/works/{w.id}/download"
class="btn btn-sm btn-dark"
class:disabled={!show_dl_btn[user.id]}
class:disabled={!user.show_dl_btn}
title="Télécharger la tarball du rendu"
>
<i class="bi bi-download"></i>
@ -111,25 +102,3 @@
</table>
{/await}
{/await}
<div class="modal fade" tabindex="-1" id="logsModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Repository Logs</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
{#if show_logs}
{#await show_logs}
<div class="modal-body d-flex justify-content-between">
<div class="spinner-border text-primary" role="status"></div>
</div>
{:then logs}
<div class="modal-body d-flex justify-content-between bg-dark text-light">
<pre class="pb-2">{#each logs as l (l.pos)}{l.out}{/each}</pre>
</div>
{/await}
{/if}
</div>
</div>
</div>