qa: Back to the same situation

This commit is contained in:
nemunaire 2022-11-07 01:00:04 +01:00
commit 1aa82bb2ef
27 changed files with 1336 additions and 22 deletions

View file

@ -5,6 +5,10 @@
} from 'sveltestrap';
import Header from '$lib/components/Header.svelte';
import { version } from '$lib/stores/auth';
version.refresh();
setInterval(version.refresh, 30000);
</script>
<svelte:head>
@ -14,7 +18,9 @@
<Styles />
<Header />
<slot></slot>
<Container class="mt-2 mb-5">
<slot></slot>
</Container>
<style>
:global(body) {

View file

@ -1,2 +1,23 @@
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<script>
import {
Container,
Row,
} from 'sveltestrap';
import MyExercices from '$lib/components/MyExercices.svelte';
import MyTodo from '$lib/components/MyTodo.svelte';
import { exercices } from '$lib/stores/exercices';
import { themes } from '$lib/stores/themes';
if ($exercices.length == 0) {
exercices.refresh();
}
if ($themes.length == 0) {
themes.refresh();
}
</script>
<Row>
<MyTodo class="col-6" />
<MyExercices class="col-6" />
</Row>

View file

@ -0,0 +1,51 @@
<script>
import { goto } from '$app/navigation';
import {
Icon,
Table,
} from 'sveltestrap';
import { fieldsExercices, getExercices } from '$lib/exercices';
let query = "";
function show(id) {
goto("exercices/" + id)
}
</script>
<h2>
Étapes
</h2>
{#await getExercices()}
{:then exercices}
<p>
<input type="search" class="form-control form-control-sm" placeholder="Search" bind:value={query} autofocus>
</p>
<Table class="table-hover table-bordered table-striped table-sm">
<thead class="thead-dark">
<tr>
{#each fieldsExercices as field}
<th>
{field}
</th>
{/each}
</tr>
</thead>
<tbody>
{#each exercices as exercice (exercice.id)}
{#if exercice.title.indexOf(query) >= 0}
<tr on:click={() => show(exercice.id)}>
{#each fieldsExercices as field}
<td>
{@html exercice[field]}
</td>
{/each}
</tr>
{/if}
{/each}
</tbody>
</Table>
{/await}

View file

@ -0,0 +1,13 @@
<script>
import { page } from '$app/stores';
import { getExercice } from '$lib/exercices';
import ExerciceQA from '$lib/components/ExerciceQA.svelte';
let exerciceP = getExercice($page.params.eid);
</script>
{#await exerciceP}
{:then exercice}
<ExerciceQA {exercice} />
{/await}

View file

@ -0,0 +1 @@
<slot></slot>

View file

@ -0,0 +1,54 @@
<script>
import { goto } from '$app/navigation';
import { themes } from '$lib/stores/themes';
import {
Table,
} from 'sveltestrap';
themes.refresh();
let query = "";
const fields = ["name", "authors", "headline", "image"];
function show(id) {
goto("themes/" + id)
}
</script>
<h2>
Scénarios
</h2>
<p>
<input type="search" class="form-control" placeholder="Filtrer" bind:value={query} autofocus>
</p>
<Table class="table-hover table-bordered table-striped">
<thead class="thead-dark">
<tr>
{#each fields as field}
<th>
{field}
</th>
{/each}
</tr>
</thead>
<tbody>
{#each $themes as theme (theme.id)}
{#if theme.name.indexOf(query) >= 0 || theme.authors.indexOf(query) >= 0 || theme.intro.indexOf(query) >= 0}
<tr on:click={() => show(theme.id)}>
{#each fields as field}
<td>
{#if field == "image"}
<img src={"../files" + theme[field]} alt="Image du scénario">
{:else}
{@html theme[field]}
{/if}
</td>
{/each}
</tr>
{/if}
{/each}
</tbody>
</Table>

View file

@ -0,0 +1,76 @@
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import {
Button,
Container,
Icon,
Table,
} from 'sveltestrap';
import { getTheme } from '$lib/themes';
import { fieldsExercices, getThemedExercices } from '$lib/exercices';
let query = "";
function show(id) {
goto("themes/" + $page.params.tid + "/" + id)
}
</script>
{#await getTheme($page.params.tid)}
{:then theme}
<div class="d-flex align-items-end">
<Button
class="align-self-center"
color="link"
on:click={() => goto('themes/')}
>
<Icon name="chevron-left" />
</Button>
<h2>
{theme.name}
</h2>
<small class="m-2 mb-3 text-muted text-truncate">{@html theme.authors}</small>
</div>
<Container class="text-muted">
{@html theme.intro}
</Container>
{#await getThemedExercices($page.params.tid)}
{:then exercices}
<h3>
Défis ({exercices.length})
</h3>
<p>
<input type="search" class="form-control form-control-sm" placeholder="Search" bind:value={query} autofocus>
</p>
<Table class="table-hover table-bordered table-striped table-sm">
<thead class="thead-dark">
<tr>
{#each fieldsExercices as field}
<th>
{field}
</th>
{/each}
</tr>
</thead>
<tbody>
{#each exercices as exercice (exercice.id)}
{#if exercice.title.indexOf(query) >= 0}
<tr on:click={() => show(exercice.id)}>
{#each fieldsExercices as field}
<td>
{@html exercice[field]}
</td>
{/each}
</tr>
{/if}
{/each}
</tbody>
</Table>
{/await}
{/await}

View file

@ -0,0 +1,13 @@
<script>
import { page } from '$app/stores';
import { getThemedExercice } from '$lib/exercices';
import ExerciceQA from '$lib/components/ExerciceQA.svelte';
let exerciceP = getThemedExercice($page.params.tid, $page.params.eid);
</script>
{#await exerciceP}
{:then exercice}
<ExerciceQA {exercice} />
{/await}