Commit b35cf8be authored by Elisabeth Reuhl's avatar Elisabeth Reuhl
Browse files

Attempted to get period and region filter values by querying Chronontology and...

Attempted to get period and region filter values by querying Chronontology and Gazetteer (wip) (issues #66 and #82)
parent 847ebb95
......@@ -145,29 +145,48 @@ export const AppContent = () => {
: {variables: {searchTerm: "", idOfRegion: 0}});
const chronOntologyTerms = [
'antoninisch', 'archaisch', 'augusteisch', 'FM III', 'frühkaiserzeitlich', 'geometrisch', 'hadrianisch',
'hellenistisch', 'hochhellenistisch', 'kaiserzeitlich', 'klassisch', 'MM II', 'MM IIB', 'römisch', 'SB II',
'severisch', 'SH IIIB', 'SM I', 'SM IB', 'trajanisch',
'Altes Reich', 'Neues Reich', 'Erste Zwischenzeit', 'Holocene', 'Early Holocene', 'Middle Holocene', 'Late Holocene', 'Pleistocene'
];
const regions = [
{title: 'Africa', id: 2042601},
{title: 'Benin', id: 2353200},
{title: 'East Africa', id: 2359915},
{title: 'Egypt', id: 2042786},
{title: 'Horn of Africa', id: 2379066},
{title: 'Maghreb', id: 2042694},
{title: 'Meroe', id: 2293921},
{title: 'Nubien', id: 2042608},
{title: 'Republic of Namibia', id: 2293917},
{title: 'Senegambia', id: 2348444},
{title: 'Sudan', id: 2042707},
{title: 'Tschad', id: 2128989},
{title: 'Wadi Howar Region Sudan', id: 2042736},
{title: 'West Africa', id: 2379014}
];
//todo: the periods and regions should probably be queried via Hub and not like this
const [periods, setPeriods] = useState(["Frühnubischer Horizont"]);
//todo: error... this does not seem to be the correct URL
/*fetch("https://chronontology.dainst.org/data/period/?fq=resource.provenance:%22SPP2143%22&q=*&from=0")
.then(response => response.json())
.then((jsonData) => {
//let tempPeriods = jsonData.results.map(result => result && result.resource && {title: result.resource?.names?.de?.[0], id: result.resource?.id})
//tempPeriods.sort((a, b) => {
// let ta = a.title.toLowerCase(), tb = b.title.toLowerCase();
// if (ta < tb) return -1;
// if (ta > tb) return 1;
// return 0;
//});
let tempPeriods = jsonData.results.map(result => result && result.resource?.names?.de?.[0] || result.resource?.names?.en?.[0])//.sort();
setPeriods(tempPeriods)
})
.catch((error) => {
console.error(error)
});*/
const [regions, setRegions] = useState([]);
fetch("https://gazetteer.dainst.org/search.json?q=parent%3A2042601%20OR%20parent%3A2293101&fq=&limit=1000&type=&pretty=true")
.then(response => response.json())
.then((jsonData) => {
let tempRegions = jsonData.result.map(result => result && {title: result.prefName.title, id: result.gazId})
tempRegions.sort((a, b) => {
let ta = a.title.toLowerCase(), tb = b.title.toLowerCase();
if (ta < tb) return -1;
if (ta > tb) return 1;
return 0;
});
setRegions(tempRegions)
})
.catch((error) => {
console.error(error)
});
const arachneTypes = [ //todo: welche davon sollen angeboten werden? einige gibt es gar nicht für SPP/Afrika nehme ich an.
{"label": t("arachneTypeEinzelobjekte"), "id": "Einzelobjekte"},
......@@ -421,7 +440,7 @@ export const AppContent = () => {
<>
<PageHeader
arachneTypes={arachneTypes}
chronOntologyTerms={chronOntologyTerms}
periods={periods}
reducer={[input, dispatch]}
regions={regions}
/>
......
......@@ -10,7 +10,7 @@ import { useTranslation } from "react-i18next";
export const Filters = (props) => {
const [input, dispatch] = props.reducer;
const { chronOntologyTerms, regions, arachneTypes } = props;
const { arachneTypes, periods, regions } = props;
const { t, i18n } = useTranslation();
......@@ -127,7 +127,7 @@ export const Filters = (props) => {
<Autocomplete
name="chronOntologyTerm"
value={input.chronOntologyTerm}
options={chronOntologyTerms}
options={periods}
onChange={(event, newValue) =>
dispatch({type: "UPDATE_INPUT", payload: {field: "chronOntologyTerm", value: newValue}})
}
......
......@@ -15,7 +15,7 @@ import SearchIcon from '@material-ui/icons/Search';
export const PageHeader = (props) => {
const [input, dispatch] = props.reducer;
const {chronOntologyTerms, regions} = props;
const {periods, regions} = props;
const { t, i18n } = useTranslation();
......@@ -146,7 +146,7 @@ export const PageHeader = (props) => {
<SearchIcon/> Close filters <ExpandLessIcon/>
</Button>
<Filters
chronOntologyTerms={chronOntologyTerms}
periods={periods}
reducer={[input, dispatch]}
regions={regions}
/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment