Compare commits
2 Commits
99d58f69c2
...
5b3bdb0429
Author | SHA1 | Date | |
---|---|---|---|
5b3bdb0429 | |||
5940f14474 |
@ -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
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
</script>
|
||||
|
||||
{#await work then w}
|
||||
@ -56,7 +62,7 @@
|
||||
<tr>
|
||||
<td><a href="users/{user.login}">{user.login}</a></td>
|
||||
<td>
|
||||
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; user.show_dl_btn = true; }} />
|
||||
<SubmissionStatus work={w} user={user} on:done={() => { nb_rendus += 1; show_dl_btn[user.id] = true; }} />
|
||||
</td>
|
||||
<td>
|
||||
{#await getRepositories(w.id, user.id) then repos}
|
||||
@ -69,7 +75,10 @@
|
||||
<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()} />
|
||||
<BuildState
|
||||
repo_pull_state={repo.getBuildState()}
|
||||
on:show_logs={() => { show_logs = repo.getBuildLogs(user.id); (new bootstrap.Modal(document.getElementById('logsModal'))).show(); }}
|
||||
/>
|
||||
{:else}
|
||||
-
|
||||
{/if}
|
||||
@ -90,7 +99,7 @@
|
||||
<a
|
||||
href="/api/users/{user.id}/works/{w.id}/download"
|
||||
class="btn btn-sm btn-dark"
|
||||
class:disabled={!user.show_dl_btn}
|
||||
class:disabled={!show_dl_btn[user.id]}
|
||||
title="Télécharger la tarball du rendu"
|
||||
>
|
||||
<i class="bi bi-download"></i>
|
||||
@ -102,3 +111,25 @@
|
||||
</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>
|
||||
|
Reference in New Issue
Block a user