Retrieve Drone build state
This commit is contained in:
parent
65b62afb82
commit
6245e49be7
3 changed files with 55 additions and 3 deletions
|
@ -52,6 +52,25 @@
|
|||
<div>
|
||||
Dépôt lié : <strong style="font-family: monospace">{repo.uri}</strong><br>
|
||||
Dernière récupération : <strong>{#if repo.last_check}<DateFormat date={new Date(repo.last_check)} dateStyle="medium" timeStyle="medium" />{:else}-{/if}</strong>
|
||||
{#await repo.getBuildState()}
|
||||
<div class="spinner-grow spinner-grow-sm mx-1" role="status"></div>
|
||||
{:then state}
|
||||
{#if state.status == "pending" || state.status == "running"}
|
||||
<div
|
||||
class="spinner-grow spinner-grow-sm mx-1"
|
||||
class:text-secondary={state.status == "pending"}
|
||||
class:text-warning={state.status == "running"}
|
||||
title="La récupération est en cours"
|
||||
role="status"
|
||||
></div>
|
||||
{:else if state.status == "success"}
|
||||
<i class="bi bi-check-circle-fill text-success mx-1" title="La récupération s'est bien passée"></i>
|
||||
{:else if state.status == "failure"}
|
||||
<i class="bi bi-exclamation-circle-fill text-danger mx-1" title="La récupération ne s'est pas bien passée"></i>
|
||||
{:else}
|
||||
{state.status}
|
||||
{/if}
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-column justify-content-center">
|
||||
|
|
|
@ -25,6 +25,17 @@ export class WorkRepository {
|
|||
}
|
||||
}
|
||||
|
||||
async getBuildState() {
|
||||
const res = await fetch(`api/repositories/${this.id}/state`, {
|
||||
headers: {'Accept': 'application/json'}
|
||||
});
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
async retrieveWork() {
|
||||
const res = await fetch(`api/repositories/${this.id}/trigger`, {
|
||||
method: 'POST',
|
||||
|
|
Reference in a new issue