Skip to content

Commit

Permalink
raznorazni popravki
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Oct 26, 2024
1 parent a7cb436 commit b8afb92
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 166 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@smui/switch": "^7.0.0",
"@smui/textfield": "^7.0.0",
"@smui/tooltip": "^7.0.0",
"@smui/top-app-bar": "^7.0.0",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@tsconfig/svelte": "^5.0.4",
"date-fns": "^3.6.0",
Expand Down
241 changes: 131 additions & 110 deletions src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import {Router, Route, useLocation} from "svelte-routing";
import {Router, Route, useLocation, navigate} from "svelte-routing";
import TopAppBar, { Row, Section, Title } from '@smui/top-app-bar';
import Drawer from "./Drawer.svelte";
import {AppContent} from "@smui/drawer";
import isMobile from "is-mobile";
Expand Down Expand Up @@ -29,117 +30,137 @@
import ProtonSettings from "./ProtonSettings.svelte";
import ErrorPage from "./ErrorPage.svelte";
import Home from "./Home.svelte";
import IconButton from "@smui/icon-button";
import {baseurl} from "./constants";
import {drawerOpen, svelteLoc} from "./stores";
const mobile = isMobile();
let open = !mobile;
let pathname = window.location.pathname;
const location = useLocation();
$: () => {
console.log($location);
if ($location === undefined) return;
pathname = $location.pathname;
}
</script>

