Compare commits
2 commits
404f29e6ea
...
4973f7ac4a
Author | SHA1 | Date | |
---|---|---|---|
4973f7ac4a | |||
0f2dafa3b1 |
5 changed files with 86 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
ListGroupItem,
|
ListGroupItem,
|
||||||
} from '@sveltestrap/sveltestrap';
|
} from '@sveltestrap/sveltestrap';
|
||||||
|
|
||||||
|
import { hasDownloaded } from '$lib/stores/downloaded.js';
|
||||||
import FileSize from './FileSize.svelte';
|
import FileSize from './FileSize.svelte';
|
||||||
|
|
||||||
export let files = [];
|
export let files = [];
|
||||||
|
@ -27,8 +28,8 @@
|
||||||
</CardBody>
|
</CardBody>
|
||||||
<ListGroup flush class="border-secondary">
|
<ListGroup flush class="border-secondary">
|
||||||
{#each files as file, index}
|
{#each files as file, index}
|
||||||
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex">
|
<ListGroupItem tag="a" href={file.path} target={(file.name.endsWith(".txt") || file.name.endsWith(".xml") || file.name.endsWith(".jpg") || file.name.endsWith(".png") || file.name.endsWith(".pdf"))?"_blank":"_self"} class="d-flex" action on:click={() => hasDownloaded.update((u) => {u[file.path] = true; return u;})}>
|
||||||
<h1 class="me-3">
|
<h1 class="me-3" class:text-info={!$hasDownloaded[file.path]}>
|
||||||
<Icon name="arrow-down-circle" />
|
<Icon name="arrow-down-circle" />
|
||||||
</h1>
|
</h1>
|
||||||
<div style="min-width: 0">
|
<div style="min-width: 0">
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import { my } from '$lib/stores/my.js';
|
import { my } from '$lib/stores/my.js';
|
||||||
import { settings } from '$lib/stores/settings.js';
|
import { settings } from '$lib/stores/settings.js';
|
||||||
|
import { submissions } from '$lib/stores/submissions.js';
|
||||||
import { timeouted, waitDiff, waitInProgress } from '$lib/wait.js';
|
import { timeouted, waitDiff, waitInProgress } from '$lib/wait.js';
|
||||||
|
|
||||||
import DateFormat from './DateFormat.svelte';
|
import DateFormat from './DateFormat.svelte';
|
||||||
|
@ -36,6 +37,20 @@
|
||||||
message = "";
|
message = "";
|
||||||
last_submission = JSON.parse(JSON.stringify(responses));
|
last_submission = JSON.parse(JSON.stringify(responses));
|
||||||
|
|
||||||
|
submissions.update((u) => {
|
||||||
|
for (const k in last_submission.flags) {
|
||||||
|
u.flags[k] = last_submission.flags[k];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const k in last_submission.mcqs) {
|
||||||
|
u.mcqs[k] = last_submission.mcqs[k];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const k in last_submission.justifications) {
|
||||||
|
u.justifications[k] = last_submission.justifications[k];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if ($my && $my.team_id === 0) {
|
if ($my && $my.team_id === 0) {
|
||||||
let allGoodResponse = true;
|
let allGoodResponse = true;
|
||||||
for (const f in flags) {
|
for (const f in flags) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import { my } from '$lib/stores/my.js';
|
import { my } from '$lib/stores/my.js';
|
||||||
import { settings } from '$lib/stores/settings.js';
|
import { settings } from '$lib/stores/settings.js';
|
||||||
|
import { submissions } from '$lib/stores/submissions.js';
|
||||||
|
|
||||||
export { className as class };
|
export { className as class };
|
||||||
let className = '';
|
let className = '';
|
||||||
|
@ -247,6 +248,15 @@
|
||||||
title="Flag trouvé à {flag.found}"
|
title="Flag trouvé à {flag.found}"
|
||||||
value={value}
|
value={value}
|
||||||
>
|
>
|
||||||
|
{:else if $submissions && $submissions.flags && $submissions.flags[flag.id]}
|
||||||
|
<input
|
||||||
|
class="form-control is-valid"
|
||||||
|
disabled
|
||||||
|
id="sol_{flag.type}{flag.id}_0"
|
||||||
|
type="text"
|
||||||
|
title="Flag trouvé à {flag.found}"
|
||||||
|
value={$submissions.flags[flag.id]}
|
||||||
|
>
|
||||||
{:else}
|
{:else}
|
||||||
<Icon
|
<Icon
|
||||||
name="check"
|
name="check"
|
||||||
|
|
25
frontend/fic/src/lib/stores/downloaded.js
Normal file
25
frontend/fic/src/lib/stores/downloaded.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
function createDownloadedStore() {
|
||||||
|
let init = { };
|
||||||
|
try {
|
||||||
|
if (window.localStorage && window.localStorage.getItem("downloadedStore")) {
|
||||||
|
init = JSON.parse(window.localStorage.getItem("downloadedStore"));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
init = { };
|
||||||
|
}
|
||||||
|
|
||||||
|
const { subscribe, set, update } = writable(init);
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
|
||||||
|
update: (u) => {
|
||||||
|
update(u);
|
||||||
|
if (window.localStorage) localStorage.setItem("downloadedStore", JSON.stringify(init));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const hasDownloaded = createDownloadedStore();
|
33
frontend/fic/src/lib/stores/submissions.js
Normal file
33
frontend/fic/src/lib/stores/submissions.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
function createSubmissionsStore() {
|
||||||
|
let init = {
|
||||||
|
flags: { },
|
||||||
|
mcqs: { },
|
||||||
|
justifications: { },
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
if (window.localStorage && window.localStorage.getItem("submissionsStore")) {
|
||||||
|
init = JSON.parse(window.localStorage.getItem("submissionsStore"));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
init = {
|
||||||
|
flags: { },
|
||||||
|
mcqs: { },
|
||||||
|
justifications: { },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const { subscribe, set, update } = writable(init);
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
|
||||||
|
update: (u) => {
|
||||||
|
update(u);
|
||||||
|
if (window.localStorage) localStorage.setItem("submissionsStore", JSON.stringify(init));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const submissions = createSubmissionsStore();
|
Reference in a new issue