qa: Can export to gitlab

This commit is contained in:
nemunaire 2023-11-25 13:43:41 +01:00
commit 60a34d3ced
13 changed files with 463 additions and 3 deletions

View file

@ -48,5 +48,8 @@
<a href="themes/{exercice.id_theme}" title={$themesIdx[exercice.id_theme].authors}>{$themesIdx[exercice.id_theme].name}</a>
</small>
<a href="../{$themesIdx[exercice.id_theme].urlid}/{exercice.urlid}" target="_self" class="float-right ml-2 btn btn-sm btn-info"><Icon name="play-fill" /> Site du challenge</a>
{#if exercice.forge_link}
<a href="{exercice.forge_link}" target="_blank" class="float-right ml-2 btn btn-sm btn-warning"><Icon name="gitlab" /> GitLab</a>
{/if}
{/if}
</h2>

View file

@ -33,6 +33,17 @@
activemenu = "";
}
}
async function rungitlab() {
const res = await fetch('api/gitlab/token');
if (res.status === 200) {
return res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
const gitlab = rungitlab();
</script>
<Navbar color="dark" dark expand="xs">
@ -90,6 +101,17 @@
{/if}
</Nav>
<Nav class="ms-auto text-light" navbar>
{#await gitlab then gl}
<Icon name="gitlab" />
{:catch err}
<Button
color="warning"
size="sm"
href="auth/gitlab?next=/"
>
<Icon name="gitlab" /> Connexion GitLab
</Button>
{/await}
<NavItem class="ms-2 text-truncate">
v{$version.version}
{#if $auth}&ndash; Logged as {$auth.name} (team #{$auth.id_team}){/if}

View file

@ -149,6 +149,17 @@
})
})
}
async function rungitlab() {
const res = await fetch('api/gitlab/token');
if (res.status === 200) {
return res.json();
} else {
throw new Error((await res.json()).errmsg);
}
}
const gitlab = rungitlab();
</script>
{#if query}
@ -157,6 +168,16 @@
<div class="d-flex justify-content-between align-items-center">
<h4 class="card-title fw-bold mb-0">{query.subject}</h4>
<div>
{#if $auth && !query.solved}
{#await gitlab then gl}
<Button
on:click={() => query.export2Gitlab()}
>
<Icon name="gitlab" />
Exporter vers GitLab
</Button>
{/await}
{/if}
{#if $auth && !query.solved && $viewIdx[query.id_exercice]}
<Button on:click={solveQA} color="success">
<Icon name="check" />