co2-galvo owner testing
This commit is contained in:
parent
ffccff85d4
commit
a100fefc77
2 changed files with 94 additions and 371 deletions
|
|
@ -22,10 +22,13 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
"setting_title",
|
"setting_title",
|
||||||
"uploader",
|
"uploader",
|
||||||
|
|
||||||
// 👇 include parent + requested subfields
|
// include parent + subfields to survive restricted expansion
|
||||||
"owner",
|
"owner",
|
||||||
"owner.id",
|
"owner.id",
|
||||||
"owner.username",
|
"owner.username",
|
||||||
|
"owner.first_name",
|
||||||
|
"owner.last_name",
|
||||||
|
"owner.email",
|
||||||
|
|
||||||
"setting_notes",
|
"setting_notes",
|
||||||
"photo.filename_disk",
|
"photo.filename_disk",
|
||||||
|
|
@ -62,15 +65,19 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
fetch(url, { cache: "no-store", credentials: "include" })
|
fetch(url, { cache: "no-store", credentials: "include" })
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
const txt = await res.text();
|
||||||
|
let j: any = null;
|
||||||
|
try {
|
||||||
|
j = txt ? JSON.parse(txt) : null;
|
||||||
|
} catch {}
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const j = await res.json().catch(() => ({}));
|
throw new Error(j?.errors?.[0]?.message || j?.message || `HTTP ${res.status}`);
|
||||||
throw new Error(j?.errors?.[0]?.message || `HTTP ${res.status}`);
|
|
||||||
}
|
}
|
||||||
return res.json();
|
return j;
|
||||||
})
|
})
|
||||||
.then((json) => setSetting(json?.data ?? null))
|
.then((json) => setSetting(json?.data ?? null))
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error("co2-galvo fetch failed:", e);
|
console.error("CO2 Galvo detail fetch failed:", e);
|
||||||
setSetting(null);
|
setSetting(null);
|
||||||
})
|
})
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
|
|
@ -79,10 +86,14 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
if (loading) return <p className="p-6">Loading setting...</p>;
|
if (loading) return <p className="p-6">Loading setting...</p>;
|
||||||
if (!setting) return <p className="p-6">Setting not found.</p>;
|
if (!setting) return <p className="p-6">Setting not found.</p>;
|
||||||
|
|
||||||
// ---- display helpers ----
|
// Owner label: username → name → email → id → —
|
||||||
const ownerDisplay: string =
|
const ownerDisplay: string =
|
||||||
typeof setting?.owner === "object"
|
typeof setting?.owner === "object"
|
||||||
? (setting.owner?.username ?? setting.owner?.id ?? "—")
|
? (setting.owner?.username
|
||||||
|
|| [setting.owner?.first_name, setting.owner?.last_name].filter(Boolean).join(" ").trim()
|
||||||
|
|| setting.owner?.email
|
||||||
|
|| setting.owner?.id
|
||||||
|
|| "—")
|
||||||
: typeof setting?.owner === "string"
|
: typeof setting?.owner === "string"
|
||||||
? setting.owner
|
? setting.owner
|
||||||
: "—";
|
: "—";
|
||||||
|
|
@ -95,45 +106,6 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
const formatBoolean = (val: any) =>
|
const formatBoolean = (val: any) =>
|
||||||
val ? "Enabled" : val === false ? "Disabled" : "—";
|
val ? "Enabled" : val === false ? "Disabled" : "—";
|
||||||
|
|
||||||
const renderRepeaterCard = (title: string, fields: any[], items: any[]) => {
|
|
||||||
const filtered = (items || []).filter((item) =>
|
|
||||||
Object.values(item).some((v) => v !== null && v !== "")
|
|
||||||
);
|
|
||||||
if (filtered.length === 0) return null;
|
|
||||||
return (
|
|
||||||
<div className="mt-6">
|
|
||||||
<h2 className="text-2xl font-semibold mb-2">{title}</h2>
|
|
||||||
<div className="grid gap-4 grid-cols-1 md:grid-cols-2">
|
|
||||||
{filtered.map((item, i) => (
|
|
||||||
<div key={i} className="border border-border rounded-lg p-4 bg-card">
|
|
||||||
{fields.map(({ key, label, condition }: any) => {
|
|
||||||
const value = item[key];
|
|
||||||
if (condition && !condition(item)) return null;
|
|
||||||
return (
|
|
||||||
<p key={key} className="text-sm">
|
|
||||||
<strong>{label}:</strong>{" "}
|
|
||||||
{typeof value === "boolean" ? formatBoolean(value) : value ?? "—"}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const openSearchInNewTab = (value: string) => {
|
|
||||||
if (!value || typeof window === "undefined") return;
|
|
||||||
const url = new URL("/settings/co2-galvo", window.location.origin);
|
|
||||||
url.searchParams.set("query", value);
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.href = url.toString();
|
|
||||||
a.target = "_blank";
|
|
||||||
a.rel = "noopener noreferrer";
|
|
||||||
a.click();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onClaim = async () => {
|
const onClaim = async () => {
|
||||||
setClaimBusy(true);
|
setClaimBusy(true);
|
||||||
setClaimErr(null);
|
setClaimErr(null);
|
||||||
|
|
@ -142,21 +114,17 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
const r = await fetch("/api/claims", {
|
const r = await fetch("/api/claims", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
|
credentials: "include",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
target_collection: "settings_co2gal",
|
target_collection: "settings_co2gal",
|
||||||
target_id: id,
|
target_id: setting.submission_id,
|
||||||
}),
|
}),
|
||||||
cache: "no-store",
|
|
||||||
});
|
});
|
||||||
const data = await r.json().catch(() => ({}));
|
const j = await r.json().catch(() => ({}));
|
||||||
if (!r.ok) {
|
if (!r.ok) throw new Error(j?.error || j?.message || `HTTP ${r.status}`);
|
||||||
throw new Error(
|
setClaimMsg("Claim request submitted. We'll update the owner shortly.");
|
||||||
data?.error || data?.errors?.[0]?.message || "Failed to submit claim"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setClaimMsg("Claim request submitted for review.");
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setClaimErr(e?.message || "Failed to submit claim");
|
setClaimErr(e?.message || "Failed to submit claim.");
|
||||||
} finally {
|
} finally {
|
||||||
setClaimBusy(false);
|
setClaimBusy(false);
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +143,6 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
{JSON.stringify({ owner: setting?.owner }, null, 2)}
|
{JSON.stringify({ owner: setting?.owner }, null, 2)}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
<div className="space-y-1 text-sm text-muted-foreground mb-3">
|
<div className="space-y-1 text-sm text-muted-foreground mb-3">
|
||||||
<p><strong>Owner:</strong> <span>{ownerDisplay}</span></p>
|
<p><strong>Owner:</strong> <span>{ownerDisplay}</span></p>
|
||||||
<p><strong>Uploader:</strong> {setting.uploader || "—"}</p>
|
<p><strong>Uploader:</strong> {setting.uploader || "—"}</p>
|
||||||
|
|
@ -190,205 +157,16 @@ export default function CO2GalvoSettingDetailPage() {
|
||||||
>
|
>
|
||||||
{claimBusy ? "Submitting…" : "Claim this setting"}
|
{claimBusy ? "Submitting…" : "Claim this setting"}
|
||||||
</button>
|
</button>
|
||||||
{claimMsg && <span className="text-green-500 text-sm">{claimMsg}</span>}
|
{claimErr && <span className="text-red-600 text-sm">{claimErr}</span>}
|
||||||
{claimErr && <span className="text-red-500 text-sm">{claimErr}</span>}
|
{claimMsg && <span className="text-green-600 text-sm">{claimMsg}</span>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a
|
|
||||||
href="/settings/co2-galvo"
|
|
||||||
className="inline-block mt-2 px-4 py-2 bg-accent text-background rounded-md text-sm self-start"
|
|
||||||
>
|
|
||||||
← Back to CO₂ Galvo Settings
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Result Photo + Material */}
|
{/* ... rest of your panels ... */}
|
||||||
<div className="card bg-card p-4 grid grid-cols-1 md:grid-cols-2 gap-4 items-start">
|
|
||||||
<div className="flex justify-center">
|
|
||||||
{setting.photo?.filename_disk && (
|
|
||||||
<a
|
|
||||||
href={`https://forms.lasereverything.net/assets/${setting.photo.filename_disk}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
src={`https://forms.lasereverything.net/assets/${setting.photo.filename_disk}`}
|
|
||||||
alt={setting.photo?.title || "Laser preview"}
|
|
||||||
width={250}
|
|
||||||
height={250}
|
|
||||||
className="rounded object-contain max-w-[250px] max-h-[250px]"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
{/* ... rest of the component ... */}
|
||||||
<div>
|
|
||||||
<h2 className="text-xl font-semibold mb-2">Material</h2>
|
|
||||||
<p>
|
|
||||||
<strong>Material:</strong>{" "}
|
|
||||||
<span
|
|
||||||
className="cursor-pointer underline hover:text-accent"
|
|
||||||
onClick={() => openSearchInNewTab(setting.mat?.name)}
|
|
||||||
>
|
|
||||||
{setting.mat?.name || "—"}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>Coating:</strong>{" "}
|
|
||||||
<span
|
|
||||||
className="cursor-pointer underline hover:text-accent"
|
|
||||||
onClick={() => openSearchInNewTab(setting.mat_coat?.name)}
|
|
||||||
>
|
|
||||||
{setting.mat_coat?.name || "—"}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p><strong>Color:</strong> {setting.mat_color?.name || "—"}</p>
|
|
||||||
<p><strong>Opacity:</strong> {setting.mat_opacity?.opacity || "—"}</p>
|
|
||||||
<p>
|
|
||||||
<strong>Thickness:</strong>{" "}
|
|
||||||
{setting.mat_thickness ? `${setting.mat_thickness} mm` : "Not Applicable"}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Setup */}
|
|
||||||
<div className="card bg-card p-4">
|
|
||||||
<h2 className="text-xl font-semibold mb-2">Setup</h2>
|
|
||||||
<p><strong>Software:</strong> {softwareLabel}</p>
|
|
||||||
<p><strong>Repeat All (global):</strong> {setting.repeat_all ?? "—"}</p>
|
|
||||||
<p className="mt-4"><strong>Focus:</strong> {setting.focus ?? "—"} mm</p>
|
|
||||||
<small>-Values Focus Closer | +Values Focus Further</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Laser */}
|
|
||||||
<div className="card bg-card p-4">
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 items-start">
|
|
||||||
<div className="flex justify-center">
|
|
||||||
{setting.screen?.filename_disk ? (
|
|
||||||
<a
|
|
||||||
href={`https://forms.lasereverything.net/assets/${setting.screen.filename_disk}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
title={setting.screen?.title || "Screenshot"}
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
src={`https://forms.lasereverything.net/assets/${setting.screen.filename_disk}`}
|
|
||||||
alt={setting.screen?.title || "Screenshot"}
|
|
||||||
width={250}
|
|
||||||
height={250}
|
|
||||||
className="rounded object-contain max-w-[250px] max-h-[250px]"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
) : (
|
|
||||||
<div className="text-sm text-muted-foreground">No screenshot</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2 className="text-xl font-semibold mb-2">Laser</h2>
|
|
||||||
<p><strong>Source Make:</strong> {setting.source?.make || "—"}</p>
|
|
||||||
<p>
|
|
||||||
<strong>Source Model:</strong>{" "}
|
|
||||||
<span
|
|
||||||
className="cursor-pointer underline hover:text-accent"
|
|
||||||
onClick={() => openSearchInNewTab(setting.source?.model)}
|
|
||||||
>
|
|
||||||
{setting.source?.model || "—"}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>Lens:</strong>{" "}
|
|
||||||
<span
|
|
||||||
className="cursor-pointer underline hover:text-accent"
|
|
||||||
onClick={() => openSearchInNewTab(setting.lens?.field_size)}
|
|
||||||
>
|
|
||||||
{setting.lens?.field_size || "—"}
|
|
||||||
</span>{" "}
|
|
||||||
mm | {setting.lens?.focal_length || "—"}
|
|
||||||
</p>
|
|
||||||
<p><strong>Lens Config:</strong> {setting.lens_conf?.name || "—"}</p>
|
|
||||||
<p><strong>Aperture Type:</strong> {setting.lens_apt?.name || "—"}</p>
|
|
||||||
<p><strong>Expansion Type:</strong> {setting.lens_exp?.name || "—"}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Notes */}
|
|
||||||
{setting.setting_notes && (
|
|
||||||
<div className="prose dark:prose-invert mt-6">
|
|
||||||
<h2>Notes</h2>
|
|
||||||
<Markdown>{setting.setting_notes}</Markdown>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<hr className="my-6 border-muted" />
|
|
||||||
|
|
||||||
{/* Repeaters */}
|
|
||||||
{renderRepeaterCard(
|
|
||||||
"Fill Settings",
|
|
||||||
[
|
|
||||||
{ key: "fill_name", label: "Fill Name" },
|
|
||||||
{ key: "power", label: "Power (%)" },
|
|
||||||
{ key: "speed", label: "Speed (mm/s)" },
|
|
||||||
{ key: "frequency", label: "Frequency (kHz)" },
|
|
||||||
{ key: "pulse", label: "Pulse Width (ns)" },
|
|
||||||
{ key: "interval", label: "Interval (mm)" },
|
|
||||||
{ key: "pass", label: "Passes" },
|
|
||||||
{ key: "type", label: "Type" },
|
|
||||||
{ key: "angle", label: "Angle (°)" },
|
|
||||||
{ key: "auto", label: "Auto-Rotate" },
|
|
||||||
{ key: "increment", label: "Increment (°)", condition: (e: any) => e.auto },
|
|
||||||
{ key: "cross", label: "Crosshatch" },
|
|
||||||
{ key: "flood", label: "Flood Fill" },
|
|
||||||
{ key: "air", label: "Air Assist" },
|
|
||||||
],
|
|
||||||
setting.fill_settings
|
|
||||||
)}
|
|
||||||
|
|
||||||
{renderRepeaterCard(
|
|
||||||
"Line Settings",
|
|
||||||
[
|
|
||||||
{ key: "name", label: "Line Name" },
|
|
||||||
{ key: "power", label: "Power (%)" },
|
|
||||||
{ key: "speed", label: "Speed (mm/s)" },
|
|
||||||
{ key: "frequency", label: "Frequency (kHz)" },
|
|
||||||
{ key: "pulse", label: "Pulse Width (ns)" },
|
|
||||||
{ key: "perf", label: "Perforation Mode" },
|
|
||||||
{ key: "cut", label: "Cut (mm)", condition: (e: any) => e.perf },
|
|
||||||
{ key: "skip", label: "Skip (mm)", condition: (e: any) => e.perf },
|
|
||||||
{ key: "wobble", label: "Wobble Mode" },
|
|
||||||
{ key: "step", label: "Step (mm)", condition: (e: any) => e.wobble },
|
|
||||||
{ key: "size", label: "Size (mm)", condition: (e: any) => e.wobble },
|
|
||||||
{ key: "pass", label: "Passes" },
|
|
||||||
{ key: "air", label: "Air Assist" },
|
|
||||||
],
|
|
||||||
setting.line_settings
|
|
||||||
)}
|
|
||||||
|
|
||||||
{renderRepeaterCard(
|
|
||||||
"Raster Settings",
|
|
||||||
[
|
|
||||||
{ key: "name", label: "Raster Name" },
|
|
||||||
{ key: "power", label: "Power (%)" },
|
|
||||||
{ key: "speed", label: "Speed (mm/s)" },
|
|
||||||
{ key: "frequency", label: "Frequency (kHz)" },
|
|
||||||
{ key: "pulse", label: "Pulse Width (ns)" },
|
|
||||||
{ key: "type", label: "Type" },
|
|
||||||
{ key: "dither", label: "Dither" },
|
|
||||||
{ key: "halftone_cell", label: "Cell Size (mm)", condition: (e: any) => e.dither === "halftone" },
|
|
||||||
{ key: "halftone_angle", label: "Halftone Angle", condition: (e: any) => e.dither === "halftone" },
|
|
||||||
{ key: "inversion", label: "Image Inverted" },
|
|
||||||
{ key: "interval", label: "Interval (mm)" },
|
|
||||||
{ key: "dot", label: "Dot-width Adjustment (mm)" },
|
|
||||||
{ key: "pass", label: "Passes" },
|
|
||||||
{ key: "cross", label: "Crosshatch" },
|
|
||||||
{ key: "air", label: "Air Assist" },
|
|
||||||
],
|
|
||||||
setting.raster_settings
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,20 @@ export default function CO2GalvoSettingsPage() {
|
||||||
}, [query]);
|
}, [query]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// ✅ use the auth proxy + include cookie so expansions (owner.*) work
|
// Use the auth proxy and request BOTH the parent field and subfields.
|
||||||
|
// This guarantees you get a raw id when expansion is restricted.
|
||||||
const fields = [
|
const fields = [
|
||||||
"submission_id",
|
"submission_id",
|
||||||
"setting_title",
|
"setting_title",
|
||||||
"uploader",
|
"uploader",
|
||||||
|
// owner (m2o -> directus_users)
|
||||||
|
"owner",
|
||||||
"owner.id",
|
"owner.id",
|
||||||
"owner.username",
|
"owner.username",
|
||||||
|
"owner.first_name",
|
||||||
|
"owner.last_name",
|
||||||
|
"owner.email",
|
||||||
|
// assets / denorms
|
||||||
"photo.id",
|
"photo.id",
|
||||||
"photo.title",
|
"photo.title",
|
||||||
"mat.name",
|
"mat.name",
|
||||||
|
|
@ -66,9 +73,17 @@ export default function CO2GalvoSettingsPage() {
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// robust owner label
|
// Robust owner label: object → username | name | email | id; primitive → id; missing → —
|
||||||
const ownerLabel = (o?: Owner) =>
|
const ownerLabel = (o?: any) => {
|
||||||
(o && (o.username || String(o.id || ""))) || "—";
|
if (!o) return "—";
|
||||||
|
if (typeof o === "string" || typeof o === "number") return String(o);
|
||||||
|
return (
|
||||||
|
o.username ||
|
||||||
|
[o.first_name, o.last_name].filter(Boolean).join(" ").trim() ||
|
||||||
|
o.email ||
|
||||||
|
String(o.id || "—")
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const highlight = (text?: string) => {
|
const highlight = (text?: string) => {
|
||||||
if (!debouncedQuery) return text || "";
|
if (!debouncedQuery) return text || "";
|
||||||
|
|
@ -101,143 +116,79 @@ export default function CO2GalvoSettingsPage() {
|
||||||
|
|
||||||
const lensCounts = settings.reduce((acc: Record<string, number>, cur) => {
|
const lensCounts = settings.reduce((acc: Record<string, number>, cur) => {
|
||||||
const v = cur.lens?.field_size;
|
const v = cur.lens?.field_size;
|
||||||
if (!v) return acc;
|
if (v) acc[v] = (acc[v] || 0) + 1;
|
||||||
acc[v] = (acc[v] || 0) + 1;
|
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const mostCommonLens =
|
|
||||||
Object.entries(lensCounts).sort(
|
|
||||||
(a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0)
|
|
||||||
)[0]?.[0] || "—";
|
|
||||||
|
|
||||||
const srcCounts = settings.reduce((acc: Record<string, number>, cur) => {
|
|
||||||
const v = cur.source?.model;
|
|
||||||
if (!v) return acc;
|
|
||||||
acc[v] = (acc[v] || 0) + 1;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
const mostCommonSource =
|
|
||||||
Object.entries(srcCounts).sort(
|
|
||||||
(a, b) => (Number(b[1]) || 0) - (Number(a[1]) || 0)
|
|
||||||
)[0]?.[0] || "—";
|
|
||||||
|
|
||||||
const recent = [...settings]
|
|
||||||
.sort((a, b) => Number(b.submission_id) - Number(a.submission_id))
|
|
||||||
.slice(0, 5);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 max-w-7xl mx-auto">
|
<div className="container mx-auto p-4">
|
||||||
<style jsx global>{`
|
<div className="mb-6">
|
||||||
mark {
|
<h1 className="text-2xl font-bold">CO₂ Galvo Settings</h1>
|
||||||
background: #ffde59;
|
<p className="text-sm text-muted-foreground">
|
||||||
color: #242424;
|
Browse community CO₂ galvo settings. Use search to narrow results.
|
||||||
padding: 0 2px;
|
</p>
|
||||||
border-radius: 2px;
|
</div>
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
{/* Header / Search */}
|
{/* search box */}
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 mb-6">
|
<div className="mb-4">
|
||||||
<div className="card bg-card text-card-foreground p-4">
|
<input
|
||||||
<h1 className="text-2xl font-bold mb-2">CO₂ Galvo Settings</h1>
|
value={query}
|
||||||
<input
|
onChange={(e) => setQuery(e.currentTarget.value)}
|
||||||
type="search"
|
placeholder="Search by title, owner, material, model…"
|
||||||
value={query}
|
className="w-full max-w-lg border rounded px-3 py-2"
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
/>
|
||||||
placeholder="Search by material, owner, uploader, model, lens…"
|
</div>
|
||||||
className="w-full mb-4 dark:bg-background border border-border rounded-md p-2"
|
|
||||||
/>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
View and explore detailed CO₂ galvo settings with context.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* How to use */}
|
{/* stats */}
|
||||||
<div className="card bg-card text-card-foreground p-4">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
||||||
<h2 className="text-lg font-semibold mb-2">How to Use</h2>
|
<div className="card bg-card text-card-foreground p-4">
|
||||||
<p className="text-sm">
|
<h2 className="text-lg font-semibold mb-2">How to Use</h2>
|
||||||
Browse community CO₂ galvo settings. Use search to narrow results.
|
<p className="text-sm">
|
||||||
Click a row to view full configuration, notes, and photos.
|
Click a row to view full configuration, notes, and photos.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="card bg-card text-card-foreground p-4">
|
||||||
{/* Stats */}
|
<h2 className="text-lg font-semibold mb-2">Stats Summary</h2>
|
||||||
<div className="card bg-card text-card-foreground p-4">
|
<ul className="text-sm space-y-1">
|
||||||
<h2 className="text-lg font-semibold mb-2">Stats Summary</h2>
|
<li>Total Settings: {total}</li>
|
||||||
<ul className="text-sm space-y-1">
|
<li>Unique Materials: {uniqueMaterials}</li>
|
||||||
<li>Total Settings: {total}</li>
|
<li>
|
||||||
<li>Unique Materials: {uniqueMaterials}</li>
|
Lens Fields:{" "}
|
||||||
<li>Most Common Lens: {mostCommonLens}</li>
|
{Object.entries(lensCounts)
|
||||||
<li>Most Used Source: {mostCommonSource}</li>
|
.map(([k, v]) => `${k} (${v})`)
|
||||||
</ul>
|
.join(", ") || "—"}
|
||||||
</div>
|
</li>
|
||||||
|
|
||||||
{/* Recently Added */}
|
|
||||||
<div className="card bg-card text-card-foreground p-4 xl:col-span-3">
|
|
||||||
<h2 className="text-lg font-semibold mb-2">Recently Added</h2>
|
|
||||||
<ul className="text-sm space-y-1">
|
|
||||||
{recent.map((s) => (
|
|
||||||
<li key={s.submission_id}>
|
|
||||||
<Link
|
|
||||||
href={detailHref(s.submission_id)}
|
|
||||||
className="underline text-accent"
|
|
||||||
>
|
|
||||||
{s.setting_title || "Untitled"}
|
|
||||||
</Link>{" "}
|
|
||||||
<span className="text-muted-foreground">
|
|
||||||
by {ownerLabel(s.owner)}
|
|
||||||
{s.uploader ? ` (uploader: ${s.uploader})` : ""}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Table */}
|
{/* table */}
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<p className="text-muted">Loading settings...</p>
|
<p>Loading…</p>
|
||||||
) : filtered.length === 0 ? (
|
|
||||||
<p className="text-muted">No CO₂ galvo settings found.</p>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="w-full text-sm">
|
<table className="min-w-full text-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr className="bg-muted">
|
||||||
<th className="px-2 py-2 text-left">Photo</th>
|
|
||||||
<th className="px-2 py-2 text-left">Title</th>
|
<th className="px-2 py-2 text-left">Title</th>
|
||||||
<th className="px-2 py-2 text-left">Owner</th>
|
<th className="px-2 py-2 text-left">Owner</th>
|
||||||
<th className="px-2 py-2 text-left">Uploader</th>
|
|
||||||
<th className="px-2 py-2 text-left">Material</th>
|
<th className="px-2 py-2 text-left">Material</th>
|
||||||
<th className="px-2 py-2 text-left">Coating</th>
|
<th className="px-2 py-2 text-left">Coating</th>
|
||||||
<th className="px-2 py-2 text-left">Source</th>
|
<th className="px-2 py-2 text-left">Model</th>
|
||||||
<th className="px-2 py-2 text-left">Lens</th>
|
<th className="px-2 py-2 text-left">Field</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{filtered.map((s) => (
|
{filtered.map((s) => (
|
||||||
<tr key={s.submission_id} className="border-t border-border">
|
<tr key={s.submission_id} className="border-b hover:bg-muted/30">
|
||||||
<td className="px-2 py-2">
|
|
||||||
{s.photo?.id ? (
|
|
||||||
<Image
|
|
||||||
src={`https://forms.lasereverything.net/assets/${s.photo.id}`}
|
|
||||||
alt={s.photo.title || "laser preview"}
|
|
||||||
width={64}
|
|
||||||
height={64}
|
|
||||||
className="rounded-md"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
"—"
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td className="px-2 py-2 whitespace-nowrap">
|
<td className="px-2 py-2 whitespace-nowrap">
|
||||||
<Link
|
<Link href={detailHref(s.submission_id)} className="underline">
|
||||||
href={detailHref(s.submission_id)}
|
<span
|
||||||
className="text-accent underline"
|
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: highlight(s.setting_title || "—"),
|
__html: highlight(s.setting_title || "Untitled"),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td
|
||||||
className="px-2 py-2 whitespace-nowrap"
|
className="px-2 py-2 whitespace-nowrap"
|
||||||
|
|
@ -247,12 +198,6 @@ export default function CO2GalvoSettingsPage() {
|
||||||
/>
|
/>
|
||||||
<td
|
<td
|
||||||
className="px-2 py-2 whitespace-nowrap"
|
className="px-2 py-2 whitespace-nowrap"
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: highlight(s.uploader || "—"),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<td
|
|
||||||
className="px-2 py-2 whitespace-nowrap"
|
|
||||||
dangerouslySetInnerHTML={{
|
dangerouslySetInnerHTML={{
|
||||||
__html: highlight(s.mat?.name || "—"),
|
__html: highlight(s.mat?.name || "—"),
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue