@eeacms/volto-datahub 0.1.8 → 0.1.10
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 +129 -112
- package/package.json +5 -3
- package/src/components/ItemView/Datasets.jsx +304 -0
- package/src/components/ItemView/ItemView.jsx +27 -274
- package/src/components/ItemView/MetadataSection.jsx +81 -0
- package/src/components/ItemView/MoreLikeThis.jsx +85 -0
- package/src/components/ItemView/icons/services.svg +2 -2
- package/src/components/ItemView/index.js +3 -0
- package/src/components/LandingPage/DatahubLandingPage.jsx +84 -67
- package/src/components/Result/DatahubCardItem.jsx +124 -181
- package/src/config/index.js +1 -1
- package/src/index.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Tab, Card, Menu } from 'semantic-ui-react';
|
|
4
4
|
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
5
5
|
import { useAtom } from 'jotai';
|
|
6
6
|
|
|
@@ -151,79 +151,96 @@ const LandingPage = (props) => {
|
|
|
151
151
|
sections,
|
|
152
152
|
]);
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
const panes = sections
|
|
155
|
+
.filter((section) => !section.hidden)
|
|
156
|
+
.map((section, index) => {
|
|
157
|
+
const tabIndex = index + 1;
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
toggle
|
|
159
|
+
return {
|
|
160
|
+
id: section,
|
|
161
|
+
menuItem: {
|
|
162
|
+
children: () => {
|
|
163
|
+
return (
|
|
164
|
+
<React.Fragment key={`tab-${tabIndex}`}>
|
|
165
|
+
<Menu.Item
|
|
167
166
|
active={activeSection === section.facetField}
|
|
168
|
-
className="ui button"
|
|
169
167
|
onClick={() => setActiveSection(section.facetField)}
|
|
170
168
|
>
|
|
171
169
|
{section.title}
|
|
172
|
-
</
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
170
|
+
</Menu.Item>
|
|
171
|
+
</React.Fragment>
|
|
172
|
+
);
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
render: () => {
|
|
176
|
+
return (
|
|
177
|
+
<Tab.Pane>
|
|
178
|
+
<div className="landing-page-cards">
|
|
179
|
+
<Card.Group itemsPerRow={5}>
|
|
180
|
+
{sortedTiles(tiles, activeSectionConfig, appConfig).map(
|
|
181
|
+
(topic, index) => {
|
|
182
|
+
const onClickHandler = () => {
|
|
183
|
+
setFilter(
|
|
184
|
+
activeSection,
|
|
185
|
+
topic.value,
|
|
186
|
+
activeSectionConfig.filterType || 'any',
|
|
187
|
+
);
|
|
185
188
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
189
|
+
// apply configured default values
|
|
190
|
+
appConfig.facets
|
|
191
|
+
.filter((f) => f.field !== activeSection && f.default)
|
|
192
|
+
.forEach((facet) => {
|
|
193
|
+
facet.default.values.forEach((value) =>
|
|
194
|
+
setFilter(
|
|
195
|
+
facet.field,
|
|
196
|
+
value,
|
|
197
|
+
facet.default.type || 'any',
|
|
198
|
+
),
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
setSort(sortField, sortDirection);
|
|
202
|
+
setShowFacets(true);
|
|
203
|
+
};
|
|
201
204
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
205
|
+
return (
|
|
206
|
+
<Card onClick={onClickHandler} key={index}>
|
|
207
|
+
<Card.Content>
|
|
208
|
+
<Card.Header>
|
|
209
|
+
{icon ? (
|
|
210
|
+
<Icon {...icon} type={topic.value} />
|
|
211
|
+
) : (
|
|
212
|
+
''
|
|
213
|
+
)}
|
|
214
|
+
<Term term={topic.value} field={activeSection} />
|
|
215
|
+
</Card.Header>
|
|
216
|
+
</Card.Content>
|
|
217
|
+
<Card.Content extra>
|
|
218
|
+
<span className="count">
|
|
219
|
+
{topic.count}{' '}
|
|
220
|
+
{topic.count === 1 ? 'item' : 'items'}
|
|
221
|
+
</span>
|
|
222
|
+
</Card.Content>
|
|
223
|
+
</Card>
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
)}
|
|
227
|
+
</Card.Group>
|
|
228
|
+
</div>
|
|
229
|
+
</Tab.Pane>
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div className="landing-page-container">
|
|
237
|
+
<div className="landing-page">
|
|
238
|
+
<h4 className="browse-by">Browse by</h4>
|
|
239
|
+
<Tab
|
|
240
|
+
className="search-tab"
|
|
241
|
+
menu={{ secondary: true, pointing: true }}
|
|
242
|
+
panes={panes}
|
|
243
|
+
/>
|
|
227
244
|
{hasOverflow ? (
|
|
228
245
|
<div className="info">
|
|
229
246
|
<p>Only first {maxPerSection} items are displayed.</p>
|
|
@@ -1,199 +1,142 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
// Button,
|
|
6
|
-
// Dropdown
|
|
7
|
-
} from 'semantic-ui-react';
|
|
8
|
-
import { DateTime as FormattedDate, StringList } from '@eeacms/search';
|
|
9
|
-
import { DateTime } from 'luxon';
|
|
10
|
-
// import { useAppConfig, useWindowDimensions } from '@eeacms/search/lib/hocs';
|
|
11
|
-
// import { TagsList } from '@eeacms/search/components'; // SegmentedBreadcrumb,
|
|
12
|
-
// import { firstWords, getTermDisplayValue } from '@eeacms/search/lib/utils';
|
|
13
|
-
// import MoreLikeThisTrigger from '@eeacms/search/components/Result/MoreLikeThisTrigger';
|
|
14
|
-
// import ExternalLink from '@eeacms/search/components/Result/ExternalLink';
|
|
15
|
-
// import ResultContext from '@eeacms/search/components/Result/ResultContext';
|
|
16
|
-
// import ContentClusters from '@eeacms/search/components/Result/ContentClusters';
|
|
17
|
-
import {
|
|
18
|
-
useAppConfig,
|
|
19
|
-
ResultContext,
|
|
20
|
-
firstWords,
|
|
21
|
-
// ContentClusters,
|
|
22
|
-
// useWindowDimensions,
|
|
23
|
-
// MoreLikeThisTrigger,
|
|
24
|
-
// TagsList,
|
|
25
|
-
// ExternalLink,
|
|
26
|
-
// getTermDisplayValue,
|
|
27
|
-
} from '@eeacms/search';
|
|
2
|
+
|
|
3
|
+
import { DateTime, StringList } from '@eeacms/search';
|
|
4
|
+
import { ResultContext } from '@eeacms/search';
|
|
28
5
|
import { Link } from 'react-router-dom';
|
|
6
|
+
import { UniversalItem } from '@eeacms/volto-listing-block';
|
|
29
7
|
|
|
30
8
|
const DatahubCardItem = (props) => {
|
|
31
|
-
const {
|
|
32
|
-
result,
|
|
33
|
-
// showControls = true
|
|
34
|
-
} = props;
|
|
35
|
-
const { appConfig } = useAppConfig();
|
|
36
|
-
const {
|
|
37
|
-
// vocab = {},
|
|
38
|
-
debugQuery,
|
|
39
|
-
} = appConfig;
|
|
9
|
+
const { result } = props;
|
|
40
10
|
const { topic } = result._result || [];
|
|
41
|
-
const [hovered, setHovered] = React.useState(false);
|
|
42
|
-
|
|
43
|
-
// const { pathname, search } = useLocation();
|
|
44
11
|
|
|
45
|
-
let metaType = result.metaTypes || '';
|
|
46
|
-
if (metaType.length === 0) {
|
|
47
|
-
|
|
48
|
-
}
|
|
12
|
+
// let metaType = result.metaTypes || '';
|
|
13
|
+
// if (metaType.length === 0) {
|
|
14
|
+
// metaType = 'Others';
|
|
15
|
+
// }
|
|
49
16
|
|
|
50
|
-
const classColLeft = result.hasImage ? 'col-left' : 'col-left no-image';
|
|
51
17
|
const [resultId] = (result.href || '').split('/').reverse();
|
|
52
18
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
19
|
+
const item = {
|
|
20
|
+
title: (
|
|
21
|
+
<Link
|
|
22
|
+
to={{
|
|
23
|
+
pathname: `/en/datahub/datahubitem-view/${resultId}`,
|
|
24
|
+
state: {
|
|
25
|
+
fromPathname: window.location.pathname,
|
|
26
|
+
fromSearch: window.location.search,
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
title={result.title}
|
|
30
|
+
>
|
|
31
|
+
{result.title}
|
|
32
|
+
</Link>
|
|
33
|
+
),
|
|
34
|
+
description: <ResultContext {...props} />,
|
|
35
|
+
preview_image_url: result.hasImage ? result.thumbUrl : undefined,
|
|
36
|
+
extra: (
|
|
37
|
+
<div className="result-bottom">
|
|
38
|
+
<div className="result-info">
|
|
39
|
+
<span className="result-info-title">Published: </span>
|
|
40
|
+
<DateTime format="DATE_MED" value={result.issued} />
|
|
70
41
|
</div>
|
|
71
|
-
|
|
72
|
-
<div className={classColLeft}>
|
|
73
|
-
<div className="details">
|
|
42
|
+
{topic ? (
|
|
74
43
|
<div className="result-info">
|
|
75
|
-
<span className="result-info-title">
|
|
76
|
-
{
|
|
44
|
+
<span className="result-info-title">Topics: </span>
|
|
45
|
+
<StringList value={topic.raw} />
|
|
77
46
|
</div>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}}
|
|
87
|
-
title={result.title}
|
|
88
|
-
>
|
|
89
|
-
{firstWords(result.title, 12)}
|
|
90
|
-
</Link>
|
|
91
|
-
{result.isNew && (
|
|
92
|
-
<Label className="new-item" horizontal>
|
|
93
|
-
New
|
|
94
|
-
</Label>
|
|
95
|
-
)}
|
|
96
|
-
{result.isExpired && (
|
|
97
|
-
<Label className="archived-item" horizontal>
|
|
98
|
-
Archived
|
|
99
|
-
</Label>
|
|
100
|
-
)}
|
|
101
|
-
</h3>
|
|
102
|
-
{/* <SegmentedBreadcrumb */}
|
|
103
|
-
{/* href={result.href} */}
|
|
104
|
-
{/* short={true} */}
|
|
105
|
-
{/* maxChars={40} */}
|
|
106
|
-
{/* /> */}
|
|
47
|
+
) : null}
|
|
48
|
+
<div className="result-info">
|
|
49
|
+
<span className="result-info-title">Available formats: </span>
|
|
50
|
+
[Icons]
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
107
55
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
getTermDisplayValue({
|
|
114
|
-
vocab,
|
|
115
|
-
field: 'cluster_name',
|
|
116
|
-
term: result.source,
|
|
117
|
-
}),
|
|
118
|
-
8,
|
|
119
|
-
)}
|
|
120
|
-
</strong>
|
|
121
|
-
</Link>
|
|
56
|
+
const itemModel = {
|
|
57
|
+
hasImage: result.hasImage,
|
|
58
|
+
hasDescription: true,
|
|
59
|
+
'@type': 'searchItem',
|
|
60
|
+
};
|
|
122
61
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
view={Button}
|
|
126
|
-
className="mlt"
|
|
127
|
-
compact
|
|
128
|
-
color="green"
|
|
129
|
-
size="mini"
|
|
130
|
-
result={result}
|
|
131
|
-
>
|
|
132
|
-
more like this
|
|
133
|
-
</MoreLikeThisTrigger>
|
|
134
|
-
)}
|
|
135
|
-
{showControls && isSmallScreen && (
|
|
136
|
-
<Dropdown icon="ellipsis vertical">
|
|
137
|
-
<Dropdown.Menu className="mlt">
|
|
138
|
-
<MoreLikeThisTrigger result={result} view={Dropdown.Item}>
|
|
139
|
-
More like this
|
|
140
|
-
</MoreLikeThisTrigger>
|
|
141
|
-
</Dropdown.Menu>
|
|
142
|
-
</Dropdown>
|
|
143
|
-
)}
|
|
144
|
-
</div>*/}
|
|
62
|
+
return <UniversalItem item={item} itemModel={itemModel} />;
|
|
63
|
+
};
|
|
145
64
|
|
|
146
|
-
|
|
65
|
+
// <div
|
|
66
|
+
// className={cx('search-result', { hovered })}
|
|
67
|
+
// onMouseEnter={() => setHovered(true)}
|
|
68
|
+
// onMouseLeave={() => setHovered(false)}
|
|
69
|
+
// >
|
|
70
|
+
// <div className={classColLeft}>
|
|
71
|
+
// <div className="details">
|
|
72
|
+
// <h3>
|
|
73
|
+
// <Link
|
|
74
|
+
// to={{
|
|
75
|
+
// pathname: `/en/datahub/datahubitem-view/${resultId}`,
|
|
76
|
+
// state: {
|
|
77
|
+
// fromPathname: window.location.pathname,
|
|
78
|
+
// fromSearch: window.location.search,
|
|
79
|
+
// },
|
|
80
|
+
// }}
|
|
81
|
+
// title={result.title}
|
|
82
|
+
// >
|
|
83
|
+
// {firstWords(result.title, 12)}
|
|
84
|
+
// </Link>
|
|
85
|
+
// {result.isNew && (
|
|
86
|
+
// <Label className="new-item" horizontal>
|
|
87
|
+
// New
|
|
88
|
+
// </Label>
|
|
89
|
+
// )}
|
|
90
|
+
// {result.isExpired && (
|
|
91
|
+
// <Label className="archived-item" horizontal>
|
|
92
|
+
// Archived
|
|
93
|
+
// </Label>
|
|
94
|
+
// )}
|
|
95
|
+
// </h3>
|
|
96
|
+
// {props.children ? props.children : <ResultContext {...props} />}
|
|
147
97
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
</
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/>
|
|
192
|
-
</a>
|
|
193
|
-
</div>
|
|
194
|
-
) : null}
|
|
195
|
-
</div>
|
|
196
|
-
);
|
|
197
|
-
};
|
|
98
|
+
// <div className="result-bottom">
|
|
99
|
+
// {topic ? (
|
|
100
|
+
// <div className="result-info">
|
|
101
|
+
// <span className="result-info-title">Topics: </span>
|
|
102
|
+
// <StringList value={topic.raw} />
|
|
103
|
+
// </div>
|
|
104
|
+
// ) : null}
|
|
105
|
+
// <div className="result-info">
|
|
106
|
+
// <span className="result-info-title">Published: </span>
|
|
107
|
+
// <DateTime format="DATE_MED" value={result.issued} />
|
|
108
|
+
// </div>
|
|
109
|
+
// <div className="result-info">
|
|
110
|
+
// <span className="result-info-title">Available formats: </span>
|
|
111
|
+
// [Icons]
|
|
112
|
+
// </div>
|
|
113
|
+
// </div>
|
|
114
|
+
// </div>
|
|
115
|
+
// {debugQuery && (
|
|
116
|
+
// <div>
|
|
117
|
+
// <div>Explanation:</div>
|
|
118
|
+
// <pre>{JSON.stringify(result.explanation, undefined, 2)}</pre>
|
|
119
|
+
// </div>
|
|
120
|
+
// )}
|
|
121
|
+
// </div>
|
|
122
|
+
// {result.hasImage ? (
|
|
123
|
+
// <div className="col-right">
|
|
124
|
+
// <a
|
|
125
|
+
// className={`centered fluid image img-thumbnail`}
|
|
126
|
+
// href={result.href}
|
|
127
|
+
// target="_blank"
|
|
128
|
+
// rel="noreferrer"
|
|
129
|
+
// >
|
|
130
|
+
// <img
|
|
131
|
+
// alt={result.title}
|
|
132
|
+
// src={result.thumbUrl}
|
|
133
|
+
// onError={(e) => {
|
|
134
|
+
// e.target.style.display = 'none';
|
|
135
|
+
// }}
|
|
136
|
+
// />
|
|
137
|
+
// </a>
|
|
138
|
+
// </div>
|
|
139
|
+
// ) : null}
|
|
140
|
+
// </div>
|
|
198
141
|
|
|
199
142
|
export default DatahubCardItem;
|
package/src/config/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const datahubConfig = {
|
|
|
14
14
|
...filters,
|
|
15
15
|
...vocabs,
|
|
16
16
|
|
|
17
|
-
sourceExcludedFields: ['nlp_*', 'event'], // don't need these in results
|
|
17
|
+
sourceExcludedFields: ['nlp_*', 'event', 'raw_value'], // don't need these in results
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const getClientProxyAddress = () => {
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import DatahubItemView from './components/ItemView/ItemView';
|
|
|
4
4
|
|
|
5
5
|
function tweakForNLPService(body, config) {
|
|
6
6
|
if (!config.enableNLP) {
|
|
7
|
-
body._source = { ...body.source };
|
|
8
7
|
delete body.source;
|
|
9
8
|
delete body.index;
|
|
10
9
|
return body;
|
|
@@ -25,9 +24,10 @@ const applyConfig = (config) => {
|
|
|
25
24
|
// Tweak the searchlib config to use the middleware instead of the index
|
|
26
25
|
datahub.elastic_index = '_es/datahub';
|
|
27
26
|
datahub.index_name = 'data_searchui_datahub';
|
|
28
|
-
datahub.enableNLP =
|
|
27
|
+
datahub.enableNLP = true;
|
|
29
28
|
datahub.showPromptQueries = false;
|
|
30
29
|
datahub.requestBodyModifiers.push(tweakForNLPService);
|
|
30
|
+
datahub.indexBaseUrl = 'https://galliwasp.eea.europa.eu';
|
|
31
31
|
// datahub.resultViews[0].factories.item = "DatahubListingViewItem"
|
|
32
32
|
|
|
33
33
|
config.settings.nonContentRoutes.push(/datahubitem-view\/(.*)/); // \/(.*)\/
|