@eeacms/volto-datahub 0.1.5 → 0.1.8

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,38 @@ 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.8](https://github.com/eea/volto-datahub/compare/0.1.7...0.1.8)
8
+
9
+ - Added facet for time coverage [`553518e`](https://github.com/eea/volto-datahub/commit/553518e7297e7bdace1323010735feb781e3b628)
10
+
11
+ #### [0.1.7](https://github.com/eea/volto-datahub/compare/0.1.6...0.1.7)
12
+
13
+ > 26 August 2022
14
+
15
+ - Release [`#8`](https://github.com/eea/volto-datahub/pull/8)
16
+ - Link to the SDI metadata pdf [`e28b3a0`](https://github.com/eea/volto-datahub/commit/e28b3a0254ee9d60d0804de57dc401c4a9fbea0a)
17
+ - Add services icon, datasets improvements [`5b9295a`](https://github.com/eea/volto-datahub/commit/5b9295ad26af7305d217e3dec99b7337603e329f)
18
+ - WIP datasets section: sorting, add formats [`7d51ec6`](https://github.com/eea/volto-datahub/commit/7d51ec63aa0716073ab6e1f75488fea83dfe585f)
19
+ - Remove more information section [`8a38fee`](https://github.com/eea/volto-datahub/commit/8a38fee341c8b7f7c830b7e0331fcb15a28857f3)
20
+ - First accordion open by default [`9b7af42`](https://github.com/eea/volto-datahub/commit/9b7af424dec504ed019a79bf5110f2054b2e3168)
21
+ - Remove unused import [`f9c62a2`](https://github.com/eea/volto-datahub/commit/f9c62a22b527923e9b02479f72f1e19a9ff6ad76)
22
+ - WIP update datahub item view [`607f9be`](https://github.com/eea/volto-datahub/commit/607f9be74604c8c5ad6ff89f29bc127a94f41288)
23
+ - Add datasets listing [`3d9cc1d`](https://github.com/eea/volto-datahub/commit/3d9cc1d25bb7f0406520473883b6af9167c3fd7b)
24
+ - Fix temporal coverage [`6bc81c5`](https://github.com/eea/volto-datahub/commit/6bc81c52daccf69813a9eb229d6ccb635e9dde49)
25
+ - Update [`d78a5ba`](https://github.com/eea/volto-datahub/commit/d78a5ba0624821820640aa91b3f51b2b75cb3edf)
26
+
27
+ #### [0.1.6](https://github.com/eea/volto-datahub/compare/0.1.5...0.1.6)
28
+
29
+ > 3 August 2022
30
+
31
+ - Add banner for datahub item view & fix cypress [`#7`](https://github.com/eea/volto-datahub/pull/7)
32
+ - Add banner for ItemView [`7c70d6a`](https://github.com/eea/volto-datahub/commit/7c70d6ad127bb9cbdae95ae898304c85d2ab8bd8)
33
+
7
34
  #### [0.1.5](https://github.com/eea/volto-datahub/compare/0.1.4...0.1.5)
8
35
 
36
+ > 29 July 2022
37
+
38
+ - Release [`#6`](https://github.com/eea/volto-datahub/pull/6)
9
39
  - Fix merge [`6a8f3d4`](https://github.com/eea/volto-datahub/commit/6a8f3d4f3bfaacb8e0938929d8038f9e31a26ced)
10
40
  - Fix layout [`129d480`](https://github.com/eea/volto-datahub/commit/129d4802a63aa346d11ae8e54b323580213c0a71)
11
41
  - Fix merge [`3df3a81`](https://github.com/eea/volto-datahub/commit/3df3a8189448dcdd052692b6f5d835a1ea752a50)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
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,12 +1,5 @@
1
1
  import React from 'react';
2
- import {
3
- Container,
4
- Card,
5
- Image,
6
- Accordion,
7
- Icon,
8
- Tab,
9
- } from 'semantic-ui-react';
2
+ import { Container, Accordion, Icon, List } from 'semantic-ui-react';
10
3
  import { Toolbar } from '@plone/volto/components';
11
4
  import { BodyClass } from '@plone/volto/helpers';
12
5
  import { Portal } from 'react-portal';
@@ -19,13 +12,30 @@ import {
19
12
  } from '@eeacms/search';
20
13
  import { DateTime } from '@eeacms/search';
21
14
  import { SearchProvider, WithSearch } from '@elastic/react-search-ui';
22
- import { Callout } from '@eeacms/volto-eea-design-system/ui';
15
+ import { Callout, Banner } from '@eeacms/volto-eea-design-system/ui';
23
16
  import { useDispatch } from 'react-redux';
24
17
  import config from '@plone/volto/registry';
25
18
  import { Link, useLocation } from 'react-router-dom';
19
+ import bannerBG from './banner.svg';
20
+ import servicesSVG from './icons/services.svg';
26
21
 
27
22
  const appName = 'datahub';
28
23
 
24
+ const SVGIcon = ({ name, size, color, className, title, onClick }) => {
25
+ return (
26
+ <svg
27
+ xmlns={name.attributes && name.attributes.xmlns}
28
+ viewBox={name.attributes && name.attributes.viewBox}
29
+ style={{ height: size, width: 'auto', fill: color || 'currentColor' }}
30
+ className={className ? `icon ${className}` : 'icon'}
31
+ onClick={onClick}
32
+ dangerouslySetInnerHTML={{
33
+ __html: title ? `<title>${title}</title>${name.content}` : name.content,
34
+ }}
35
+ />
36
+ );
37
+ };
38
+
29
39
  function ItemView(props) {
30
40
  const { docid, location } = props;
31
41
  const { fromPathname, fromSearch } = location?.state || {};
@@ -33,10 +43,20 @@ function ItemView(props) {
33
43
  // const content = useSelector((state) => state.content.data);
34
44
  const result = useResult(null, docid);
35
45
  const item = result ? result._result : null;
36
- const { title, description, raw_value, event, issued, time_coverage } =
37
- item || {}; // readingTime
46
+ const { title, description, raw_value, issued, time_coverage } = item || {}; // readingTime
47
+ const { changeDate, children } = raw_value?.raw || {};
48
+ const startTempCoverage = time_coverage?.raw.at(0);
49
+ const endTempCoverage = time_coverage?.raw.at(-1);
38
50
  const rawTitle = title?.raw || '';
39
51
 
52
+ const [activeIndex, setActiveIndex] = React.useState(0);
53
+
54
+ function handleClick(e, titleProps) {
55
+ const { index } = titleProps;
56
+ const newIndex = activeIndex === index ? -1 : index;
57
+ setActiveIndex(newIndex);
58
+ }
59
+
40
60
  React.useEffect(() => {
41
61
  const handler = async () => {
42
62
  if (item) {
@@ -62,71 +82,46 @@ function ItemView(props) {
62
82
 
63
83
  handler();
64
84
  }, [item, dispatch, docid, rawTitle]);
65
- const {
66
- // contactForResource,
67
- // contact,
68
- // resourceTemporalDateRange,
69
- changeDate,
70
- } = raw_value?.raw || {};
71
-
72
- const relatedItemsData = event?.raw.original;
73
- const relatedDatasets =
74
- (relatedItemsData && JSON.parse(relatedItemsData)) || {};
75
- const { children } = relatedDatasets?.raw_value || {};
76
- const startTempCoverage = parseInt(time_coverage?.raw.at(0));
77
- const endTempCoverage = parseInt(time_coverage?.raw.at(-1));
78
85
 
79
- const [activeIndex, setActiveIndex] = React.useState([]);
80
-
81
- const toggleOpenAccordion = (e, titleProps) => {
82
- const { index } = titleProps;
83
- const newIndex =
84
- activeIndex.indexOf(index) === -1
85
- ? [...activeIndex, index]
86
- : activeIndex.filter((item) => item !== index);
86
+ const datasets = React.useMemo(
87
+ () =>
88
+ (children || []).sort(
89
+ (a, b) =>
90
+ new Date(b.publicationDateForResource).getTime() -
91
+ new Date(a.publicationDateForResource).getTime(),
92
+ ),
93
+ [children],
94
+ );
87
95
 
88
- setActiveIndex(newIndex);
89
- };
90
96
  // console.log('result', result?._result);
91
97
 
92
- const panes = [
93
- {
94
- menuItem: 'European data',
95
- render: () => <Tab.Pane attached={false}>Tab 1 Content</Tab.Pane>,
96
- },
97
- {
98
- menuItem: 'Dataset definition',
99
- render: () => <Tab.Pane attached={false}>Tab 2 Content</Tab.Pane>,
100
- },
101
- ];
102
-
103
98
  return item ? (
104
99
  <div className="dataset-view">
105
100
  <Portal node={document.getElementById('page-header')}>
106
- <div className="eea banner">
107
- <div className="gradient">
108
- <div className="ui container">
109
- <div className="content">
110
- <h1 className="documentFirstHeading">Datahub</h1>
111
- </div>
112
- </div>
113
- </div>
101
+ <div className="dataset">
102
+ <Banner image_url={bannerBG} image>
103
+ <Banner.Content>
104
+ <Banner.Title>Datahub</Banner.Title>
105
+ </Banner.Content>
106
+ </Banner>
114
107
  </div>
115
108
  </Portal>
116
109
 
117
110
  <div className="dataset-container">
118
- {location?.state && (
119
- <Link
120
- className="search-link"
121
- to={{
122
- pathname: fromPathname,
123
- search: fromSearch,
124
- }}
125
- >
126
- <i class="ri-arrow-go-back-line"></i>
127
- Back to search
128
- </Link>
129
- )}
111
+ <Link
112
+ className="search-link"
113
+ to={
114
+ location?.state
115
+ ? { pathname: fromPathname, search: fromSearch }
116
+ : {
117
+ pathname: '/en/datahub/',
118
+ }
119
+ }
120
+ >
121
+ <Icon className="ri-arrow-go-back-line" />
122
+ Back to search
123
+ </Link>
124
+
130
125
  <div className="dataset-header">
131
126
  <h1>{title?.raw}</h1>
132
127
  <div className="dataset-header-bottom">
@@ -143,209 +138,242 @@ function ItemView(props) {
143
138
  </span>*/}
144
139
  </div>
145
140
  </div>
141
+
146
142
  <Callout>{description?.raw}</Callout>
147
143
 
148
- <Tab
149
- menu={{ secondary: true, pointing: true }}
150
- panes={panes}
151
- className="dataset-tab-setion"
152
- />
153
- </div>
144
+ {datasets && datasets.length > 0 && (
145
+ <>
146
+ <h2>Data</h2>
147
+ <Accordion>
148
+ {datasets.map((dataset, index) => {
149
+ return (
150
+ <>
151
+ <Accordion.Title
152
+ active={activeIndex === index}
153
+ index={index}
154
+ onClick={handleClick}
155
+ >
156
+ <span className="dataset-title">
157
+ <div>{dataset.resourceTitleObject.default}</div>
158
+ <span>
159
+ {(dataset.format || []).map((item, i) => {
160
+ return <span className="format-label">{item}</span>;
161
+ })}
162
+ </span>
163
+ </span>
164
+ <Icon className="ri-arrow-down-s-line" />
165
+ </Accordion.Title>
166
+ <Accordion.Content active={activeIndex === index}>
167
+ {!!dataset.link && dataset.link.length > 0 ? (
168
+ <List divided relaxed>
169
+ {dataset.link
170
+ .filter((i) => i.protocol === 'WWW:URL')
171
+ .map((item, i) => {
172
+ return (
173
+ <List.Item>
174
+ <List.Content>
175
+ <div className="dataset-item">
176
+ <Icon className="download" />
177
+ <a href={item.url} className="item-link">
178
+ <span>{item.name}</span>
179
+ </a>
180
+ </div>
181
+ </List.Content>
182
+ {item.description && (
183
+ <span
184
+ className="item-description"
185
+ title={item.description}
186
+ >
187
+ {item.description}
188
+ </span>
189
+ )}
190
+ </List.Item>
191
+ );
192
+ })}
154
193
 
155
- <div className="info-wrapper">
156
- <div className="info-content">
157
- <div className="info-title">More Information for {title?.raw}.</div>
158
- <p>{description?.raw}</p>
159
- </div>
160
- </div>
194
+ {dataset.link
195
+ .filter((i) => i.protocol === 'WWW:LINK')
196
+ .map((item, i) => {
197
+ return (
198
+ <List.Item>
199
+ <List.Content>
200
+ <div className="dataset-item">
201
+ <Icon className="download" />
202
+ {item.name ? (
203
+ <a
204
+ href={item.url}
205
+ className="item-link"
206
+ >
207
+ {item.name}
208
+ </a>
209
+ ) : (
210
+ <a
211
+ href={item.url}
212
+ className="item-link"
213
+ >
214
+ Download link
215
+ </a>
216
+ )}
217
+ </div>
218
+ </List.Content>
219
+ </List.Item>
220
+ );
221
+ })}
161
222
 
162
- {children && children.length > 0 && (
163
- <div className="related-wrapper">
164
- <h2>Related content</h2>
165
- <Card.Group itemsPerRow={4}>
166
- {children.map((item, index) => {
167
- return (
168
- <Card
169
- href={`/datahub/view/${item.metadataIdentifier}`}
170
- key={index}
171
- >
172
- <Image src={item.overview[0].url} wrapped ui={false} />
173
- <Card.Content>
174
- <Card.Description>
175
- {item.resourceTitleObject.default}
176
- </Card.Description>
177
- </Card.Content>
178
- </Card>
179
- );
180
- })}
181
- </Card.Group>
182
- </div>
183
- )}
223
+ {dataset.link
224
+ .filter(
225
+ (i) =>
226
+ i.protocol === 'EEA:FILEPATH' ||
227
+ i.protocol === 'EEA:FOLDERPATH',
228
+ )
229
+ .map((item, i) => {
230
+ return (
231
+ <List.Item>
232
+ <List.Content>
233
+ <div className="dataset-item">
234
+ <Icon className="download" />
235
+ <a href={item.url} className="item-link">
236
+ WebDAV: {item.name || item.function}
237
+ </a>
238
+ </div>
239
+ </List.Content>
240
+ </List.Item>
241
+ );
242
+ })}
184
243
 
185
- <div className="below-content-wrapper">
186
- <Accordion exclusive={false}>
187
- <Accordion.Title
188
- active={activeIndex.includes(0)}
189
- index={0}
190
- onClick={toggleOpenAccordion}
191
- >
192
- Metadata
193
- <Icon className="ri-arrow-down-s-line" />
194
- </Accordion.Title>
195
- <Accordion.Content active={activeIndex.includes(0)}>
196
- {!!item?.rod && (
197
- <div>
198
- Reporting obligations (ROD):
199
- <ul>
200
- {Array.isArray(item.rod?.raw) ? (
201
- <>
202
- {item?.rod?.raw.map((item, i) => {
203
- return <li key={i}>{item}</li>;
204
- })}
205
- </>
206
- ) : (
207
- <li>{item.rod?.raw}</li>
208
- )}
209
- </ul>
210
- </div>
211
- )}
244
+ {dataset.link
245
+ .filter(
246
+ (i) =>
247
+ i.protocol === 'ESRI:REST' ||
248
+ i.protocol === 'OGC:WMS',
249
+ )
250
+ .map((item, i) => {
251
+ return (
252
+ <List.Item>
253
+ <List.Content>
254
+ <SVGIcon name={servicesSVG} size="19" />{' '}
255
+ {(item.name || item.description) && (
256
+ <span className="item-protocol">
257
+ {item.protocol}:
258
+ </span>
259
+ )}
260
+ <a className="item-link" href={item.url}>
261
+ {item.name ||
262
+ item.description ||
263
+ item.protocol}
264
+ </a>
265
+ </List.Content>
266
+ </List.Item>
267
+ );
268
+ })}
212
269
 
213
- {!!item?.organisation && (
214
- <div>
215
- Organisation:
216
- <ul>
217
- {Array.isArray(item?.organisation?.raw) ? (
218
- <>
219
- {item?.organisation?.raw.map((item, i) => {
220
- return <li key={i}>{item}</li>;
221
- })}
222
- </>
223
- ) : (
224
- <li>{item?.organisation?.raw}</li>
225
- )}
226
- </ul>
227
- </div>
228
- )}
229
- </Accordion.Content>
230
-
231
- <Accordion.Title
232
- active={activeIndex.includes(1)}
233
- index={1}
234
- onClick={toggleOpenAccordion}
235
- >
236
- Permalinks
237
- <Icon className="ri-arrow-down-s-line" />
238
- </Accordion.Title>
239
- <Accordion.Content active={activeIndex.includes(1)}>
240
- [No data]
241
- </Accordion.Content>
270
+ {dataset.link
271
+ .filter((i) => i.protocol.includes('WWW:LINK'))
272
+ .map((item, i) => {
273
+ return (
274
+ <List.Item>
275
+ <List.Content>
276
+ <div className="dataset-item">
277
+ <Icon className="linkify" />
278
+ <a href={item.url} className="item-link">
279
+ <span>{item.name || item.url}</span>
280
+ </a>
281
+ </div>
282
+ </List.Content>
283
+ {item.description && (
284
+ <span className="item-description">
285
+ {item.description}
286
+ </span>
287
+ )}
288
+ </List.Item>
289
+ );
290
+ })}
242
291
 
243
- <Accordion.Title
244
- active={activeIndex.includes(2)}
245
- index={2}
246
- onClick={toggleOpenAccordion}
247
- >
248
- Geographic coverage
249
- <Icon className="ri-arrow-down-s-line" />
250
- </Accordion.Title>
251
- <Accordion.Content active={activeIndex.includes(2)}>
252
- {item.spatial && (
253
- <div className="geotags">
254
- {Array.isArray(item?.spatial?.raw) ? (
255
- <>
256
- {item?.spatial?.raw.map((item, i) => {
257
- return <span key={i}>{item}</span>;
258
- })}
292
+ {dataset.resourceType[0] !==
293
+ 'nonGeographicDataset' && (
294
+ <List.Item>
295
+ <List.Content>
296
+ <div className="dataset-item">
297
+ <Icon className="file pdf" />
298
+ <a
299
+ className="item-link"
300
+ target="_blank"
301
+ rel="noreferrer"
302
+ href={`https://sdi.eea.europa.eu/catalogue/srv/api/records/${dataset.metadataIdentifier}/formatters/xsl-view?output=pdf&language=eng&approved=true`}
303
+ >
304
+ PDF Factsheet
305
+ </a>
306
+ </div>
307
+ </List.Content>
308
+ </List.Item>
309
+ )}
310
+ </List>
311
+ ) : (
312
+ ''
313
+ )}
314
+ </Accordion.Content>
259
315
  </>
260
- ) : (
261
- <span>{item?.spatial?.raw}</span>
262
- )}
263
- </div>
264
- )}
265
- </Accordion.Content>
266
-
267
- <Accordion.Title
268
- active={activeIndex.includes(3)}
269
- index={3}
270
- onClick={toggleOpenAccordion}
271
- >
272
- Temporal coverage
273
- <Icon className="ri-arrow-down-s-line" />
274
- </Accordion.Title>
275
- <Accordion.Content active={activeIndex.includes(3)}>
276
- {/*<ul>
277
- {resourceTemporalDateRange?.map((temp, i) => {
278
- return (
279
- <li key={i}>
280
- <DateTime format="DATE_MED" value={temp.gte} /> -
281
- <DateTime format="DATE_MED" value={temp.lte} />
282
- </li>
283
316
  );
284
317
  })}
285
- </ul>*/}
286
- {time_coverage?.raw.length > 0 && (
287
- <div className="temporal-coverage">
288
- <div className="side-temp">{`${startTempCoverage - 1}`}</div>
289
- <div className="time-range">
290
- <span>{startTempCoverage}</span> -
291
- <span>{endTempCoverage}</span>
292
- </div>
293
- <div className="side-temp">{`${endTempCoverage + 1}`}</div>
294
- </div>
295
- )}
296
- </Accordion.Content>
297
-
298
- <Accordion.Title
299
- active={activeIndex.includes(4)}
300
- index={4}
301
- onClick={toggleOpenAccordion}
302
- >
303
- Topics
304
- <Icon className="ri-arrow-down-s-line" />
305
- </Accordion.Title>
306
- <Accordion.Content active={activeIndex.includes(4)}>
307
- {item.topic && (
308
- <>
309
- {Array.isArray(item?.topic?.raw) ? (
310
- <>
311
- {item?.topic?.raw.map((item, i) => {
312
- return (
313
- <span className="tag-item" key={i}>
314
- {item}
315
- </span>
316
- );
317
- })}
318
- </>
319
- ) : (
320
- <span className="tag-item">{item?.topic?.raw}</span>
321
- )}
322
- </>
323
- )}
324
- </Accordion.Content>
318
+ </Accordion>
319
+ </>
320
+ )}
325
321
 
326
- <Accordion.Title
327
- active={activeIndex.includes(5)}
328
- index={5}
329
- onClick={toggleOpenAccordion}
330
- >
331
- Tags
332
- <Icon className="ri-arrow-down-s-line" />
333
- </Accordion.Title>
334
- <Accordion.Content active={activeIndex.includes(5)}>
335
- <div className="dataset-tags">
336
- {raw_value?.raw['allKeywords.th_EEAkeywordlist.keywords']?.map(
337
- (tag, i) => {
338
- return (
339
- <span className="tag-item" key={i}>
340
- {tag.default}
341
- </span>
342
- );
343
- },
322
+ {(item?.rod || item?.organisation || time_coverage?.raw.length > 0) && (
323
+ <h2>SDI Metadata Catalogue</h2>
324
+ )}
325
+ {!!item?.rod && (
326
+ <div>
327
+ <h5>Reporting obligations (ROD)</h5>
328
+ <ul>
329
+ {Array.isArray(item.rod?.raw) ? (
330
+ <>
331
+ {item?.rod?.raw.map((item, i) => {
332
+ return <li key={i}>{item}</li>;
333
+ })}
334
+ </>
335
+ ) : (
336
+ <li>{item.rod?.raw}</li>
344
337
  )}
345
- </div>
346
- </Accordion.Content>
347
- </Accordion>
338
+ </ul>
339
+ </div>
340
+ )}
341
+ {!!item?.organisation && (
342
+ <div>
343
+ <h5>Organisation</h5>
344
+ <ul>
345
+ {Array.isArray(item?.organisation?.raw) ? (
346
+ <>
347
+ {item?.organisation?.raw.map((item, i) => {
348
+ return <li key={i}>{item}</li>;
349
+ })}
350
+ </>
351
+ ) : (
352
+ <li>{item?.organisation?.raw}</li>
353
+ )}
354
+ </ul>
355
+ </div>
356
+ )}
357
+ {time_coverage?.raw && time_coverage?.raw.length > 0 && (
358
+ <>
359
+ <h5>Temporal coverage</h5>
360
+ {Array.isArray(time_coverage?.raw) ? (
361
+ <span>
362
+ {startTempCoverage} - {endTempCoverage}
363
+ </span>
364
+ ) : (
365
+ <span>{time_coverage?.raw}</span>
366
+ )}
367
+ </>
368
+ )}
348
369
  </div>
370
+
371
+ {/* <div className="info-wrapper">
372
+ <div className="info-content">
373
+ <div className="info-title">More Information for {title?.raw}.</div>
374
+ <p>{description?.raw}</p>
375
+ </div>
376
+ </div> */}
349
377
  </div>
350
378
  ) : null;
351
379
  }