Compare commits
No commits in common. "a4c09c9643a5450ad45ae7cb4e9406c90fa76057" and "f983ecf26c132d2ee3ce7055da23ce102a836361" have entirely different histories.
a4c09c9643
...
f983ecf26c
10 changed files with 24 additions and 212 deletions
|
|
@ -9,11 +9,6 @@ Facebook links; the server downloads it, then you cut clips from it:
|
||||||
the crop; the white box over the video shows what's kept.
|
the crop; the white box over the video shows what's kept.
|
||||||
- **Format**: video (MP4, H.264 and AAC) or audio only (MP3).
|
- **Format**: video (MP4, H.264 and AAC) or audio only (MP3).
|
||||||
|
|
||||||
A downloaded video can be kept whole too, before or without cutting
|
|
||||||
it: **Save to library** and **Save to Drive** on the download itself.
|
|
||||||
It stays on the server to cut clips from either way (until the day's
|
|
||||||
sweep).
|
|
||||||
|
|
||||||
Clips queue and run one at a time. A finished clip is deleted from the
|
Clips queue and run one at a time. A finished clip is deleted from the
|
||||||
server once it's downloaded, unless **Save to library** is pressed first,
|
server once it's downloaded, unless **Save to library** is pressed first,
|
||||||
which puts it in the media library as an upload (usable as a featured
|
which puts it in the media library as an upload (usable as a featured
|
||||||
|
|
|
||||||
|
|
@ -490,10 +490,9 @@ export function kick(db = dbRef) {
|
||||||
|
|
||||||
export const fileOf = (job) => (job?.file ? filePath(job.file) : null);
|
export const fileOf = (job) => (job?.file ? filePath(job.file) : null);
|
||||||
|
|
||||||
/* A finished clip, or a whole downloaded video, into the media
|
/* A finished clip into the media library: copied into the uploads
|
||||||
library: copied into the uploads directory under a random name and
|
directory under a random name, given a media row, and its working
|
||||||
given a media row. A clip's working file is deleted; a video's is
|
file deleted. Returns the media row's id. */
|
||||||
kept for cutting. Returns the media row's id. */
|
|
||||||
export async function saveToLibrary(db, job, userId) {
|
export async function saveToLibrary(db, job, userId) {
|
||||||
const from = fileOf(job);
|
const from = fileOf(job);
|
||||||
if (!from) throw new ClipError(410, "That clip's file is gone. Make it again.");
|
if (!from) throw new ClipError(410, "That clip's file is gone. Make it again.");
|
||||||
|
|
@ -529,11 +528,7 @@ export async function saveToLibrary(db, job, userId) {
|
||||||
const { size } = await stat(from);
|
const { size } = await stat(from);
|
||||||
const params = JSON.parse(job.params ?? "{}");
|
const params = JSON.parse(job.params ?? "{}");
|
||||||
const stamp = (s) => `${Math.floor(s / 60)}m${String(Math.floor(s % 60)).padStart(2, "0")}s`;
|
const stamp = (s) => `${Math.floor(s / 60)}m${String(Math.floor(s % 60)).padStart(2, "0")}s`;
|
||||||
// A whole download is named for itself; a clip for its span.
|
const label = `${job.title ?? "Clip"} (${stamp(params.start ?? 0)} to ${stamp(params.end ?? 0)})${ext}`;
|
||||||
const label =
|
|
||||||
job.kind === "source"
|
|
||||||
? `${job.title ?? "Video"}${ext}`
|
|
||||||
: `${job.title ?? "Clip"} (${stamp(params.start ?? 0)} to ${stamp(params.end ?? 0)})${ext}`;
|
|
||||||
|
|
||||||
id = await step("adding it to the media table", () =>
|
id = await step("adding it to the media table", () =>
|
||||||
Number(
|
Number(
|
||||||
|
|
@ -551,14 +546,8 @@ export async function saveToLibrary(db, job, userId) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A clip's working file goes; a downloaded video's stays, to cut
|
|
||||||
// clips from (the day's sweep clears it).
|
|
||||||
if (job.kind === "source") {
|
|
||||||
update(db, job.id, { saved_media_id: id });
|
|
||||||
} else {
|
|
||||||
await rm(from, { force: true });
|
await rm(from, { force: true });
|
||||||
update(db, job.id, { saved_media_id: id, file: null });
|
update(db, job.id, { saved_media_id: id, file: null });
|
||||||
}
|
|
||||||
return { id, url: `${PUBLIC_PREFIX}${filename}` };
|
return { id, url: `${PUBLIC_PREFIX}${filename}` };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import { requireAuth, requireRole } from "../auth.js";
|
||||||
import { NO_STORE } from "../shape.js";
|
import { NO_STORE } from "../shape.js";
|
||||||
import { driveDelete, driveDownload, driveReady, driveTree } from "../googleService.js";
|
import { driveDelete, driveDownload, driveReady, driveTree } from "../googleService.js";
|
||||||
import { DRIVE_FOLDER, TYPE_FOLDERS } from "./requests.js";
|
import { DRIVE_FOLDER, TYPE_FOLDERS } from "./requests.js";
|
||||||
import { addToLibrary, shape as mediaShape } from "./media.js";
|
|
||||||
import { HttpError } from "../admin-crud.js";
|
import { HttpError } from "../admin-crud.js";
|
||||||
import { importDocx } from "./import.js";
|
import { importDocx } from "./import.js";
|
||||||
|
|
||||||
|
|
@ -247,9 +246,6 @@ admin.delete("/feedback/:id", requireRole("admin"), async (c) => {
|
||||||
GET /feedback/:id/files/:file download, from Drive
|
GET /feedback/:id/files/:file download, from Drive
|
||||||
POST /feedback/:id/files/:file/blog-post a .docx as a new
|
POST /feedback/:id/files/:file/blog-post a .docx as a new
|
||||||
unpublished blog post (import.js), editors and up
|
unpublished blog post (import.js), editors and up
|
||||||
POST /feedback/:id/files/:file/to-library { folder }: a photo
|
|
||||||
into the media library, for an image field (the picker's
|
|
||||||
From requests tab), editors and up
|
|
||||||
DELETE /feedback/:id/files/:file into Drive's trash and
|
DELETE /feedback/:id/files/:file into Drive's trash and
|
||||||
off the request, admins and up
|
off the request, admins and up
|
||||||
GET /request-files every request's files,
|
GET /request-files every request's files,
|
||||||
|
|
@ -288,29 +284,6 @@ admin.get("/feedback/:id/files/:file", async (c) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* A request's photo as an upload: records' images live in the media
|
|
||||||
library, not Drive. Once per file: the copy is found again by name. */
|
|
||||||
admin.post("/feedback/:id/files/:file/to-library", requireRole("editor"), async (c) => {
|
|
||||||
const file = fileOf(c);
|
|
||||||
if (!file) return c.json({ error: "No such file." }, 404);
|
|
||||||
if (!file.mime.startsWith("image/")) return c.json({ error: "Only a photo (JPEG or PNG) can go in the library." }, 400);
|
|
||||||
const db = c.get("db");
|
|
||||||
const name = `${file.name} (request ${c.req.param("id")})`.slice(0, 200);
|
|
||||||
const known = db.prepare(`SELECT m.* FROM media m WHERE m.original_name = ?`).get(name);
|
|
||||||
if (known) return c.json({ media: mediaShape(known) }, 200, NO_STORE);
|
|
||||||
try {
|
|
||||||
const bytes = await fromDrive(file);
|
|
||||||
const body = (await c.req.json().catch(() => null)) ?? {};
|
|
||||||
const row = await addToLibrary(db, bytes, { originalName: name, folder: body.folder, userId: c.get("user").id });
|
|
||||||
console.log(`feedback #${c.req.param("id")}: ${file.name} into the media library by ${c.get("user").email}`);
|
|
||||||
return c.json({ media: mediaShape(row) }, 201, NO_STORE);
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof HttpError) return c.json({ error: err.message }, err.status);
|
|
||||||
if (err?.status && err?.message) return c.json({ error: err.message }, err.status); // MediaError
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
admin.post("/feedback/:id/files/:file/blog-post", requireRole("editor"), async (c) => {
|
admin.post("/feedback/:id/files/:file/blog-post", requireRole("editor"), async (c) => {
|
||||||
const file = fileOf(c);
|
const file = fileOf(c);
|
||||||
if (!file) return c.json({ error: "No such file." }, 404);
|
if (!file) return c.json({ error: "No such file." }, 404);
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,9 @@
|
||||||
GET /clips/:id/download a finished clip, as an attachment;
|
GET /clips/:id/download a finished clip, as an attachment;
|
||||||
its file is deleted once it has
|
its file is deleted once it has
|
||||||
gone out in full, unless saved
|
gone out in full, unless saved
|
||||||
POST /clips/:id/save a finished clip, or a whole
|
POST /clips/:id/save a finished clip into the media
|
||||||
downloaded video, into the media
|
|
||||||
library
|
library
|
||||||
POST /clips/:id/drive { folder }: a finished clip (or a
|
POST /clips/:id/drive { folder }: a finished clip into a
|
||||||
whole downloaded video) into a
|
|
||||||
folder under Media in Drive, as a
|
folder under Media in Drive, as a
|
||||||
Files entry (routes/files.js)
|
Files entry (routes/files.js)
|
||||||
DELETE /clips/:id a job and its files (a source
|
DELETE /clips/:id a job and its files (a source
|
||||||
|
|
@ -216,9 +214,8 @@ clips.get("/clips/:id/download", async (c) => {
|
||||||
clips.post("/clips/:id/save", async (c) => {
|
clips.post("/clips/:id/save", async (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const job = findOr404(c);
|
const job = findOr404(c);
|
||||||
if (job.status !== "done") throw new ClipError(400, "Only a finished download or clip can be saved.");
|
if (job.kind !== "clip" || job.status !== "done") throw new ClipError(400, "Only a finished clip can be saved.");
|
||||||
if (job.saved_media_id) throw new ClipError(409, "It's already in the media library.");
|
if (job.saved_media_id) throw new ClipError(409, "It's already in the media library.");
|
||||||
if (!job.file) throw new ClipError(410, "Its file is gone from the server.");
|
|
||||||
const media = await saveToLibrary(db, job, c.get("user").id);
|
const media = await saveToLibrary(db, job, c.get("user").id);
|
||||||
console.log(`clips: clip ${job.id} saved to the library by ${c.get("user").email}`);
|
console.log(`clips: clip ${job.id} saved to the library by ${c.get("user").email}`);
|
||||||
return c.json({ media, job: shape(db.prepare(`${SELECT} WHERE j.id = ?`).get(job.id)) }, 200, NO_STORE);
|
return c.json({ media, job: shape(db.prepare(`${SELECT} WHERE j.id = ?`).get(job.id)) }, 200, NO_STORE);
|
||||||
|
|
@ -230,7 +227,7 @@ clips.post("/clips/:id/save", async (c) => {
|
||||||
clips.post("/clips/:id/drive", async (c) => {
|
clips.post("/clips/:id/drive", async (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const job = findOr404(c);
|
const job = findOr404(c);
|
||||||
if (job.status !== "done") throw new ClipError(400, "Only a finished download or clip can be saved.");
|
if (job.kind !== "clip" || job.status !== "done") throw new ClipError(400, "Only a finished clip can be saved.");
|
||||||
if (job.saved_drive_file_id) throw new ClipError(409, "It's already in Drive.");
|
if (job.saved_drive_file_id) throw new ClipError(409, "It's already in Drive.");
|
||||||
if (!driveReady()) throw new ClipError(400, "Google Drive isn't set up on the server (docs/google-drive-and-mail.md).");
|
if (!driveReady()) throw new ClipError(400, "Google Drive isn't set up on the server (docs/google-drive-and-mail.md).");
|
||||||
const folder = cleanFolder((await body(c)).folder);
|
const folder = cleanFolder((await body(c)).folder);
|
||||||
|
|
@ -242,11 +239,7 @@ clips.post("/clips/:id/drive", async (c) => {
|
||||||
const mime = audio ? "audio/mpeg" : "video/mp4";
|
const mime = audio ? "audio/mpeg" : "video/mp4";
|
||||||
const params = job.params ? JSON.parse(job.params) : {};
|
const params = job.params ? JSON.parse(job.params) : {};
|
||||||
const stamp = (s) => `${Math.floor(s / 60)}m${String(Math.floor(s % 60)).padStart(2, "0")}s`;
|
const stamp = (s) => `${Math.floor(s / 60)}m${String(Math.floor(s % 60)).padStart(2, "0")}s`;
|
||||||
const title = (job.title ?? "").replace(/[\u0000-\u001f"\\/]+/g, " ").trim().slice(0, 120);
|
const name = `${(job.title ?? "Clip").replace(/[\u0000-\u001f"\\/]+/g, " ").trim().slice(0, 120) || "Clip"} (${stamp(params.start ?? 0)} to ${stamp(params.end ?? 0)}).${audio ? "mp3" : "mp4"}`;
|
||||||
const name =
|
|
||||||
job.kind === "source"
|
|
||||||
? `${title || "Video"}.mp4`
|
|
||||||
: `${title || "Clip"} (${stamp(params.start ?? 0)} to ${stamp(params.end ?? 0)}).${audio ? "mp3" : "mp4"}`;
|
|
||||||
|
|
||||||
let uploaded;
|
let uploaded;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ let lastScan = 0;
|
||||||
/* Tables that can't hold an image path, or mustn't be searched. */
|
/* Tables that can't hold an image path, or mustn't be searched. */
|
||||||
const NOT_CONTENT = new Set(["media", "drive_files", "admin_users", "sessions", "feedback", "feedback_files", "sqlite_sequence"]);
|
const NOT_CONTENT = new Set(["media", "drive_files", "admin_users", "sessions", "feedback", "feedback_files", "sqlite_sequence"]);
|
||||||
|
|
||||||
export function shape(row) {
|
function shape(row) {
|
||||||
return {
|
return {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
// A hand-copied file keeps its own name, which may need escaping
|
// A hand-copied file keeps its own name, which may need escaping
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@
|
||||||
ImageInput the `widget: "image"` form field. A preview, the
|
ImageInput the `widget: "image"` form field. A preview, the
|
||||||
stored value as editable text, and buttons to
|
stored value as editable text, and buttons to
|
||||||
upload a new file or pick an earlier one.
|
upload a new file or pick an earlier one.
|
||||||
MediaPicker the dialog behind "Choose from library". Its From
|
MediaPicker the dialog behind "Choose from library".
|
||||||
requests tab lists photos sent with the Request
|
|
||||||
form (in Drive); picking one copies it into the
|
|
||||||
library first (RequestImages).
|
|
||||||
MediaGrid the thumbnails both the picker and the Media page
|
MediaGrid the thumbnails both the picker and the Media page
|
||||||
(pages/admin/AdminMedia.tsx) draw.
|
(pages/admin/AdminMedia.tsx) draw.
|
||||||
UploadButton a file input dressed as a button, with the
|
UploadButton a file input dressed as a button, with the
|
||||||
|
|
@ -40,8 +37,6 @@
|
||||||
import { FileAudio, X } from "@phosphor-icons/react";
|
import { FileAudio, X } from "@phosphor-icons/react";
|
||||||
import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from "react";
|
import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from "react";
|
||||||
|
|
||||||
import { useLocation } from "react-router-dom";
|
|
||||||
|
|
||||||
import { ApiError, get, post, upload } from "../../lib/api.ts";
|
import { ApiError, get, post, upload } from "../../lib/api.ts";
|
||||||
import { useAuth } from "../../lib/auth.tsx";
|
import { useAuth } from "../../lib/auth.tsx";
|
||||||
import { canWrite as roleCanWrite } from "../../lib/roles.ts";
|
import { canWrite as roleCanWrite } from "../../lib/roles.ts";
|
||||||
|
|
@ -70,20 +65,11 @@ export const IMAGE_FOLDERS = [
|
||||||
] as const;
|
] as const;
|
||||||
export type ImageFolder = (typeof IMAGE_FOLDERS)[number][0];
|
export type ImageFolder = (typeof IMAGE_FOLDERS)[number][0];
|
||||||
|
|
||||||
/* A tab strip over the folders; `value` is the one showing. `extra`
|
/* A tab strip over the folders; `value` is the one showing. */
|
||||||
adds tabs after them (the picker's From requests). */
|
export function FolderTabs({ value, onChange }: { value: string; onChange: (folder: ImageFolder) => void }) {
|
||||||
export function FolderTabs({
|
|
||||||
value,
|
|
||||||
onChange,
|
|
||||||
extra = [],
|
|
||||||
}: {
|
|
||||||
value: string;
|
|
||||||
onChange: (folder: string) => void;
|
|
||||||
extra?: [string, string][];
|
|
||||||
}) {
|
|
||||||
return (
|
return (
|
||||||
<div role="tablist" aria-label="Folders" className="flex flex-wrap gap-1">
|
<div role="tablist" aria-label="Folders" className="flex flex-wrap gap-1">
|
||||||
{[...IMAGE_FOLDERS, ...extra].map(([folder, label]) => (
|
{IMAGE_FOLDERS.map(([folder, label]) => (
|
||||||
<button
|
<button
|
||||||
key={folder}
|
key={folder}
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -319,75 +305,6 @@ export function MediaGrid({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Photos sent with requests ───────────────────────────────── */
|
|
||||||
|
|
||||||
const REQUESTS_TAB = "requests";
|
|
||||||
|
|
||||||
/* Photos from the Request form, which live in Drive: the one being
|
|
||||||
edited from first (Forms → Content requests → Create from this),
|
|
||||||
then newest. Picking one copies it into the library, into the
|
|
||||||
field's folder, and that copy is what the field gets. */
|
|
||||||
function RequestImages({ folder, onPick }: { folder?: string; onPick: (item: MediaItem) => void }) {
|
|
||||||
const current = (useLocation().state as any)?.fromRequest?.request ?? null;
|
|
||||||
const [files, setFiles] = useState<any[] | null>(null);
|
|
||||||
const [busy, setBusy] = useState<number | null>(null);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
get("/admin/request-files", { ttl: 0 })
|
|
||||||
.then((data) => {
|
|
||||||
const photos = data.files.filter((f) => f.mime.startsWith("image/") && !f.missing);
|
|
||||||
setFiles([...photos.filter((f) => f.feedback_id === current), ...photos.filter((f) => f.feedback_id !== current)]);
|
|
||||||
})
|
|
||||||
.catch((err) => setError(err instanceof ApiError ? err.message : "Couldn't load the request files."));
|
|
||||||
}, [current]);
|
|
||||||
|
|
||||||
async function pick(file) {
|
|
||||||
setBusy(file.id);
|
|
||||||
setError(null);
|
|
||||||
try {
|
|
||||||
const { media } = await post(`/admin/feedback/${file.feedback_id}/files/${file.id}/to-library`, { folder });
|
|
||||||
onPick(media);
|
|
||||||
} catch (err) {
|
|
||||||
setError(err instanceof ApiError ? err.message : "Couldn't copy it into the library.");
|
|
||||||
setBusy(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error && !files) return <p className="text-sm text-danger">{error}</p>;
|
|
||||||
if (!files) return <p className="text-sm text-muted">Loading…</p>;
|
|
||||||
if (files.length === 0) return <p className="text-sm text-muted">No photos have come in with requests.</p>;
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{error && <p className="mb-3 text-sm text-danger">{error}</p>}
|
|
||||||
<ul className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">
|
|
||||||
{files.map((file) => (
|
|
||||||
<li key={file.id} className="rounded-xl border border-muted/20 bg-surface p-2">
|
|
||||||
<button type="button" disabled={busy !== null} onClick={() => pick(file)} className="block w-full text-left disabled:opacity-60">
|
|
||||||
<div className="aspect-[4/3] overflow-hidden rounded-lg" style={CHECKER}>
|
|
||||||
{/* Straight from Drive through the server; private to the admin. */}
|
|
||||||
<img
|
|
||||||
src={`/api/admin/feedback/${file.feedback_id}/files/${file.id}`}
|
|
||||||
alt=""
|
|
||||||
loading="lazy"
|
|
||||||
className="h-full w-full object-contain"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<p className="mt-1.5 truncate text-xs font-medium text-body" title={file.name}>
|
|
||||||
{busy === file.id ? "Copying…" : file.name}
|
|
||||||
</p>
|
|
||||||
<p className="truncate text-xs text-muted/80">
|
|
||||||
{file.feedback_id === current ? "This request" : `Request #${file.feedback_id}`}
|
|
||||||
{file.subject ? `: ${file.subject}` : ""}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Picker dialog ───────────────────────────────────────────── */
|
/* ── Picker dialog ───────────────────────────────────────────── */
|
||||||
|
|
||||||
export function MediaPicker({
|
export function MediaPicker({
|
||||||
|
|
@ -405,8 +322,7 @@ export function MediaPicker({
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [tab, setTab] = useState<string>(folder);
|
const [tab, setTab] = useState<string>(folder);
|
||||||
const fromRequests = tab === REQUESTS_TAB;
|
const { items, error, setItems } = useMediaLibrary(query, "image", tab);
|
||||||
const { items, error, setItems } = useMediaLibrary(query, "image", fromRequests ? undefined : tab);
|
|
||||||
const dialogRef = useRef<HTMLDialogElement>(null);
|
const dialogRef = useRef<HTMLDialogElement>(null);
|
||||||
|
|
||||||
// showModal gives focus trapping, Escape and the backdrop for free.
|
// showModal gives focus trapping, Escape and the backdrop for free.
|
||||||
|
|
@ -445,7 +361,7 @@ export function MediaPicker({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="border-b border-brand/10 px-5 py-3">
|
<div className="border-b border-brand/10 px-5 py-3">
|
||||||
<FolderTabs value={tab} onChange={setTab} extra={[[REQUESTS_TAB, "From requests"]]} />
|
<FolderTabs value={tab} onChange={setTab} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{roleCanWrite(user) && (
|
{roleCanWrite(user) && (
|
||||||
|
|
@ -464,16 +380,7 @@ export function MediaPicker({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="overflow-y-auto px-5 py-4">
|
<div className="overflow-y-auto px-5 py-4">
|
||||||
{fromRequests ? (
|
{error ? (
|
||||||
<RequestImages
|
|
||||||
folder={folder}
|
|
||||||
onPick={(item) => {
|
|
||||||
setItems((current) => [item, ...(current ?? []).filter((m) => m.id !== item.id)]);
|
|
||||||
onPick(item);
|
|
||||||
dialogRef.current?.close();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : error ? (
|
|
||||||
<p className="text-sm text-danger">{error}</p>
|
<p className="text-sm text-danger">{error}</p>
|
||||||
) : items === null ? (
|
) : items === null ? (
|
||||||
<p className="text-sm text-muted">Loading…</p>
|
<p className="text-sm text-muted">Loading…</p>
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@
|
||||||
box or a build banner can read the same value later.
|
box or a build banner can read the same value later.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
export const SITE_VERSION = "NGU-Web.v1.9.14-content-display";
|
export const SITE_VERSION = "NGU-Web.v1.9.13-content-display";
|
||||||
|
|
|
||||||
|
|
@ -491,26 +491,6 @@ export default function AdminClips() {
|
||||||
{openId === s.id ? "Close" : "Make clips"}
|
{openId === s.id ? "Close" : "Make clips"}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{/* The whole video, before (or without) cutting: it
|
|
||||||
stays here to cut from either way. */}
|
|
||||||
{s.status === "done" && s.has_file && !s.saved_url && (
|
|
||||||
<button type="button" className={button} onClick={() => act(() => post(`/admin/clips/${s.id}/save`, {}))}>
|
|
||||||
Save to library
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{s.saved_url && (
|
|
||||||
<Link to="/admin/media" className="text-sm underline" style={{ color: accentText(BRAND) }}>
|
|
||||||
In the media library
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
{s.status === "done" && !s.saved_drive && (s.has_file || s.saved_url) && (
|
|
||||||
<SaveToDrive clip={s} onSaved={load} />
|
|
||||||
)}
|
|
||||||
{s.saved_drive && (
|
|
||||||
<a href={s.saved_drive.url} target="_blank" rel="noreferrer" className="text-sm underline" style={{ color: accentText(BRAND) }}>
|
|
||||||
In Drive: Media{s.saved_drive.folder ? `/${s.saved_drive.folder}` : ""}
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
{s.status !== "running" && (
|
{s.status !== "running" && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
||||||
|
|
@ -51,26 +51,6 @@ export function OptionalTag() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On a field the send button waits for. */
|
|
||||||
export function RequiredTag() {
|
|
||||||
return (
|
|
||||||
<span className="ml-2 rounded-full bg-danger-tint px-2 py-0.5 text-xs font-medium text-danger">
|
|
||||||
Required
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Under a message box: how many more characters it needs, until it
|
|
||||||
has them (the send button stays off until then). */
|
|
||||||
export function MinimumNote({ length, min }: { length: number; min: number }) {
|
|
||||||
if (length >= min) return null;
|
|
||||||
return (
|
|
||||||
<span className="text-xs" style={{ color: MUTED }}>
|
|
||||||
{length === 0 ? `At least ${min} characters` : `${min - length} more character${min - length === 1 ? "" : "s"} needed`}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function FieldError({ id, children }) {
|
export function FieldError({ id, children }) {
|
||||||
if (!children) return null;
|
if (!children) return null;
|
||||||
return (
|
return (
|
||||||
|
|
@ -376,7 +356,6 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
className="text-base font-semibold text-body"
|
className="text-base font-semibold text-body"
|
||||||
>
|
>
|
||||||
{request ? "Your request" : "Tell us more"}
|
{request ? "Your request" : "Tell us more"}
|
||||||
<RequiredTag />
|
|
||||||
</label>
|
</label>
|
||||||
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
||||||
{request
|
{request
|
||||||
|
|
@ -402,7 +381,6 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 flex items-start justify-between gap-4">
|
<div className="mt-2 flex items-start justify-between gap-4">
|
||||||
<FieldError id="feedback-message-error">{fieldErrors.message}</FieldError>
|
<FieldError id="feedback-message-error">{fieldErrors.message}</FieldError>
|
||||||
{!fieldErrors.message && <MinimumNote length={message.trim().length} min={MIN_MESSAGE} />}
|
|
||||||
<span
|
<span
|
||||||
className="ml-auto shrink-0 text-xs tabular-nums"
|
className="ml-auto shrink-0 text-xs tabular-nums"
|
||||||
style={{ color: MUTED }}
|
style={{ color: MUTED }}
|
||||||
|
|
@ -504,8 +482,8 @@ export default function FeedbackForm({ fixedType }: { fixedType?: string } = {})
|
||||||
{!ready && !sending && (
|
{!ready && !sending && (
|
||||||
<p className="text-sm" style={{ color: MUTED }}>
|
<p className="text-sm" style={{ color: MUTED }}>
|
||||||
{request
|
{request
|
||||||
? `Write at least ${MIN_MESSAGE} characters and give an email address to send.`
|
? "Write at least a sentence and give an email address to send."
|
||||||
: `Choose a type and write at least ${MIN_MESSAGE} characters to send.`}
|
: "Choose a type and write at least a sentence to send."}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { ApiError, upload } from "../../lib/api.ts";
|
||||||
import { accentText, BRAND } from "../../lib/color.ts";
|
import { accentText, BRAND } from "../../lib/color.ts";
|
||||||
import { REQUEST_FILES } from "../../lib/site.ts";
|
import { REQUEST_FILES } from "../../lib/site.ts";
|
||||||
import { REQUEST_TYPES, type RequestAction } from "../../data/requestTypes.ts";
|
import { REQUEST_TYPES, type RequestAction } from "../../data/requestTypes.ts";
|
||||||
import { FieldError, MinimumNote, OptionalTag, RequiredTag, TilePicker, errorFieldClass, fieldClass } from "./FeedbackForm.tsx";
|
import { FieldError, OptionalTag, TilePicker, errorFieldClass, fieldClass } from "./FeedbackForm.tsx";
|
||||||
|
|
||||||
const MUTED = "var(--color-muted)";
|
const MUTED = "var(--color-muted)";
|
||||||
const MAX_CHARS = 5000;
|
const MAX_CHARS = 5000;
|
||||||
|
|
@ -206,7 +206,6 @@ export default function RequestForm() {
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<label htmlFor="request-subject" className="text-base font-semibold text-body">
|
<label htmlFor="request-subject" className="text-base font-semibold text-body">
|
||||||
{action === "update" && type.actions.length > 1 ? `Which ${type.label.toLowerCase()}?` : type.subject}
|
{action === "update" && type.actions.length > 1 ? `Which ${type.label.toLowerCase()}?` : type.subject}
|
||||||
<RequiredTag />
|
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="request-subject"
|
id="request-subject"
|
||||||
|
|
@ -263,7 +262,6 @@ export default function RequestForm() {
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<label htmlFor="request-message" className="text-base font-semibold text-body">
|
<label htmlFor="request-message" className="text-base font-semibold text-body">
|
||||||
{action === "update" ? "What should change?" : "Tell us about it"}
|
{action === "update" ? "What should change?" : "Tell us about it"}
|
||||||
<RequiredTag />
|
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
id="request-message"
|
id="request-message"
|
||||||
|
|
@ -282,7 +280,6 @@ export default function RequestForm() {
|
||||||
/>
|
/>
|
||||||
<div className="mt-2 flex items-start justify-between gap-4">
|
<div className="mt-2 flex items-start justify-between gap-4">
|
||||||
<FieldError id="request-message-error">{fieldErrors.message}</FieldError>
|
<FieldError id="request-message-error">{fieldErrors.message}</FieldError>
|
||||||
{!fieldErrors.message && <MinimumNote length={message.trim().length} min={MIN_MESSAGE} />}
|
|
||||||
<span className="ml-auto shrink-0 text-xs tabular-nums" style={{ color: MUTED }}>
|
<span className="ml-auto shrink-0 text-xs tabular-nums" style={{ color: MUTED }}>
|
||||||
{message.length} / {MAX_CHARS}
|
{message.length} / {MAX_CHARS}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -385,7 +382,7 @@ export default function RequestForm() {
|
||||||
</button>
|
</button>
|
||||||
{!ready && !sending && (
|
{!ready && !sending && (
|
||||||
<p className="text-sm" style={{ color: MUTED }}>
|
<p className="text-sm" style={{ color: MUTED }}>
|
||||||
Choose what it's about, give it a name, write at least {MIN_MESSAGE} characters and give an email address to send.
|
Choose what it's about, give it a name, write at least a sentence and give an email address to send.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue