Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobil skema #235

Merged
merged 7 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[build]
command = "npm run build"
publish = "build"


[functions."lectiodelay"]
schedule = "@hourly"
publish = "build"
116 changes: 0 additions & 116 deletions netlify/functions/lectiodelay.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "betterlectio",
"version": "0.10.136",
"version": "0.10.139",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
10 changes: 5 additions & 5 deletions src/lib/components/Calendars/Mobile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
skemaData[`${week}${year}`].moduler.forEach(modul => {
let titel = '';
if (modul.navn !== null) {
titel = modul.navn !== null && modul.navn !== 'Ændret!' ? modul.navn : $fag[modul.hold_id];
titel = modul.navn !== null && modul.navn !== 'Ændret!' ? modul.navn : $fag && $fag[modul.hold_id] ? $fag[modul.hold_id] : modul.hold;
if (modul.status === 'eksamen') {
titel
= `Eksamen! ${
Expand All @@ -192,7 +192,7 @@
titel += ` · ${ modul.lokale.split(/(?:[\uD800-\uDBFF][\uDC00-\uDFFF])/u)[0]}`;
}
} else {
if ($indstillinger.brugHoldOversætter) titel = $fag[modul.hold_id];
if ($indstillinger.brugHoldOversætter && $fag && $fag[modul.hold_id]) titel = $fag[modul.hold_id];
else titel = modul.hold;

if (modul.lokale) titel += ` · ${ modul.lokale.split(/(?:[\uD800-\uDBFF][\uDC00-\uDFFF])/u)[0]}`;
Expand Down Expand Up @@ -243,13 +243,13 @@
$: if (selectedDay) loadSkema(selectedDay);
</script>

<div class="relative z-0">
<div class="relative z-0 w-[97vw]">
<div class="-mt-8 text-2xl">
<p><b>Uge {getWeekNumber(viewDate)}</b> ({måneder[viewDate.getMonth()]} {viewDate.getFullYear()})</p>
</div>

{#if dates[2][6]}
<div class="w-screen">
<div class="w-full">
<swiper-container bind:this={swiperElement} initial-slide="1">
{#each Array(3) as _, i}
<swiper-slide class="flex items-stretch space-x-2 p-1">
Expand All @@ -267,7 +267,7 @@
</div>
{/if}

<div class="w-screen">
<div class="w-full">
<swiper-container bind:this={calendarSwiperElement} initial-slide="1">
<swiper-slide><Calendar bind:this={skemaBefore} {plugins} {options} /></swiper-slide> <!-- Måske hvis dagen for skemaet er tom efter den er loaded så lav en besked med det-->
<swiper-slide><Calendar bind:this={skema} {plugins} {options} /></swiper-slide> <!-- Måske hvis dagen for skemaet er tom efter den er loaded så lav en besked med det-->
Expand Down
36 changes: 0 additions & 36 deletions src/routes/api/getdelay/+server.js

This file was deleted.

64 changes: 39 additions & 25 deletions src/routes/auth/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,37 @@
});
}

let delayGraphUrl = '';
let delayGraphAvailable = false;
let delay = 0;
fetch('/api/getdelay').then(res => res.json()).then(json => {
delayGraphUrl = json.imgUrl;
delay = json.delay;
console.log(delayGraphUrl);
if (delayGraphUrl !== '' && delayGraphUrl.includes('https://quickchart.io/chart?c=')) delayGraphAvailable = true;
});
function itemFilter(item, keywords) {
const keywordsArray = keywords.join('').split('');

// return false if no letters match
if (!keywordsArray.some(keyword => item.skole.toLowerCase().includes(keyword.toLowerCase()))) return false;

// return true if schoolId is the keyword
if (keywords.some(keyword => item.skoleid.toLowerCase().includes(keyword.toLowerCase()))) return true;

return true;
}

function itemSortFunction(item1, item2, keywords) {
// do the same as the filter function but return a number instead of a boolean representing the number of letters that match
const keywordsArray = keywords.join('').split('');
let item1MatchCount = 0;
let item2MatchCount = 0;

item1MatchCount = keywordsArray.filter(keyword => item1.skole.toLowerCase().includes(keyword.toLowerCase())).length;
item2MatchCount = keywordsArray.filter(keyword => item2.skole.toLowerCase().includes(keyword.toLowerCase())).length;

// mult bu the matches in a row
item1MatchCount *= keywordsArray.filter((keyword, index) => item1.skole.toLowerCase().includes(keywordsArray.slice(index, index + 2).join('').toLowerCase())).length;
item2MatchCount *= keywordsArray.filter((keyword, index) => item2.skole.toLowerCase().includes(keywordsArray.slice(index, index + 2).join('').toLowerCase())).length;

// if the schoolId is the keyword, add 10000000 to the match count
if (keywords[0] === item1.skoleid.toLowerCase()) item1MatchCount += 10000000;
if (keywords[0] === item2.skoleid.toLowerCase()) item2MatchCount += 10000000;

return item2MatchCount - item1MatchCount;
}
</script>

<div class="flex items-center justify-center md:h-[75vh]">
Expand Down Expand Up @@ -212,14 +234,18 @@
valueFieldName="id"
bind:selectedItem="{$form.school}"
matchAllKeywords={false}
sortByMatchedKeywords={true}
keywordsFunction={skole => `${skole.skole } ${ skole.skoleid}`}
sortByMatchedKeywords={false}
keywordsFunction={item => `${item.skole } ${ item.skoleid}`}
itemFilterFunction={itemFilter}
itemSortFunction={itemSortFunction}
noResultsText="Ingen skoler fundet"
placeholder="Vælg din skole"
placeholder="Vælg din skole (skriv for at søge)"
required={true}
hideArrow={true}
className="select select-sm w-full max-w-wl py-0 mb-2.5 px-0"
dropdownClassName="rounded-box"
maxItemsToShowInList={40}

>
</AutoComplete>
<div class="join p-1.5 bg-base-100">
Expand Down Expand Up @@ -257,19 +283,7 @@
<a class="font-medium text-blue-600 hover:underline dark:text-blue-500" href="/tos">Servicevilkår & Privatlivspolitik</a>
</p>
<div class="divider" />
<div class="flex {delayGraphAvailable ? 'justify-between' : 'justify-end'}">
{#if delayGraphAvailable}
{#key delayGraphUrl}
<div class="flex gap-2">
<img src={delayGraphUrl} alt="" class="h-12 border-2 border-base-content rounded-xl" height="44" width="91"/>
<div>
<p class="py-0 my-0 text-xs">{delay} ms</p>
<p class="py-0 my-0 text-xs text-base-content/50">gns. Lectio responstid</p>
<p class="py-0 my-0 text-xs text-base-content/50">Graf over de sidste 50 timer</p>
</div>
</div>
{/key}
{/if}
<div class="flex justify-end">
<button tabindex="0" type="submit" class="btn-primary btn group">
<p>Log ind</p>
<label class="swap {$delayed ? 'swap-active' : ''} " for="login">
Expand Down
Loading