qa: Back to the same situation
This commit is contained in:
parent
00f84e43ca
commit
1aa82bb2ef
27 changed files with 1336 additions and 22 deletions
29
qa/ui/src/lib/stores/auth.js
Normal file
29
qa/ui/src/lib/stores/auth.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { writable, derived } from 'svelte/store';
|
||||
|
||||
function createVersionStore() {
|
||||
const { subscribe, set, update } = writable({"auth":null});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
set: (v) => {
|
||||
update((m) => Object.assign(m, v));
|
||||
},
|
||||
|
||||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const version = await (await fetch('api/version', {headers: {'Accept': 'application/json'}})).json()
|
||||
update((m) => version);
|
||||
return version;
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export const version = createVersionStore();
|
||||
|
||||
export const auth = derived(
|
||||
version,
|
||||
$version => $version.auth,
|
||||
);
|
||||
39
qa/ui/src/lib/stores/exercices.js
Normal file
39
qa/ui/src/lib/stores/exercices.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { writable, derived } from 'svelte/store';
|
||||
|
||||
import { getExercices } from '$lib/exercices'
|
||||
|
||||
function createExercicesStore() {
|
||||
const { subscribe, set, update } = writable([]);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
set: (v) => {
|
||||
update((m) => Object.assign(m, v));
|
||||
},
|
||||
|
||||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const list = await getExercices();
|
||||
update((m) => list);
|
||||
return list;
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export const exercices = createExercicesStore();
|
||||
|
||||
export const exercicesIdx = derived(
|
||||
exercices,
|
||||
$exercices => {
|
||||
const exercices_idx = { };
|
||||
|
||||
for (const e of $exercices) {
|
||||
exercices_idx[e.id] = e;
|
||||
}
|
||||
|
||||
return exercices_idx;
|
||||
},
|
||||
);
|
||||
39
qa/ui/src/lib/stores/themes.js
Normal file
39
qa/ui/src/lib/stores/themes.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { writable, derived } from 'svelte/store';
|
||||
|
||||
import { getThemes } from '$lib/themes'
|
||||
|
||||
function createThemesStore() {
|
||||
const { subscribe, set, update } = writable([]);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
set: (v) => {
|
||||
update((m) => Object.assign(m, v));
|
||||
},
|
||||
|
||||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const list = await getThemes();
|
||||
update((m) => list);
|
||||
return list;
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export const themes = createThemesStore();
|
||||
|
||||
export const themesIdx = derived(
|
||||
themes,
|
||||
$themes => {
|
||||
const themes_idx = { };
|
||||
|
||||
for (const t of $themes) {
|
||||
themes_idx[t.id] = t;
|
||||
}
|
||||
|
||||
return themes_idx;
|
||||
},
|
||||
);
|
||||
26
qa/ui/src/lib/stores/todo.js
Normal file
26
qa/ui/src/lib/stores/todo.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { writable } from 'svelte/store';
|
||||
|
||||
import { getQAWork } from '$lib/todo'
|
||||
|
||||
function createTodosStore() {
|
||||
const { subscribe, set, update } = writable([]);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
set: (v) => {
|
||||
update((m) => Object.assign(m, v));
|
||||
},
|
||||
|
||||
update,
|
||||
|
||||
refresh: async () => {
|
||||
const list = await getQAWork();
|
||||
update((m) => list);
|
||||
return list;
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export const todos = createTodosStore();
|
||||
Reference in a new issue