svelte-migrate: updated files

This commit is contained in:
nemunaire 2022-12-12 10:24:30 +01:00
parent 4d6149760d
commit ff5a2eef65
36 changed files with 1286 additions and 1418 deletions

View File

@ -10,7 +10,7 @@ import (
"net/http" "net/http"
) )
//go:embed ui/build/* ui/build/css/* ui/build/surveys/* ui/build/_app/* ui/build/_app/immutable/* ui/build/_app/immutable/pages/* ui/build/_app/immutable/pages/surveys/* ui/build/_app/immutable/pages/surveys/_sid_/* ui/build/_app/immutable/pages/surveys/_sid_/responses/* ui/build/_app/immutable/pages/grades/* ui/build/_app/immutable/pages/works/* ui/build/_app/immutable/pages/works/_wid_/* ui/build/_app/immutable/pages/users/* ui/build/_app/immutable/pages/users/_uid_/* ui/build/_app/immutable/pages/users/_uid_/surveys/* ui/build/_app/immutable/chunks/* ui/build/_app/immutable/assets/* ui/build/img/* ui/build/works/* //go:embed all:ui/build
var _assets embed.FS var _assets embed.FS
var Assets http.FileSystem var Assets http.FileSystem

View File

@ -48,7 +48,6 @@ func serveOrReverse(forced_url string) func(c *gin.Context) {
} }
func declareStaticRoutes(router *gin.Engine) { func declareStaticRoutes(router *gin.Engine) {
router.GET("/@fs/*_", serveOrReverse(""))
router.GET("/", serveOrReverse("")) router.GET("/", serveOrReverse(""))
router.GET("/_app/*_", serveOrReverse("")) router.GET("/_app/*_", serveOrReverse(""))
router.GET("/auth/", serveOrReverse("/")) router.GET("/auth/", serveOrReverse("/"))
@ -74,7 +73,7 @@ func declareStaticRoutes(router *gin.Engine) {
router.GET("/.svelte-kit/*_", serveOrReverse("")) router.GET("/.svelte-kit/*_", serveOrReverse(""))
router.GET("/node_modules/*_", serveOrReverse("")) router.GET("/node_modules/*_", serveOrReverse(""))
router.GET("/@vite/*_", serveOrReverse("")) router.GET("/@vite/*_", serveOrReverse(""))
router.GET("/__vite_ping", serveOrReverse("")) router.GET("/@fs/*_", serveOrReverse(""))
router.GET("/src/*_", serveOrReverse("")) router.GET("/src/*_", serveOrReverse(""))
} }
} }

View File

@ -1,6 +0,0 @@
export async function handle({ event, resolve }) {
const response = await resolve(event, {
ssr: false,
});
return response;
}

View File

