⬆️ Updated frontend deps and fixed search on the dashboard

This commit is contained in:
Mawoka
2022-12-01 18:26:43 +01:00
parent 3d3b282776
commit 91ddb81f4d
4 changed files with 582 additions and 559 deletions
+28 -25
View File
@@ -15,19 +15,19 @@
},
"devDependencies": {
"@beyonk/svelte-mapbox": "^8.2.0",
"@ckeditor/ckeditor5-autoformat": "^35.3.1",
"@ckeditor/ckeditor5-basic-styles": "^35.3.1",
"@ckeditor/ckeditor5-build-balloon": "^35.3.1",
"@ckeditor/ckeditor5-editor-balloon": "^35.3.1",
"@ckeditor/ckeditor5-essentials": "^35.3.1",
"@ckeditor/ckeditor5-theme-lark": "^35.3.1",
"@ckeditor/ckeditor5-autoformat": "^35.3.2",
"@ckeditor/ckeditor5-basic-styles": "^35.3.2",
"@ckeditor/ckeditor5-build-balloon": "^35.3.2",
"@ckeditor/ckeditor5-editor-balloon": "^35.3.2",
"@ckeditor/ckeditor5-essentials": "^35.3.2",
"@ckeditor/ckeditor5-theme-lark": "^35.3.2",
"@felte/reporter-tippy": "^1.1.4",
"@felte/validator-yup": "^1.0.10",
"@fontsource/marck-script": "^4.5.11",
"@sentry/browser": "^7.20.0",
"@sentry/tracing": "^7.20.0",
"@sentry/browser": "^7.23.0",
"@sentry/tracing": "^7.23.0",
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-node": "^1.0.0-next.100",
"@sveltejs/adapter-node": "^1.0.0-next.101",
"@sveltejs/kit": "next",
"@tailwindcss/typography": "^0.5.8",
"@types/canvas-confetti": "^1.6.0",
@@ -35,16 +35,18 @@
"@types/js-cookie": "^3.0.2",
"@types/luxon": "^2.4.0",
"@types/ua-parser-js": "^0.7.36",
"@types/yup": "^0.32.0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"@uppy/compressor": "^0.3.3",
"@uppy/core": "^2.3.4",
"@uppy/dashboard": "^2.4.3",
"@uppy/drop-target": "^1.1.4",
"@uppy/image-editor": "^1.4.2",
"@uppy/svelte": "^1.0.9",
"@uppy/xhr-upload": "^2.1.3",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@uppy/compressor": "^1.0.1",
"@uppy/core": "^3.0.4",
"@uppy/dashboard": "^3.2.0",
"@uppy/drag-drop": "^3.0.1",
"@uppy/drop-target": "^2.0.1",
"@uppy/image-editor": "^2.1.0",
"@uppy/progress-bar": "^3.0.1",
"@uppy/status-bar": "^3.0.1",
"@uppy/svelte": "^3.0.1",
"@uppy/xhr-upload": "^3.0.4",
"autoprefixer": "^10.4.13",
"canvas-confetti": "^1.6.0",
"cookie": "^0.5.0",
@@ -54,26 +56,27 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"felte": "^1.2.6",
"highlight.js": "^11.6.0",
"fuse.js": "^6.6.2",
"highlight.js": "^11.7.0",
"i18next-browser-languagedetector": "^7.0.1",
"js-cookie": "^3.0.1",
"luxon": "^2.5.0",
"luxon": "^3.1.1",
"mapbox-gl": "^2.11.0",
"minisearch": "^5.1.0",
"plausible-tracker": "^0.3.8",
"postcss": "^8.4.19",
"postcss-import": "^14.1.0",
"postcss-load-config": "^4.0.1",
"prettier": "^2.7.1",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"sass": "^1.56.1",
"socket.io-client": "^4.5.3",
"socket.io-client": "^4.5.4",
"svelte": "^3.53.1",
"svelte-check": "^2.9.2",
"svelte-check": "^2.10.0",
"svelte-preprocess": "^4.10.7",
"svelte-range-slider-pips": "^2.1.0",
"svelte-tippy": "^1.3.2",
"swiper": "^8.4.4",
"swiper": "^8.4.5",
"tailwindcss": "^3.2.4",
"tippy.js": "^6.3.7",
"tslib": "^2.4.1",
+533 -502
View File
File diff suppressed because it is too large Load Diff
@@ -18,7 +18,7 @@
let copy_toast_open = false;
let start_game = null;
const { t } = getLocalization();
export let quizzes;
export let quizzes = [];
const deleteQuiz = async (to_delete: string) => {
if (!confirm('Do you really want to delete this quiz?')) {
@@ -45,6 +45,7 @@
onMount(() => {
document.body.addEventListener('keydown', close_start_game_if_esc_is_pressed);
});
$: console.log(quizzes, 'quizzes_here');
</script>
{#if copy_toast_open}
+19 -31
View File
@@ -9,7 +9,7 @@
import Footer from '$lib/footer.svelte';
import { navbarVisible, signedIn } from '$lib/stores';
import Spinner from '$lib/Spinner.svelte';
import MiniSearch from 'minisearch';
import Fuse from 'fuse.js';
interface QuizData {
id: string;
@@ -27,20 +27,24 @@
navbarVisible.set(true);
const { t } = getLocalization();
let quizzes_to_show;
let quizzes_to_show = [];
let quizzes: Array<any>;
const minisearch = new MiniSearch({
fields: ['title', 'description'],
idField: 'id',
storeFields: ['id']
});
let fuse;
/* const minisearch = new MiniSearch({
fields: ['title', 'description'],
idField: 'id',
storeFields: ['id']
})*/
let id_to_position_map = {};
const getData = async (): Promise<Array<QuizData>> => {
const res = await fetch('/api/v1/quiz/list');
quizzes_to_show = await res.json();
await minisearch.addAllAsync(quizzes_to_show);
fuse = new Fuse(quizzes_to_show, {
keys: ['title', 'description', 'questions.question'],
findAllMatches: true
});
quizzes = quizzes_to_show;
for (let i = 0; i < quizzes.length; i++) {
id_to_position_map[quizzes[i].id] = i;
@@ -56,20 +60,19 @@
quizzes_to_show = quizzes;
quizzes_to_show = quizzes_to_show;
} else {
const res = minisearch.search(search_term, { prefix: true, fuzzy: 0.3 });
if (res.length === 0) {
quizzes_to_show = [];
suggestions = minisearch.autoSuggest(search_term);
} else {
for (const quiz_data of res) {
quizzes_to_show.push(quizzes[id_to_position_map[quiz_data.id]]);
}
const res = fuse.search(search_term);
console.log(res, 'search_res');
quizzes_to_show = [];
for (const quiz_data of res) {
quizzes_to_show.push(quiz_data.item);
}
quizzes_to_show = quizzes_to_show;
}
};
$: {
search_term;
console.log(search_term);
search();
}
</script>
@@ -154,21 +157,6 @@
</svg>
</button>
</div>
{#if quizzes_to_show.length === 0 && suggestions.length !== 0}
<ul class="relative bg-white mt-0.5 dark:bg-gray-700">
{#each suggestions as res}
<li>
<button
class="w-full"
on:click={() => {
suggestions = [];
search_term = res.suggestion;
}}>{res.suggestion}</button
>
</li>
{/each}
</ul>
{/if}
</div>
</div>
<svelte:component this={c.default} bind:quizzes={quizzes_to_show} />