diff --git a/README.md b/README.md index 103e995..09b0035 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ A centralised resource hub for Deakin University students studying **SIT** (IT, - ๐Ÿ‘ **Voting** โ€” upvote or downvote notes and questions. - ๐Ÿ” **Search** โ€” find notes by title or content. - ๐ŸŽ“ **Deakin-only accounts** โ€” only `@deakin.edu.au` email addresses can contribute. Create an account with a password after verifying your email, then sign in with email and password. +- ๐Ÿ› ๏ธ **Admin dashboard** โ€” manage units, accounts, and notes, plus weekly posting statistics. The first person to open the dashboard verifies their email to become the admin. - ๐Ÿ—‚๏ธ **Units & topics** โ€” browse content by Deakin unit code (e.g. `SIT102`, `SIT192`) or topic (e.g. Algorithms, Mathematics). - ๐Ÿ’พ **Persistent storage** โ€” all data is stored in a local SQLite database. @@ -109,6 +110,7 @@ src/ โ”‚ โ”œโ”€โ”€ units/[code]/ # Unit pages โ”‚ โ”œโ”€โ”€ search/ # Search page โ”‚ โ”œโ”€โ”€ auth/login/ # Sign in page +โ”‚ โ”œโ”€โ”€ admin/ # Admin dashboard โ”‚ โ””โ”€โ”€ api/+server.ts # JSON API endpoint โ””โ”€โ”€ app.html ``` @@ -124,7 +126,7 @@ src/ The SQLite database contains the following tables: -- `users` โ€” Deakin email accounts +- `users` โ€” Deakin email accounts (each has a `role`: `user` or `admin`) - `units` โ€” Deakin unit codes and names - `topics` โ€” CS and maths topics - `notes` โ€” shared study notes diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index 6c88f0f..581dfd0 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -1,21 +1,27 @@
@@ -27,6 +33,9 @@ Questions + {#if admin} + Admin + {/if} {#if auth} + + {:else} +
+

+ We sent a 6-digit code to {setupEmail}. It + expires in 10 minutes. +

+ +
+ + +
+ + {#if setupError} +

{setupError}

+ {/if} + + + + +
+ {/if} + + {:else if !adminState.isAdmin} +

Admin

+

You need to be an admin to view this page.

+ {#if !adminState.currentUser} + + Sign in + + {/if} + {:else} +
+
+

Admin

+

Dashboard

+
+
+ + + + +
+
+ + {#if pageError} +

{pageError}

+ {/if} + + {#if tab === "overview"} + {#if stats} +
+
+

Notes

+

{stats.totals.notes}

+
+
+

Questions

+

{stats.totals.questions}

+
+
+

Accounts

+

{stats.totals.users}

+
+
+

Units

+

{stats.totals.units}

+
+
+ +
+
+

Posts โ€” last {stats.weeks.length} weeks

+
+ โ–  Notes + โ–  Questions +
+
+ +
+ {#each stats.weeks as week} +
+
+
+
+
+ {weekLabel(week.weekStart)} + {week.notes} notes ยท {week.questions} questions +
+ {/each} +
+
+ {/if} + {:else if tab === "units"} +
+
+
+

All units

+ {units.length} total +
+
+ {#each units as unit} +
+
+

{unit.code}

+

{unit.name}

+
+
+ + +
+
+ {/each} +
+
+ +
+

{unitForm.id ? "Edit unit" : "Add unit"}

+
+ + +
+
+ + +
+
+ + +
+ + {#if unitError} +

{unitError}

+ {/if} + {#if unitSuccess} +

{unitSuccess}

+ {/if} + +
+ + {#if unitForm.id} + + {/if} +
+
+
+ {:else if tab === "accounts"} +
+
+
+

All accounts

+ {users.length} total +
+
+ {#each users as user} +
+
+
+

{user.name}

+

{user.email}

+
+ + {user.role} + +
+
+ {user.noteCount} note{user.noteCount === 1 + ? "" + : "s"} + {user.questionCount} question{user.questionCount === 1 + ? "" + : "s"} +
+ + + +
+
+
+ {/each} +
+ + {#if userError} +

{userError}

+ {/if} +
+ +
+ {#if userForm} +
+

Edit account

+
+ + +
+
+ + +
+
+ + +
+ + {#if userError} +

{userError}

+ {/if} + +
+ + +
+
+ {:else} +

Account editor

+

+ Select an account and choose Edit to change its name, email, or role. +

+ {/if} +
+
+ {:else if tab === "notes"} +
+
+
+

All notes

+ {notes.length} total +
+
+ {#each notes as note} +
+
+
+

{note.title}

+

+ {note.unitCode ?? "โ€”"} ยท {note.authorName} ยท {timeAgo( + note.createdAt, + )} +

+
+
+ + +
+
+
+ {/each} +
+ + {#if noteError} +

{noteError}

+ {/if} +
+ +
+ {#if noteForm} +
+

Edit note

+
+ + +
+
+ + +
+ + {#if noteError} +

{noteError}

+ {/if} + +
+ + +
+
+ {:else} +

Note editor

+

+ Select a note and choose Edit to update its title or content. +

+ {/if} +
+
+ {/if} + {/if} +