@eeacms/volto-datahub 0.1.3 → 0.1.6

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,8 +4,42 @@ 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
+ #### [0.1.6](https://github.com/eea/volto-datahub/compare/0.1.5...0.1.6)
8
+
9
+ - Add banner for ItemView [`7c70d6a`](https://github.com/eea/volto-datahub/commit/7c70d6ad127bb9cbdae95ae898304c85d2ab8bd8)
10
+
11
+ #### [0.1.5](https://github.com/eea/volto-datahub/compare/0.1.4...0.1.5)
12
+
13
+ > 29 July 2022
14
+
15
+ - Release [`#6`](https://github.com/eea/volto-datahub/pull/6)
16
+ - Fix merge [`6a8f3d4`](https://github.com/eea/volto-datahub/commit/6a8f3d4f3bfaacb8e0938929d8038f9e31a26ced)
17
+ - Fix layout [`129d480`](https://github.com/eea/volto-datahub/commit/129d4802a63aa346d11ae8e54b323580213c0a71)
18
+ - Fix merge [`3df3a81`](https://github.com/eea/volto-datahub/commit/3df3a8189448dcdd052692b6f5d835a1ea752a50)
19
+ - Add back to search [`b80ce25`](https://github.com/eea/volto-datahub/commit/b80ce250d326fa75c8451d70fe366148f7d49abb)
20
+ - Change datahubitem path [`7ccdbf0`](https://github.com/eea/volto-datahub/commit/7ccdbf0619e45a99e85b096dcdfb2e645e3ecc90)
21
+ - Integrate the Breadcrumb [`bccae64`](https://github.com/eea/volto-datahub/commit/bccae6445b3c46d4715743558343a14b08c7c07f)
22
+
23
+ #### [0.1.4](https://github.com/eea/volto-datahub/compare/0.1.3...0.1.4)
24
+
25
+ > 28 July 2022
26
+
27
+ - Develop [`#5`](https://github.com/eea/volto-datahub/pull/5)
28
+ - Improve temporal coverage [`d0483d4`](https://github.com/eea/volto-datahub/commit/d0483d46259b956a96a66268b9ec305d27456f88)
29
+ - Fix warning message [`305d2d6`](https://github.com/eea/volto-datahub/commit/305d2d61123d1ee23e8a4baf837b1aadc5d9a41f)
30
+ - Hide readingTime for now [`5e508d3`](https://github.com/eea/volto-datahub/commit/5e508d3c2bfd97bcc01dca59894a4f9ad582284b)
31
+ - ESlint fix [`dcfbab4`](https://github.com/eea/volto-datahub/commit/dcfbab4effa23ddcc3d4bf9a61d0b0d101c796b6)
32
+ - Set topics filter always visible [`1c062f4`](https://github.com/eea/volto-datahub/commit/1c062f473c123b5c04055fc6a52ea56bbd00e7b4)
33
+ - Update item view [`a53d297`](https://github.com/eea/volto-datahub/commit/a53d297916bb8d2c5d020acb9de600228e344982)
34
+ - Fix import [`bfa1cbc`](https://github.com/eea/volto-datahub/commit/bfa1cbc04c60009f949ac675278df894b4e1c892)
35
+ - WIP Update dataset's page based on new figma design [`01eecfa`](https://github.com/eea/volto-datahub/commit/01eecfacd482ca6abea81e4fd24eb7871e5365c9)
36
+ - Reconfigure datahub facets [`8636536`](https://github.com/eea/volto-datahub/commit/863653613d05faaa73101943896f05243055c696)
37
+ - Update result item based on new figma design [`eb618a0`](https://github.com/eea/volto-datahub/commit/eb618a0ce441cb9d797b39efad6bf98e4b07c728)
38
+
7
39
  #### [0.1.3](https://github.com/eea/volto-datahub/compare/0.1.2...0.1.3)
8
40
 
41
+ > 30 June 2022
42
+
9
43
 
10
44
  #### [0.1.2](https://github.com/eea/volto-datahub/compare/0.1.1...0.1.2)
11
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
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,22 +1,15 @@
1
1
  import React from 'react';
2
2
  import {
3
3
  Container,
4
- Grid,
5
4
  Card,
6
5
  Image,
7
6
  Accordion,
8
7
  Icon,
8
+ Tab,
9
9
  } from 'semantic-ui-react';
10
10
  import { Toolbar } from '@plone/volto/components';
11
11
  import { BodyClass } from '@plone/volto/helpers';
12
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
13
  import {
21
14
  useResult,
22
15
  AppConfigContext,
@@ -24,22 +17,66 @@ import {
24
17
  rebind,
25
18
  applyConfigurationSchema,
26
19
  } from '@eeacms/search';
27
- import { SearchProvider, WithSearch } from '@elastic/react-search-ui'; // ErrorBoundary,
28
- import { Callout } from '@eeacms/volto-eea-design-system/ui';
20
+ import { DateTime } from '@eeacms/search';
21
+ import { SearchProvider, WithSearch } from '@elastic/react-search-ui';
22
+ import { Callout, Banner } from '@eeacms/volto-eea-design-system/ui';
23
+ import { useDispatch } from 'react-redux';
29
24
  import config from '@plone/volto/registry';
25
+ import { Link, useLocation } from 'react-router-dom';
26
+ import bannerBG from './banner.svg';
30
27
 
31
28
  const appName = 'datahub';
32
29
 
33
30
  function ItemView(props) {
34
- const { docid } = props;
31
+ const { docid, location } = props;
32
+ const { fromPathname, fromSearch } = location?.state || {};
33
+ const dispatch = useDispatch();
34
+ // const content = useSelector((state) => state.content.data);
35
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 || {};
36
+ const item = result ? result._result : null;
37
+ const { title, description, raw_value, event, issued, time_coverage } =
38
+ item || {}; // readingTime
39
+ const rawTitle = title?.raw || '';
40
+
41
+ React.useEffect(() => {
42
+ const handler = async () => {
43
+ if (item) {
44
+ const action = {
45
+ type: 'GET_BREADCRUMBS_SUCCESS',
46
+ result: {
47
+ items: [
48
+ {
49
+ title: 'Datahub',
50
+ '@id': '/en/datahub',
51
+ },
52
+ {
53
+ title: rawTitle,
54
+ '@id': `/en/datahub/view/${docid}`,
55
+ },
56
+ ],
57
+ },
58
+ };
59
+ await dispatch({ type: 'GET_BREADCRUMBS_PENDING' }); // satisfy content load protection
60
+ await dispatch(action);
61
+ }
62
+ };
63
+
64
+ handler();
65
+ }, [item, dispatch, docid, rawTitle]);
66
+ const {
67
+ // contactForResource,
68
+ // contact,
69
+ // resourceTemporalDateRange,
70
+ changeDate,
71
+ } = raw_value?.raw || {};
72
+
39
73
  const relatedItemsData = event?.raw.original;
40
74
  const relatedDatasets =
41
75
  (relatedItemsData && JSON.parse(relatedItemsData)) || {};
42
76
  const { children } = relatedDatasets?.raw_value || {};
77
+ const startTempCoverage = parseInt(time_coverage?.raw.at(0));
78
+ const endTempCoverage = parseInt(time_coverage?.raw.at(-1));
79
+
43
80
  const [activeIndex, setActiveIndex] = React.useState([]);
44
81
 
45
82
  const toggleOpenAccordion = (e, titleProps) => {
@@ -51,216 +88,269 @@ function ItemView(props) {
51
88
 
52
89
  setActiveIndex(newIndex);
53
90
  };
91
+ // console.log('result', result?._result);
54
92
 
55
- // console.log('datahub item', item);
56
- // console.log('related datasets', children);
93
+ const panes = [
94
+ {
95
+ menuItem: 'European data',
96
+ render: () => <Tab.Pane attached={false}>Tab 1 Content</Tab.Pane>,
97
+ },
98
+ {
99
+ menuItem: 'Dataset definition',
100
+ render: () => <Tab.Pane attached={false}>Tab 2 Content</Tab.Pane>,
101
+ },
102
+ ];
57
103
 
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>
104
+ return item ? (
105
+ <div className="dataset-view">
106
+ <Portal node={document.getElementById('page-header')}>
107
+ <div className="dataset">
108
+ <Banner image_url={bannerBG} image>
109
+ <Banner.Content>
110
+ <Banner.Title>Datahub</Banner.Title>
111
+ </Banner.Content>
112
+ </Banner>
113
+ </div>
114
+ </Portal>
87
115
 
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>
116
+ <div className="dataset-container">
117
+ {location?.state && (
118
+ <Link
119
+ className="search-link"
120
+ to={{
121
+ pathname: fromPathname,
122
+ search: fromSearch,
123
+ }}
124
+ >
125
+ <i class="ri-arrow-go-back-line"></i>
126
+ Back to search
127
+ </Link>
128
+ )}
129
+ <div className="dataset-header">
130
+ <h1>{title?.raw}</h1>
131
+ <div className="dataset-header-bottom">
132
+ <span className="header-data">Prod-ID: [No data]</span>
133
+ <span className="header-data">
134
+ Created: <DateTime format="DATE_MED" value={issued?.raw} />
135
+ </span>
136
+ <span className="header-data">Published: [No data]</span>
137
+ <span className="header-data">
138
+ Last modified: <DateTime format="DATE_MED" value={changeDate} />
139
+ </span>
140
+ {/*<span className="header-data">
141
+ Reading time: {readingTime?.raw}
142
+ </span>*/}
143
+ </div>
144
+ </div>
145
+ <Callout>{description?.raw}</Callout>
106
146
 
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>
147
+ <Tab
148
+ menu={{ secondary: true, pointing: true }}
149
+ panes={panes}
150
+ className="dataset-tab-setion"
151
+ />
152
+ </div>
118
153
 
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>
154
+ <div className="info-wrapper">
155
+ <div className="info-content">
156
+ <div className="info-title">More Information for {title?.raw}.</div>
157
+ <p>{description?.raw}</p>
158
+ </div>
159
+ </div>
144
160
 
145
- <h3>Geospatial data</h3>
161
+ {children && children.length > 0 && (
162
+ <div className="related-wrapper">
163
+ <h2>Related content</h2>
164
+ <Card.Group itemsPerRow={4}>
165
+ {children.map((item, index) => {
166
+ return (
167
+ <Card
168
+ href={`/datahub/view/${item.metadataIdentifier}`}
169
+ key={index}
170
+ >
171
+ <Image src={item.overview[0].url} wrapped ui={false} />
172
+ <Card.Content>
173
+ <Card.Description>
174
+ {item.resourceTitleObject.default}
175
+ </Card.Description>
176
+ </Card.Content>
177
+ </Card>
178
+ );
179
+ })}
180
+ </Card.Group>
181
+ </div>
182
+ )}
146
183
 
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>
184
+ <div className="below-content-wrapper">
185
+ <Accordion exclusive={false}>
186
+ <Accordion.Title
187
+ active={activeIndex.includes(0)}
188
+ index={0}
189
+ onClick={toggleOpenAccordion}
190
+ >
191
+ Metadata
192
+ <Icon className="ri-arrow-down-s-line" />
193
+ </Accordion.Title>
194
+ <Accordion.Content active={activeIndex.includes(0)}>
195
+ {!!item?.rod && (
196
+ <div>
197
+ Reporting obligations (ROD):
198
+ <ul>
199
+ {Array.isArray(item.rod?.raw) ? (
200
+ <>
201
+ {item?.rod?.raw.map((item, i) => {
202
+ return <li key={i}>{item}</li>;
203
+ })}
204
+ </>
205
+ ) : (
206
+ <li>{item.rod?.raw}</li>
207
+ )}
208
+ </ul>
209
+ </div>
210
+ )}
160
211
 
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
- );
212
+ {!!item?.organisation && (
213
+ <div>
214
+ Organisation:
215
+ <ul>
216
+ {Array.isArray(item?.organisation?.raw) ? (
217
+ <>
218
+ {item?.organisation?.raw.map((item, i) => {
219
+ return <li key={i}>{item}</li>;
220
+ })}
221
+ </>
222
+ ) : (
223
+ <li>{item?.organisation?.raw}</li>
224
+ )}
225
+ </ul>
226
+ </div>
227
+ )}
228
+ </Accordion.Content>
229
+
230
+ <Accordion.Title
231
+ active={activeIndex.includes(1)}
232
+ index={1}
233
+ onClick={toggleOpenAccordion}
234
+ >
235
+ Permalinks
236
+ <Icon className="ri-arrow-down-s-line" />
237
+ </Accordion.Title>
238
+ <Accordion.Content active={activeIndex.includes(1)}>
239
+ [No data]
240
+ </Accordion.Content>
241
+
242
+ <Accordion.Title
243
+ active={activeIndex.includes(2)}
244
+ index={2}
245
+ onClick={toggleOpenAccordion}
246
+ >
247
+ Geographic coverage
248
+ <Icon className="ri-arrow-down-s-line" />
249
+ </Accordion.Title>
250
+ <Accordion.Content active={activeIndex.includes(2)}>
251
+ {item.spatial && (
252
+ <div className="geotags">
253
+ {Array.isArray(item?.spatial?.raw) ? (
254
+ <>
255
+ {item?.spatial?.raw.map((item, i) => {
256
+ return <span key={i}>{item}</span>;
217
257
  })}
218
- </>
219
- )}
220
- </Accordion.Content>
221
- </Accordion>
258
+ </>
259
+ ) : (
260
+ <span>{item?.spatial?.raw}</span>
261
+ )}
262
+ </div>
263
+ )}
264
+ </Accordion.Content>
222
265
 
223
- <h3>Related datasets</h3>
224
- {children && children.length > 0 && (
225
- <Card.Group itemsPerRow={3}>
226
- {children.map((item, index) => {
266
+ <Accordion.Title
267
+ active={activeIndex.includes(3)}
268
+ index={3}
269
+ onClick={toggleOpenAccordion}
270
+ >
271
+ Temporal coverage
272
+ <Icon className="ri-arrow-down-s-line" />
273
+ </Accordion.Title>
274
+ <Accordion.Content active={activeIndex.includes(3)}>
275
+ {/*<ul>
276
+ {resourceTemporalDateRange?.map((temp, i) => {
227
277
  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>
278
+ <li key={i}>
279
+ <DateTime format="DATE_MED" value={temp.gte} /> -
280
+ <DateTime format="DATE_MED" value={temp.lte} />
281
+ </li>
239
282
  );
240
283
  })}
241
- </Card.Group>
242
- )}
284
+ </ul>*/}
285
+ {time_coverage?.raw.length > 0 && (
286
+ <div className="temporal-coverage">
287
+ <div className="side-temp">{`${startTempCoverage - 1}`}</div>
288
+ <div className="time-range">
289
+ <span>{startTempCoverage}</span> -
290
+ <span>{endTempCoverage}</span>
291
+ </div>
292
+ <div className="side-temp">{`${endTempCoverage + 1}`}</div>
293
+ </div>
294
+ )}
295
+ </Accordion.Content>
243
296
 
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
- );
297
+ <Accordion.Title
298
+ active={activeIndex.includes(4)}
299
+ index={4}
300
+ onClick={toggleOpenAccordion}
301
+ >
302
+ Topics
303
+ <Icon className="ri-arrow-down-s-line" />
304
+ </Accordion.Title>
305
+ <Accordion.Content active={activeIndex.includes(4)}>
306
+ {item.topic && (
307
+ <>
308
+ {Array.isArray(item?.topic?.raw) ? (
309
+ <>
310
+ {item?.topic?.raw.map((item, i) => {
311
+ return (
312
+ <span className="tag-item" key={i}>
313
+ {item}
314
+ </span>
315
+ );
316
+ })}
317
+ </>
318
+ ) : (
319
+ <span className="tag-item">{item?.topic?.raw}</span>
320
+ )}
321
+ </>
322
+ )}
323
+ </Accordion.Content>
324
+
325
+ <Accordion.Title
326
+ active={activeIndex.includes(5)}
327
+ index={5}
328
+ onClick={toggleOpenAccordion}
329
+ >
330
+ Tags
331
+ <Icon className="ri-arrow-down-s-line" />
332
+ </Accordion.Title>
333
+ <Accordion.Content active={activeIndex.includes(5)}>
334
+ <div className="dataset-tags">
335
+ {raw_value?.raw['allKeywords.th_EEAkeywordlist.keywords']?.map(
336
+ (tag, i) => {
337
+ return (
338
+ <span className="tag-item" key={i}>
339
+ {tag.default}
340
+ </span>
341
+ );
342
+ },
343
+ )}
344
+ </div>
345
+ </Accordion.Content>
346
+ </Accordion>
347
+ </div>
348
+ </div>
349
+ ) : null;
261
350
  }
262
351
 
263
352
  function DatahubItemView(props) {
353
+ const location = useLocation();
264
354
  const [isClient, setIsClient] = React.useState();
265
355
  React.useEffect(() => setIsClient(true), []);
266
356
 
@@ -293,7 +383,7 @@ function DatahubItemView(props) {
293
383
  return (
294
384
  <AppConfigContext.Provider value={appConfigContext}>
295
385
  <SearchContext.Provider value={params}>
296
- <ItemView docid={docid} />
386
+ <ItemView docid={docid} location={location} />
297
387
  </SearchContext.Provider>
298
388
  </AppConfigContext.Provider>
299
389
  );