<div class="drawer-container">
<Router>
<Drawer open={open} statusCallback={(o) => open = o} />
<AppContent class="app-content">
<main class="main-content">
{#if isMobile() && !(pathname === "/login" || pathname === "/register")}
<Button on:click={() => open = !open}>
<Icon class="material-icons">menu_open</Icon>
{#if open}
<Label>Zapri navigacijo</Label>
{:else}
<Label>Odpri navigacijo</Label>
{/if}
</Button>
{/if}
<div>
<Route path="/samotestiranje">
<Samotestiranje />
</Route>
<Route path="/login">
<Login />
</Route>
<Route path="/register">
<Register />
</Route>
<Route path="/users">
<Users />
</Route>
<Route path="/new/meeting">
<NewMeeting />
</Route>
<!--<Route path="/my/grades" component="{MyGrades}" />-->
<Route path="/my/class">
<MyClass />
</Route>
<Route path="/communication/:id" let:params >
<Communication id="{params.id}" />
</Route>
<Route path="/user/:id" let:params >
<User id="{params.id}" />
</Route>
<Route path="/class/user/:id" let:params >
<ClassUser studentId="{params.id}" />
</Route>
<Route path="/edit/:id" let:params >
<NewMeeting editId="{params.id}" />
</Route>
<Route path="/meeting/:id/grading" let:params >
<SubjectGrades meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id/absence" let:params >
<AbsenceManagement meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id/homework" let:params >
<Homework meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id" let:params >
<Meeting meetingId="{params.id}" />
</Route>
<Route path="/class/:id" let:params >
<Class id="{params.id}" />
</Route>
<Route path="/subject/:id" let:params >
<Subject id="{params.id}" />
</Route>
<Route path="/subjects">
<Subjects />
</Route>
<Route path="/meals">
<Meals />
</Route>
<Route path="/classes">
<Classes />
</Route>
<Route path="/settings">
<Settings />
</Route>
<Route path="/notifications">
<Notifications />
</Route>
<Route path="/documents">
<Documents />
</Route>
<Route path="/settings/user">
<UserSettings />
</Route>
<Route path="/proton/settings">
<ProtonSettings />
</Route>
<Route path="/napaka">
<ErrorPage />
</Route>
<Route path="/">
<Home />
</Route>
</div>
</main>
</AppContent>
</Router>
</div>
<Router>
<div class="flexy">
{#if $svelteLoc !== "/login" && $svelteLoc !== "/register"}
<div class="top-app-bar-container flexor">
<TopAppBar variant="static" style="background-color: #6082B6;">
<Row>
<Section style="display: flex; flex-direction: row; align-items: center;">
<IconButton style="margin: 0 0 0 0.5em;" class="material-icons" on:click={() => drawerOpen.update((open) => !open)}>{#if $drawerOpen}close{:else}menu{/if}</IconButton>
<Title>MeetPlan</Title>
</Section>
<Section align="end" toolbar>
<IconButton style="margin: 0;" class="material-icons" aria-hidden="true" on:click={() => navigate("/settings/user")}>settings</IconButton>
<IconButton style="margin: 0;" class="material-icons" aria-hidden="true" on:click={async () => {
localStorage.clear();
// TODO
await fetch(`${baseurl}/account/logout`, {method: "POST", credentials: "include"});
navigate("/login");
}}>
<div style="margin: 0 0 0 0.1em;">logout</div>
</IconButton>
</Section>
</Row>
</TopAppBar>
</div>
{/if}

<div class="drawer-container" id="router" style="width: 100vw; flex-grow: 1; height: 100%; overflow: auto !important;">
<Drawer />
<AppContent class="app-content">
<main class="main-content">
{#if isMobile() && !($svelteLoc === "/login" || $svelteLoc === "/register")}
<Button on:click={() => open = !open}>
<Icon class="material-icons">menu_open</Icon>
{#if open}
<Label>Zapri navigacijo</Label>
{:else}
<Label>Odpri navigacijo</Label>
{/if}
</Button>
{/if}
<div>
<Route path="/samotestiranje">
<Samotestiranje />
</Route>
<Route path="/login">
<Login />
</Route>
<Route path="/register">
<Register />
</Route>
<Route path="/users">
<Users />
</Route>
<Route path="/new/meeting">
<NewMeeting />
</Route>
<!--<Route path="/my/grades" component="{MyGrades}" />-->
<Route path="/my/class">
<MyClass />
</Route>
<Route path="/communication/:id" let:params >
<Communication id="{params.id}" />
</Route>
<Route path="/user/:id" let:params >
<User id="{params.id}" />
</Route>
<Route path="/class/user/:id" let:params >
<ClassUser studentId="{params.id}" />
</Route>
<Route path="/edit/:id" let:params >
<NewMeeting editId="{params.id}" />
</Route>
<Route path="/meeting/:id/grading" let:params >
<SubjectGrades meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id/absence" let:params >
<AbsenceManagement meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id/homework" let:params >
<Homework meetingId="{params.id}" />
</Route>
<Route path="/meeting/:id" let:params >
<Meeting meetingId="{params.id}" />
</Route>
<Route path="/class/:id" let:params >
<Class id="{params.id}" />
</Route>
<Route path="/subject/:id" let:params >
<Subject id="{params.id}" />
</Route>
<Route path="/subjects">
<Subjects />
</Route>
<Route path="/meals">
<Meals />
</Route>
<Route path="/classes">
<Classes />
</Route>
<Route path="/settings">
<Settings />
</Route>
<Route path="/notifications">
<Notifications />
</Route>
<Route path="/documents">
<Documents />
</Route>
<Route path="/settings/user">
<UserSettings />
</Route>
<Route path="/proton/settings">
<ProtonSettings />
</Route>
<Route path="/napaka">
<ErrorPage />
</Route>
<Route path="/">
<Home />
</Route>
</div>
</main>
</AppContent>
</div>
</div>
</Router>
6 changes: 3 additions & 3 deletions src/Classes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
async function getClasses() {
let response = await fetch(`${baseurl}/classes/get`, {credentials: "include"});
let r = await response.json();
items = r["data"];
items = r.data;
}
async function getTeachers() {
let response = await fetch(`${baseurl}/teachers/get`, {credentials: "include"});
let r = response.json();
teachers = r["data"];
let r = await response.json();
teachers = r.data;
}
getClasses();
Expand Down
37 changes: 12 additions & 25 deletions src/Drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import {useLocation} from "svelte-routing";
import Checkbox from "@smui/checkbox";
import {drawerOpen, svelteLoc} from "./stores";
const location = useLocation();
Expand All @@ -32,19 +33,18 @@
let communicationUnread = {};
let unreadMessages;
let allPaths = {};
let allPaths: Record<string, string> = {};
let lastUrl = "";
let showDrawer = false;
let hasRequested = false;
$: (async () => {
statusCallback(open);
if (!($location.pathname === "/login" || $location.pathname === "/register")) {
showDrawer = true;
const path = $location.pathname;
let path = $location.pathname;
console.log(path);
svelteLoc.set(path);
if (path !== "/login" && path !== "/register") {
if (path === lastUrl) {
return
}
Expand Down Expand Up @@ -77,7 +77,7 @@
communicationActive = pathSplit[2];
}
} else {
console.log("resetting", $location.pathname)
console.log("resetting", path)
meetingActive = undefined
communicationActive = undefined
}
Expand Down Expand Up @@ -105,7 +105,7 @@
return
}
showDrawer = false;
drawerOpen.set(false);
hasRequested = false;
// Set a fake timeout to get the highest timeout id
Expand Down Expand Up @@ -160,8 +160,6 @@
let user = 0;
const mobile = isMobile();
export let open: boolean = !mobile;
export let statusCallback;
async function fetchData() {
if (hasRequested) {
Expand Down Expand Up @@ -237,7 +235,8 @@
</DialogTitle>
<DialogContent id="simple-content">
<p/>
<Select bind:value={user} variant="outlined" style="width: 100%;" label="Izberite učenca">
<Select bind:value={user} variant="outlined" style="width: 100%; overflow: visible;"
label="Izberite učenca">
<Option value="" on:click={() => user = -1}/>
{#each users as c}
<Option on:click={async () => {
Expand Down Expand Up @@ -281,7 +280,6 @@
aria-labelledby="simple-title"
aria-describedby="list-content"
>
<!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
<Title id="simple-title">
<FormField>
<Textfield
Expand Down Expand Up @@ -375,19 +373,8 @@
</Actions>
</Dialog>

{#if showDrawer}
<Drawer variant={mobile ? "modal" : "dismissible"} fixed={false} style="position: absolute; top: 0;" bind:open>
<Header class="sameline">
<Title style="display:inline-block;">MeetPlan</Title>
<div style="display:inline-block; float:right;">
<IconButton class="material-icons" aria-hidden="true" on:click={() => navigate("/settings/user")}>settings</IconButton>
<IconButton class="material-icons" aria-hidden="true" on:click={() => {
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
localStorage.clear()
navigate("/login")
}}>logout</IconButton>
</div>
</Header>
{#if $drawerOpen}
<Drawer variant={mobile ? "modal" : "dismissible"} fixed={false} style="position: absolute; top: 0;" bind:open={$drawerOpen}>
<Content>
<List>
<Item
Expand Down
3 changes: 1 addition & 2 deletions src/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
Za čim boljšo uporabniško izkušnjo, razvijalci MeetPlan sistema priporočajo uporabo računalnikov (namiznih ali prenosnih).
</div>
{/if}
<h1>Pozdravljeni v MeetPlan sistemu</h1>
<b>Vaša dovoljenja: {localStorage.getItem("role")}</b>
Vaša dovoljenja: <b>{localStorage.getItem("role")}</b>
<hr />
<Select bind:classId variant="outlined">
<Option value="" on:click={() => {
Expand Down
Loading

0 comments on commit b8afb92

Please sign in to comment.