Polish the SPA: focus rings, reduced motion, forms that report errors
- Global :focus-visible ring (text fields get a border instead) and a prefers-reduced-motion override; the navbar marquee stops for it too. - Button: disabled state and horizontal padding. - useCreateForm returns error and submitting, so the create forms show a refused save inline and can't double-submit; they, Login, CreatePlace and CreateUser are real <form>s so Enter submits from any field. - Admin: section list wraps on phones, Manage Users is a table with errors, Manage Radio confirms before deleting, page delete errors show inline. - Hard-coded Tailwind colours replaced with tokens; 404 image alt text and no forced scrollbars. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -388,6 +388,8 @@ Note that Tailwind's spacing unit is set to **3px** (not the default 4px), so `p
|
|||||||
- Never hard-code a colour in a component; use a token. The one exception is `<canvas>` drawing (MobileAutomata), which can't read CSS variables.
|
- Never hard-code a colour in a component; use a token. The one exception is `<canvas>` drawing (MobileAutomata), which can't read CSS variables.
|
||||||
- Home widgets: wrap the title in `<Header>`; admin-only create forms use `<CreateToggle v-model="showCreate">` in the header's `#action` slot and render the form inside a `<Modal v-model="showCreate">` so it pops up over the page instead of replacing the widget.
|
- Home widgets: wrap the title in `<Header>`; admin-only create forms use `<CreateToggle v-model="showCreate">` in the header's `#action` slot and render the form inside a `<Modal v-model="showCreate">` so it pops up over the page instead of replacing the widget.
|
||||||
- Crossfading content in place: `<Transition name="fade">` inside a `position: relative` parent. Route changes use `<Transition name="slide">`.
|
- Crossfading content in place: `<Transition name="fade">` inside a `position: relative` parent. Route changes use `<Transition name="slide">`.
|
||||||
|
- Keyboard focus and reduced motion are handled globally in `styles.css`: every focusable element gets a pink `:focus-visible` ring (text fields a pink border instead), and `prefers-reduced-motion` collapses transitions and CSS animations. Both are low-specificity, so a component's own focus or outline style wins. A JS animation loop has to check `matchMedia("(prefers-reduced-motion: reduce)")` itself, as `Headline.vue` does.
|
||||||
|
- Forms are real `<form @submit.prevent>` elements with `type="submit"` / `type="button"` on their buttons, not `@keyup.enter` on each input: Enter then submits from any field and password managers recognise the login. A form that saves shows its error inline and disables its button while the request is out (`useCreateForm` returns `error` and `submitting` for this).
|
||||||
|
|
||||||
## Production Build
|
## Production Build
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,11 @@
|
|||||||
* every token is BOTH a utility class in templates
|
* every token is BOTH a utility class in templates
|
||||||
* (text-primary, bg-surface, font-heading) AND a CSS variable
|
* (text-primary, bg-surface, font-heading) AND a CSS variable
|
||||||
* in component <style> blocks (var(--color-primary)).
|
* in component <style> blocks (var(--color-primary)).
|
||||||
* 3. Base default look of plain HTML elements (the dark theme)
|
* 3. Base default look of plain HTML elements (the dark theme),
|
||||||
|
* including the keyboard focus ring
|
||||||
* 4. Components reusable classes: gif borders, A4 sheet, halftone background
|
* 4. Components reusable classes: gif borders, A4 sheet, halftone background
|
||||||
* 5. Transitions <Transition name="slide"> and <Transition name="fade">
|
* 5. Transitions <Transition name="slide"> and <Transition name="fade">,
|
||||||
|
* and the reduced-motion override
|
||||||
* 6. Print
|
* 6. Print
|
||||||
*
|
*
|
||||||
* The CV pages are a light theme: src/layouts/CVLayout.vue re-points the colour
|
* The CV pages are a light theme: src/layouts/CVLayout.vue re-points the colour
|
||||||
@@ -150,6 +152,26 @@ textarea::placeholder {
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keyboard focus. Nothing on the site had a visible focus ring, so tabbing
|
||||||
|
through it was blind. Text fields get the border treatment the login form
|
||||||
|
had; everything else an outline. The selectors are wrapped in :where() to
|
||||||
|
keep their specificity just above the bare `input` rule above, so any
|
||||||
|
component with its own focus or outline style (BoxFrame, the hotels and
|
||||||
|
automata forms) still wins. Not in an @layer: unlayered rules such as
|
||||||
|
`input` above would then beat it whatever its specificity. */
|
||||||
|
:where(*):focus-visible {
|
||||||
|
outline: 2px solid var(--color-tertiary);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
:where(
|
||||||
|
input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]),
|
||||||
|
textarea
|
||||||
|
):focus-visible {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--color-tertiary);
|
||||||
|
box-shadow: 0 0 0 2px var(--color-quaternary);
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
color: var(--color-primary);
|
color: var(--color-primary);
|
||||||
border: 1px solid var(--color-primary);
|
border: 1px solid var(--color-primary);
|
||||||
@@ -255,6 +277,20 @@ th {
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Visitors who ask the OS for less motion get instant route changes and
|
||||||
|
crossfades. The JS animation loops check the same query themselves
|
||||||
|
(Headline.vue for the navbar marquee). */
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
/* 6. Print */
|
/* 6. Print */
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<!--
|
<!--
|
||||||
The site's standard button. Wraps a native <button>, so all attributes and
|
The site's standard button. Wraps a native <button>, so all attributes and
|
||||||
listeners (including @click) fall through to it via Vue's attribute inheritance.
|
listeners (including @click) fall through to it via Vue's attribute inheritance.
|
||||||
|
A disabled button is dimmed and stops reacting to hover and press, so a form
|
||||||
|
that is busy saving looks it.
|
||||||
-->
|
-->
|
||||||
<script setup></script>
|
<script setup></script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
class="text-primary bg-link-bg text-center border cursor-pointer transition-colors duration-150 ease-in-out hover:bg-surface active:scale-95"
|
class="px-2 text-primary bg-link-bg text-center border cursor-pointer transition-colors duration-150 ease-in-out hover:bg-surface active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-link-bg disabled:active:scale-100"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ function animate() {
|
|||||||
let resizeObserver;
|
let resizeObserver;
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
// A visitor who asked the OS for less motion gets the text standing still.
|
||||||
|
// The CSS reduced-motion override in styles.css can't reach this: the
|
||||||
|
// movement is a transform written every frame, not a transition.
|
||||||
|
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||||
|
|
||||||
measureWidth();
|
measureWidth();
|
||||||
rafId = requestAnimationFrame(animate);
|
rafId = requestAnimationFrame(animate);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
// The shared body of the admin "create X" forms (CreatePost, CreateFavorite,
|
// The shared body of the admin "create X" forms (CreatePost, CreateFavorite,
|
||||||
// CreateActivity, CreateBookmark): a ref per field, a GraphQL mutation taking a
|
// CreateActivity, CreateBookmark): a ref per field, a GraphQL mutation taking a
|
||||||
// single `input`, clear the fields on success, then emit "done" so the host
|
// single `input`, clear the fields on success, then emit "done" so the host
|
||||||
// modal can close. Failures are logged and leave the fields alone, exactly as
|
// modal can close. A failure leaves the fields alone and its message on
|
||||||
// the hand-written versions did.
|
// `error` for the form to show — it used to go only to the console, so a
|
||||||
|
// refused save looked exactly like a button that did nothing. `submitting`
|
||||||
|
// disables the button while the request is out, and a second submit in that
|
||||||
|
// window is ignored, so a double click cannot create the row twice.
|
||||||
|
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { gql } from "@/graphql";
|
import { gql } from "@/graphql";
|
||||||
@@ -15,7 +18,12 @@ import { gql } from "@/graphql";
|
|||||||
* @param {string[]} [options.optional] fields sent as undefined when blank,
|
* @param {string[]} [options.optional] fields sent as undefined when blank,
|
||||||
* so the backend sees "not set" rather than an empty string
|
* so the backend sees "not set" rather than an empty string
|
||||||
* @param {string} [options.resultKey] mutation field to log on success
|
* @param {string} [options.resultKey] mutation field to log on success
|
||||||
* @returns {{ values: Record<string, import("vue").Ref<string>>, submit: () => Promise<void> }}
|
* @returns {{
|
||||||
|
* values: Record<string, import("vue").Ref<string>>,
|
||||||
|
* submit: () => Promise<void>,
|
||||||
|
* error: import("vue").Ref<string>,
|
||||||
|
* submitting: import("vue").Ref<boolean>,
|
||||||
|
* }}
|
||||||
*/
|
*/
|
||||||
export function useCreateForm({
|
export function useCreateForm({
|
||||||
mutation,
|
mutation,
|
||||||
@@ -25,8 +33,13 @@ export function useCreateForm({
|
|||||||
resultKey,
|
resultKey,
|
||||||
}) {
|
}) {
|
||||||
const values = Object.fromEntries(fields.map((name) => [name, ref("")]));
|
const values = Object.fromEntries(fields.map((name) => [name, ref("")]));
|
||||||
|
const error = ref("");
|
||||||
|
const submitting = ref(false);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
if (submitting.value) return;
|
||||||
|
submitting.value = true;
|
||||||
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
const input = {};
|
const input = {};
|
||||||
for (const name of fields) {
|
for (const name of fields) {
|
||||||
@@ -39,8 +52,11 @@ export function useCreateForm({
|
|||||||
emit("done");
|
emit("done");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err?.message || "Failed to save";
|
||||||
|
} finally {
|
||||||
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { values, submit };
|
return { values, submit, error, submitting };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<main class="flex flex-col items-center">
|
<main class="flex flex-col items-center">
|
||||||
<div
|
<div
|
||||||
class="page-a4 items-center bdr-1 flex flex-col relative overflow-scroll"
|
class="page-a4 items-center bdr-1 flex flex-col relative overflow-auto"
|
||||||
>
|
>
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<RouterLink to="/" class="bdr-2">
|
<RouterLink to="/" class="bdr-2" aria-label="Back to the home page">
|
||||||
<img src="/img/memes/epic.jpeg" loading="lazy" />
|
<img src="/img/memes/epic.jpeg" alt="" class="block max-w-full" />
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<h1>Click her, she will take you home</h1>
|
<h1>Click her, she will take you home</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -85,12 +85,14 @@ async function handleLogout() {
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="admin-body">
|
<div class="admin-body">
|
||||||
<nav class="admin-nav">
|
<nav class="admin-nav" aria-label="Admin sections">
|
||||||
<button
|
<button
|
||||||
v-for="section in sections"
|
v-for="section in sections"
|
||||||
:key="section.id"
|
:key="section.id"
|
||||||
|
type="button"
|
||||||
class="admin-nav-link"
|
class="admin-nav-link"
|
||||||
:class="{ 'is-active': active === section.id }"
|
:class="{ 'is-active': active === section.id }"
|
||||||
|
:aria-current="active === section.id ? 'page' : undefined"
|
||||||
@click="selectSection(section.id)"
|
@click="selectSection(section.id)"
|
||||||
>
|
>
|
||||||
{{ section.label }}
|
{{ section.label }}
|
||||||
@@ -114,7 +116,9 @@ async function handleLogout() {
|
|||||||
@done="onDone"
|
@done="onDone"
|
||||||
@cancel="onCancel"
|
@cancel="onCancel"
|
||||||
/>
|
/>
|
||||||
<small v-if="notice" class="admin-notice">{{ notice }}</small>
|
<small v-if="notice" class="admin-notice" role="status">
|
||||||
|
{{ notice }}
|
||||||
|
</small>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -195,9 +199,18 @@ async function handleLogout() {
|
|||||||
color: var(--color-secondary);
|
color: var(--color-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On a phone the section list would be eleven full-width rows above the
|
||||||
|
form; as wrapping chips it takes three or four lines. */
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.admin-body {
|
.admin-body {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
.admin-nav {
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.admin-nav-link {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useCreateForm } from "@/js/useCreateForm";
|
|||||||
|
|
||||||
const emit = defineEmits(["done", "cancel"]);
|
const emit = defineEmits(["done", "cancel"]);
|
||||||
|
|
||||||
const { values, submit: post } = useCreateForm({
|
const { values, submit: post, error, submitting } = useCreateForm({
|
||||||
mutation: `mutation CreateActivity($input: CreateActivityInput!) { createActivity(input: $input) { id } }`,
|
mutation: `mutation CreateActivity($input: CreateActivityInput!) { createActivity(input: $input) { id } }`,
|
||||||
fields: ["type", "name", "link"],
|
fields: ["type", "name", "link"],
|
||||||
optional: ["link"],
|
optional: ["link"],
|
||||||
@@ -19,12 +19,15 @@ const { type, name, link } = values;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<form class="flex flex-col" @submit.prevent="post">
|
||||||
<h1>Create Activity</h1>
|
<h1>Create Activity</h1>
|
||||||
<input type="text" v-model="type" placeholder="Type" @keyup.enter="post" />
|
<input type="text" v-model="type" placeholder="Type" />
|
||||||
<input type="text" v-model="name" placeholder="Name" @keyup.enter="post" />
|
<input type="text" v-model="name" placeholder="Name" />
|
||||||
<input type="text" v-model="link" placeholder="Link" @keyup.enter="post" />
|
<input type="text" v-model="link" placeholder="Link" />
|
||||||
<Button @click="post">Upload</Button>
|
<small v-if="error" class="p-1" role="alert">{{ error }}</small>
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
<Button type="submit" :disabled="submitting">
|
||||||
</div>
|
{{ submitting ? "Uploading…" : "Upload" }}
|
||||||
|
</Button>
|
||||||
|
<Button type="button" @click="emit('cancel')">Cancel</Button>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useCreateForm } from "@/js/useCreateForm";
|
|||||||
|
|
||||||
const emit = defineEmits(["done", "cancel"]);
|
const emit = defineEmits(["done", "cancel"]);
|
||||||
|
|
||||||
const { values, submit } = useCreateForm({
|
const { values, submit, error, submitting } = useCreateForm({
|
||||||
mutation: `mutation CreateBookmark($input: CreateBookmarkInput!) { createBookmark(input: $input) { id } }`,
|
mutation: `mutation CreateBookmark($input: CreateBookmarkInput!) { createBookmark(input: $input) { id } }`,
|
||||||
fields: ["category", "name", "link"],
|
fields: ["category", "name", "link"],
|
||||||
emit,
|
emit,
|
||||||
@@ -17,22 +17,15 @@ const { category, name, link } = values;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<form class="flex flex-col" @submit.prevent="submit">
|
||||||
<h1>Create Bookmark</h1>
|
<h1>Create Bookmark</h1>
|
||||||
<input type="text" v-model="category" placeholder="Category" />
|
<input type="text" v-model="category" placeholder="Category" />
|
||||||
<input
|
<input type="text" v-model="name" placeholder="Name" />
|
||||||
type="text"
|
<input type="text" v-model="link" placeholder="Link" />
|
||||||
v-model="name"
|
<small v-if="error" class="p-1" role="alert">{{ error }}</small>
|
||||||
placeholder="Name"
|
<Button type="submit" :disabled="submitting">
|
||||||
@keyup.enter="submit"
|
{{ submitting ? "Uploading…" : "Upload" }}
|
||||||
/>
|
</Button>
|
||||||
<input
|
<Button type="button" @click="emit('cancel')">Cancel</Button>
|
||||||
type="text"
|
</form>
|
||||||
v-model="link"
|
|
||||||
placeholder="Link"
|
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
|
||||||
<Button @click="submit">Upload</Button>
|
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useCreateForm } from "@/js/useCreateForm";
|
|||||||
|
|
||||||
const emit = defineEmits(["done", "cancel"]);
|
const emit = defineEmits(["done", "cancel"]);
|
||||||
|
|
||||||
const { values, submit: post } = useCreateForm({
|
const { values, submit: post, error, submitting } = useCreateForm({
|
||||||
mutation: `mutation CreateFavorite($input: CreateFavoriteInput!) { createFavorite(input: $input) { id } }`,
|
mutation: `mutation CreateFavorite($input: CreateFavoriteInput!) { createFavorite(input: $input) { id } }`,
|
||||||
fields: ["type", "name", "link"],
|
fields: ["type", "name", "link"],
|
||||||
optional: ["link"],
|
optional: ["link"],
|
||||||
@@ -19,12 +19,15 @@ const { type, name, link } = values;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<form class="flex flex-col" @submit.prevent="post">
|
||||||
<h1>Create Favorite</h1>
|
<h1>Create Favorite</h1>
|
||||||
<input type="text" v-model="type" placeholder="Type" @keyup.enter="post" />
|
<input type="text" v-model="type" placeholder="Type" />
|
||||||
<input type="text" v-model="name" placeholder="Name" @keyup.enter="post" />
|
<input type="text" v-model="name" placeholder="Name" />
|
||||||
<input type="text" v-model="link" placeholder="Link" @keyup.enter="post" />
|
<input type="text" v-model="link" placeholder="Link" />
|
||||||
<Button @click="post">Upload</Button>
|
<small v-if="error" class="p-1" role="alert">{{ error }}</small>
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
<Button type="submit" :disabled="submitting">
|
||||||
</div>
|
{{ submitting ? "Uploading…" : "Upload" }}
|
||||||
|
</Button>
|
||||||
|
<Button type="button" @click="emit('cancel')">Cancel</Button>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -19,13 +19,16 @@ const imageUrl = ref("");
|
|||||||
const notes = ref("");
|
const notes = ref("");
|
||||||
const done = ref(false);
|
const done = ref(false);
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
|
const submitting = ref(false);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
if (submitting.value) return;
|
||||||
if (!title.value.trim()) {
|
if (!title.value.trim()) {
|
||||||
error.value = "Title is required";
|
error.value = "Title is required";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
error.value = "";
|
error.value = "";
|
||||||
|
submitting.value = true;
|
||||||
try {
|
try {
|
||||||
await places.create({
|
await places.create({
|
||||||
title: title.value.trim(),
|
title: title.value.trim(),
|
||||||
@@ -48,56 +51,38 @@ async function submit() {
|
|||||||
emit("done");
|
emit("done");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err?.message || "Failed to save";
|
error.value = err?.message || "Failed to save";
|
||||||
|
} finally {
|
||||||
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<form class="flex flex-col" @submit.prevent="submit">
|
||||||
<h1>Add Place / Thing To Do</h1>
|
<h1>Add Place / Thing To Do</h1>
|
||||||
<input
|
<input type="text" v-model="title" placeholder="Title (required)" />
|
||||||
type="text"
|
<input type="text" v-model="location" placeholder="Location" />
|
||||||
v-model="title"
|
|
||||||
placeholder="Title (required)"
|
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
v-model="location"
|
|
||||||
placeholder="Location"
|
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
v-model="category"
|
v-model="category"
|
||||||
placeholder="Category (place, activity, food…)"
|
placeholder="Category (place, activity, food…)"
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
v-model="cost"
|
|
||||||
placeholder="Cost (e.g. £20 pp)"
|
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
/>
|
||||||
|
<input type="text" v-model="cost" placeholder="Cost (e.g. £20 pp)" />
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
v-model="priority"
|
v-model="priority"
|
||||||
placeholder="Priority (higher = sooner)"
|
placeholder="Priority (higher = sooner)"
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
v-model="imageUrl"
|
|
||||||
placeholder="Image URL"
|
|
||||||
@keyup.enter="submit"
|
|
||||||
/>
|
/>
|
||||||
|
<input type="text" v-model="imageUrl" placeholder="Image URL" />
|
||||||
<textarea class="h-25" v-model="notes" placeholder="Notes"></textarea>
|
<textarea class="h-25" v-model="notes" placeholder="Notes"></textarea>
|
||||||
<label class="flex flex-row items-center gap-2 p-2 text-primary">
|
<label class="flex flex-row items-center gap-2 p-2 text-primary">
|
||||||
<input type="checkbox" v-model="done" class="w-auto" />
|
<input type="checkbox" v-model="done" class="w-auto" />
|
||||||
Already done
|
Already done
|
||||||
</label>
|
</label>
|
||||||
<small v-if="error" class="p-1">{{ error }}</small>
|
<small v-if="error" class="p-1" role="alert">{{ error }}</small>
|
||||||
<Button @click="submit">Upload</Button>
|
<Button type="submit" :disabled="submitting">
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
{{ submitting ? "Uploading…" : "Upload" }}
|
||||||
</div>
|
</Button>
|
||||||
|
<Button type="button" @click="emit('cancel')">Cancel</Button>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useCreateForm } from "@/js/useCreateForm";
|
|||||||
|
|
||||||
const emit = defineEmits(["done", "cancel"]);
|
const emit = defineEmits(["done", "cancel"]);
|
||||||
|
|
||||||
const { values, submit: post } = useCreateForm({
|
const { values, submit: post, error, submitting } = useCreateForm({
|
||||||
mutation: `mutation CreatePost($input: CreatePostInput!) { createPost(input: $input) { id } }`,
|
mutation: `mutation CreatePost($input: CreatePostInput!) { createPost(input: $input) { id } }`,
|
||||||
fields: ["title", "content"],
|
fields: ["title", "content"],
|
||||||
resultKey: "createPost",
|
resultKey: "createPost",
|
||||||
@@ -20,16 +20,14 @@ const { title, content } = values;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<form class="flex flex-col" @submit.prevent="post">
|
||||||
<h1>Create Post</h1>
|
<h1>Create Post</h1>
|
||||||
<input
|
<input type="text" v-model="title" placeholder="Title" />
|
||||||
type="text"
|
|
||||||
v-model="title"
|
|
||||||
placeholder="Title"
|
|
||||||
@keyup.enter="post"
|
|
||||||
/>
|
|
||||||
<textarea class="h-50" v-model="content" placeholder="Content"></textarea>
|
<textarea class="h-50" v-model="content" placeholder="Content"></textarea>
|
||||||
<Button @click="post">Upload</Button>
|
<small v-if="error" class="p-1" role="alert">{{ error }}</small>
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
<Button type="submit" :disabled="submitting">
|
||||||
</div>
|
{{ submitting ? "Uploading…" : "Upload" }}
|
||||||
|
</Button>
|
||||||
|
<Button type="button" @click="emit('cancel')">Cancel</Button>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const emit = defineEmits(["done", "cancel"]);
|
|||||||
|
|
||||||
const images = ref([]);
|
const images = ref([]);
|
||||||
const results = ref([]);
|
const results = ref([]);
|
||||||
|
const uploading = ref(false);
|
||||||
|
|
||||||
function onFileChange(e) {
|
function onFileChange(e) {
|
||||||
images.value = Array.from(e.target.files);
|
images.value = Array.from(e.target.files);
|
||||||
@@ -23,7 +24,8 @@ function onFileChange(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!images.value.length) return;
|
if (!images.value.length || uploading.value) return;
|
||||||
|
uploading.value = true;
|
||||||
results.value = images.value.map((f) => ({
|
results.value = images.value.map((f) => ({
|
||||||
name: f.name,
|
name: f.name,
|
||||||
status: "Uploading...",
|
status: "Uploading...",
|
||||||
@@ -54,6 +56,7 @@ async function submit() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
images.value = [];
|
images.value = [];
|
||||||
|
uploading.value = false;
|
||||||
// Only a clean run counts as done: hosts close or confirm on "done", which
|
// Only a clean run counts as done: hosts close or confirm on "done", which
|
||||||
// would hide or contradict the per-file failure rows above.
|
// would hide or contradict the per-file failure rows above.
|
||||||
if (results.value.every((r) => r.ok)) emit("done");
|
if (results.value.every((r) => r.ok)) emit("done");
|
||||||
@@ -69,11 +72,13 @@ async function submit() {
|
|||||||
multiple
|
multiple
|
||||||
@change="onFileChange"
|
@change="onFileChange"
|
||||||
/>
|
/>
|
||||||
<Button @click="submit">Upload</Button>
|
<Button @click="submit" :disabled="uploading || !images.length">
|
||||||
|
{{ uploading ? "Reading…" : "Upload" }}
|
||||||
|
</Button>
|
||||||
<Button @click="emit('cancel')">Cancel</Button>
|
<Button @click="emit('cancel')">Cancel</Button>
|
||||||
<div v-for="r in results" :key="r.name">
|
<div v-for="r in results" :key="r.name">
|
||||||
<span class="text-primary">{{ r.name }}: </span>
|
<span class="text-primary">{{ r.name }}: </span>
|
||||||
<span :class="r.ok ? 'text-secondary' : 'text-red-500'">{{
|
<span :class="r.ok ? 'text-secondary' : 'text-tertiary'">{{
|
||||||
r.status
|
r.status
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ const username = ref("");
|
|||||||
const password = ref("");
|
const password = ref("");
|
||||||
const message = ref("");
|
const message = ref("");
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
|
const submitting = ref(false);
|
||||||
|
|
||||||
async function handleCreate() {
|
async function handleCreate() {
|
||||||
|
if (submitting.value) return;
|
||||||
message.value = "";
|
message.value = "";
|
||||||
error.value = "";
|
error.value = "";
|
||||||
|
submitting.value = true;
|
||||||
try {
|
try {
|
||||||
const data = await gql(
|
const data = await gql(
|
||||||
`mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id username } }`,
|
`mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id username } }`,
|
||||||
@@ -26,29 +29,37 @@ async function handleCreate() {
|
|||||||
password.value = "";
|
password.value = "";
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err.message || "Failed to create user.";
|
error.value = err.message || "Failed to create user.";
|
||||||
|
} finally {
|
||||||
|
submitting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="auth.loggedIn && auth.user.admin" class="flex flex-col">
|
<form
|
||||||
|
v-if="auth.loggedIn && auth.user.admin"
|
||||||
|
class="flex flex-col"
|
||||||
|
@submit.prevent="handleCreate"
|
||||||
|
>
|
||||||
<h1>Create User</h1>
|
<h1>Create User</h1>
|
||||||
<p v-if="message" class="text-green-500">{{ message }}</p>
|
<p v-if="message" class="text-secondary" role="status">{{ message }}</p>
|
||||||
<p v-if="error" class="text-red-500">{{ error }}</p>
|
<p v-if="error" class="text-tertiary" role="alert">{{ error }}</p>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
v-model="username"
|
v-model="username"
|
||||||
placeholder="Username"
|
placeholder="Username"
|
||||||
@keyup.enter="handleCreate"
|
autocomplete="off"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
@keyup.enter="handleCreate"
|
autocomplete="new-password"
|
||||||
/>
|
/>
|
||||||
<Button @click="handleCreate">Create Account</Button>
|
<Button type="submit" :disabled="submitting">
|
||||||
</div>
|
{{ submitting ? "Creating…" : "Create Account" }}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
<div v-else-if="auth.loggedIn" class="flex flex-col">
|
<div v-else-if="auth.loggedIn" class="flex flex-col">
|
||||||
<p>You do not have permission to create users.</p>
|
<p>You do not have permission to create users.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -86,7 +86,9 @@ function handleLogout() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="login-card bdr-1">
|
<!-- A real <form>, so Enter submits from either field and password
|
||||||
|
managers recognise it as a sign-in. -->
|
||||||
|
<form v-else class="login-card bdr-1" @submit.prevent="handleLogin">
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<small class="login-hint">
|
<small class="login-hint">
|
||||||
Admin access is required beyond this point.
|
Admin access is required beyond this point.
|
||||||
@@ -99,7 +101,7 @@ function handleLogout() {
|
|||||||
v-model="username"
|
v-model="username"
|
||||||
autocomplete="username"
|
autocomplete="username"
|
||||||
placeholder="Username"
|
placeholder="Username"
|
||||||
@keyup.enter="handleLogin"
|
required
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -110,16 +112,18 @@ function handleLogout() {
|
|||||||
v-model="password"
|
v-model="password"
|
||||||
autocomplete="current-password"
|
autocomplete="current-password"
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
@keyup.enter="handleLogin"
|
required
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<small v-if="errorMsg" class="login-error">{{ errorMsg }}</small>
|
<small v-if="errorMsg" class="login-error" role="alert">
|
||||||
|
{{ errorMsg }}
|
||||||
|
</small>
|
||||||
|
|
||||||
<Button @click="handleLogin" :disabled="submitting">
|
<Button type="submit" class="mt-1 py-2" :disabled="submitting">
|
||||||
{{ submitting ? "Signing in…" : "Log In" }}
|
{{ submitting ? "Signing in…" : "Log In" }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const pages = usePagesStore();
|
|||||||
pages.fetch();
|
pages.fetch();
|
||||||
const removeTarget = ref(null);
|
const removeTarget = ref(null);
|
||||||
const confirmationOpen = ref(false);
|
const confirmationOpen = ref(false);
|
||||||
|
const removeError = ref("");
|
||||||
|
|
||||||
async function remove(page) {
|
async function remove(page) {
|
||||||
removeTarget.value = page;
|
removeTarget.value = page;
|
||||||
@@ -27,10 +28,11 @@ async function confirmRemove() {
|
|||||||
const page = removeTarget.value;
|
const page = removeTarget.value;
|
||||||
removeTarget.value = null;
|
removeTarget.value = null;
|
||||||
if (!page) return;
|
if (!page) return;
|
||||||
|
removeError.value = "";
|
||||||
try {
|
try {
|
||||||
await pages.remove(page.id);
|
await pages.remove(page.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err?.message || "Failed to delete");
|
removeError.value = err?.message || "Failed to delete";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -43,6 +45,9 @@ async function confirmRemove() {
|
|||||||
The home page (/stp) and the landing page's notes are canvases too —
|
The home page (/stp) and the landing page's notes are canvases too —
|
||||||
edit those on the pages themselves.
|
edit those on the pages themselves.
|
||||||
</p>
|
</p>
|
||||||
|
<p v-if="removeError" class="text-tertiary" role="alert">
|
||||||
|
{{ removeError }}
|
||||||
|
</p>
|
||||||
<p v-if="pages.error" class="text-tertiary">Couldn't load the pages.</p>
|
<p v-if="pages.error" class="text-tertiary">Couldn't load the pages.</p>
|
||||||
<table v-else-if="pages.pages.length" class="w-full">
|
<table v-else-if="pages.pages.length" class="w-full">
|
||||||
<tr v-for="page in pages.pages" :key="page.id">
|
<tr v-for="page in pages.pages" :key="page.id">
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
/**
|
/**
|
||||||
* Admin panel: list and upload tracks for the Icecast radio. REST
|
* Admin panel: list and upload tracks for the Icecast radio. REST
|
||||||
* (multipart/form-data) rather than GraphQL because it moves files.
|
* (multipart/form-data) rather than GraphQL because it moves files.
|
||||||
|
* Deleting removes the file from the radio's library for good, so it asks
|
||||||
|
* first; a failed list, enable/disable or delete is shown above the list.
|
||||||
*/
|
*/
|
||||||
import Button from "@/components/input/Button.vue";
|
import Button from "@/components/input/Button.vue";
|
||||||
|
import ConfirmDialog from "@/components/util/ConfirmDialog.vue";
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { api } from "@/api";
|
import { api } from "@/api";
|
||||||
|
|
||||||
@@ -11,13 +14,19 @@ const songs = ref([]);
|
|||||||
const files = ref([]);
|
const files = ref([]);
|
||||||
const results = ref([]);
|
const results = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const error = ref("");
|
||||||
|
const deleteTarget = ref(null);
|
||||||
|
const confirmOpen = ref(false);
|
||||||
|
|
||||||
async function fetchSongs() {
|
async function fetchSongs() {
|
||||||
try {
|
try {
|
||||||
const res = await api.get("/radio/songs");
|
const res = await api.get("/radio/songs", {
|
||||||
|
fallback: "Couldn't load the songs",
|
||||||
|
});
|
||||||
songs.value = res.songs;
|
songs.value = res.songs;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,22 +66,40 @@ async function upload() {
|
|||||||
await fetchSongs();
|
await fetchSongs();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteSong(name) {
|
function askDelete(song) {
|
||||||
|
deleteTarget.value = song;
|
||||||
|
confirmOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteSong() {
|
||||||
|
const song = deleteTarget.value;
|
||||||
|
deleteTarget.value = null;
|
||||||
|
if (!song) return;
|
||||||
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
await api.delete(`/radio/songs/${encodeURIComponent(name)}`);
|
await api.delete(`/radio/songs/${encodeURIComponent(song.name)}`, {
|
||||||
|
fallback: "Delete failed",
|
||||||
|
});
|
||||||
await fetchSongs();
|
await fetchSongs();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleSong(song) {
|
async function toggleSong(song) {
|
||||||
const action = song.disabled ? "enable" : "disable";
|
const action = song.disabled ? "enable" : "disable";
|
||||||
|
error.value = "";
|
||||||
try {
|
try {
|
||||||
await api.patch(`/radio/songs/${encodeURIComponent(song.name)}/${action}`);
|
await api.patch(
|
||||||
|
`/radio/songs/${encodeURIComponent(song.name)}/${action}`,
|
||||||
|
undefined,
|
||||||
|
{ fallback: `Couldn't ${action} the song` },
|
||||||
|
);
|
||||||
await fetchSongs();
|
await fetchSongs();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,26 +121,41 @@ onMounted(fetchSongs);
|
|||||||
multiple
|
multiple
|
||||||
@change="onFileChange"
|
@change="onFileChange"
|
||||||
/>
|
/>
|
||||||
<Button @click="upload" :disabled="loading">Upload</Button>
|
<Button @click="upload" :disabled="loading || !files.length">
|
||||||
|
{{ loading ? "Uploading…" : "Upload" }}
|
||||||
|
</Button>
|
||||||
|
<p v-if="error" class="text-tertiary" role="alert">{{ error }}</p>
|
||||||
<div v-for="r in results" :key="r.name">
|
<div v-for="r in results" :key="r.name">
|
||||||
<span class="text-primary">{{ r.name }}: </span>
|
<span class="text-primary">{{ r.name }}: </span>
|
||||||
<span :class="r.ok ? 'text-secondary' : 'text-red-500'">{{
|
<span :class="r.ok ? 'text-secondary' : 'text-tertiary'">{{
|
||||||
r.status
|
r.status
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="song in songs"
|
v-for="song in songs"
|
||||||
:key="song.name"
|
:key="song.name"
|
||||||
class="flex flex-row items-center gap-2"
|
class="flex flex-row flex-wrap items-center gap-2"
|
||||||
:class="{ 'opacity-50': song.disabled }"
|
:class="{ 'opacity-50': song.disabled }"
|
||||||
>
|
>
|
||||||
<span :class="{ 'line-through': song.disabled }">{{ song.name }}</span>
|
<span class="text-primary" :class="{ 'line-through': song.disabled }">
|
||||||
|
{{ song.name }}
|
||||||
|
</span>
|
||||||
<span class="text-secondary text-sm">{{ formatSize(song.size) }}</span>
|
<span class="text-secondary text-sm">{{ formatSize(song.size) }}</span>
|
||||||
<span v-if="song.disabled" class="text-red-400 text-xs">disabled</span>
|
<span v-if="song.disabled" class="text-tertiary text-xs">disabled</span>
|
||||||
<Button @click="toggleSong(song)">{{
|
<Button @click="toggleSong(song)">{{
|
||||||
song.disabled ? "Enable" : "Disable"
|
song.disabled ? "Enable" : "Disable"
|
||||||
}}</Button>
|
}}</Button>
|
||||||
<Button @click="deleteSong(song.name)">Delete</Button>
|
<Button @click="askDelete(song)">Delete</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
v-if="deleteTarget"
|
||||||
|
v-model="confirmOpen"
|
||||||
|
title="Delete song"
|
||||||
|
:message="`Delete “${deleteTarget.name}” from the radio? The file is removed for good.`"
|
||||||
|
confirm-label="Delete"
|
||||||
|
@confirm="deleteSong"
|
||||||
|
@cancel="deleteTarget = null"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* Admin panel: list users and toggle their admin flag. Mutates the local `user`
|
* Admin panel: list users and toggle their admin flag. Mutates the local `user`
|
||||||
* object in place from the mutation's response, so the row updates without a
|
* object in place from the mutation's response, so the row updates without a
|
||||||
* refetch.
|
* refetch. A failed load or toggle is shown above the table rather than only
|
||||||
|
* logged, and a row's button is disabled while its toggle is in flight.
|
||||||
*/
|
*/
|
||||||
import Button from "@/components/input/Button.vue";
|
import Button from "@/components/input/Button.vue";
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
@@ -11,6 +12,9 @@ import { gql } from "@/graphql";
|
|||||||
|
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const users = ref([]);
|
const users = ref([]);
|
||||||
|
const loaded = ref(false);
|
||||||
|
const error = ref("");
|
||||||
|
const pending = ref(null);
|
||||||
|
|
||||||
async function fetchUsers() {
|
async function fetchUsers() {
|
||||||
try {
|
try {
|
||||||
@@ -18,15 +22,23 @@ async function fetchUsers() {
|
|||||||
users.value = data.users;
|
users.value = data.users;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err.message || "Couldn't load the users";
|
||||||
|
} finally {
|
||||||
|
loaded.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleAdmin(user) {
|
async function toggleAdmin(user) {
|
||||||
|
error.value = "";
|
||||||
|
pending.value = user.id;
|
||||||
try {
|
try {
|
||||||
const data = await auth.setUserAdmin(user.id, !user.admin);
|
const data = await auth.setUserAdmin(user.id, !user.admin);
|
||||||
user.admin = data.admin;
|
user.admin = data.admin;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
error.value = err.message || `Couldn't change ${user.username}`;
|
||||||
|
} finally {
|
||||||
|
pending.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,18 +46,26 @@ onMounted(fetchUsers);
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col gap-2">
|
||||||
<h1>Manage Users</h1>
|
<h1>Manage Users</h1>
|
||||||
<div
|
<p v-if="error" class="text-tertiary" role="alert">{{ error }}</p>
|
||||||
v-for="user in users"
|
<p v-if="!loaded" class="text-muted">Loading…</p>
|
||||||
:key="user.id"
|
<table v-else-if="users.length" class="w-full">
|
||||||
class="flex flex-row items-center gap-2"
|
<tr v-for="user in users" :key="user.id">
|
||||||
|
<td class="py-1">{{ user.username }}</td>
|
||||||
|
<td class="py-1">{{ user.admin ? "admin" : "user" }}</td>
|
||||||
|
<td class="py-1 text-right">
|
||||||
|
<span v-if="user.id === auth.user.id" class="text-muted">you</span>
|
||||||
|
<Button
|
||||||
|
v-else
|
||||||
|
:disabled="pending === user.id"
|
||||||
|
@click="toggleAdmin(user)"
|
||||||
>
|
>
|
||||||
<span>{{ user.username }}</span>
|
|
||||||
<span v-if="user.admin">(admin)</span>
|
|
||||||
<Button v-if="user.id !== auth.user.id" @click="toggleAdmin(user)">
|
|
||||||
{{ user.admin ? "Demote" : "Promote" }}
|
{{ user.admin ? "Demote" : "Promote" }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p v-else-if="!error" class="text-muted">No users.</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ function formatHours(minutes) {
|
|||||||
Steam
|
Steam
|
||||||
<span
|
<span
|
||||||
class="inline-block w-2 h-2 rounded-full"
|
class="inline-block w-2 h-2 rounded-full"
|
||||||
:class="steamStatus.online ? 'bg-green-500' : 'bg-gray-400'"
|
:class="steamStatus.online ? 'bg-secondary' : 'bg-muted'"
|
||||||
:title="steamStatus.online ? 'Online' : 'Offline'"
|
:title="steamStatus.online ? 'Online' : 'Offline'"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user