@eeacms/volto-datahub 0.1.9 → 0.1.11

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,7 +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
- ### [0.1.9](https://github.com/eea/volto-datahub/compare/0.1.8...0.1.9) - 12 September 2022
7
+ ### [0.1.11](https://github.com/eea/volto-datahub/compare/0.1.10...0.1.11) - 27 September 2022
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
12
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
13
+ ### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
14
+
15
+ #### :hammer_and_wrench: Others
16
+
17
+ - Update dependencies [kreafox - [`e9fc8c3`](https://github.com/eea/volto-datahub/commit/e9fc8c35530214b19e969d1e5d9b88ffe9098c4d)]
18
+ - Use tabs on the landing page [kreafox - [`d0f4b91`](https://github.com/eea/volto-datahub/commit/d0f4b910d414f5cbad58d9b8eaa7090b1aa3b7dd)]
19
+ - Fix card model [Tiberiu Ichim - [`3d98969`](https://github.com/eea/volto-datahub/commit/3d98969ce9339c6aa6126cb5bbe7ad630ab74faf)]
20
+ - WIP integrate UniversalItem [kreafox - [`02e37f4`](https://github.com/eea/volto-datahub/commit/02e37f43fe580982acba5ae731f77a6724ec13fe)]
21
+ - WIP use universalItem [Tiberiu Ichim - [`024313e`](https://github.com/eea/volto-datahub/commit/024313e1d43135ae4f9c170d19065eea23fa7138)]
22
+ - Code cleanup in datahub item [Tiberiu Ichim - [`3856914`](https://github.com/eea/volto-datahub/commit/3856914da9b2759bb8c9bdf5af233d2eb6bfd9b3)]
23
+ ### [0.1.9](https://github.com/eea/volto-datahub/compare/0.1.8...0.1.9) - 16 September 2022
8
24
 
9
25
  #### :hammer_and_wrench: Others
10
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -17,7 +17,8 @@
17
17
  "url": "git@github.com:eea/volto-datahub.git"
18
18
  },
19
19
  "dependencies": {
20
- "@eeacms/volto-globalsearch": "*"
20
+ "@eeacms/volto-globalsearch": "*",
21
+ "@eeacms/volto-listing-block": "*"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@plone/scripts": "*",
@@ -25,7 +26,8 @@
25
26
  "babel-plugin-transform-class-properties": "^6.24.1"
26
27
  },
27
28
  "addons": [
28
- "@eeacms/volto-globalsearch"
29
+ "@eeacms/volto-globalsearch",
30
+ "@eeacms/volto-listing-block"
29
31
  ],
30
32
  "scripts": {
31
33
  "release": "release-it",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Card } from 'semantic-ui-react';
3
3
  import { runRequest, firstWords } from '@eeacms/search';
4
4
 
5
- function buildQuery(title, docid) {
5
+ function buildQuery(title, docid, index_name) {
6
6
  const body = {
7
7
  // _source: {
8
8
  // include: ['label', 'about', ],
@@ -32,18 +32,19 @@ function buildQuery(title, docid) {
32
32
  ],
33
33
  },
34
34
  },
35
+ ...(index_name ? { index: index_name } : {}),
35
36
  };
36
37
  return body;
37
38
  }
38
39
 
39
40
  const MoreLikeThis = (props) => {
40
41
  const { docid, title, appConfig } = props;
41
-
42
42
  const [similarDocs, setSimilarDocs] = React.useState();
43
43
 
44
44
  React.useEffect(() => {
45
45
  async function getSimilarDocs(docid, title, appConfig) {
46
- const query_body = buildQuery(title, docid);
46
+ const { index_name } = appConfig;
47
+ const query_body = buildQuery(title, docid, index_name);
47
48
  const resp = await runRequest(query_body, appConfig);
48
49
  setSimilarDocs(resp.body.hits.hits);
49
50
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { Button } from 'semantic-ui-react';
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
- return (
155
- <div className="landing-page-container">
156
- <div className="landing-page">
157
- <h4 className="browse-by">Browse by</h4>
154
+ const panes = sections
155
+ .filter((section) => !section.hidden)
156
+ .map((section, index) => {
157
+ const tabIndex = index + 1;
158
158
 
159
- <div className="filters">
160
- {sections
161
- .filter((section) => !section.hidden)
162
- .map((section) => {
163
- return (
164
- <Button
165
- key={section.facetField}
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
- </Button>
173
- );
174
- })}
175
- </div>
176
- <div className="landing-page-cards">
177
- <div className="ui cards">
178
- {sortedTiles(tiles, activeSectionConfig, appConfig).map((topic) => {
179
- const onClickHandler = () => {
180
- setFilter(
181
- activeSection,
182
- topic.value,
183
- activeSectionConfig.filterType || 'any',
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
- // apply configured default values
187
- appConfig.facets
188
- .filter((f) => f.field !== activeSection && f.default)
189
- .forEach((facet) => {
190
- facet.default.values.forEach((value) =>
191
- setFilter(
192
- facet.field,
193
- value,
194
- facet.default.type || 'any',
195
- ),
196
- );
197
- });
198
- setSort(sortField, sortDirection);
199
- setShowFacets(true);
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
- return (
203
- <div
204
- key={topic.value}
205
- tabIndex="-1"
206
- role="button"
207
- onKeyDown={onClickHandler}
208
- className="ui card"
209
- onClick={onClickHandler}
210
- >
211
- <div className="content">
212
- <div className="header">
213
- {icon ? <Icon {...icon} type={topic.value} /> : ''}
214
- <Term term={topic.value} field={activeSection} />
215
- </div>
216
- </div>
217
- <div className="extra content">
218
- <span className="count">
219
- {topic.count} {topic.count === 1 ? 'item' : 'items'}
220
- </span>
221
- </div>
222
- </div>
223
- );
224
- })}
225
- </div>
226
- </div>
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,194 +1,142 @@
1
1
  import React from 'react';
2
- import cx from 'classnames';
3
- import {
4
- Label,
5
- // Button,
6
- // Dropdown
7
- } from 'semantic-ui-react';
2
+
8
3
  import { DateTime, 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';
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
- metaType = 'Others';
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
- // const { width } = useWindowDimensions();
54
- // const isSmallScreen = width < 1000;
55
- // const clusters = result.clusterInfo;
56
- // console.log('result', result._result);
57
-
58
- return (
59
- <div
60
- className={cx('search-result', { hovered })}
61
- onMouseEnter={() => setHovered(true)}
62
- onMouseLeave={() => setHovered(false)}
63
- >
64
- {/*<div className="col-full">
65
- <div className="meta">
66
- <ContentClusters clusters={clusters} item={result} />
67
- <div className="tags-list">
68
- <TagsList value={result.tags} />
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} />
41
+ </div>
42
+ {topic ? (
43
+ <div className="result-info">
44
+ <span className="result-info-title">Topics: </span>
45
+ <StringList value={topic.raw} />
69
46
  </div>
47
+ ) : null}
48
+ <div className="result-info">
49
+ <span className="result-info-title">Available formats: </span>
50
+ [Icons]
70
51
  </div>
71
- </div>*/}
72
- <div className={classColLeft}>
73
- <div className="details">
74
- {/* <div className="result-info">
75
- <span className="result-info-title">Author: </span>
76
- {result._result?.raw_value?.raw.Org}
77
- </div> */}
78
- <h3>
79
- <Link
80
- to={{
81
- pathname: `/en/datahub/datahubitem-view/${resultId}`,
82
- state: {
83
- fromPathname: window.location.pathname,
84
- fromSearch: window.location.search,
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
- {/* /> */}
52
+ </div>
53
+ ),
54
+ };
107
55
 
108
- {/*<div className="source">
109
- <span>Source: </span>
110
- <Link to={`/datahub/view/${resultId}`} title={result.title}>
111
- <strong title={result.source} className="source">
112
- {firstWords(
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
- {showControls && !isSmallScreen && (
124
- <MoreLikeThisTrigger
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
- {props.children ? props.children : <ResultContext {...props} />}
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
- <div className="result-bottom">
149
- {topic ? (
150
- <div className="result-info">
151
- <span className="result-info-title">Topics: </span>
152
- <StringList value={topic.raw} />
153
- </div>
154
- ) : null}
155
- <div className="result-info">
156
- <span className="result-info-title">Published: </span>
157
- <DateTime format="DATE_MED" value={result.issued} />
158
- </div>
159
- <div className="result-info">
160
- <span className="result-info-title">Available formats: </span>
161
- [Icons]
162
- </div>
163
- </div>
164
- </div>
165
- {debugQuery && (
166
- <div>
167
- <div>Explanation:</div>
168
- <pre>{JSON.stringify(result.explanation, undefined, 2)}</pre>
169
- </div>
170
- )}
171
- </div>
172
- {result.hasImage ? (
173
- <div className="col-right">
174
- <a
175
- className={`centered fluid image img-thumbnail`}
176
- href={result.href}
177
- target="_blank"
178
- rel="noreferrer"
179
- >
180
- <img
181
- alt={result.title}
182
- src={result.thumbUrl}
183
- onError={(e) => {
184
- e.target.style.display = 'none';
185
- }}
186
- />
187
- </a>
188
- </div>
189
- ) : null}
190
- </div>
191
- );
192
- };
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>
193
141
 
194
142
  export default DatahubCardItem;
@@ -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,7 +24,7 @@ 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 = false;
27
+ datahub.enableNLP = true;
29
28
  datahub.showPromptQueries = false;
30
29
  datahub.requestBodyModifiers.push(tweakForNLPService);
31
30
  datahub.indexBaseUrl = 'https://galliwasp.eea.europa.eu';