Skip to content

Commit f27a2bd

Browse files
authored
Merge pull request #381 from UW-Macrostrat/lex
Lex fix
2 parents 5a076eb + a45afbd commit f27a2bd

File tree

14 files changed

+531
-54
lines changed

14 files changed

+531
-54
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import h from "@macrostrat/hyper";
2+
3+
import {
4+
MapAreaContainer,
5+
MapView,
6+
buildInspectorStyle
7+
} from "@macrostrat/map-interface";
8+
import { mapboxAccessToken } from "@macrostrat-web/settings";
9+
import { useEffect, useState } from "react";
10+
import { useDarkMode, FlexRow } from "@macrostrat/ui-components";
11+
import { FullscreenPage } from "~/layouts";
12+
import { MultiSelect } from "@blueprintjs/select"
13+
import { MenuItem, Switch, Divider, Icon } from "@blueprintjs/core";
14+
import { tileserverDomain } from "@macrostrat-web/settings";
15+
import { fetchAPIData, fetchPGData } from "~/_utils";
16+
import { Measurement } from "./measurement";
17+
import { usePageContext } from "vike-react/usePageContext";
18+
import { Loading } from "~/components";
19+
import { buildMacrostratStyle } from "@macrostrat/map-styles";
20+
21+
export function Page() {
22+
return h(FullscreenPage, h(Map))
23+
}
24+
25+
function Map() {
26+
27+
28+
29+
const style = buildMacrostratStyle({
30+
tileserverDomain,
31+
fillOpacity: 0.3,
32+
strokeOpacity: 0.1,
33+
}) as mapboxgl.Style;
34+
35+
if(style == null) return null;
36+
37+
const mapPosition = {
38+
camera: {
39+
lat: 39,
40+
lng: -98,
41+
altitude: 6000000,
42+
},
43+
};
44+
45+
46+
return h(
47+
"div.map-container",
48+
[
49+
// The Map Area Container
50+
h(
51+
MapAreaContainer,
52+
{
53+
className: 'map-area-container',
54+
},
55+
[
56+
h(MapView, {
57+
style,
58+
mapboxToken: mapboxAccessToken,
59+
mapPosition,
60+
}),
61+
]
62+
),
63+
]
64+
);
65+
}

