@eeacms/volto-datahub 1.0.17 → 1.0.19
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 +17 -0
- package/package.json +1 -1
- package/src/components/ItemView/Datasets/DatasetItemDownloadList.jsx +227 -0
- package/src/components/ItemView/Datasets/DatasetItemsList.jsx +134 -0
- package/src/components/ItemView/Datasets/DatasetsTab.jsx +51 -0
- package/src/components/ItemView/Datasets/DatasetsView.jsx +95 -0
- package/src/components/ItemView/ItemView.jsx +3 -3
- package/src/components/ItemView/index.js +1 -1
- package/src/components/ItemView/utils.js +45 -0
- package/src/express-middleware.js +89 -0
- package/src/index.js +10 -0
- package/src/components/ItemView/Datasets.jsx +0 -452
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@ 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.19](https://github.com/eea/volto-datahub/compare/1.0.18...1.0.19) - 14 March 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Fix case when there are no datasets [kreafox - [`20c58dc`](https://github.com/eea/volto-datahub/commit/20c58dcd270a020e1d5c1a4809e8cd7e0169f276)]
|
|
12
|
+
- Merge from develop [Zoltan Szabo - [`3478d37`](https://github.com/eea/volto-datahub/commit/3478d3795f14f16d322f6fcd9a948b46f0e25917)]
|
|
13
|
+
- removed duplicated formats [Zoltan Szabo - [`eefe941`](https://github.com/eea/volto-datahub/commit/eefe94178f1976aca7ad57ecbdcecf004fbc24ec)]
|
|
14
|
+
- Make multiple dataset tabs work [kreafox - [`7762336`](https://github.com/eea/volto-datahub/commit/7762336fb6ee50349879e693218bb58d295ff1e8)]
|
|
15
|
+
- remove duplicated formats [Zoltan Szabo - [`675a203`](https://github.com/eea/volto-datahub/commit/675a203c86baea3dd4344d28672b2fb336478a44)]
|
|
16
|
+
- WIP [Zoltan Szabo - [`56660f9`](https://github.com/eea/volto-datahub/commit/56660f96545216491c0eb604852bc87d13c6b22d)]
|
|
17
|
+
### [1.0.18](https://github.com/eea/volto-datahub/compare/1.0.17...1.0.18) - 13 March 2023
|
|
18
|
+
|
|
19
|
+
#### :hammer_and_wrench: Others
|
|
20
|
+
|
|
21
|
+
- lint [Zoltan Szabo - [`3d9c842`](https://github.com/eea/volto-datahub/commit/3d9c8428fac3aa66cba164639926745b81434b52)]
|
|
22
|
+
- Remove console.logs [Zoltan Szabo - [`09e19bf`](https://github.com/eea/volto-datahub/commit/09e19bf7656b3a11c5f967b0ff45d05ca8b3bcd5)]
|
|
23
|
+
- set lastmod in sitemap [Zoltan Szabo - [`bb2819c`](https://github.com/eea/volto-datahub/commit/bb2819c41eed63a23532cba01eeedd7c3f8b7217)]
|
|
7
24
|
### [1.0.17](https://github.com/eea/volto-datahub/compare/1.0.16...1.0.17) - 10 March 2023
|
|
8
25
|
|
|
9
26
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, List } from 'semantic-ui-react';
|
|
3
|
+
import { isInternalURL, groupBy, SVGIcon } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
import servicesSVG from '../icons/services.svg';
|
|
6
|
+
import lockSVG from 'remixicon/icons/System/lock-line.svg';
|
|
7
|
+
|
|
8
|
+
const DatasetItemDownloadList = (props) => {
|
|
9
|
+
const { link } = props;
|
|
10
|
+
const dataset = groupBy(link, 'protocol');
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div>
|
|
14
|
+
{(dataset['WWW:URL'] ||
|
|
15
|
+
dataset['WWW:LINK'] ||
|
|
16
|
+
dataset['EEA:FILEPATH'] ||
|
|
17
|
+
dataset['EEA:FOLDERPATH']) && (
|
|
18
|
+
<>
|
|
19
|
+
<h5>Download:</h5>
|
|
20
|
+
<List divided relaxed>
|
|
21
|
+
{(dataset['WWW:URL'] || []).map((item, i) => {
|
|
22
|
+
return (
|
|
23
|
+
<List.Item key={i}>
|
|
24
|
+
<List.Content>
|
|
25
|
+
<div className="dataset-item">
|
|
26
|
+
<Icon className="download" />
|
|
27
|
+
<a
|
|
28
|
+
href={item.url}
|
|
29
|
+
className="item-link"
|
|
30
|
+
target="_blank"
|
|
31
|
+
rel="noreferrer"
|
|
32
|
+
>
|
|
33
|
+
<span>{item.name}</span>
|
|
34
|
+
</a>
|
|
35
|
+
{isInternalURL(item.url) && (
|
|
36
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
</List.Content>
|
|
40
|
+
{item.description && (
|
|
41
|
+
<span className="item-description" title={item.description}>
|
|
42
|
+
{item.description}
|
|
43
|
+
</span>
|
|
44
|
+
)}
|
|
45
|
+
</List.Item>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
|
|
49
|
+
{(dataset['WWW:LINK'] || []).map((item, i) => {
|
|
50
|
+
return (
|
|
51
|
+
<List.Item key={i}>
|
|
52
|
+
<List.Content>
|
|
53
|
+
<div className="dataset-item">
|
|
54
|
+
<Icon className="download" />
|
|
55
|
+
{item.name ? (
|
|
56
|
+
<a
|
|
57
|
+
href={item.url}
|
|
58
|
+
className="item-link"
|
|
59
|
+
target="_blank"
|
|
60
|
+
rel="noreferrer"
|
|
61
|
+
>
|
|
62
|
+
{item.name}
|
|
63
|
+
</a>
|
|
64
|
+
) : (
|
|
65
|
+
<a
|
|
66
|
+
href={item.url}
|
|
67
|
+
className="item-link"
|
|
68
|
+
target="_blank"
|
|
69
|
+
rel="noreferrer"
|
|
70
|
+
>
|
|
71
|
+
Download link
|
|
72
|
+
</a>
|
|
73
|
+
)}
|
|
74
|
+
{isInternalURL(item.url) && (
|
|
75
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
</List.Content>
|
|
79
|
+
</List.Item>
|
|
80
|
+
);
|
|
81
|
+
})}
|
|
82
|
+
|
|
83
|
+
{(dataset['EEA:FILEPATH'] || []).map((item, i) => {
|
|
84
|
+
return (
|
|
85
|
+
<List.Item key={i}>
|
|
86
|
+
<List.Content>
|
|
87
|
+
<div className="dataset-item">
|
|
88
|
+
<Icon className="download" />
|
|
89
|
+
<a
|
|
90
|
+
href={item.url}
|
|
91
|
+
className="item-link"
|
|
92
|
+
target="_blank"
|
|
93
|
+
rel="noreferrer"
|
|
94
|
+
>
|
|
95
|
+
WebDAV: {item.name || item.function}
|
|
96
|
+
</a>
|
|
97
|
+
{isInternalURL(item.url) && (
|
|
98
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
</List.Content>
|
|
102
|
+
</List.Item>
|
|
103
|
+
);
|
|
104
|
+
})}
|
|
105
|
+
|
|
106
|
+
{(dataset['EEA:FOLDERPATH'] || []).map((item, i) => {
|
|
107
|
+
return (
|
|
108
|
+
<List.Item key={i}>
|
|
109
|
+
<List.Content>
|
|
110
|
+
<div className="dataset-item">
|
|
111
|
+
<Icon className="download" />
|
|
112
|
+
<a
|
|
113
|
+
href={item.url}
|
|
114
|
+
className="item-link"
|
|
115
|
+
target="_blank"
|
|
116
|
+
rel="noreferrer"
|
|
117
|
+
>
|
|
118
|
+
WebDAV: {item.name || item.function}
|
|
119
|
+
</a>
|
|
120
|
+
{isInternalURL(item.url) && (
|
|
121
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
122
|
+
)}
|
|
123
|
+
</div>
|
|
124
|
+
</List.Content>
|
|
125
|
+
</List.Item>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</List>
|
|
129
|
+
</>
|
|
130
|
+
)}
|
|
131
|
+
|
|
132
|
+
{(dataset['ESRI:REST'] || dataset['OGC:WMS']) && (
|
|
133
|
+
<>
|
|
134
|
+
<h5>Services:</h5>
|
|
135
|
+
<List divided relaxed>
|
|
136
|
+
{(dataset['ESRI:REST'] || []).map((item, i) => {
|
|
137
|
+
return (
|
|
138
|
+
<List.Item key={i}>
|
|
139
|
+
<List.Content>
|
|
140
|
+
<div>
|
|
141
|
+
<SVGIcon name={servicesSVG} size="18" />
|
|
142
|
+
{/* {(item.name || item.description) && (
|
|
143
|
+
<span className="item-protocol">{item.protocol}:</span>
|
|
144
|
+
)} */}
|
|
145
|
+
<a
|
|
146
|
+
className="item-link"
|
|
147
|
+
href={item.url}
|
|
148
|
+
target="_blank"
|
|
149
|
+
rel="noreferrer"
|
|
150
|
+
>
|
|
151
|
+
{item.protocol} {item.name || item.description}
|
|
152
|
+
</a>
|
|
153
|
+
{isInternalURL(item.url) && (
|
|
154
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
</List.Content>
|
|
158
|
+
</List.Item>
|
|
159
|
+
);
|
|
160
|
+
})}
|
|
161
|
+
|
|
162
|
+
{(dataset['OGC:WMS'] || []).map((item, i) => {
|
|
163
|
+
return (
|
|
164
|
+
<List.Item key={i}>
|
|
165
|
+
<List.Content>
|
|
166
|
+
<div>
|
|
167
|
+
<SVGIcon name={servicesSVG} size="18" />
|
|
168
|
+
{/* {(item.name || item.description) && (
|
|
169
|
+
<span className="item-protocol">{item.protocol}:</span>
|
|
170
|
+
)} */}
|
|
171
|
+
<a
|
|
172
|
+
className="item-link"
|
|
173
|
+
href={item.url}
|
|
174
|
+
target="_blank"
|
|
175
|
+
rel="noreferrer"
|
|
176
|
+
>
|
|
177
|
+
{item.protocol} {item.name || item.description}
|
|
178
|
+
</a>
|
|
179
|
+
{isInternalURL(item.url) && (
|
|
180
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
</List.Content>
|
|
184
|
+
</List.Item>
|
|
185
|
+
);
|
|
186
|
+
})}
|
|
187
|
+
</List>
|
|
188
|
+
</>
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
{dataset['WWW:LINK-1.0-http--link'] && (
|
|
192
|
+
<>
|
|
193
|
+
<h5>Links:</h5>
|
|
194
|
+
<List divided relaxed>
|
|
195
|
+
{(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) => {
|
|
196
|
+
return (
|
|
197
|
+
<List.Item key={i}>
|
|
198
|
+
<List.Content>
|
|
199
|
+
<div className="dataset-item">
|
|
200
|
+
<Icon className="linkify" />
|
|
201
|
+
<a
|
|
202
|
+
href={item.url}
|
|
203
|
+
className="item-link"
|
|
204
|
+
target="_blank"
|
|
205
|
+
rel="noreferrer"
|
|
206
|
+
>
|
|
207
|
+
<span>{item.name || item.url}</span>
|
|
208
|
+
</a>
|
|
209
|
+
{isInternalURL(item.url) && (
|
|
210
|
+
<SVGIcon name={lockSVG} size="18" />
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
</List.Content>
|
|
214
|
+
{item.description && (
|
|
215
|
+
<span className="item-description">{item.description}</span>
|
|
216
|
+
)}
|
|
217
|
+
</List.Item>
|
|
218
|
+
);
|
|
219
|
+
})}
|
|
220
|
+
</List>
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export default DatasetItemDownloadList;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Accordion } from 'semantic-ui-react';
|
|
3
|
+
import { Icon } from 'semantic-ui-react';
|
|
4
|
+
import { DateTime } from '@eeacms/search';
|
|
5
|
+
import { isInternal, SVGIcon } from '../utils.js';
|
|
6
|
+
import DatasetItemDownloadList from './DatasetItemDownloadList';
|
|
7
|
+
|
|
8
|
+
import lockSVG from 'remixicon/icons/System/lock-line.svg';
|
|
9
|
+
|
|
10
|
+
const DatasetItemsList = (props) => {
|
|
11
|
+
const { appConfig, item, setActiveTabIndex, activeTabIndex } = props;
|
|
12
|
+
|
|
13
|
+
const [activeIndex, setActiveIndex] = React.useState(activeTabIndex);
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
setActiveIndex(activeTabIndex);
|
|
17
|
+
}, [activeTabIndex]);
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
setActiveTabIndex(activeIndex);
|
|
21
|
+
}, [activeIndex, setActiveTabIndex]);
|
|
22
|
+
|
|
23
|
+
function handleClick(e, titleProps) {
|
|
24
|
+
const { index } = titleProps;
|
|
25
|
+
const newIndex = activeIndex === index ? -1 : index;
|
|
26
|
+
setActiveIndex(newIndex);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Accordion>
|
|
31
|
+
{item?.children.map((dataset, index) => {
|
|
32
|
+
const {
|
|
33
|
+
resourceTemporalExtentDetails,
|
|
34
|
+
temporalDateRange,
|
|
35
|
+
publicationDateForResource,
|
|
36
|
+
} = dataset;
|
|
37
|
+
return (
|
|
38
|
+
<React.Fragment key={index}>
|
|
39
|
+
<Accordion.Title
|
|
40
|
+
active={activeIndex === index}
|
|
41
|
+
index={index}
|
|
42
|
+
onClick={handleClick}
|
|
43
|
+
>
|
|
44
|
+
<span className="dataset-title">
|
|
45
|
+
{dataset.resourceTitleObject.default}
|
|
46
|
+
<span className="formats">
|
|
47
|
+
{(dataset.format || [])
|
|
48
|
+
.filter((item, pos, self) => self.indexOf(item) === pos)
|
|
49
|
+
.map((item, i) => {
|
|
50
|
+
return (
|
|
51
|
+
<span className="format-label" key={i}>
|
|
52
|
+
{item}
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
})}
|
|
56
|
+
|
|
57
|
+
{Array.isArray(dataset.linkProtocol) ? (
|
|
58
|
+
<>
|
|
59
|
+
{dataset.linkProtocol
|
|
60
|
+
.filter((i) => i.includes('ESRI') || i.includes('OGC'))
|
|
61
|
+
.filter((item, pos, self) => self.indexOf(item) === pos)
|
|
62
|
+
.map((item, i) => {
|
|
63
|
+
return (
|
|
64
|
+
<span className="format-label" key={i}>
|
|
65
|
+
{item}
|
|
66
|
+
</span>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
</>
|
|
70
|
+
) : (
|
|
71
|
+
<>
|
|
72
|
+
{['ESRI', 'OGC'].includes(dataset.linkProtocol) && (
|
|
73
|
+
<span className="format-label">
|
|
74
|
+
{dataset.linkProtocol}
|
|
75
|
+
</span>
|
|
76
|
+
)}
|
|
77
|
+
</>
|
|
78
|
+
)}
|
|
79
|
+
</span>
|
|
80
|
+
|
|
81
|
+
{isInternal(dataset) && <SVGIcon name={lockSVG} size="18" />}
|
|
82
|
+
</span>
|
|
83
|
+
<Icon className="ri-arrow-down-s-line" />
|
|
84
|
+
</Accordion.Title>
|
|
85
|
+
<Accordion.Content active={activeIndex === index}>
|
|
86
|
+
<div className="dataset-content">
|
|
87
|
+
<div>
|
|
88
|
+
{publicationDateForResource && (
|
|
89
|
+
<div>
|
|
90
|
+
<strong>Published: </strong>
|
|
91
|
+
<DateTime
|
|
92
|
+
format="DATE_MED"
|
|
93
|
+
value={publicationDateForResource}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
{resourceTemporalExtentDetails &&
|
|
99
|
+
resourceTemporalExtentDetails?.length > 0 && (
|
|
100
|
+
<div>
|
|
101
|
+
<strong>Temporal coverage: </strong>
|
|
102
|
+
{temporalDateRange}
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
{dataset.resourceType[0] !== 'nonGeographicDataset' && (
|
|
108
|
+
<div className="dataset-pdf">
|
|
109
|
+
<div className="d-link">
|
|
110
|
+
<Icon className="file pdf" />
|
|
111
|
+
<a
|
|
112
|
+
target="_blank"
|
|
113
|
+
rel="noreferrer"
|
|
114
|
+
href={`${appConfig.indexBaseUrl}/catalogue/datahub/api/records/${dataset.metadataIdentifier}/formatters/xsl-view?output=pdf&language=eng&approved=true`}
|
|
115
|
+
>
|
|
116
|
+
Metadata Factsheet
|
|
117
|
+
</a>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
)}
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
{!!dataset.link && dataset.link.length > 0 && (
|
|
124
|
+
<DatasetItemDownloadList link={dataset.link} />
|
|
125
|
+
)}
|
|
126
|
+
</Accordion.Content>
|
|
127
|
+
</React.Fragment>
|
|
128
|
+
);
|
|
129
|
+
})}
|
|
130
|
+
</Accordion>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default DatasetItemsList;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tab, Menu } from 'semantic-ui-react';
|
|
3
|
+
|
|
4
|
+
import DatasetItemsList from './DatasetItemsList';
|
|
5
|
+
|
|
6
|
+
const DatasetsTab = (props) => {
|
|
7
|
+
const { items, appConfig, defaultAccordionOpenIndex } = props;
|
|
8
|
+
|
|
9
|
+
const [activeAccordionIndex, setActiveAccordionIndex] = React.useState(
|
|
10
|
+
defaultAccordionOpenIndex,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (defaultAccordionOpenIndex !== undefined) {
|
|
15
|
+
setActiveAccordionIndex(defaultAccordionOpenIndex);
|
|
16
|
+
} else {
|
|
17
|
+
setActiveAccordionIndex(-1);
|
|
18
|
+
}
|
|
19
|
+
}, [defaultAccordionOpenIndex]);
|
|
20
|
+
|
|
21
|
+
const panes = (items || []).map((item, i) => ({
|
|
22
|
+
menuItem: (
|
|
23
|
+
<Menu.Item key={i}>
|
|
24
|
+
{item.date ? <span>{item.date}</span> : 'No date'}
|
|
25
|
+
</Menu.Item>
|
|
26
|
+
),
|
|
27
|
+
render: () => (
|
|
28
|
+
<Tab.Pane>
|
|
29
|
+
<DatasetItemsList
|
|
30
|
+
appConfig={appConfig}
|
|
31
|
+
item={item}
|
|
32
|
+
activeTabIndex={activeAccordionIndex}
|
|
33
|
+
setActiveTabIndex={setActiveAccordionIndex}
|
|
34
|
+
/>
|
|
35
|
+
</Tab.Pane>
|
|
36
|
+
),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Tab
|
|
41
|
+
className="datasets-tab"
|
|
42
|
+
menu={{ vertical: true, secondary: true, pointing: true }}
|
|
43
|
+
panes={panes}
|
|
44
|
+
onTabChange={() => {
|
|
45
|
+
setActiveAccordionIndex(0);
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default DatasetsTab;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isObsolete, isInternal, groupBy } from '../utils.js';
|
|
3
|
+
import DatasetsTab from './DatasetsTab';
|
|
4
|
+
|
|
5
|
+
const DatasetsView = (props) => {
|
|
6
|
+
const { item, appConfig } = props;
|
|
7
|
+
const { children } = item?.raw_value?.raw || {};
|
|
8
|
+
|
|
9
|
+
const all_datasets = children.map((v, e) => {
|
|
10
|
+
let date;
|
|
11
|
+
if (v.resourceTemporalExtentDetails) {
|
|
12
|
+
const tc = v.resourceTemporalExtentDetails[0];
|
|
13
|
+
const { start, end } = tc || {};
|
|
14
|
+
const tc_start = start?.date
|
|
15
|
+
? new Date(Date.parse(start.date)).getFullYear()
|
|
16
|
+
: '';
|
|
17
|
+
const tc_end = end?.date
|
|
18
|
+
? new Date(Date.parse(end.date)).getFullYear()
|
|
19
|
+
: '';
|
|
20
|
+
if (tc_start === tc_end) {
|
|
21
|
+
date = tc_start;
|
|
22
|
+
} else {
|
|
23
|
+
date = tc_start + '-' + tc_end;
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
date = '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Object.assign({ temporalDateRange: date, ...v }, e);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const datasets = all_datasets.filter((v) => {
|
|
33
|
+
return !(isObsolete(v.cl_status) || isInternal(v));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const archivedOrRestrictedDatasets = all_datasets.filter((v) => {
|
|
37
|
+
return isObsolete(v.cl_status) || isInternal(v);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const groupDatasets = (items) => {
|
|
41
|
+
const datasetsByCoverage = groupBy(items, 'temporalDateRange');
|
|
42
|
+
|
|
43
|
+
const sortedDatasets = Object.keys(datasetsByCoverage).sort(function (
|
|
44
|
+
a,
|
|
45
|
+
b,
|
|
46
|
+
) {
|
|
47
|
+
a = Math.max(...a.split('-'));
|
|
48
|
+
b = Math.max(...b.split('-'));
|
|
49
|
+
return b - a;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const groupedDatasets = sortedDatasets.map((v) => {
|
|
53
|
+
return { date: v, children: datasetsByCoverage[v] };
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return groupedDatasets;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const groupedByTemporalCoverage = groupDatasets(datasets);
|
|
60
|
+
const groupedByArchivedOrRestricted = groupDatasets(
|
|
61
|
+
archivedOrRestrictedDatasets,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
{groupedByTemporalCoverage && groupedByTemporalCoverage.length > 0 && (
|
|
67
|
+
<>
|
|
68
|
+
<div className="dataset-container">
|
|
69
|
+
<h2>Datasets</h2>
|
|
70
|
+
</div>
|
|
71
|
+
<DatasetsTab
|
|
72
|
+
appConfig={appConfig}
|
|
73
|
+
items={groupedByTemporalCoverage}
|
|
74
|
+
defaultAccordionOpenIndex={0}
|
|
75
|
+
/>
|
|
76
|
+
</>
|
|
77
|
+
)}
|
|
78
|
+
|
|
79
|
+
{groupedByArchivedOrRestricted &&
|
|
80
|
+
groupedByArchivedOrRestricted.length > 0 && (
|
|
81
|
+
<>
|
|
82
|
+
<div className="dataset-container">
|
|
83
|
+
<h2>Archived or restricted datasets</h2>
|
|
84
|
+
</div>
|
|
85
|
+
<DatasetsTab
|
|
86
|
+
appConfig={appConfig}
|
|
87
|
+
items={groupedByArchivedOrRestricted}
|
|
88
|
+
/>
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default DatasetsView;
|
|
@@ -11,7 +11,7 @@ import { Callout, Banner } from '@eeacms/volto-eea-design-system/ui';
|
|
|
11
11
|
import {
|
|
12
12
|
MoreLikeThis,
|
|
13
13
|
MetadataSection,
|
|
14
|
-
|
|
14
|
+
DatasetsView,
|
|
15
15
|
} from '@eeacms/volto-datahub/components/ItemView';
|
|
16
16
|
|
|
17
17
|
import { asyncConnect, Helmet } from '@plone/volto/helpers';
|
|
@@ -116,7 +116,7 @@ function ItemView(props) {
|
|
|
116
116
|
</Banner.Subtitle>
|
|
117
117
|
<Banner.Title>{title?.raw}</Banner.Title>
|
|
118
118
|
<Banner.Metadata>
|
|
119
|
-
{obsolete && <div class="ui label archived-item">
|
|
119
|
+
{obsolete && <div class="ui label archived-item">Archived</div>}
|
|
120
120
|
<Banner.MetadataField label="Prod-ID" value={prodID} />
|
|
121
121
|
<Banner.MetadataField
|
|
122
122
|
label="Published"
|
|
@@ -142,7 +142,7 @@ function ItemView(props) {
|
|
|
142
142
|
<Callout>{description?.raw}</Callout>
|
|
143
143
|
</div>
|
|
144
144
|
|
|
145
|
-
<
|
|
145
|
+
<DatasetsView item={item} appConfig={appConfig} />
|
|
146
146
|
|
|
147
147
|
<MetadataSection item={item} appConfig={appConfig} docid={docid} />
|
|
148
148
|
|
|
@@ -17,3 +17,48 @@ export const isObsolete = (status) => {
|
|
|
17
17
|
}
|
|
18
18
|
return obsolete;
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
export const isInternalURL = (url) => {
|
|
22
|
+
let internal = false;
|
|
23
|
+
url.split('/').forEach((part) => {
|
|
24
|
+
if (part.split('_')[6] === 'i') {
|
|
25
|
+
internal = true;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return internal;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const isInternal = (item) => {
|
|
32
|
+
let internal = false;
|
|
33
|
+
const links = item?.link || [];
|
|
34
|
+
links.forEach((link) => {
|
|
35
|
+
if (isInternalURL(link?.url)) {
|
|
36
|
+
internal = true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return internal;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const groupBy = (obj, key) => {
|
|
43
|
+
return obj.reduce((rv, item) => {
|
|
44
|
+
const group = rv[item[key]] || [];
|
|
45
|
+
group.push(item);
|
|
46
|
+
rv[item[key]] = group;
|
|
47
|
+
return rv;
|
|
48
|
+
}, {});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const SVGIcon = ({ name, size, color, className, title, onClick }) => {
|
|
52
|
+
return (
|
|
53
|
+
<svg
|
|
54
|
+
xmlns={name.attributes && name.attributes.xmlns}
|
|
55
|
+
viewBox={name.attributes && name.attributes.viewBox}
|
|
56
|
+
style={{ height: size, width: 'auto', fill: color || 'currentColor' }}
|
|
57
|
+
className={className ? `icon ${className}` : 'icon'}
|
|
58
|
+
onClick={onClick}
|
|
59
|
+
dangerouslySetInnerHTML={{
|
|
60
|
+
__html: title ? `<title>${title}</title>${name.content}` : name.content,
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { registry } from '@eeacms/search';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import buildRequest from '@eeacms/search/lib/search/query';
|
|
4
|
+
import superagent from 'superagent';
|
|
5
|
+
// import zlib from 'zlib';
|
|
6
|
+
|
|
7
|
+
const getUrlES = (appName) => {
|
|
8
|
+
return (
|
|
9
|
+
process.env[`RAZZLE_PROXY_ES_DSN_${appName}`] ||
|
|
10
|
+
process.env.RAZZLE_PROXY_ES_DSN ||
|
|
11
|
+
'http://localhost:9200/_all'
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function handleSearchRequest(body, params) {
|
|
16
|
+
const { urlES } = params;
|
|
17
|
+
const url = `${urlES}/_search`;
|
|
18
|
+
if (body?.params?.config) {
|
|
19
|
+
delete body.params.config;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
superagent
|
|
24
|
+
.post(url)
|
|
25
|
+
.send(body)
|
|
26
|
+
.set('accept', 'application/json')
|
|
27
|
+
.end((err, resp) => {
|
|
28
|
+
if (resp && resp.body) {
|
|
29
|
+
return resolve(resp.body);
|
|
30
|
+
}
|
|
31
|
+
return reject({ error: 'Error' });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function toPublicURL(id) {
|
|
37
|
+
return `https://www.eea.europa.eu/en/datahub/datahubitem-view/${id}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function generateSitemap(appConfig) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const body = buildRequest({ filters: [] }, appConfig);
|
|
43
|
+
delete body['source'];
|
|
44
|
+
delete body['params'];
|
|
45
|
+
delete body['runtime_mappings'];
|
|
46
|
+
delete body['index'];
|
|
47
|
+
body._source = { include: ['about', 'last_modified'] };
|
|
48
|
+
body.size = 10000;
|
|
49
|
+
const urlES = getUrlES('datahub');
|
|
50
|
+
handleSearchRequest(body, { urlES }).then((body) => {
|
|
51
|
+
const items = body?.hits?.hits || [];
|
|
52
|
+
|
|
53
|
+
const urls = items.map(
|
|
54
|
+
(item) => ` <url>\n <loc>${toPublicURL(item._id)}</loc>\n
|
|
55
|
+
<lastmod>${item._source.last_modified}</lastmod>\n </url>`,
|
|
56
|
+
);
|
|
57
|
+
const result = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n${urls.join(
|
|
58
|
+
'\n',
|
|
59
|
+
)}\n</urlset>`;
|
|
60
|
+
|
|
61
|
+
// zlib.gzip(Buffer.from(result, 'utf8'), (_err, buffer) => {
|
|
62
|
+
// resolve(buffer);
|
|
63
|
+
// });
|
|
64
|
+
|
|
65
|
+
resolve(result);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function sitemap(req, res, next) {
|
|
71
|
+
const appConfig = registry.searchui['datahub'];
|
|
72
|
+
|
|
73
|
+
generateSitemap(appConfig)
|
|
74
|
+
.then((body) => res.send(body))
|
|
75
|
+
.catch((body) => {
|
|
76
|
+
res.send({ error: body });
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default function makeMiddlewares(config) {
|
|
81
|
+
const middleware = express.Router();
|
|
82
|
+
// middleware.use(express.json({ limit: config.settings.maxResponseSize }));
|
|
83
|
+
middleware.use(express.urlencoded({ extended: true }));
|
|
84
|
+
|
|
85
|
+
middleware.all('**/datahub/sitemap-data.xml', sitemap);
|
|
86
|
+
middleware.id = 'datahub-sitemap';
|
|
87
|
+
|
|
88
|
+
return middleware;
|
|
89
|
+
}
|
package/src/index.js
CHANGED
|
@@ -45,6 +45,16 @@ const applyConfig = (config) => {
|
|
|
45
45
|
...(config.addonRoutes || []),
|
|
46
46
|
];
|
|
47
47
|
config.addonReducers.datahub_results = datahub_results;
|
|
48
|
+
|
|
49
|
+
if (__SERVER__) {
|
|
50
|
+
const makeMiddlewares = require('./express-middleware').default;
|
|
51
|
+
|
|
52
|
+
config.settings.expressMiddleware = [
|
|
53
|
+
...config.settings.expressMiddleware,
|
|
54
|
+
makeMiddlewares(config),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
return config;
|
|
49
59
|
};
|
|
50
60
|
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Icon, List, Accordion, Tab, Menu } from 'semantic-ui-react';
|
|
3
|
-
import { DateTime } from '@eeacms/search';
|
|
4
|
-
import servicesSVG from './icons/services.svg';
|
|
5
|
-
import lockSVG from 'remixicon/icons/System/lock-line.svg';
|
|
6
|
-
|
|
7
|
-
const is_internal_url = (url) => {
|
|
8
|
-
let internal = false;
|
|
9
|
-
url.split('/').forEach((part) => {
|
|
10
|
-
if (part.split('_')[6] === 'i') {
|
|
11
|
-
internal = true;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return internal;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const is_internal = (dataset) => {
|
|
18
|
-
let internal = false;
|
|
19
|
-
const links = dataset?.link || [];
|
|
20
|
-
links.forEach((link) => {
|
|
21
|
-
if (is_internal_url(link?.url)) {
|
|
22
|
-
internal = true;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return internal;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const groupBy = (obj, key) => {
|
|
29
|
-
return obj.reduce((rv, item) => {
|
|
30
|
-
const group = rv[item[key]] || [];
|
|
31
|
-
group.push(item);
|
|
32
|
-
rv[item[key]] = group;
|
|
33
|
-
return rv;
|
|
34
|
-
}, {});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const SVGIcon = ({ name, size, color, className, title, onClick }) => {
|
|
38
|
-
return (
|
|
39
|
-
<svg
|
|
40
|
-
xmlns={name.attributes && name.attributes.xmlns}
|
|
41
|
-
viewBox={name.attributes && name.attributes.viewBox}
|
|
42
|
-
style={{ height: size, width: 'auto', fill: color || 'currentColor' }}
|
|
43
|
-
className={className ? `icon ${className}` : 'icon'}
|
|
44
|
-
onClick={onClick}
|
|
45
|
-
dangerouslySetInnerHTML={{
|
|
46
|
-
__html: title ? `<title>${title}</title>${name.content}` : name.content,
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const DatasetList = (props) => {
|
|
53
|
-
const { link } = props;
|
|
54
|
-
const dataset = groupBy(link, 'protocol');
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div>
|
|
58
|
-
{(dataset['WWW:URL'] ||
|
|
59
|
-
dataset['WWW:LINK'] ||
|
|
60
|
-
dataset['EEA:FILEPATH'] ||
|
|
61
|
-
dataset['EEA:FOLDERPATH']) && (
|
|
62
|
-
<>
|
|
63
|
-
<h5>Download:</h5>
|
|
64
|
-
<List divided relaxed>
|
|
65
|
-
{(dataset['WWW:URL'] || []).map((item, i) => {
|
|
66
|
-
return (
|
|
67
|
-
<List.Item key={i}>
|
|
68
|
-
<List.Content>
|
|
69
|
-
<div className="dataset-item">
|
|
70
|
-
<Icon className="download" />
|
|
71
|
-
<a
|
|
72
|
-
href={item.url}
|
|
73
|
-
className="item-link"
|
|
74
|
-
target="_blank"
|
|
75
|
-
rel="noreferrer"
|
|
76
|
-
>
|
|
77
|
-
<span>{item.name}</span>
|
|
78
|
-
</a>
|
|
79
|
-
{is_internal_url(item.url) && (
|
|
80
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
81
|
-
)}
|
|
82
|
-
</div>
|
|
83
|
-
</List.Content>
|
|
84
|
-
{item.description && (
|
|
85
|
-
<span className="item-description" title={item.description}>
|
|
86
|
-
{item.description}
|
|
87
|
-
</span>
|
|
88
|
-
)}
|
|
89
|
-
</List.Item>
|
|
90
|
-
);
|
|
91
|
-
})}
|
|
92
|
-
|
|
93
|
-
{(dataset['WWW:LINK'] || []).map((item, i) => {
|
|
94
|
-
return (
|
|
95
|
-
<List.Item key={i}>
|
|
96
|
-
<List.Content>
|
|
97
|
-
<div className="dataset-item">
|
|
98
|
-
<Icon className="download" />
|
|
99
|
-
{item.name ? (
|
|
100
|
-
<a
|
|
101
|
-
href={item.url}
|
|
102
|
-
className="item-link"
|
|
103
|
-
target="_blank"
|
|
104
|
-
rel="noreferrer"
|
|
105
|
-
>
|
|
106
|
-
{item.name}
|
|
107
|
-
</a>
|
|
108
|
-
) : (
|
|
109
|
-
<a
|
|
110
|
-
href={item.url}
|
|
111
|
-
className="item-link"
|
|
112
|
-
target="_blank"
|
|
113
|
-
rel="noreferrer"
|
|
114
|
-
>
|
|
115
|
-
Download link
|
|
116
|
-
</a>
|
|
117
|
-
)}
|
|
118
|
-
{is_internal_url(item.url) && (
|
|
119
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
120
|
-
)}
|
|
121
|
-
</div>
|
|
122
|
-
</List.Content>
|
|
123
|
-
</List.Item>
|
|
124
|
-
);
|
|
125
|
-
})}
|
|
126
|
-
|
|
127
|
-
{(dataset['EEA:FILEPATH'] || []).map((item, i) => {
|
|
128
|
-
return (
|
|
129
|
-
<List.Item key={i}>
|
|
130
|
-
<List.Content>
|
|
131
|
-
<div className="dataset-item">
|
|
132
|
-
<Icon className="download" />
|
|
133
|
-
<a
|
|
134
|
-
href={item.url}
|
|
135
|
-
className="item-link"
|
|
136
|
-
target="_blank"
|
|
137
|
-
rel="noreferrer"
|
|
138
|
-
>
|
|
139
|
-
WebDAV: {item.name || item.function}
|
|
140
|
-
</a>
|
|
141
|
-
{is_internal_url(item.url) && (
|
|
142
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
143
|
-
)}
|
|
144
|
-
</div>
|
|
145
|
-
</List.Content>
|
|
146
|
-
</List.Item>
|
|
147
|
-
);
|
|
148
|
-
})}
|
|
149
|
-
|
|
150
|
-
{(dataset['EEA:FOLDERPATH'] || []).map((item, i) => {
|
|
151
|
-
return (
|
|
152
|
-
<List.Item key={i}>
|
|
153
|
-
<List.Content>
|
|
154
|
-
<div className="dataset-item">
|
|
155
|
-
<Icon className="download" />
|
|
156
|
-
<a
|
|
157
|
-
href={item.url}
|
|
158
|
-
className="item-link"
|
|
159
|
-
target="_blank"
|
|
160
|
-
rel="noreferrer"
|
|
161
|
-
>
|
|
162
|
-
WebDAV: {item.name || item.function}
|
|
163
|
-
</a>
|
|
164
|
-
{is_internal_url(item.url) && (
|
|
165
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
166
|
-
)}
|
|
167
|
-
</div>
|
|
168
|
-
</List.Content>
|
|
169
|
-
</List.Item>
|
|
170
|
-
);
|
|
171
|
-
})}
|
|
172
|
-
</List>
|
|
173
|
-
</>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
{(dataset['ESRI:REST'] || dataset['OGC:WMS']) && (
|
|
177
|
-
<>
|
|
178
|
-
<h5>Services:</h5>
|
|
179
|
-
<List divided relaxed>
|
|
180
|
-
{(dataset['ESRI:REST'] || []).map((item, i) => {
|
|
181
|
-
return (
|
|
182
|
-
<List.Item key={i}>
|
|
183
|
-
<List.Content>
|
|
184
|
-
<div>
|
|
185
|
-
<SVGIcon name={servicesSVG} size="18" />
|
|
186
|
-
{/* {(item.name || item.description) && (
|
|
187
|
-
<span className="item-protocol">{item.protocol}:</span>
|
|
188
|
-
)} */}
|
|
189
|
-
<a
|
|
190
|
-
className="item-link"
|
|
191
|
-
href={item.url}
|
|
192
|
-
target="_blank"
|
|
193
|
-
rel="noreferrer"
|
|
194
|
-
>
|
|
195
|
-
{item.protocol} {item.name || item.description}
|
|
196
|
-
</a>
|
|
197
|
-
{is_internal_url(item.url) && (
|
|
198
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
199
|
-
)}
|
|
200
|
-
</div>
|
|
201
|
-
</List.Content>
|
|
202
|
-
</List.Item>
|
|
203
|
-
);
|
|
204
|
-
})}
|
|
205
|
-
|
|
206
|
-
{(dataset['OGC:WMS'] || []).map((item, i) => {
|
|
207
|
-
return (
|
|
208
|
-
<List.Item key={i}>
|
|
209
|
-
<List.Content>
|
|
210
|
-
<div>
|
|
211
|
-
<SVGIcon name={servicesSVG} size="18" />
|
|
212
|
-
{/* {(item.name || item.description) && (
|
|
213
|
-
<span className="item-protocol">{item.protocol}:</span>
|
|
214
|
-
)} */}
|
|
215
|
-
<a
|
|
216
|
-
className="item-link"
|
|
217
|
-
href={item.url}
|
|
218
|
-
target="_blank"
|
|
219
|
-
rel="noreferrer"
|
|
220
|
-
>
|
|
221
|
-
{item.protocol} {item.name || item.description}
|
|
222
|
-
</a>
|
|
223
|
-
{is_internal_url(item.url) && (
|
|
224
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
225
|
-
)}
|
|
226
|
-
</div>
|
|
227
|
-
</List.Content>
|
|
228
|
-
</List.Item>
|
|
229
|
-
);
|
|
230
|
-
})}
|
|
231
|
-
</List>
|
|
232
|
-
</>
|
|
233
|
-
)}
|
|
234
|
-
|
|
235
|
-
{dataset['WWW:LINK-1.0-http--link'] && (
|
|
236
|
-
<>
|
|
237
|
-
<h5>Links:</h5>
|
|
238
|
-
<List divided relaxed>
|
|
239
|
-
{(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) => {
|
|
240
|
-
return (
|
|
241
|
-
<List.Item key={i}>
|
|
242
|
-
<List.Content>
|
|
243
|
-
<div className="dataset-item">
|
|
244
|
-
<Icon className="linkify" />
|
|
245
|
-
<a
|
|
246
|
-
href={item.url}
|
|
247
|
-
className="item-link"
|
|
248
|
-
target="_blank"
|
|
249
|
-
rel="noreferrer"
|
|
250
|
-
>
|
|
251
|
-
<span>{item.name || item.url}</span>
|
|
252
|
-
</a>
|
|
253
|
-
{is_internal_url(item.url) && (
|
|
254
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
255
|
-
)}
|
|
256
|
-
</div>
|
|
257
|
-
</List.Content>
|
|
258
|
-
{item.description && (
|
|
259
|
-
<span className="item-description">{item.description}</span>
|
|
260
|
-
)}
|
|
261
|
-
</List.Item>
|
|
262
|
-
);
|
|
263
|
-
})}
|
|
264
|
-
</List>
|
|
265
|
-
</>
|
|
266
|
-
)}
|
|
267
|
-
</div>
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const Datasets = (props) => {
|
|
272
|
-
const { item, appConfig } = props;
|
|
273
|
-
const { children } = item?.raw_value?.raw || {};
|
|
274
|
-
|
|
275
|
-
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
276
|
-
|
|
277
|
-
function handleClick(e, titleProps) {
|
|
278
|
-
const { index } = titleProps;
|
|
279
|
-
const newIndex = activeIndex === index ? -1 : index;
|
|
280
|
-
setActiveIndex(newIndex);
|
|
281
|
-
}
|
|
282
|
-
|
|
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');
|
|
308
|
-
|
|
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
|
-
});
|
|
314
|
-
|
|
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
|
-
),
|
|
325
|
-
render: () => (
|
|
326
|
-
<Tab.Pane>
|
|
327
|
-
<Accordion>
|
|
328
|
-
{item?.children.map((dataset, index) => {
|
|
329
|
-
const {
|
|
330
|
-
resourceTemporalExtentDetails,
|
|
331
|
-
temporalDateRange,
|
|
332
|
-
publicationDateForResource,
|
|
333
|
-
} = dataset;
|
|
334
|
-
return (
|
|
335
|
-
<React.Fragment key={index}>
|
|
336
|
-
<Accordion.Title
|
|
337
|
-
active={activeIndex === index}
|
|
338
|
-
index={index}
|
|
339
|
-
onClick={handleClick}
|
|
340
|
-
>
|
|
341
|
-
<span className="dataset-title">
|
|
342
|
-
{dataset.resourceTitleObject.default}
|
|
343
|
-
<span className="formats">
|
|
344
|
-
{(dataset.format || []).map((item, i) => {
|
|
345
|
-
return (
|
|
346
|
-
<span className="format-label" key={i}>
|
|
347
|
-
{item}
|
|
348
|
-
</span>
|
|
349
|
-
);
|
|
350
|
-
})}
|
|
351
|
-
|
|
352
|
-
{Array.isArray(dataset.linkProtocol) ? (
|
|
353
|
-
<>
|
|
354
|
-
{dataset.linkProtocol
|
|
355
|
-
.filter(
|
|
356
|
-
(i) => i.includes('ESRI') || i.includes('OGC'),
|
|
357
|
-
)
|
|
358
|
-
.map((item, i) => {
|
|
359
|
-
return (
|
|
360
|
-
<span className="format-label" key={i}>
|
|
361
|
-
{item}
|
|
362
|
-
</span>
|
|
363
|
-
);
|
|
364
|
-
})}
|
|
365
|
-
</>
|
|
366
|
-
) : (
|
|
367
|
-
<>
|
|
368
|
-
{['ESRI', 'OGC'].includes(dataset.linkProtocol) && (
|
|
369
|
-
<span className="format-label">
|
|
370
|
-
{dataset.linkProtocol}
|
|
371
|
-
</span>
|
|
372
|
-
)}
|
|
373
|
-
</>
|
|
374
|
-
)}
|
|
375
|
-
</span>
|
|
376
|
-
|
|
377
|
-
{is_internal(dataset) && (
|
|
378
|
-
<SVGIcon name={lockSVG} size="18" />
|
|
379
|
-
)}
|
|
380
|
-
</span>
|
|
381
|
-
<Icon className="ri-arrow-down-s-line" />
|
|
382
|
-
</Accordion.Title>
|
|
383
|
-
<Accordion.Content active={activeIndex === index}>
|
|
384
|
-
<div className="dataset-content">
|
|
385
|
-
<div>
|
|
386
|
-
{publicationDateForResource && (
|
|
387
|
-
<div>
|
|
388
|
-
<strong>Published: </strong>
|
|
389
|
-
<DateTime
|
|
390
|
-
format="DATE_MED"
|
|
391
|
-
value={publicationDateForResource}
|
|
392
|
-
/>
|
|
393
|
-
</div>
|
|
394
|
-
)}
|
|
395
|
-
|
|
396
|
-
{resourceTemporalExtentDetails &&
|
|
397
|
-
resourceTemporalExtentDetails?.length > 0 && (
|
|
398
|
-
<div>
|
|
399
|
-
<strong>Temporal coverage: </strong>
|
|
400
|
-
{temporalDateRange}
|
|
401
|
-
</div>
|
|
402
|
-
)}
|
|
403
|
-
</div>
|
|
404
|
-
|
|
405
|
-
{dataset.resourceType[0] !== 'nonGeographicDataset' && (
|
|
406
|
-
<div className="dataset-pdf">
|
|
407
|
-
<div className="d-link">
|
|
408
|
-
<Icon className="file pdf" />
|
|
409
|
-
<a
|
|
410
|
-
target="_blank"
|
|
411
|
-
rel="noreferrer"
|
|
412
|
-
href={`${appConfig.indexBaseUrl}/catalogue/datahub/api/records/${dataset.metadataIdentifier}/formatters/xsl-view?output=pdf&language=eng&approved=true`}
|
|
413
|
-
>
|
|
414
|
-
Metadata Factsheet
|
|
415
|
-
</a>
|
|
416
|
-
</div>
|
|
417
|
-
</div>
|
|
418
|
-
)}
|
|
419
|
-
</div>
|
|
420
|
-
|
|
421
|
-
{!!dataset.link && dataset.link.length > 0 && (
|
|
422
|
-
<DatasetList link={dataset.link} />
|
|
423
|
-
)}
|
|
424
|
-
</Accordion.Content>
|
|
425
|
-
</React.Fragment>
|
|
426
|
-
);
|
|
427
|
-
})}
|
|
428
|
-
</Accordion>
|
|
429
|
-
</Tab.Pane>
|
|
430
|
-
),
|
|
431
|
-
}));
|
|
432
|
-
|
|
433
|
-
return children && children.length > 0 ? (
|
|
434
|
-
<>
|
|
435
|
-
<div className="dataset-container">
|
|
436
|
-
<h2>Datasets</h2>
|
|
437
|
-
</div>
|
|
438
|
-
|
|
439
|
-
<div className="item tabs-title">Temporal coverage</div>
|
|
440
|
-
<Tab
|
|
441
|
-
className="datasets-tab"
|
|
442
|
-
menu={{ vertical: true, secondary: true, pointing: true }}
|
|
443
|
-
panes={panes}
|
|
444
|
-
onTabChange={() => {
|
|
445
|
-
setActiveIndex(0);
|
|
446
|
-
}}
|
|
447
|
-
/>
|
|
448
|
-
</>
|
|
449
|
-
) : null;
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
export default Datasets;
|