@eeacms/volto-datahub 1.0.12 → 1.0.14

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/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.0.14](https://github.com/eea/volto-datahub/compare/1.0.13...1.0.14) - 1 March 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Fix warnings [kreafox - [`aa2648d`](https://github.com/eea/volto-datahub/commit/aa2648de683d57163600dc0bd144463f439d9b2a)]
12
+ - Prettier [kreafox - [`89d2b1e`](https://github.com/eea/volto-datahub/commit/89d2b1e76fbf38f478a62d04d157dbb8ac614ee3)]
13
+ - Make first tab open [kreafox - [`e578106`](https://github.com/eea/volto-datahub/commit/e578106ee06c8e2c4f48148f719f9ad9098b19b6)]
14
+ - updated wording [Zoltan Szabo - [`792aeec`](https://github.com/eea/volto-datahub/commit/792aeec6d7b21b3021ef77fd321e849b0f109216)]
15
+ ### [1.0.13](https://github.com/eea/volto-datahub/compare/1.0.12...1.0.13) - 10 February 2023
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - Fix case with no coverage [kreafox - [`6a67083`](https://github.com/eea/volto-datahub/commit/6a67083acebb5fc358882e8592d1eca05fcb38bc)]
7
20
  ### [1.0.12](https://github.com/eea/volto-datahub/compare/1.0.11...1.0.12) - 9 February 2023
8
21
 
9
22
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { Icon, List, Accordion, Tab } from 'semantic-ui-react';
2
+ import { Icon, List, Accordion, Tab, Menu } from 'semantic-ui-react';
3
+ import { DateTime } from '@eeacms/search';
3
4
  import servicesSVG from './icons/services.svg';
4
5
  import lockSVG from 'remixicon/icons/System/lock-line.svg';
5
6
 
@@ -271,7 +272,7 @@ const Datasets = (props) => {
271
272
  const { item, appConfig } = props;
272
273
  const { children } = item?.raw_value?.raw || {};
273
274
 
274
- const [activeIndex, setActiveIndex] = React.useState(-1);
275
+ const [activeIndex, setActiveIndex] = React.useState(0);
275
276
 
276
277
  function handleClick(e, titleProps) {
277
278
  const { index } = titleProps;
@@ -279,25 +280,57 @@ const Datasets = (props) => {
279
280
  setActiveIndex(newIndex);
280
281
  }
281
282
 
282
- const sortedDatasets = React.useMemo(
283
- () =>
284
- (children || []).sort(
285
- (a, b) =>
286
- new Date(b.publicationDateForResource).getTime() -
287
- new Date(a.publicationDateForResource).getTime(),
288
- ),
289
- [children],
290
- );
283
+ const datasets = children.map((v, e) => {
284
+ let date;
285
+
286
+ if (v.resourceTemporalExtentDetails) {
287
+ const tc = v.resourceTemporalExtentDetails[0];
288
+ const { start, end } = tc || {};
289
+ const tc_start = start?.date
290
+ ? new Date(Date.parse(start.date)).getFullYear()
291
+ : '';
292
+ const tc_end = end?.date
293
+ ? new Date(Date.parse(end.date)).getFullYear()
294
+ : '';
295
+ if (tc_start === tc_end) {
296
+ date = tc_start;
297
+ } else {
298
+ date = tc_start + '-' + tc_end;
299
+ }
300
+ } else {
301
+ date = '';
302
+ }
303
+
304
+ return Object.assign({ temporalDateRange: date, ...v }, e);
305
+ });
306
+
307
+ const datasetsByCoverage = groupBy(datasets, 'temporalDateRange');
291
308
 
292
- const datasets = groupBy(sortedDatasets, 'publicationYearForResource');
309
+ const sortedDatasets = Object.keys(datasetsByCoverage).sort(function (a, b) {
310
+ a = Math.max(...a.split('-'));
311
+ b = Math.max(...b.split('-'));
312
+ return b - a;
313
+ });
293
314
 
294
- const panes = Object.keys(datasets).map((dataset) => ({
295
- menuItem: dataset === 'undefined' ? 'Missing' : dataset,
315
+ const groupedDatasets = sortedDatasets.map((v) => {
316
+ return { date: v, children: datasetsByCoverage[v] };
317
+ });
318
+
319
+ const panes = (groupedDatasets || []).map((item, i) => ({
320
+ menuItem: (
321
+ <Menu.Item key={i}>
322
+ {item.date ? <span>{item.date}</span> : 'No date'}
323
+ </Menu.Item>
324
+ ),
296
325
  render: () => (
297
326
  <Tab.Pane>
298
327
  <Accordion>
299
- {datasets[dataset].map((dataset, index) => {
300
- const { resourceTemporalExtentDetails } = dataset;
328
+ {item?.children.map((dataset, index) => {
329
+ const {
330
+ resourceTemporalExtentDetails,
331
+ temporalDateRange,
332
+ publicationDateForResource,
333
+ } = dataset;
301
334
  return (
302
335
  <React.Fragment key={index}>
303
336
  <Accordion.Title
@@ -349,42 +382,26 @@ const Datasets = (props) => {
349
382
  </Accordion.Title>
350
383
  <Accordion.Content active={activeIndex === index}>
351
384
  <div className="dataset-content">
352
- {resourceTemporalExtentDetails &&
353
- resourceTemporalExtentDetails?.length > 0 && (
385
+ <div>
386
+ {publicationDateForResource && (
354
387
  <div>
355
- <strong>Temporal coverage: </strong>
356
-
357
- {resourceTemporalExtentDetails.map((tc, i) => {
358
- let tc_start = tc?.start?.date;
359
- if (tc_start) {
360
- tc_start = new Date(
361
- Date.parse(tc_start),
362
- ).getFullYear();
363
- }
364
- let tc_end = tc?.end?.date;
365
- if (tc_end) {
366
- tc_end = new Date(
367
- Date.parse(tc_end),
368
- ).getFullYear();
369
- }
370
- tc_start = tc_start || '';
371
- tc_end = tc_end || '';
372
- return (
373
- <React.Fragment key={i}>
374
- <span>
375
- {tc_start === tc_end && tc_start}
376
- {tc_start !== tc_end &&
377
- tc_start + ' - ' + tc_end}
378
- </span>
379
- {i !== resourceTemporalExtentDetails.length - 1
380
- ? ', '
381
- : ' '}
382
- </React.Fragment>
383
- );
384
- })}
388
+ <strong>Published: </strong>
389
+ <DateTime
390
+ format="DATE_MED"
391
+ value={publicationDateForResource}
392
+ />
385
393
  </div>
386
394
  )}
387
395
 
396
+ {resourceTemporalExtentDetails &&
397
+ resourceTemporalExtentDetails?.length > 0 && (
398
+ <div>
399
+ <strong>Temporal coverage: </strong>
400
+ {temporalDateRange}
401
+ </div>
402
+ )}
403
+ </div>
404
+
388
405
  {dataset.resourceType[0] !== 'nonGeographicDataset' && (
389
406
  <div className="dataset-pdf">
390
407
  <div className="d-link">
@@ -419,7 +436,7 @@ const Datasets = (props) => {
419
436
  <h2>Datasets</h2>
420
437
  </div>
421
438
 
422
- <div className="item tabs-title">Publication year</div>
439
+ <div className="item tabs-title">Temporal coverage</div>
423
440
  <Tab
424
441
  className="datasets-tab"
425
442
  menu={{ vertical: true, secondary: true, pointing: true }}
@@ -32,8 +32,7 @@ function IsomorphicPortal({ children }) {
32
32
  }
33
33
 
34
34
  function ItemView(props) {
35
- const { docid, location, staticContext } = props;
36
- const { fromPathname, fromSearch } = location?.state || {};
35
+ const { docid, staticContext } = props;
37
36
  const dispatch = useDispatch();
38
37
  // const content = useSelector((state) => state.content.data);
39
38
  let result = useSelector((state) => state.datahub_results?.[docid]);
@@ -107,15 +106,7 @@ function ItemView(props) {
107
106
  <Banner>
108
107
  <Banner.Content>
109
108
  <Banner.Subtitle>
110
- <Link
111
- to={
112
- location?.state
113
- ? { pathname: fromPathname, search: fromSearch }
114
- : {
115
- pathname: '/en/datahub/',
116
- }
117
- }
118
- >
109
+ <Link to={appConfig.landingPageURL}>
119
110
  <Icon className="arrow left" />
120
111
  Datahub overview
121
112
  </Link>
@@ -252,13 +252,9 @@ const LandingPage = (props) => {
252
252
  onKeyDown={fixedOnClickHandler}
253
253
  onClick={fixedOnClickHandler}
254
254
  >
255
- <div className="content">
256
- <Term term={all_series.value} field="cluster_name" />
257
- </div>
258
255
  <div className="extra content">
259
256
  <span className="count">
260
- {all_series.count}{' '}
261
- {all_series.count === 1 ? 'item' : 'items'}
257
+ See all {all_series.count} datasets
262
258
  </span>
263
259
  </div>
264
260
  </div>
@@ -13,18 +13,10 @@ const DatahubCardItem = (props) => {
13
13
  // if (metaType.length === 0) {
14
14
  // metaType = 'Others';
15
15
  // }
16
+
16
17
  const item = {
17
18
  title: (
18
- <Link
19
- to={{
20
- pathname: result.href,
21
- state: {
22
- fromPathname: window.location.pathname,
23
- fromSearch: window.location.search,
24
- },
25
- }}
26
- title={result.title}
27
- >
19
+ <Link to={result.href} title={result.title}>
28
20
  {result.title}
29
21
  </Link>
30
22
  ),
@@ -1,6 +1,6 @@
1
1
  const vocab = {
2
2
  cluster_name: {
3
- sdi: 'Datahub series',
3
+ sdi: 'Datahub datasets',
4
4
  },
5
5
  };
6
6