pages/integrations/xdd/feedback/@sourceTextID/+Page.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function FeedbackInterface({ data, models, entityTypes, autoSelect, customFeedba
194194
concept: "/lex/strat-concepts",
195195
},
196196
lineHeight: 3,
197-
// view: user === null,
197+
// view: user === null, TODO: Enable view mode for non-logged in users
198198
autoSelect,
199199
onSave: wrapWithToaster(
200200
async (tree) => {

pages/lex/legends/+Page.client.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import h from "./main.module.sass";
2+
import { StickyHeader, LinkCard, PageBreadcrumbs, Footer, BetaTag } from "~/components";
3+
import { ContentPage } from "~/layouts";
4+
import { usePageContext } from "vike-react/usePageContext";
5+
import { PostgRESTInfiniteScrollView } from "@macrostrat/ui-components";
6+
import { postgrestPrefix, apiDomain } from "@macrostrat-web/settings";
7+
import { LithologyTag, FlexRow, ExpansionPanel } from "~/components/lex/tag";
8+
9+
export function Page() {
10+
const url = usePageContext().urlOriginal.split("?")[1];
11+
12+
if (!url) {
13+
return h(Base);
14+
}
15+
16+
const params = getUrlParams(url);
17+
const idType = params.idType;
18+
const id = params[idType];
19+
const color = params.color;
20+
const name = params.name;
21+
22+
23+
return h(ContentPage, [
24+
h(Header, { name, color, idType, id }),
25+
h(FilterData),
26+
]);
27+
}
28+
29+
function Header({ name, color, idType, id }) {
30+
const map = {
31+
'int_id': "intervals",
32+
'lith_id': "lithologies",
33+
'econ_id': "economics",
34+
'environ_id': "environments",
35+
'strat_name_id': "strat-names",
36+
}
37+
38+
return h(StickyHeader, { className: "header" }, [
39+
h(PageBreadcrumbs, {
40+
title: h(FlexRow, { gap: ".5em", alignItems: "center" }, [
41+
h('p.title', 'Legends for '),
42+
h(LithologyTag, { data: { name, color }, href: `/lex/${map[idType]}/${id}` }),
43+
]),
44+
}),
45+
h(BetaTag)
46+
]);
47+
}
48+
49+
function getUrlParams(urlString) {
50+
const params = new URLSearchParams(urlString);
51+
const result = {};
52+
53+
for (const [key, value] of params.entries()) {
54+
result[key] = value;
55+
56+
if (key.toLowerCase().includes('id')) {
57+
result.idType = key;
58+
}
59+
}
60+
61+
return result;
62+
}
63+
64+
function Base() {
65+
return h(ContentPage, { className: 'page' }, [
66+
h(StickyHeader, { className: "header" }, h(PageBreadcrumbs, { title: "Legends" })),
67+
h(PostgRESTInfiniteScrollView, {
68+
route: postgrestPrefix + '/legend_liths',
69+
id_key: 'legend_id',
70+
limit: 20,
71+
itemComponent: LegendItem,
72+
filterable: true,
73+
searchColumns: [{value: "map_unit_name", label: "Map unit name"}],
74+
}),
75+
]);
76+
}
77+
78+
function BaseUnitItem({ data }) {
79+
const { id, col_id, strat_name } = data;
80+
81+
return h(LinkCard, {
82+
href: `/columns/${col_id}#unit=${id}`,
83+
title: strat_name,
84+
})
85+
}
86+
87+
function FilterData() {
88+
const params = usePageContext().urlParsed.href.split("?")[1].split("=")
89+
const id = params[1].split("&")[0]
90+
91+
return h(PostgRESTInfiniteScrollView, {
92+
route: postgrestPrefix + `/legend_liths`,
93+
id_key: "legend_id",
94+
limit: 20,
95+
extraParams: {
96+
lith_ids: `cs.{${id}}`,
97+
},
98+
filterable: true,
99+
searchColumns: [{value: "map_unit_name", label: "Map unit name"}],
100+
itemComponent: LegendItem,
101+
});
102+
}
103+
104+
function LegendItem({ data }) {
105+
const { map_unit_name, legend_id, source_id } = data;
106+
107+
return h(LinkCard, {
108+
href: `/maps/${source_id}?legend_id=${legend_id}`,
109+
title: h("div.title", map_unit_name),
110+
});
111+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import h from "@macrostrat/hyper";
2+
import { usePageContext } from "vike-react/usePageContext";
3+
import { fetchAPIData } from "~/_utils";
4+
import { navigate } from "vike/client/router";
5+
6+
export function Page() {
7+
const unit_id = usePageContext()?.urlPathname.split("/")?.[3] || [];
8+
9+
fetchAPIData("/units", { unit_id })
10+
.then(data => navigate(`/columns/${data[0].col_id}#unit=${unit_id}`))
11+
12+
return null
13+
}

pages/lex/legends/main.module.sass

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.title
2+
margin: .5em 0
3+
4+
.page
5+
display: flex
6+
flex-direction: column
7+
gap: 1em
8+
9+
.header
10+
display: flex
11+
justify-content: space-between
12+
13+
.units
14+
margin: 1em 0
15+
16+
.unit-title
17+
display: flex
18+
justify-content: space-between
19+
align-items: center
20+
21+
.count
22+
margin: 0
23+
font-size: 15px

pages/lex/lithologies/@id/+Page.client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export function Page() {
3232
h(Charts, { features }),
3333
h(PrevalentTaxa, { taxaData }),
3434
h(Timescales, { timescales }),
35-
h(Maps, { mapsData }),
3635
h(TextExtractions, { lith_id: id, href: "autoselect=" + resData?.name + "&lith_id=" + id + "&color=" + resData?.color }),
37-
h.if(fossilsData.features.length > 0)(Fossils, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
38-
h.if(unitsData.length > 0)(Units, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
36+
h.if(unitsData?.length > 0)(Units, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
37+
h.if(mapsData?.length > 0)(Maps, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
38+
h.if(fossilsData?.features.length > 0)(Fossils, { href: "lith_id=" + id + "&color=" + resData?.color + "&name=" + resData?.name }),
3939
];
4040

4141
return LexItemPage({ children, id, refs, resData, siftLink: "lithology" });

pages/lex/lithologies/@id/+data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function data(pageContext) {
3131
}),
3232
"colData"
3333
),
34-
safeFetch(() => fetchAPIData("/geologic_units/map/legend", { lith_id }), "mapsData"),
34+
safeFetch(() => fetchAPIData("/geologic_units/map/legend", { lith_id, sample: "true" }), "mapsData"),
3535
safeFetch(() => fetchAPIData("/fossils", { lith_id, format: "geojson" }), "fossilsData"),
3636
safeFetch(() => fetchAPIRefs("/fossils", { lith_id }), "refs1"),
3737
safeFetch(() => fetchAPIRefs("/columns", { lith_id }), "refs2"),

pages/lex/strat-names/@id/+Page.client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ export function Page() {
3535
h(Charts, { features }),
3636
h(PrevalentTaxa, { taxaData }),
3737
h(Timescales, { timescales }),
38-
h.if(unitsData.length > 0)(Units, { href: "strat_name_id=" + id + "&name=" + resData?.strat_name }),
39-
h.if(fossilsData.features.length > 0)(Fossils, { href: "strat_name_id=" + id + "&name=" + resData?.name }),
40-
h(Maps, { mapsData }),
4138
h(TextExtractions, {
4239
strat_name_id: id,
4340
href: "autoselect=" + resData?.strat_name_long + "&strat_name_id=" + id,
4441
}),
42+
h.if(unitsData.length > 0)(Units, { href: "strat_name_id=" + id + "&name=" + resData?.strat_name }),
43+
// h.if(mapsData?.length > 0)(Maps, { href: "strat_name_id=" + id + "&name=" + resData?.name }), (add strat names to legends view first)
44+
h.if(fossilsData.features.length > 0)(Fossils, { href: "strat_name_id=" + id + "&name=" + resData?.name }),
4545
h(StratNameHierarchy, { id }),
4646
h(ConceptInfo, { concept_id: resData?.concept_id, showHeader: true }),
4747
];

pages/lex/strat-names/@id/+data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function data(pageContext) {
1414
format: "geojson",
1515
}),
1616
fetchAPIData("/fossils", { strat_name_id, format: "geojson" }),
17-
fetchAPIData("/geologic_units/map/legend", { strat_name_id }),
17+
fetchAPIData("/geologic_units/map/legend", { strat_name_id, sample: "true" }),
1818
fetchAPIRefs("/fossils", { strat_name_id }),
1919
fetchAPIRefs("/columns", { strat_name_id }),
2020
fetchAPIData("/units", { strat_name_id }),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ function SourceItem({ data }) {
119119
]),
120120
]
121121
);
122-
}
122+
}

0 commit comments

Comments
 (0)