Distribute and handle challenge.json
This commit is contained in:
parent
e8f6a03cd9
commit
dff4f4eb63
20 changed files with 167 additions and 48 deletions
|
|
@ -5,7 +5,6 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
|
||||
<meta name="author" content="EPITA Laboratoire SRS">
|
||||
<meta name="robots" content="all">
|
||||
<base href="/">
|
||||
%svelte.head%
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
Icon,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { challengeInfo } from '../stores/challengeinfo.js';
|
||||
import { settings, time } from '../stores/settings.js';
|
||||
</script>
|
||||
|
||||
|
|
@ -53,9 +54,9 @@
|
|||
Classement
|
||||
</a>
|
||||
<a
|
||||
href="{$settings.videoslink}"
|
||||
href="{$challengeInfo.videoslink}"
|
||||
class="btn btn-light"
|
||||
class:disabled={$settings.videoslink === ''}
|
||||
class:disabled={$challengeInfo.videoslink === ''}
|
||||
>
|
||||
<Icon name="laptop-fill" />
|
||||
Vidéos
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
import ExerciceVideo from '../../components/ExerciceVideo.svelte';
|
||||
import ThemeNav from '../../components/ThemeNav.svelte';
|
||||
|
||||
import { challengeInfo } from '../../stores/challengeinfo.js';
|
||||
import { my } from '../../stores/my.js';
|
||||
import { settings } from '../../stores/settings.js';
|
||||
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{exercice?exercice.title+" - ":""}{$settings.title}</title>
|
||||
<title>{exercice?exercice.title+" - ":""}{$challengeInfo.title}</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if exercice}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@
|
|||
Container,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { settings } from '../../stores/settings.js';
|
||||
import { challengeInfo } from '../../stores/challengeinfo.js';
|
||||
|
||||
export let theme;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{theme?theme.name:""} - {$settings.title}</title>
|
||||
<title>{theme?theme.name:""} - {$challengeInfo.title}</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if theme}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<script context="module">
|
||||
import { challengeInfo } from '../stores/challengeinfo.js';
|
||||
import { issuesStore } from '../stores/issues.js';
|
||||
import { my } from '../stores/my.js';
|
||||
import { teamsStore } from '../stores/teams.js';
|
||||
|
|
@ -41,6 +42,10 @@
|
|||
settings.update(await fetch('settings.json', {headers: {'Accept': 'application/json'}}), cb);
|
||||
}
|
||||
|
||||
async function refresh_challengeInfo(cb=null) {
|
||||
challengeInfo.update(await fetch('challenge.json', {headers: {'Accept': 'application/json'}}), cb);
|
||||
}
|
||||
|
||||
let refresh_interval_teams = null;
|
||||
async function refresh_teams(cb=null, interval=null) {
|
||||
if (refresh_interval_teams)
|
||||
|
|
@ -102,6 +107,7 @@
|
|||
}
|
||||
|
||||
export async function load({ stuff }) {
|
||||
await refresh_challengeInfo();
|
||||
await refresh_settings();
|
||||
await refresh_themes();
|
||||
refresh_teams();
|
||||
|
|
@ -115,6 +121,7 @@
|
|||
return {
|
||||
stuff: {
|
||||
...stuff,
|
||||
refresh_challengeInfo,
|
||||
refresh_settings,
|
||||
refresh_teams,
|
||||
refresh_themes,
|
||||
|
|
@ -138,7 +145,8 @@
|
|||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{$settings.title}</title>
|
||||
<title>{$challengeInfo.title}</title>
|
||||
<meta name="author" content="{$challengeInfo.authors}">
|
||||
</svelte:head>
|
||||
|
||||
<!--Styles /-->
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import { my } from '../stores/my.js';
|
||||
import { rank } from '../stores/teams.js';
|
||||
import { settings } from '../stores/settings.js';
|
||||
import { challengeInfo } from '../stores/challengeinfo.js';
|
||||
|
||||
import CardTheme from '../components/CardTheme.svelte';
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<Container fluid class="my-3">
|
||||
<h1 class="text-dark">
|
||||
{$settings.title}
|
||||
{$challengeInfo.title}
|
||||
<small class="text-muted">Classement</small>
|
||||
</h1>
|
||||
<div class="card niceborder text-light">
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
Icon,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { challengeInfo } from '../stores/challengeinfo.js';
|
||||
import { settings } from '../stores/settings.js';
|
||||
</script>
|
||||
|
||||
<Container class="my-3">
|
||||
<h1 class="text-dark">
|
||||
{$settings.title}
|
||||
{$challengeInfo.title}
|
||||
<small class="text-muted">Règles générales</small>
|
||||
</h1>
|
||||
|
||||
|
|
|
|||
22
frontend/ui/src/stores/challengeinfo.js
Normal file
22
frontend/ui/src/stores/challengeinfo.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { readable, writable } from 'svelte/store';
|
||||
|
||||
function createChallengeStore() {
|
||||
const { subscribe, set, update } = writable({});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
update: (res_challenge, cb) => {
|
||||
if (res_challenge.status === 200) {
|
||||
res_challenge.json().then((challenge) => {
|
||||
update((s) => (Object.assign({}, challenge)));
|
||||
|
||||
if (cb) {
|
||||
cb(challenge);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const challengeInfo = createChallengeStore();
|
||||
Reference in a new issue