@ -8,14 +8,10 @@ function createUserStore() {
set: (auth) => { set: (auth) => {
update((m) => auth); update((m) => auth);
}, },
update: (res_auth, cb=null) => { update: (res_auth) => {
if (res_auth.status === 200) { if (res_auth.status === 200) {
res_auth.json().then((auth) => { res_auth.json().then((auth) => {
update((m) => (Object.assign(m?m:{}, auth))); update((m) => (Object.assign(m?m:{}, auth)));
if (cb) {
cb(my);
}
}); });
} else if (res_auth.status >= 400 && res_auth.status < 500) { } else if (res_auth.status >= 400 && res_auth.status < 500) {
update((m) => (null)); update((m) => (null));
@ -24,4 +20,14 @@ function createUserStore() {
}; };
} }
export async function refresh_auth() {
const res = await fetch('api/auth', {headers: {'Accept': 'application/json'}})
if (res.status == 200) {
const auth = await res.json();
user.set(auth);
} else {
user.set(null);
}
}
export const user = createUserStore(); export const user = createUserStore();

16
ui/src/routes/+layout.js Normal file
View File

@ -0,0 +1,16 @@
import { refresh_auth, user } from '$lib/stores/user';
export const ssr = false;
let refresh_interval_auth = null;
export async function load({ url }) {
refresh_interval_auth = setInterval(refresh_auth, Math.floor(Math.random() * 200000) + 200000);
refresh_auth();
const rroutes = url.pathname.split('/');
return {
rroute: rroutes.length>1?rroutes[1]:'',
};
}

View File

@ -1,51 +1,9 @@
<script context="module">
import { user } from '$lib/stores/user';
let stop_refresh = false;
let refresh_interval_auth = null;
async function refresh_auth(cb=null, interval=null) {
if (refresh_interval_auth)
clearInterval(refresh_interval_auth);
if (interval === null) {
interval = Math.floor(Math.random() * 200000) + 200000;
}
if (stop_refresh) {
return;
}
refresh_interval_auth = setInterval(refresh_auth, interval);
const res = await fetch('api/auth', {headers: {'Accept': 'application/json'}})
if (res.status == 200) {
const auth = await res.json();
user.set(auth);
} else {
user.set(null);
}
}
export async function load({ props, stuff, url }) {
refresh_auth();
const rroutes = url.pathname.split('/');
return {
props: {
...props,
rroute: rroutes.length>1?rroutes[1]:'',
},
stuff: {
...stuff,
refresh_auth,
}
};
}
</script>
<script> <script>
import AuthButton from '$lib/components/AuthButton.svelte'; import AuthButton from '$lib/components/AuthButton.svelte';
import Toaster from '$lib/components/Toaster.svelte'; import Toaster from '$lib/components/Toaster.svelte';
import { refresh_auth, user } from '$lib/stores/user';
export let rroute = ''; export let data;
function switchAdminMode() { function switchAdminMode() {
var tmp = $user.is_admin; var tmp = $user.is_admin;
@ -94,17 +52,17 @@
</li> </li>
{/if} {/if}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" class:active={rroute === 'surveys'} href="surveys"> <a class="nav-link" class:active={data.rroute === 'surveys'} href="surveys">
Questionnaires Questionnaires
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" class:active={rroute === 'works'} href="works"> <a class="nav-link" class:active={data.rroute === 'works'} href="works">
Travaux Travaux
</a> </a>
</li> </li>
{#if $user && $user.is_admin} {#if $user && $user.is_admin}
<li class="nav-item"><a class="nav-link" class:active={rroute === 'users'} href="users">Étudiants</a></li> <li class="nav-item"><a class="nav-link" class:active={data.rroute === 'users'} href="users">Étudiants</a></li>
{/if} {/if}
<li class="nav-item"><a class="nav-link" href="virli" target="_self">VIRLI</a></li> <li class="nav-item"><a class="nav-link" href="virli" target="_self">VIRLI</a></li>
</ul> </ul>
@ -129,9 +87,9 @@
<img class="rounded-circle" src="//photos.cri.epita.fr/square/{$user.login}" alt="Menu" style="margin: -0.75em 0; max-height: 2.5em; border: 2px solid white;"> <img class="rounded-circle" src="//photos.cri.epita.fr/square/{$user.login}" alt="Menu" style="margin: -0.75em 0; max-height: 2.5em; border: 2px solid white;">
</a> </a>
<ul class="dropdown-menu dropdown-menu-end"> <ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" class:active={rroute === 'keys'} href="keys">Clef PGP</a></li> <li><a class="dropdown-item" class:active={data.rroute === 'keys'} href="keys">Clef PGP</a></li>
<li><a class="dropdown-item" class:active={rroute === 'help'} href="help">Besoin d'aide&nbsp;?</a></li> <li><a class="dropdown-item" class:active={data.rroute === 'help'} href="help">Besoin d'aide&nbsp;?</a></li>
<li><a class="dropdown-item" class:active={rroute === 'bug-bounty'} href="bug-bounty">Bug Bounty</a></li> <li><a class="dropdown-item" class:active={data.rroute === 'bug-bounty'} href="bug-bounty">Bug Bounty</a></li>
<li><hr class="dropdown-divider"></li> <li><hr class="dropdown-divider"></li>
<li> <li>
<button class="dropdown-item" on:click={disconnectCurrentUser}> <button class="dropdown-item" on:click={disconnectCurrentUser}>

View File

@ -0,0 +1,5 @@
export async function load({ params }) {
return {
cid: params.cid,
};
}

View File

@ -1,15 +1,3 @@
<script context="module">
import { getWork } from '$lib/works';
export async function load({ params }) {
return {
props: {
cid: params.cid,
},
};
}
</script>
<script> <script>
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@ -17,12 +5,10 @@
import CategoryAdmin from '$lib/components/CategoryAdmin.svelte'; import CategoryAdmin from '$lib/components/CategoryAdmin.svelte';
import { Category, getCategory } from '$lib/categories'; import { Category, getCategory } from '$lib/categories';
export let cid; export let data;
let categoryP = null; let categoryP = null;
$: { $: categoryP = getCategory(data.cid);
categoryP = getCategory(cid);
}
</script> </script>
{#await categoryP then category} {#await categoryP then category}

View File

@ -0,0 +1,5 @@
export async function load({ params }) {
return {
promo: params.promo,
};
}

View File

@ -1,17 +1,7 @@
<script context="module">
export async function load({ params }) {
return {
props: {
promo: params.promo,
}
};
}
</script>
<script> <script>
import StudentGrades from '$lib/components/StudentGrades.svelte'; import StudentGrades from '$lib/components/StudentGrades.svelte';
export let promo; export let data;
</script> </script>
<StudentGrades {promo} /> <StudentGrades promo={data.promo} />

View File

@ -0,0 +1,7 @@
export async function load({ url }) {
return {
secret: url.searchParams.get("secret"),
idsurvey: url.searchParams.get("survey"),
exportview_list: url.searchParams.get("graph_list")?false:true,
};
}

View File

@ -1,26 +1,13 @@
<script context="module">
export async function load({ url }) {
return {
props: {
secret: url.searchParams.get("secret"),
idsurvey: url.searchParams.get("survey"),
exportview_list: url.searchParams.get("graph_list")?false:true,
}
};
}
</script>
<script> <script>
import { getSharedQuestions } from '$lib/questions'; import { getSharedQuestions } from '$lib/questions';
import { getSharedSurvey } from '$lib/surveys'; import { getSharedSurvey } from '$lib/surveys';
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte'; import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
import SurveyBadge from '$lib/components/SurveyBadge.svelte'; import SurveyBadge from '$lib/components/SurveyBadge.svelte';
export let secret; export let data;
export let idsurvey;
let surveyP = getSharedSurvey(idsurvey, secret); let surveyP = null;
export let exportview_list = true; $: surveyP = getSharedSurvey(data.idsurvey, data.secret);
</script> </script>
{#await surveyP then survey} {#await surveyP then survey}
@ -32,7 +19,7 @@
<SurveyBadge class="ms-2" {survey} /> <SurveyBadge class="ms-2" {survey} />
</div> </div>
{#await getSharedQuestions(survey.id, secret)} {#await getSharedQuestions(survey.id, data.secret)}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement des questions &hellip;</span> <span>Chargement des questions &hellip;</span>
@ -40,8 +27,8 @@
{:then questions} {:then questions}
{#each questions as question (question.id)} {#each questions as question (question.id)}
<h3>{question.title}</h3> <h3>{question.title}</h3>
{#if question.kind == "text" || (exportview_list && question.kind.indexOf("list") == 0)} {#if question.kind == "text" || (data.exportview_list && question.kind.indexOf("list") == 0)}
{#await question.getResponses(secret) then responses} {#await question.getResponses(data.secret) then responses}
{#each responses as response (response.id)} {#each responses as response (response.id)}
<div class="card mb-2"> <div class="card mb-2">
<div class="card-body"> <div class="card-body">
@ -53,7 +40,7 @@
{/each} {/each}
{/await} {/await}
{:else} {:else}
<CorrectionPieChart {question} {secret} /> <CorrectionPieChart {question} secret={data.secret} />
{/if} {/if}
<hr class="mb-3"> <hr class="mb-3">
{/each} {/each}

View File

@ -0,0 +1,9 @@
import { getSurvey } from '$lib/surveys';
export async function load({ params }) {
const survey = getSurvey(params.sid);
return {
survey,
};
}

View File

@ -1,27 +1,8 @@
<script context="module">
import { getSurvey } from '$lib/surveys';
export async function load({ params, stuff }) {
const survey = getSurvey(params.sid);
return {
props: {
survey,
},
stuff: {
...stuff,
survey,
}
};
}
</script>
<script lang="ts"> <script lang="ts">
export let data;
export let survey;
</script> </script>
{#await survey} {#await data.survey}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement du questionnaire &hellip;</span> <span>Chargement du questionnaire &hellip;</span>

View File

@ -0,0 +1,5 @@
export async function load({ parent }) {
const stuff = await parent();
return stuff;
}

View File

@ -1,15 +1,3 @@
<script context="module">
import { getSurvey } from '$lib/surveys';
export async function load({ params, stuff }) {
return {
props: {
surveyP: stuff.survey,
},
};
}
</script>
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@ -19,22 +7,19 @@
import SurveyQuestions from '$lib/components/SurveyQuestions.svelte'; import SurveyQuestions from '$lib/components/SurveyQuestions.svelte';
import { getQuestions } from '$lib/questions'; import { getQuestions } from '$lib/questions';
export let surveyP; export let data;
let survey = null;
$: { $: {
if (surveyP) { survey = data.survey;
surveyP.then((survey) => {
if (survey.direct && !$user.is_admin) { if (survey.direct && !$user.is_admin) {
goto(`surveys/${survey.id}/live`); goto(`surveys/${survey.id}/live`);
} }
})
}
} }
let edit = false; let edit = false;
</script> </script>
{#await surveyP then survey}
{#if $user && $user.is_admin} {#if $user && $user.is_admin}
<button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button> <button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button>
<a href="surveys/{survey.id}/responses" class="btn btn-success ms-1 float-end" title="Voir les réponses"><i class="bi bi-files"></i></a> <a href="surveys/{survey.id}/responses" class="btn btn-success ms-1 float-end" title="Voir les réponses"><i class="bi bi-files"></i></a>
@ -77,4 +62,3 @@
</div> </div>
{/if} {/if}
{/await} {/await}
{/await}

View File

@ -0,0 +1,8 @@
export async function load({ parent, params }) {
const stuff = await parent();
return {
survey: stuff.survey,
sid: params.sid,
};
}

View File

@ -1,14 +1,3 @@
<script context="module">
export async function load({ params, stuff }) {
return {
props: {
surveyP: stuff.survey,
sid: params.sid,
},
};
}
</script>
<script> <script>
import { user } from '$lib/stores/user'; import { user } from '$lib/stores/user';
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte'; import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
@ -21,28 +10,24 @@
import { getQuestion, getQuestions, Question } from '$lib/questions'; import { getQuestion, getQuestions, Question } from '$lib/questions';
import { getUsers } from '$lib/users'; import { getUsers } from '$lib/users';
export let surveyP; export let data;
export let sid;
let survey; let survey;
let req_questions; let req_questions;
surveyP.then((s) => { $: {
survey = s; survey = data.survey;
updateQuestions(); updateQuestions();
if (survey.direct !== null) { if (survey.direct !== null) {
wsconnect(); wsconnect();
} }
}); }
function updateSurvey() { async function updateSurvey() {
surveyP = getSurvey(survey.id); survey = await getSurvey(survey.id);
surveyP.then((s) => {
survey = s;
updateQuestions(); updateQuestions();
if (survey.direct !== null) { if (survey.direct !== null) {
wsconnect(); wsconnect();
} }
});
} }
function updateQuestions() { function updateQuestions() {
@ -162,7 +147,7 @@
function wsconnect() { function wsconnect() {
if (ws !== null) return; if (ws !== null) return;
ws = new WebSocket((window.location.protocol == 'https:'?'wss://':'ws://') + window.location.host + `/api/surveys/${sid}/ws-admin`); ws = new WebSocket((window.location.protocol == 'https:'?'wss://':'ws://') + window.location.host + `/api/surveys/${data.sid}/ws-admin`);
ws.addEventListener("open", () => { ws.addEventListener("open", () => {
ws_up = true; ws_up = true;
@ -233,7 +218,6 @@
} }
</script> </script>
{#await surveyP then survey}
{#if $user && $user.is_admin} {#if $user && $user.is_admin}
<StartStopLiveSurvey <StartStopLiveSurvey
{survey} {survey}
@ -251,7 +235,7 @@
Administration Administration
</small> </small>
{#if asks.length} {#if asks.length}
<a href="surveys/{sid}/admin#questions_part"> <a href="surveys/{data.sid}/admin#questions_part">
<i class="bi bi-patch-question-fill text-danger"></i> <i class="bi bi-patch-question-fill text-danger"></i>
</a> </a>
{/if} {/if}
@ -368,7 +352,7 @@
<tr> <tr>
<td> <td>
{#if responses[question.id]} {#if responses[question.id]}
<a href="surveys/{sid}/admin#q{question.id}_res"> <a href="surveys/{data.sid}/admin#q{question.id}_res">
{question.title} {question.title}
</a> </a>
{:else} {:else}
@ -700,5 +684,3 @@
</div> </div>
{/if} {/if}
{/if} {/if}
{/await}

View File

@ -0,0 +1,8 @@
export async function load({ params, parent }) {
const stuff = await parent();
return {
survey: stuff.survey,
sid: params.sid,
};
}

View File

@ -1,14 +1,3 @@
<script context="module">
export async function load({ params, stuff }) {
return {
props: {
surveyP: stuff.survey,
sid: params.sid,
},
};
}
</script>
<script> <script>
import { onDestroy } from 'svelte'; import { onDestroy } from 'svelte';
@ -18,11 +7,9 @@
import QuestionForm from '$lib/components/QuestionForm.svelte'; import QuestionForm from '$lib/components/QuestionForm.svelte';
import { getQuestion } from '$lib/questions'; import { getQuestion } from '$lib/questions';
export let surveyP; export let data;
export let sid;
let survey; let survey;
$: survey = data.survey;
surveyP.then((s) => survey = s);
let ws_up = false; let ws_up = false;
let show_question = null; let show_question = null;
@ -75,7 +62,7 @@
} }
}); });
function wsconnect() { function wsconnect() {
ws = new WebSocket((window.location.protocol == 'https:'?'wss://':'ws://') + window.location.host + `/api/surveys/${sid}/ws`); ws = new WebSocket((window.location.protocol == 'https:'?'wss://':'ws://') + window.location.host + `/api/surveys/${data.sid}/ws`);
ws.addEventListener("open", () => { ws.addEventListener("open", () => {
ws_up = true; ws_up = true;
@ -183,7 +170,6 @@
let corrections = null; let corrections = null;
</script> </script>
{#await surveyP then unused}
<div <div
style={"transition: opacity 150ms ease-out; opacity: " + (displaySendInProgress?1:0)} style={"transition: opacity 150ms ease-out; opacity: " + (displaySendInProgress?1:0)}
class="ms-2 float-end" class="ms-2 float-end"
@ -299,4 +285,3 @@
</h2> </h2>
{/if} {/if}
</form> </form>
{/await}

View File

@ -0,0 +1,7 @@
export async function load({ parent }) {
const stuff = await parent();
return {
survey: stuff.survey,
};
}

View File

@ -1,32 +1,20 @@
<script context="module">
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
import { getSurvey } from '$lib/surveys';
import { getUsers } from '$lib/users';
export async function load({ params, stuff }) {
return {
props: {
surveyP: stuff.survey,
},
};
}
</script>
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { user } from '$lib/stores/user'; import { user } from '$lib/stores/user';
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
import StartStopLiveSurvey from '$lib/components/StartStopLiveSurvey.svelte'; import StartStopLiveSurvey from '$lib/components/StartStopLiveSurvey.svelte';
import SurveyAdmin from '$lib/components/SurveyAdmin.svelte'; import SurveyAdmin from '$lib/components/SurveyAdmin.svelte';
import SurveyBadge from '$lib/components/SurveyBadge.svelte'; import SurveyBadge from '$lib/components/SurveyBadge.svelte';
import SurveyQuestions from '$lib/components/SurveyQuestions.svelte'; import SurveyQuestions from '$lib/components/SurveyQuestions.svelte';
import { getQuestions } from '$lib/questions'; import { getQuestions } from '$lib/questions';
import { getUsers } from '$lib/users';
export let surveyP; export let data;
let usersP = null; let survey;
surveyP.then((s) => { let usersP;
usersP = getUsers(s.promo, s.group); $: survey = data.survey;
}) $: usersP = getUsers(data.survey.promo, data.survey.group);
let edit = false; let edit = false;
let exportview = false; let exportview = false;
let exportview_list = false; let exportview_list = false;
@ -41,7 +29,6 @@
} }
</script> </script>
{#await surveyP then survey}
{#if $user && $user.is_admin} {#if $user && $user.is_admin}
<button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button> <button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button>
<StartStopLiveSurvey <StartStopLiveSurvey
@ -157,7 +144,6 @@
{/each} {/each}
{/if} {/if}
{/await} {/await}
{/await}
<div class="modal fade" tabindex="-1" id="shareModal"> <div class="modal fade" tabindex="-1" id="shareModal">
<div class="modal-dialog"> <div class="modal-dialog">

View File

@ -0,0 +1,8 @@
export async function load({ params, parent }) {
const stuff = await parent();
return {
survey: stuff.survey,
rid: params.rid,
};
}

View File

@ -1,16 +1,3 @@
<script context="module">
import { getSurvey } from '$lib/surveys';
export async function load({ params, stuff }) {
return {
props: {
surveyP: stuff.survey,
rid: params.rid,
},
};
}
</script>
<script lang="ts"> <script lang="ts">
import Correction from '$lib/components/Correction.svelte'; import Correction from '$lib/components/Correction.svelte';
import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte'; import CorrectionPieChart from '$lib/components/CorrectionPieChart.svelte';
@ -20,8 +7,7 @@
import { getCorrectionTemplates } from '$lib/correctionTemplates'; import { getCorrectionTemplates } from '$lib/correctionTemplates';
import { getQuestion } from '$lib/questions'; import { getQuestion } from '$lib/questions';
export let surveyP; export let data;
export let rid;
let showChart = false; let showChart = false;
let showResponses = false; let showResponses = false;
@ -31,10 +17,11 @@
let child; let child;
let waitApply = false; let waitApply = false;
let ctpls = getCorrectionTemplates(rid); let ctpls;
let filter = "";
let cts = { }; let cts = { };
$: {
ctpls = getCorrectionTemplates(data.rid);
if (ctpls) {
ctpls.then((ctpls) => { ctpls.then((ctpls) => {
for (const tpl of ctpls) { for (const tpl of ctpls) {
cts[tpl.id] = { }; cts[tpl.id] = { };
@ -46,18 +33,22 @@
} }
}) })
} }
cts = cts;
}); });
}
}
let filter = "";
let nodescription = false; let nodescription = false;
let y = 0; let y = 0;
$: nodescription = y > 10; $: nodescription = y > 10;
let survey = null;
$: survey = data.survey;
</script> </script>
<svelte:window bind:scrollY={y} /> <svelte:window bind:scrollY={y} />
{#await surveyP then survey} {#await getQuestion(data.rid)}
{#await getQuestion(rid)}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement de la question&hellip;</span> <span>Chargement de la question&hellip;</span>
@ -66,7 +57,7 @@
{#await ctpls} {#await ctpls}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement de la question&hellip;</span> <span>Chargement des templates&hellip;</span>
</div> </div>
{:then correctionTemplates} {:then correctionTemplates}
<div class="float-end"> <div class="float-end">
@ -178,6 +169,5 @@
/> />
{/await} {/await}
{/await} {/await}
{/await}
<div class="mb-5" style="min-height: 60vh"></div> <div class="mb-5" style="min-height: 60vh"></div>

View File

@ -0,0 +1,5 @@
export async function load({ params }) {
return {
uid: params.uid,
};
}

View File

@ -1,13 +1,3 @@
<script context="module">
export async function load({ params }) {
return {
props: {
uid: params.uid,
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import UserKeys from '$lib/components/UserKeys.svelte'; import UserKeys from '$lib/components/UserKeys.svelte';
import UserSurveys from '$lib/components/UserSurveys.svelte'; import UserSurveys from '$lib/components/UserSurveys.svelte';
@ -15,13 +5,13 @@
import { getSurveys } from '$lib/surveys'; import { getSurveys } from '$lib/surveys';
import { getUser, getUserGrade, getUserScore } from '$lib/users'; import { getUser, getUserGrade, getUserScore } from '$lib/users';
export let uid; export let data;
let allPromos = false; let allPromos = false;
let myuser = null; let myuser = null;
let userP = null; let userP = null;
$: userP = getUser(uid).then((u) => myuser = u) $: userP = getUser(data.uid).then((u) => myuser = u)
function impersonate() { function impersonate() {
fetch('api/auth/impersonate', { fetch('api/auth/impersonate', {

View File

@ -0,0 +1,5 @@
export async function load({ params }) {
return {
uid: params.uid,
};
}

View File

@ -1,25 +1,15 @@
<script context="module">
export async function load({ params }) {
return {
props: {
uid: params.uid,
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import UserSurveys from '$lib/components/UserSurveys.svelte'; import UserSurveys from '$lib/components/UserSurveys.svelte';
import { user } from '$lib/stores/user'; import { user } from '$lib/stores/user';
import { getSurveys } from '$lib/surveys'; import { getSurveys } from '$lib/surveys';
import { getUser, getUserGrade, getUserScore } from '$lib/users'; import { getUser, getUserGrade, getUserScore } from '$lib/users';
export let uid; export let data;
let allPromos = false; let allPromos = false;
</script> </script>
{#await getUser(uid)} {#await getUser(data.uid)}
<h2> <h2>
Étudiant Étudiant
</h2> </h2>

View File

@ -0,0 +1,6 @@
export async function load({ params }) {
return {
sid: params.sid,
uid: params.uid,
};
}

View File

@ -1,14 +1,3 @@
<script context="module">
export async function load({ params }) {
return {
props: {
sid: params.sid,
uid: params.uid,
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import SurveyBadge from '$lib/components/SurveyBadge.svelte'; import SurveyBadge from '$lib/components/SurveyBadge.svelte';
import SurveyQuestions from '$lib/components/SurveyQuestions.svelte'; import SurveyQuestions from '$lib/components/SurveyQuestions.svelte';
@ -16,11 +5,10 @@
import { getQuestions } from '$lib/questions'; import { getQuestions } from '$lib/questions';
import { getUser } from '$lib/users'; import { getUser } from '$lib/users';
export let sid; export let data;
export let uid;
</script> </script>
{#await getUser(uid)} {#await getUser(data.uid)}
<h2> <h2>
Étudiant Étudiant
</h2> </h2>
@ -30,7 +18,7 @@
Chargement des d&eacute;tails&hellip; Chargement des d&eacute;tails&hellip;
</div> </div>
{:then student} {:then student}
{#await getSurvey(sid)} {#await getSurvey(data.sid)}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement du questionnaire &hellip;</span> <span>Chargement du questionnaire &hellip;</span>
@ -50,7 +38,7 @@
<span>Chargement des questions &hellip;</span> <span>Chargement des questions &hellip;</span>
</div> </div>
{:then questions} {:then questions}
<SurveyQuestions {survey} {questions} id_user={uid} /> <SurveyQuestions {survey} {questions} id_user={data.uid} />
{/await} {/await}
{:catch error} {:catch error}
<div class="text-center"> <div class="text-center">

View File

@ -0,0 +1,9 @@
import { getWork } from '$lib/works';
export async function load({ params }) {
const work = getWork(params.wid);
return {
work,
};
}

View File

@ -1,27 +1,8 @@
<script context="module">
import { getWork } from '$lib/works';
export async function load({ params, stuff }) {
const work = getWork(params.wid);
return {
props: {
work,
},
stuff: {
...stuff,
work,
}
};
}
</script>
<script lang="ts"> <script lang="ts">
export let data;
export let work;
</script> </script>
{#await work} {#await data.work}
<div class="text-center"> <div class="text-center">
<div class="spinner-border text-primary mx-3" role="status"></div> <div class="spinner-border text-primary mx-3" role="status"></div>
<span>Chargement du rendu &hellip;</span> <span>Chargement du rendu &hellip;</span>

View File

@ -0,0 +1,7 @@
export async function load({ parent }) {
const stuff = await parent();
return {
work: stuff.work,
};
}

View File

@ -1,15 +1,3 @@
<script context="module">
import { getWork } from '$lib/works';
export async function load({ params, stuff }) {
return {
props: {
work: stuff.work,
},
};
}
</script>
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@ -21,21 +9,20 @@
import WorkRepository from '$lib/components/WorkRepository.svelte'; import WorkRepository from '$lib/components/WorkRepository.svelte';
import { getScore } from '$lib/users'; import { getScore } from '$lib/users';
export let work = null; export let data;
let edit = false; let edit = false;
let my_submission = null; let my_submission = null;
let warn_already_used = false; let warn_already_used = false;
let w = null;
work.then((w) => { $: w = data.work;
refresh_submission(w); $: refresh_submission(data.work);
})
function refresh_submission(w) { function refresh_submission(w) {
my_submission = w.getSubmission(); my_submission = w.getSubmission();
} }
</script> </script>
{#await work then w}
{#if $user && $user.is_admin} {#if $user && $user.is_admin}
<button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button> <button class="btn btn-primary ms-1 float-end" on:click={() => { edit = !edit; } } title="Éditer"><i class="bi bi-pencil"></i></button>
<a class="btn btn-success ms-1 float-end" href="works/{w.id}/rendus" title="Voir les rendus"><i class="bi bi-files"></i></a> <a class="btn btn-success ms-1 float-end" href="works/{w.id}/rendus" title="Voir les rendus"><i class="bi bi-files"></i></a>
@ -238,5 +225,4 @@
</div> </div>
{/if} {/if}
{/if} {/if}
{/await}
<div class="mb-5"></div> <div class="mb-5"></div>

View File

@ -0,0 +1,7 @@
export async function load({ parent }) {
const stuff = await parent();
return {
work: stuff.work,
};
}

View File

@ -1,15 +1,3 @@
<script context="module">
import { getWork } from '$lib/works';
export async function load({ params, stuff }) {
return {
props: {
work: stuff.work,
},
};
}
</script>
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@ -23,11 +11,13 @@
import { ToastsStore } from '$lib/stores/toasts'; import { ToastsStore } from '$lib/stores/toasts';
import { getUsers } from '$lib/users'; import { getUsers } from '$lib/users';
export let work = null; export let data;
let usersP = null; let usersP = null;
let show_dl_btn = { }; let show_dl_btn = { };
let repositoriesP = { }; let repositoriesP = { };
work.then((w) => { let w = null;
$: {
w = data.work;
usersP = getUsers(w.promo, w.group); usersP = getUsers(w.promo, w.group);
usersP.then((users) => { usersP.then((users) => {
nb_users = users.length; nb_users = users.length;
@ -36,7 +26,7 @@
updateRepoUser(w.id, user.id); updateRepoUser(w.id, user.id);
} }
}); });
}); }
function updateRepoUser(wid, userid) { function updateRepoUser(wid, userid) {
repositoriesP[userid] = getRepositories(wid, userid); repositoriesP[userid] = getRepositories(wid, userid);
@ -50,7 +40,6 @@
let search_repo_for = {repo: null, user: null}; let search_repo_for = {repo: null, user: null};
</script> </script>
{#await work then w}
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<h2> <h2>
<a href="works/{w.id}" class="text-muted" style="text-decoration: none">&lt;</a> <a href="works/{w.id}" class="text-muted" style="text-decoration: none">&lt;</a>
@ -188,7 +177,6 @@
</form> </form>
</div> </div>
</div> </div>
{/await}
<div class="modal fade" tabindex="-1" id="logsModal"> <div class="modal fade" tabindex="-1" id="logsModal">
<div class="modal-dialog modal-xl"> <div class="modal-dialog modal-xl">