Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,51 @@ app.use("/verify-email", async function (req, res, next) {
}
});

// Multiple fragments GeoJSON (must be before /fragments/:hash/geojson)
app.get("/fragments/geojson", async function (req: SSNRequest, res) {
if (!req.user?.id) {
return res.status(401).json({ error: "Authentication required" });
}
const hashesParam = req.query.hashes;
const hashes =
typeof hashesParam === "string"
? hashesParam.split(",").map((h) => h.trim()).filter(Boolean)
: Array.isArray(hashesParam)
? (hashesParam as string[]).map((h) => String(h).trim()).filter(Boolean)
: [];
if (hashes.length === 0) {
return res.status(400).json({ error: "At least one fragment hash is required (hashes=hash1,hash2,...)" });
}
const client = await loadersPool.connect();
try {
const { rows } = await client.query(
`SELECT hash, ST_AsGeoJSON(geometry)::json as geometry FROM fragments WHERE hash = ANY($1::text[])`,
[hashes],
);
const features = rows.map(
(row: { hash: string; geometry: unknown }) => ({
type: "Feature" as const,
properties: { hash: row.hash },
geometry: row.geometry,
}),
);
const geojson = {
type: "FeatureCollection" as const,
features,
};
res.setHeader("Content-Type", "application/json");
res.setHeader(
"Content-Disposition",
`attachment; filename=fragments.geojson.json`,
);
res.send(JSON.stringify(geojson));
} catch (e: any) {
res.status(500).json({ error: e.message });
} finally {
client.release();
}
});

app.get("/fragments/:hash/geojson", async function (req: SSNRequest, res) {
if (!req.user?.id) {
return res.status(401).json({ error: "Authentication required" });
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/sketches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ export async function updateSketchFragments(
pgClient: PoolClient,
deletionScope?: string[],
): Promise<void> {
if (fragments.length > 80) {
throw new Error("Too many fragments to update. Maximum is 80.");
}
const fragmentInputs = fragments
.map((f) => {
const geomJson = JSON.stringify(f.geometry);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/client/src/admin/users/ProfilePhoto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import clsx from "clsx";
// const supportsSrcSet = "srcset" in document.createElement("img");

export default function ProfilePhoto({
className,
fullname,
email,
canonicalEmail,
Expand All @@ -16,6 +17,7 @@ export default function ProfilePhoto({
border,
square,
}: {
className?: string;
fullname?: string | Maybe<string>;
email?: string | Maybe<string>;
canonicalEmail: string;
Expand All @@ -40,6 +42,7 @@ export default function ProfilePhoto({
}
className={clsx(
`w-full h-full inline-block`,
className,
square ? "rounded-sm" : "rounded-full",
border ? "border-2 shadow bg-white border-white" : ""
)}
Expand Down
16 changes: 16 additions & 0 deletions packages/client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -8853,6 +8853,10 @@ select{
overflow-wrap:break-word
}

.break-all{
word-break:break-all
}

.rounded{
border-radius:0.25rem
}
Expand Down Expand Up @@ -9376,6 +9380,10 @@ select{
border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))
}

.border-white\/20{
border-color:rgb(255 255 255 / 0.2)
}

.border-b-black{
--tw-border-opacity:1;
border-bottom-color:rgb(0 0 0 / var(--tw-border-opacity, 1))
Expand Down Expand Up @@ -11795,6 +11803,14 @@ select{
color:rgb(255 255 255 / 0.8)
}

.text-white\/70{
color:rgb(255 255 255 / 0.7)
}

.text-white\/50{
color:rgb(255 255 255 / 0.5)
}

.text-opacity-50{
--tw-text-opacity:0.5
}
Expand Down
Loading
Loading