Skip to content

Commit cf963d3

Browse files
committed
ingestion page works now. fixing points table
1 parent c8428b7 commit cf963d3

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ RUN apt-get remove -y rsync
3636

3737
COPY . ./
3838

39-
ENV NODE_ENV=production
40-
4139
RUN yarn run build
4240

4341
EXPOSE 3000

pages/maps/ingestion/+Page.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,23 @@ import { ContentPage } from "~/layouts";
1111
import Tag from "./components/Tag";
1212

1313
const h = hyper.styled(styles);
14-
14+
type MapSource = {
15+
source_id: number;
16+
name: string | null;
17+
};
18+
interface IngestProcess {
19+
id: number;
20+
source_id: number | null;
21+
slug: string;
22+
name: string;
23+
scale: string | null;
24+
raster_url: string | null;
25+
tags?: string[] | { tag: string }[];
26+
state?: string;
27+
}
1528
export function Page() {
1629
const { user } = useAuth();
17-
30+
const [mapSources, setMapSources] = useState<Record<number, MapSource>>({});
1831
const [ingestProcess, setIngestProcess] = useState<IngestProcess[]>([]);
1932
const [ingestFilter, setIngestFilter] = useState<URLSearchParams>(undefined);
2033
const [tags, setTags] = useState<string[]>([]);
@@ -23,6 +36,15 @@ export function Page() {
2336
getTags().then((tags) => setTags(tags));
2437
}, []);
2538

39+
const getMapSources = async (): Promise<Record<number, MapSource>> => {
40+
const res = await fetch(
41+
"https://dev.macrostrat.org/api/pg/maps_sources?select=source_id,name"
42+
);
43+
const rows: MapSource[] = await res.json();
44+
45+
return Object.fromEntries(rows.map((r) => [r.source_id, r]));
46+
};
47+
2648
const updateIngestProcesses = useCallback(() => {
2749
getIngestProcesses(ingestFilter).then((ingestProcesses) => {
2850
setIngestProcess(ingestProcesses);
@@ -44,6 +66,9 @@ export function Page() {
4466
updateIngestProcesses();
4567
};
4668
}, []);
69+
useEffect(() => {
70+
getMapSources().then(setMapSources);
71+
}, []);
4772

4873
// Re-fetch data when the filter changes
4974
react.useEffect(() => {
@@ -72,9 +97,13 @@ export function Page() {
7297
h(
7398
"div.ingestion-body",
7499
ingestProcess.map((d) => {
100+
const name =
101+
d.source_id != null ? mapSources[d.source_id]?.name : undefined;
102+
75103
return h(IngestProcessCard, {
76104
key: d.id,
77105
ingestProcess: d,
106+
refTitle: name,
78107
user: user,
79108
onUpdate: () => {
80109
updateTags();

pages/maps/ingestion/@id/_data.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { apiV2Prefix, ingestPrefix } from "@macrostrat-web/settings";
1+
import { apiV2Prefix, postgrestPrefix } from "@macrostrat-web/settings";
22

33
const apiAddress = apiV2Prefix + "/defs/sources/";
44

@@ -23,11 +23,16 @@ export async function getIngestProcessData(
2323

2424
// API v3 query
2525
const ingest_processes_response = await fetch(
26-
`${ingestPrefix}/ingest-process?source_id=eq.${source_id}`
26+
`${postgrestPrefix}/map_ingest?source_id=eq.${source_id}`
2727
);
2828
const ingestProcesses = await ingest_processes_response.json();
2929
const ingestProcess = ingestProcesses[0];
30-
const source = ingestProcess["source"];
30+
31+
const source_response = await fetch(
32+
`${postgrestPrefix}/maps_sources?source_id=eq.${source_id}&select=*`
33+
);
34+
const sources = await source_response.json();
35+
const source = sources[0];
3136

3237
return {
3338
source,

pages/maps/ingestion/components/ingest-process-card.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ interface IngestProcess {
2222

2323
export function IngestProcessCard({
2424
ingestProcess,
25+
refTitle,
2526
user,
2627
onUpdate,
2728
}: {
2829
ingestProcess: IngestProcess;
30+
refTitle?: string | null;
2931
user: any | undefined;
3032
onUpdate: () => void;
3133
}) {
32-
const { slug, name, source_id, scale, raster_url } = ingestProcess;
34+
const { slug, source_id, scale, raster_url } = ingestProcess;
3335
const edit_href = `/maps/ingestion/${source_id}`;
3436

3537
return h(
@@ -39,7 +41,7 @@ export function IngestProcessCard({
3941
},
4042
[
4143
h("div.flex.row", [
42-
h("h3.map-card-title", name),
44+
h("h3.map-card-title", refTitle),
4345
h("div.spacer"),
4446
h.if(user !== undefined)(AnchorButton, {
4547
href: edit_href,

0 commit comments

Comments
 (0)