@eeacms/volto-datahub 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coverage.babel.config.js +9 -0
- package/.project.eslintrc.js +46 -0
- package/.release-it.json +17 -0
- package/CHANGELOG.md +42 -0
- package/DEVELOP.md +52 -0
- package/LICENSE.md +9 -0
- package/README.md +103 -0
- package/RELEASE.md +74 -0
- package/babel.config.js +17 -0
- package/bootstrap +41 -0
- package/cypress.json +17 -0
- package/jest-addon.config.js +36 -0
- package/locales/volto.pot +0 -0
- package/package.json +47 -0
- package/src/components/ItemView/ItemView.jsx +313 -0
- package/src/components/LandingPage/DatahubLandingPage.jsx +254 -0
- package/src/components/Result/DatahubCardItem.jsx +150 -0
- package/src/config/facets.js +370 -0
- package/src/config/filters.js +4 -0
- package/src/config/index.js +55 -0
- package/src/config/views.js +45 -0
- package/src/config/vocabulary.js +7 -0
- package/src/index.js +44 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Container,
|
|
4
|
+
Grid,
|
|
5
|
+
Card,
|
|
6
|
+
Image,
|
|
7
|
+
Accordion,
|
|
8
|
+
Icon,
|
|
9
|
+
} from 'semantic-ui-react';
|
|
10
|
+
import { Toolbar } from '@plone/volto/components';
|
|
11
|
+
import { BodyClass } from '@plone/volto/helpers';
|
|
12
|
+
import { Portal } from 'react-portal';
|
|
13
|
+
// import { useResult } from '@eeacms/search/lib/hocs';
|
|
14
|
+
// import {
|
|
15
|
+
// AppConfigContext,
|
|
16
|
+
// SearchContext,
|
|
17
|
+
// // useIsMounted,
|
|
18
|
+
// } from '@eeacms/search/lib/hocs';
|
|
19
|
+
// import { rebind, applyConfigurationSchema } from '@eeacms/search/lib/utils';
|
|
20
|
+
import {
|
|
21
|
+
useResult,
|
|
22
|
+
AppConfigContext,
|
|
23
|
+
SearchContext,
|
|
24
|
+
rebind,
|
|
25
|
+
applyConfigurationSchema,
|
|
26
|
+
} from '@eeacms/search';
|
|
27
|
+
import { SearchProvider, WithSearch } from '@elastic/react-search-ui'; // ErrorBoundary,
|
|
28
|
+
import { Callout } from '@eeacms/volto-eea-design-system/ui';
|
|
29
|
+
import config from '@plone/volto/registry';
|
|
30
|
+
|
|
31
|
+
const appName = 'datahub';
|
|
32
|
+
|
|
33
|
+
function ItemView(props) {
|
|
34
|
+
const { docid } = props;
|
|
35
|
+
const result = useResult(null, docid);
|
|
36
|
+
const item = result ? result._result : {};
|
|
37
|
+
const { title, description, id, raw_value, event } = item;
|
|
38
|
+
const { contactForResource, contact } = raw_value?.raw || {};
|
|
39
|
+
const relatedItemsData = event?.raw.original;
|
|
40
|
+
const relatedDatasets =
|
|
41
|
+
(relatedItemsData && JSON.parse(relatedItemsData)) || {};
|
|
42
|
+
const { children } = relatedDatasets?.raw_value || {};
|
|
43
|
+
const [activeIndex, setActiveIndex] = React.useState([]);
|
|
44
|
+
|
|
45
|
+
const toggleOpenAccordion = (e, titleProps) => {
|
|
46
|
+
const { index } = titleProps;
|
|
47
|
+
const newIndex =
|
|
48
|
+
activeIndex.indexOf(index) === -1
|
|
49
|
+
? [...activeIndex, index]
|
|
50
|
+
: activeIndex.filter((item) => item !== index);
|
|
51
|
+
|
|
52
|
+
setActiveIndex(newIndex);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// console.log('datahub item', item);
|
|
56
|
+
// console.log('related datasets', children);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{item ? (
|
|
61
|
+
<div>
|
|
62
|
+
<Portal node={document.getElementById('page-header')}>
|
|
63
|
+
<div className="eea banner">
|
|
64
|
+
<div className="gradient">
|
|
65
|
+
<div className="ui container">
|
|
66
|
+
<div className="content">
|
|
67
|
+
<h1 className="documentFirstHeading">{title?.raw}</h1>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</Portal>
|
|
73
|
+
<Callout>{description?.raw}</Callout>
|
|
74
|
+
<h3>Tabular data</h3>
|
|
75
|
+
<Accordion exclusive={false}>
|
|
76
|
+
<Accordion.Title
|
|
77
|
+
active={activeIndex.includes(0)}
|
|
78
|
+
index={0}
|
|
79
|
+
onClick={toggleOpenAccordion}
|
|
80
|
+
>
|
|
81
|
+
Distribution files
|
|
82
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
83
|
+
</Accordion.Title>
|
|
84
|
+
<Accordion.Content active={activeIndex.includes(0)}>
|
|
85
|
+
<p></p>
|
|
86
|
+
</Accordion.Content>
|
|
87
|
+
|
|
88
|
+
<Accordion.Title
|
|
89
|
+
active={activeIndex.includes(1)}
|
|
90
|
+
index={1}
|
|
91
|
+
onClick={toggleOpenAccordion}
|
|
92
|
+
>
|
|
93
|
+
Programmatic access (APIs)
|
|
94
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
95
|
+
</Accordion.Title>
|
|
96
|
+
<Accordion.Content active={activeIndex.includes(1)}>
|
|
97
|
+
<a
|
|
98
|
+
href="https://discodata.eea.europa.eu/#!/"
|
|
99
|
+
title="DiscoData REST API call"
|
|
100
|
+
rel="noopener noreferrer"
|
|
101
|
+
>
|
|
102
|
+
DiscoData
|
|
103
|
+
</a>
|
|
104
|
+
(REST API)
|
|
105
|
+
</Accordion.Content>
|
|
106
|
+
|
|
107
|
+
<Accordion.Title
|
|
108
|
+
active={activeIndex.includes(2)}
|
|
109
|
+
index={2}
|
|
110
|
+
onClick={toggleOpenAccordion}
|
|
111
|
+
>
|
|
112
|
+
Additional information
|
|
113
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
114
|
+
</Accordion.Title>
|
|
115
|
+
<Accordion.Content active={activeIndex.includes(2)}>
|
|
116
|
+
{description?.raw}
|
|
117
|
+
</Accordion.Content>
|
|
118
|
+
|
|
119
|
+
<Accordion.Title
|
|
120
|
+
active={activeIndex.includes(3)}
|
|
121
|
+
index={3}
|
|
122
|
+
onClick={toggleOpenAccordion}
|
|
123
|
+
>
|
|
124
|
+
Metadata
|
|
125
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
126
|
+
</Accordion.Title>
|
|
127
|
+
<Accordion.Content active={activeIndex.includes(3)}>
|
|
128
|
+
Topics:
|
|
129
|
+
<ul>
|
|
130
|
+
{raw_value?.raw['allKeywords.th_eea-topics.keywords']?.map(
|
|
131
|
+
(topic, i) => {
|
|
132
|
+
return (
|
|
133
|
+
<li key={i}>
|
|
134
|
+
<a href={topic.link} target="_blank" rel="noreferrer">
|
|
135
|
+
{topic.default}
|
|
136
|
+
</a>
|
|
137
|
+
</li>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
)}
|
|
141
|
+
</ul>
|
|
142
|
+
</Accordion.Content>
|
|
143
|
+
</Accordion>
|
|
144
|
+
|
|
145
|
+
<h3>Geospatial data</h3>
|
|
146
|
+
|
|
147
|
+
<h3>Additional information</h3>
|
|
148
|
+
<Accordion exclusive={false}>
|
|
149
|
+
<Accordion.Title
|
|
150
|
+
active={activeIndex.includes(4)}
|
|
151
|
+
index={4}
|
|
152
|
+
onClick={toggleOpenAccordion}
|
|
153
|
+
>
|
|
154
|
+
About this dataset
|
|
155
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
156
|
+
</Accordion.Title>
|
|
157
|
+
<Accordion.Content active={activeIndex.includes(4)}>
|
|
158
|
+
{description?.raw}
|
|
159
|
+
</Accordion.Content>
|
|
160
|
+
|
|
161
|
+
<Accordion.Title
|
|
162
|
+
active={activeIndex.includes(5)}
|
|
163
|
+
index={5}
|
|
164
|
+
onClick={toggleOpenAccordion}
|
|
165
|
+
>
|
|
166
|
+
Contact information
|
|
167
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
168
|
+
</Accordion.Title>
|
|
169
|
+
<Accordion.Content active={activeIndex.includes(5)}>
|
|
170
|
+
{contactForResource ? (
|
|
171
|
+
<>
|
|
172
|
+
{contactForResource.map((c, i) => {
|
|
173
|
+
return (
|
|
174
|
+
<Grid key={i}>
|
|
175
|
+
<Grid.Column width={4}>
|
|
176
|
+
<p>{c.role}: </p>
|
|
177
|
+
</Grid.Column>
|
|
178
|
+
<Grid.Column width={8}>
|
|
179
|
+
<a
|
|
180
|
+
href="https://www.eea.europa.eu/"
|
|
181
|
+
target="_blank"
|
|
182
|
+
rel="noreferrer"
|
|
183
|
+
>
|
|
184
|
+
<strong>{c.organisation}</strong>
|
|
185
|
+
</a>
|
|
186
|
+
<p>{c.address}</p>
|
|
187
|
+
<a href={'mailto:' + c.email}>{c.email}</a>
|
|
188
|
+
</Grid.Column>
|
|
189
|
+
</Grid>
|
|
190
|
+
);
|
|
191
|
+
})}
|
|
192
|
+
</>
|
|
193
|
+
) : (
|
|
194
|
+
<>
|
|
195
|
+
{contact &&
|
|
196
|
+
contact.length > 0 &&
|
|
197
|
+
contact.map((c, i) => {
|
|
198
|
+
return (
|
|
199
|
+
<Grid key={i}>
|
|
200
|
+
<Grid.Column width={4}>
|
|
201
|
+
{/*<p>{contact.role}: </p>*/}
|
|
202
|
+
<p>Point of contact:</p>
|
|
203
|
+
</Grid.Column>
|
|
204
|
+
<Grid.Column width={8}>
|
|
205
|
+
<a
|
|
206
|
+
href="https://www.eea.europa.eu/"
|
|
207
|
+
target="_blank"
|
|
208
|
+
rel="noreferrer"
|
|
209
|
+
>
|
|
210
|
+
<strong>{c.organisation}</strong>
|
|
211
|
+
</a>
|
|
212
|
+
<p>{c.address}</p>
|
|
213
|
+
<a href={'mailto:' + c.email}>{c.email}</a>
|
|
214
|
+
</Grid.Column>
|
|
215
|
+
</Grid>
|
|
216
|
+
);
|
|
217
|
+
})}
|
|
218
|
+
</>
|
|
219
|
+
)}
|
|
220
|
+
</Accordion.Content>
|
|
221
|
+
</Accordion>
|
|
222
|
+
|
|
223
|
+
<h3>Related datasets</h3>
|
|
224
|
+
{children && children.length > 0 && (
|
|
225
|
+
<Card.Group itemsPerRow={3}>
|
|
226
|
+
{children.map((item, index) => {
|
|
227
|
+
return (
|
|
228
|
+
<Card
|
|
229
|
+
href={`/datahub/view/${item.metadataIdentifier}`}
|
|
230
|
+
key={index}
|
|
231
|
+
>
|
|
232
|
+
<Image src={item.overview[0].url} wrapped ui={false} />
|
|
233
|
+
<Card.Content>
|
|
234
|
+
<Card.Header>
|
|
235
|
+
{item.resourceTitleObject.default}
|
|
236
|
+
</Card.Header>
|
|
237
|
+
</Card.Content>
|
|
238
|
+
</Card>
|
|
239
|
+
);
|
|
240
|
+
})}
|
|
241
|
+
</Card.Group>
|
|
242
|
+
)}
|
|
243
|
+
|
|
244
|
+
<p>
|
|
245
|
+
Source: SDI record{' '}
|
|
246
|
+
<a
|
|
247
|
+
href={
|
|
248
|
+
'https://galliwasp.eea.europa.eu/catalogue/srv/eng/catalog.search#/metadata/' +
|
|
249
|
+
id
|
|
250
|
+
}
|
|
251
|
+
>
|
|
252
|
+
{id}
|
|
253
|
+
</a>
|
|
254
|
+
</p>
|
|
255
|
+
</div>
|
|
256
|
+
) : (
|
|
257
|
+
''
|
|
258
|
+
)}
|
|
259
|
+
</>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function DatahubItemView(props) {
|
|
264
|
+
const [isClient, setIsClient] = React.useState();
|
|
265
|
+
React.useEffect(() => setIsClient(true), []);
|
|
266
|
+
|
|
267
|
+
const docid = props.match?.params?.id;
|
|
268
|
+
const registry = config.settings.searchlib;
|
|
269
|
+
|
|
270
|
+
const appConfig = React.useMemo(
|
|
271
|
+
() => applyConfigurationSchema(rebind(registry.searchui[appName])),
|
|
272
|
+
[registry],
|
|
273
|
+
);
|
|
274
|
+
const appConfigContext = React.useMemo(() => ({ appConfig, registry }), [
|
|
275
|
+
appConfig,
|
|
276
|
+
registry,
|
|
277
|
+
]);
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<div id="view">
|
|
281
|
+
{/* <ContentMetadataTags content={this.props.content} /> */}
|
|
282
|
+
{/* Body class if displayName in component is set */}
|
|
283
|
+
<BodyClass className="view-datahub-item" />
|
|
284
|
+
<Container className="view-wrapper">
|
|
285
|
+
<SearchProvider config={config}>
|
|
286
|
+
<WithSearch
|
|
287
|
+
mapContextToProps={(searchContext) => ({
|
|
288
|
+
...searchContext,
|
|
289
|
+
})}
|
|
290
|
+
>
|
|
291
|
+
{(params) => {
|
|
292
|
+
// TODO: this needs to be optimized, it causes unmounts
|
|
293
|
+
return (
|
|
294
|
+
<AppConfigContext.Provider value={appConfigContext}>
|
|
295
|
+
<SearchContext.Provider value={params}>
|
|
296
|
+
<ItemView docid={docid} />
|
|
297
|
+
</SearchContext.Provider>
|
|
298
|
+
</AppConfigContext.Provider>
|
|
299
|
+
);
|
|
300
|
+
}}
|
|
301
|
+
</WithSearch>
|
|
302
|
+
</SearchProvider>
|
|
303
|
+
</Container>
|
|
304
|
+
{isClient && (
|
|
305
|
+
<Portal node={document.getElementById('toolbar')}>
|
|
306
|
+
<Toolbar pathname={props.pathname || ''} inner={<span />} />
|
|
307
|
+
</Portal>
|
|
308
|
+
)}
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export default DatahubItemView;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button } from 'semantic-ui-react';
|
|
4
|
+
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
5
|
+
import { useAtom } from 'jotai';
|
|
6
|
+
|
|
7
|
+
// import { showFacetsAsideAtom } from '@eeacms/search/state';
|
|
8
|
+
// import { getFacetCounts } from '@eeacms/search/components/LandingPage/request';
|
|
9
|
+
// import buildStateFacets from '@eeacms/search/lib/search/state/facets';
|
|
10
|
+
// import { customOrder } from '@eeacms/search/lib/utils';
|
|
11
|
+
// import {
|
|
12
|
+
// landingPageDataAtom,
|
|
13
|
+
// isRequestedAtom,
|
|
14
|
+
// } from '@eeacms/search/components/LandingPage/state';
|
|
15
|
+
// import { Icon, Term } from '@eeacms/search/components';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
customOrder,
|
|
19
|
+
showFacetsAsideAtom,
|
|
20
|
+
getFacetCounts,
|
|
21
|
+
buildStateFacets,
|
|
22
|
+
landingPageDataAtom,
|
|
23
|
+
isRequestedAtom,
|
|
24
|
+
Icon,
|
|
25
|
+
Term,
|
|
26
|
+
} from '@eeacms/search';
|
|
27
|
+
|
|
28
|
+
const getFacetConfig = (sections, name) => {
|
|
29
|
+
return sections?.find((facet) => facet.facetField === name);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const cmp = (a, b, sortOrder) => {
|
|
33
|
+
const modifier = sortOrder === 'desc' ? -1 : 1;
|
|
34
|
+
return a > b ? modifier * 1 : a === b ? 0 : modifier * -1;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const sortedTiles = (tiles, sectionConfig, appConfig) => {
|
|
38
|
+
if (sectionConfig.sortOn === 'custom') {
|
|
39
|
+
const fConfig = appConfig.facets.filter(
|
|
40
|
+
(f) => f.field === sectionConfig.facetField,
|
|
41
|
+
);
|
|
42
|
+
const facetValues = fConfig[0].facetValues;
|
|
43
|
+
return customOrder(tiles, facetValues);
|
|
44
|
+
} else {
|
|
45
|
+
return tiles.sort((a, b) =>
|
|
46
|
+
sectionConfig.sortOn === 'alpha'
|
|
47
|
+
? cmp(a.value, b.value, sectionConfig.sortOrder || 'asc')
|
|
48
|
+
: cmp(a.count, b.count, sectionConfig.sortOrder || 'asc'),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const LandingPage = (props) => {
|
|
54
|
+
const { appConfig, children, setFilter, setSort } = props;
|
|
55
|
+
// const facetsConfig = appConfig.facets;
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
sections = [],
|
|
59
|
+
maxPerSection = 12,
|
|
60
|
+
sortField,
|
|
61
|
+
sortDirection,
|
|
62
|
+
} = appConfig.initialView.tilesLandingPageParams;
|
|
63
|
+
|
|
64
|
+
const sectionFacetFields = sections.map((s) => s.facetField);
|
|
65
|
+
const [activeSection, setActiveSection] = React.useState(
|
|
66
|
+
sections?.[0]?.facetField,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const [, setShowFacets] = useAtom(showFacetsAsideAtom);
|
|
70
|
+
|
|
71
|
+
const [landingPageData, setLandingPageData] = useAtom(landingPageDataAtom);
|
|
72
|
+
const [isRequested, setIsRequested] = useAtom(isRequestedAtom);
|
|
73
|
+
|
|
74
|
+
const getTiles = (maxPerSection) => {
|
|
75
|
+
let result = landingPageData?.[activeSection]?.[0]?.data || [];
|
|
76
|
+
|
|
77
|
+
// if (activeSection === 'language') {
|
|
78
|
+
// const fConfig = appConfig.facets.filter((f) => f.field === 'language');
|
|
79
|
+
// const languages = fConfig[0].facetValues;
|
|
80
|
+
// result = customOrder(result, languages);
|
|
81
|
+
// }
|
|
82
|
+
return [result.length > maxPerSection, result.slice(0, maxPerSection)];
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const [hasOverflow, tiles] = getTiles(maxPerSection);
|
|
86
|
+
|
|
87
|
+
const allSeries = () => {
|
|
88
|
+
return landingPageData?.['cluster_name']?.[0]?.data[0] || {};
|
|
89
|
+
};
|
|
90
|
+
const all_series = allSeries();
|
|
91
|
+
|
|
92
|
+
const activeSectionConfig = getFacetConfig(sections, activeSection);
|
|
93
|
+
|
|
94
|
+
const { icon } = activeSectionConfig;
|
|
95
|
+
|
|
96
|
+
const fixedOnClickHandler = () => {
|
|
97
|
+
setFilter('cluster_name', 'sdi', 'any');
|
|
98
|
+
appConfig.facets
|
|
99
|
+
.filter((f) => f.field !== 'cluster_name' && f.default)
|
|
100
|
+
.forEach((facet) => {
|
|
101
|
+
facet.default.values.forEach((value) =>
|
|
102
|
+
setFilter(facet.field, value, facet.default.type || 'any'),
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
setSort(sortField, sortDirection);
|
|
106
|
+
setShowFacets(true);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
useDeepCompareEffect(() => {
|
|
110
|
+
async function fetchFacets() {
|
|
111
|
+
let facets;
|
|
112
|
+
if (!isRequested) {
|
|
113
|
+
setIsRequested(true);
|
|
114
|
+
} else {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!landingPageData) {
|
|
119
|
+
const state = {
|
|
120
|
+
filters: (sections || [])
|
|
121
|
+
.filter((f) => f.filterType === 'any:exact')
|
|
122
|
+
.map(({ facetField, filterType = 'any' }) => ({
|
|
123
|
+
field: facetField,
|
|
124
|
+
values: [],
|
|
125
|
+
type: filterType,
|
|
126
|
+
})),
|
|
127
|
+
};
|
|
128
|
+
// console.log('state', state);
|
|
129
|
+
const facetCounts = await getFacetCounts(
|
|
130
|
+
state,
|
|
131
|
+
appConfig,
|
|
132
|
+
sectionFacetFields,
|
|
133
|
+
);
|
|
134
|
+
facets = buildStateFacets(facetCounts, appConfig);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!landingPageData && facets) {
|
|
138
|
+
setLandingPageData(facets);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!landingPageData) {
|
|
142
|
+
fetchFacets();
|
|
143
|
+
}
|
|
144
|
+
}, [
|
|
145
|
+
isRequested,
|
|
146
|
+
setIsRequested,
|
|
147
|
+
appConfig,
|
|
148
|
+
sectionFacetFields,
|
|
149
|
+
landingPageData,
|
|
150
|
+
setLandingPageData,
|
|
151
|
+
sections,
|
|
152
|
+
]);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div className="landing-page-container">
|
|
156
|
+
<div className="landing-page">
|
|
157
|
+
<h3 className="browse-by">Browse by</h3>
|
|
158
|
+
|
|
159
|
+
<div className="filters">
|
|
160
|
+
{sections
|
|
161
|
+
.filter((section) => !section.hidden)
|
|
162
|
+
.map((section) => {
|
|
163
|
+
return (
|
|
164
|
+
<Button
|
|
165
|
+
key={section.facetField}
|
|
166
|
+
toggle
|
|
167
|
+
active={activeSection === section.facetField}
|
|
168
|
+
className="ui button"
|
|
169
|
+
onClick={() => setActiveSection(section.facetField)}
|
|
170
|
+
>
|
|
171
|
+
{section.title}
|
|
172
|
+
</Button>
|
|
173
|
+
);
|
|
174
|
+
})}
|
|
175
|
+
</div>
|
|
176
|
+
<div className="ui cards">
|
|
177
|
+
{sortedTiles(tiles, activeSectionConfig, appConfig).map((topic) => {
|
|
178
|
+
const onClickHandler = () => {
|
|
179
|
+
setFilter(
|
|
180
|
+
activeSection,
|
|
181
|
+
topic.value,
|
|
182
|
+
activeSectionConfig.filterType || 'any',
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
// apply configured default values
|
|
186
|
+
appConfig.facets
|
|
187
|
+
.filter((f) => f.field !== activeSection && f.default)
|
|
188
|
+
.forEach((facet) => {
|
|
189
|
+
facet.default.values.forEach((value) =>
|
|
190
|
+
setFilter(facet.field, value, facet.default.type || 'any'),
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
setSort(sortField, sortDirection);
|
|
194
|
+
setShowFacets(true);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<div
|
|
199
|
+
key={topic.value}
|
|
200
|
+
tabIndex="-1"
|
|
201
|
+
role="button"
|
|
202
|
+
onKeyDown={onClickHandler}
|
|
203
|
+
className="ui card"
|
|
204
|
+
onClick={onClickHandler}
|
|
205
|
+
>
|
|
206
|
+
<div className="content">
|
|
207
|
+
<div className="header">
|
|
208
|
+
{icon ? <Icon {...icon} type={topic.value} /> : ''}
|
|
209
|
+
<Term term={topic.value} field={activeSection} />
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
<div className="extra content">
|
|
213
|
+
<span className="count">
|
|
214
|
+
{topic.count} {topic.count === 1 ? 'item' : 'items'}
|
|
215
|
+
</span>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
})}
|
|
220
|
+
</div>
|
|
221
|
+
{hasOverflow ? (
|
|
222
|
+
<div className="info">
|
|
223
|
+
<p>Only first {maxPerSection} items are displayed.</p>
|
|
224
|
+
</div>
|
|
225
|
+
) : null}
|
|
226
|
+
{children}
|
|
227
|
+
<hr></hr>
|
|
228
|
+
<div className="ui cards">
|
|
229
|
+
<div
|
|
230
|
+
key="all_series"
|
|
231
|
+
tabIndex="-1"
|
|
232
|
+
role="button"
|
|
233
|
+
onKeyDown={fixedOnClickHandler}
|
|
234
|
+
className="ui card"
|
|
235
|
+
onClick={fixedOnClickHandler}
|
|
236
|
+
>
|
|
237
|
+
<div className="content">
|
|
238
|
+
<div className="header">
|
|
239
|
+
<Term term={all_series.value} field="cluster_name" />
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
<div className="extra content">
|
|
243
|
+
<span className="count">
|
|
244
|
+
{all_series.count} {all_series.count === 1 ? 'item' : 'items'}
|
|
245
|
+
</span>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export default LandingPage;
|