qa: Can export to gitlab
This commit is contained in:
parent
0a22d09947
commit
60a34d3ced
13 changed files with 463 additions and 3 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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}– Logged as {$auth.name} (team #{$auth.id_team}){/if}
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export class Exercice {
|
|||
}
|
||||
}
|
||||
|
||||
update({ id, id_theme, title, wip, urlid, path, statement, overview, headline, finished, issue, issuekind, depend, gain, coefficient, videoURI, resolution, seealso }) {
|
||||
update({ id, id_theme, title, wip, urlid, path, statement, overview, headline, finished, issue, issuekind, depend, gain, coefficient, videoURI, resolution, seealso, forge_link }) {
|
||||
this.id = id;
|
||||
this.id_theme = id_theme;
|
||||
this.title = title;
|
||||
|
|
@ -26,6 +26,7 @@ export class Exercice {
|
|||
this.videoURI = videoURI;
|
||||
this.resolution = resolution;
|
||||
this.seealso = seealso;
|
||||
this.forge_link = forge_link;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,15 @@ export class QAQuery {
|
|||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
async export2Gitlab() {
|
||||
const res = await fetch(`api/qa/${this.id}/gitlab_export`, {method: 'POST', headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function getExerciceQA(eid) {
|
||||
|
|
|
|||
Reference in a new issue