diff --git a/src/routes/account/+page.svelte b/src/routes/account/+page.svelte index 8117244..c14c0f6 100644 --- a/src/routes/account/+page.svelte +++ b/src/routes/account/+page.svelte @@ -111,7 +111,11 @@ passwordError = ""; passwordMessage = ""; try { - await mutation("users:changePassword", { token, currentPassword, newPassword }); + await mutation("users:changePassword", { + token, + currentPassword, + newPassword, + }); currentPassword = ""; newPassword = ""; confirmPassword = ""; @@ -131,7 +135,7 @@ - Account — Notebook + Account — DSEC Notebook
@@ -202,8 +206,12 @@

- {#if profileError}

{profileError}

{/if} - {#if profileMessage}

{profileMessage}

{/if} + {#if profileError}

+ {profileError} +

{/if} + {#if profileMessage}

+ {profileMessage} +

{/if} @@ -250,8 +258,12 @@ required /> - {#if passwordError}

{passwordError}

{/if} - {#if passwordMessage}

{passwordMessage}

{/if} + {#if passwordError}

+ {passwordError} +

{/if} + {#if passwordMessage}

+ {passwordMessage} +

{/if} diff --git a/src/routes/admin/+page.svelte b/src/routes/admin/+page.svelte index b913bc7..236546d 100644 --- a/src/routes/admin/+page.svelte +++ b/src/routes/admin/+page.svelte @@ -16,7 +16,12 @@ type WeekStat = { weekStart: number; notes: number; questions: number }; type Stats = { weeks: WeekStat[]; - totals: { notes: number; questions: number; users: number; units: number }; + totals: { + notes: number; + questions: number; + users: number; + units: number; + }; }; type AdminUser = UserDoc & { noteCount: number; questionCount: number }; @@ -54,18 +59,33 @@ let pageError = $state(""); // Unit editor - let unitForm = $state({ id: "", code: "", code2: "", name: "", description: "" }); + let unitForm = $state({ + id: "", + code: "", + code2: "", + name: "", + description: "", + }); let unitBusy = $state(false); let unitError = $state(""); let unitSuccess = $state(""); // Account editor - let userForm = $state<{ id: string; email: string; name: string; role: string } | null>(null); + let userForm = $state<{ + id: string; + email: string; + name: string; + role: string; + } | null>(null); let userBusy = $state(false); let userError = $state(""); // Note editor - let noteForm = $state<{ id: string; title: string; content: string } | null>(null); + let noteForm = $state<{ + id: string; + title: string; + content: string; + } | null>(null); let noteBusy = $state(false); let noteError = $state(""); @@ -207,7 +227,10 @@ unitError = ""; unitSuccess = ""; try { - await mutation("admin:unitsDelete", { token: adminToken(), id: unit._id }); + await mutation("admin:unitsDelete", { + token: adminToken(), + id: unit._id, + }); units = (await query("units:getAll")) as UnitDoc[]; } catch (err: any) { unitError = err.message ?? "Failed to delete unit"; @@ -217,7 +240,12 @@ // ---- accounts ---- function startEditUser(user: AdminUser) { - userForm = { id: user._id, email: user.email, name: user.name, role: user.role }; + userForm = { + id: user._id, + email: user.email, + name: user.name, + role: user.role, + }; userError = ""; } @@ -239,7 +267,9 @@ name: userForm.name, role: userForm.role, }); - users = (await query("admin:usersList", { token: adminToken() })) as AdminUser[]; + users = (await query("admin:usersList", { + token: adminToken(), + })) as AdminUser[]; resetUserForm(); } catch (err: any) { userError = err.message ?? "Failed to update account"; @@ -258,7 +288,9 @@ name: user.name, role: user.role === "admin" ? "user" : "admin", }); - users = (await query("admin:usersList", { token: adminToken() })) as AdminUser[]; + users = (await query("admin:usersList", { + token: adminToken(), + })) as AdminUser[]; } catch (err: any) { userError = err.message ?? "Failed to change role"; } @@ -268,8 +300,13 @@ if (!confirm(`Delete ${user.email} and all of their content?`)) return; userError = ""; try { - await mutation("admin:usersDelete", { token: adminToken(), id: user._id }); - users = (await query("admin:usersList", { token: adminToken() })) as AdminUser[]; + await mutation("admin:usersDelete", { + token: adminToken(), + id: user._id, + }); + users = (await query("admin:usersList", { + token: adminToken(), + })) as AdminUser[]; } catch (err: any) { userError = err.message ?? "Failed to delete account"; } @@ -299,7 +336,9 @@ title: noteForm.title, content: noteForm.content, }); - notes = (await query("admin:notesList", { token: adminToken() })) as AdminNote[]; + notes = (await query("admin:notesList", { + token: adminToken(), + })) as AdminNote[]; resetNoteForm(); } catch (err: any) { noteError = err.message ?? "Failed to update note"; @@ -312,8 +351,13 @@ if (!confirm(`Delete note "${note.title}"?`)) return; noteError = ""; try { - await mutation("admin:notesDelete", { token: adminToken(), id: note._id }); - notes = (await query("admin:notesList", { token: adminToken() })) as AdminNote[]; + await mutation("admin:notesDelete", { + token: adminToken(), + id: note._id, + }); + notes = (await query("admin:notesList", { + token: adminToken(), + })) as AdminNote[]; } catch (err: any) { noteError = err.message ?? "Failed to delete note"; } @@ -321,7 +365,7 @@ - Admin — Notebook + Admin — DSEC Notebook
@@ -473,25 +517,35 @@

Notes

-

{stats.totals.notes}

+

+ {stats.totals.notes} +

Questions

-

{stats.totals.questions}

+

+ {stats.totals.questions} +

Accounts

-

{stats.totals.users}

+

+ {stats.totals.users} +

Units

-

{stats.totals.units}

+

+ {stats.totals.units} +

-

Posts — last {stats.weeks.length} weeks

+

+ Posts — last {stats.weeks.length} weeks +

Notes {unit.code}{unit.code2 ? ` / ${unit.code2}` : ""}

-

{unit.name}

+

+ {unit.name} +

{/if} - {:else} - {#if !sent} -
-
- - -

- We'll email a reset code to your @deakin.edu.au address. -

-
- - {#if error} -

{error}

- {/if} - - - - -
- {:else} -
-

- We sent a 6-digit code to {email}. It expires - in 10 minutes. + {:else if !sent} + +

+ + +

+ We'll email a reset code to your @deakin.edu.au address.

+
-
- - -
+ {#if error} +

{error}

+ {/if} -
- - -
+ - {#if error} -

{error}

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

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

- +
+ + +
- -
- {/if} +
+ + +
+ + {#if error} +

{error}

+ {/if} + + + + + {/if}
diff --git a/src/routes/notes/+page.svelte b/src/routes/notes/+page.svelte index cd78cfb..e6fbebb 100644 --- a/src/routes/notes/+page.svelte +++ b/src/routes/notes/+page.svelte @@ -18,7 +18,10 @@ onMount(async () => { const [n, u] = await Promise.all([query("notes:list", {}), query("units:getAll")]); const unitMap = new Map((u as UnitDoc[]).map((unit) => [unit._id, unit])); - notes = (n as NoteDoc[]).map((note) => ({ ...note, unit: unitMap.get(note.unitId) })); + notes = (n as NoteDoc[]).map((note) => ({ + ...note, + unit: unitMap.get(note.unitId), + })); units = u as UnitDoc[]; loading = false; }); @@ -43,7 +46,7 @@ - Notes — Notebook + Notes — DSEC Notebook
diff --git a/src/routes/post/note/+page.svelte b/src/routes/post/note/+page.svelte index 9d1471d..6b95277 100644 --- a/src/routes/post/note/+page.svelte +++ b/src/routes/post/note/+page.svelte @@ -128,7 +128,7 @@ - Post a note — Notebook + Post a note — DSEC Notebook diff --git a/src/routes/post/question/+page.svelte b/src/routes/post/question/+page.svelte index 7a6311e..6740c4c 100644 --- a/src/routes/post/question/+page.svelte +++ b/src/routes/post/question/+page.svelte @@ -128,7 +128,7 @@ - Ask a question — Notebook + Ask a question — DSEC Notebook diff --git a/src/routes/questions/+page.svelte b/src/routes/questions/+page.svelte index 2970f9d..ba88a38 100644 --- a/src/routes/questions/+page.svelte +++ b/src/routes/questions/+page.svelte @@ -45,7 +45,7 @@ - Questions — Notebook + Questions — DSEC Notebook
diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 1114e00..940471b 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -15,7 +15,9 @@ searchQuery = new URL(window.location.href).searchParams.get("q") ?? ""; if (searchQuery) { ranQuery = true; - results = (await query("search:all", { query: searchQuery })) as SearchResult[]; + results = (await query("search:all", { + query: searchQuery, + })) as SearchResult[]; } loading = false; }); @@ -25,7 +27,7 @@ - {searchQuery ? `Search: ${searchQuery}` : "Search"} — Notebook + {searchQuery ? `Search: ${searchQuery}` : "Search"} — DSEC Notebook
@@ -110,7 +112,9 @@ {/if} {:else} {#if unitResults.length === 0} -

No results found for “{searchQuery}”.

+

+ No results found for “{searchQuery}”. +

{/if} {/each} {/if} diff --git a/src/routes/topics/[slug]/+page.svelte b/src/routes/topics/[slug]/+page.svelte index a059bac..9ef53f4 100644 --- a/src/routes/topics/[slug]/+page.svelte +++ b/src/routes/topics/[slug]/+page.svelte @@ -40,15 +40,19 @@ - {topic?.name ?? "Topic"} — Notebook + {topic?.name ?? "Topic"} — DSEC Notebook
{#if loading}

Loading

{:else if topic} -

Home · Topic

-

{topic.name}

+

+ Home · Topic +

+

+ {topic.name} +

{#if topic.description}

{topic.description}

{/if} diff --git a/src/routes/units/+page.svelte b/src/routes/units/+page.svelte index fe098e8..56656f1 100644 --- a/src/routes/units/+page.svelte +++ b/src/routes/units/+page.svelte @@ -21,7 +21,7 @@ - Units — Notebook + Units — DSEC Notebook
@@ -47,7 +47,9 @@ {:else if units.length === 0}

No units yet.

{:else if visible.length === 0} -

No units match “{searchQuery.trim()}”.

+

+ No units match “{searchQuery.trim()}”. +

{:else}
{#each visible as unit (unit._id)} diff --git a/src/routes/users/[id]/+page.svelte b/src/routes/users/[id]/+page.svelte index 8cb52dd..a22a813 100644 --- a/src/routes/users/[id]/+page.svelte +++ b/src/routes/users/[id]/+page.svelte @@ -43,7 +43,9 @@ tab = "posts"; void (async () => { - const result = (await query("users:getPublicProfile", { id })) as Profile | null; + const result = (await query("users:getPublicProfile", { + id, + })) as Profile | null; if (cancelled) return; profile = result; loading = false; @@ -60,7 +62,7 @@ - {profile?.name ?? "Profile"} — Notebook + {profile?.name ?? "Profile"} — DSEC Notebook
@@ -71,7 +73,9 @@

Contributor

-

{profile.name}

+

+ {profile.name} +

Member since {new Date(profile._creationTime).toLocaleDateString(undefined, { month: "long", @@ -83,7 +87,9 @@

-

{profile.totalContributions}

+

+ {profile.totalContributions} +

Contributions

@@ -91,11 +97,15 @@

Notes

-

{profile.questionCount}

+

+ {profile.questionCount} +

Questions

-

{profile.commentCount}

+

+ {profile.commentCount} +

Comments

@@ -161,7 +171,9 @@

{previewMarkdown(comment.content)}

-

{timeAgo(comment.createdAt)}

+

+ {timeAgo(comment.createdAt)} +

{/each} {/if}