@eeacms/volto-datahub 0.1.10 → 0.1.12

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,6 +4,19 @@ 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.12](https://github.com/eea/volto-datahub/compare/0.1.11...0.1.12) - 19 October 2022
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Add proper class name on the landing page [kreafox - [`767bdac`](https://github.com/eea/volto-datahub/commit/767bdac51851301d229eeff23cee666a381488fb)]
12
+ - Fix undefined error [kreafox - [`a589629`](https://github.com/eea/volto-datahub/commit/a5896295a1d74d0b63bc3625efcbfd25fc39fcda)]
13
+ - added specific model for datahub results [Zoltan Szabo - [`71fd2e7`](https://github.com/eea/volto-datahub/commit/71fd2e78e114f50dcbcc6ff3e8dfa5e96d2b7fd0)]
14
+ ### [0.1.11](https://github.com/eea/volto-datahub/compare/0.1.10...0.1.11) - 27 September 2022
15
+
16
+ #### :hammer_and_wrench: Others
17
+
18
+ - fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
19
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
7
20
  ### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
8
21
 
9
22
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -23,7 +23,8 @@
23
23
  "devDependencies": {
24
24
  "@plone/scripts": "*",
25
25
  "@cypress/code-coverage": "^3.9.5",
26
- "babel-plugin-transform-class-properties": "^6.24.1"
26
+ "babel-plugin-transform-class-properties": "^6.24.1",
27
+ "md5": "^2.3.0"
27
28
  },
28
29
  "addons": [
29
30
  "@eeacms/volto-globalsearch",
@@ -21,7 +21,7 @@ import {
21
21
  MetadataSection,
22
22
  Datasets,
23
23
  } from '@eeacms/volto-datahub/components/ItemView';
24
- import bannerBG from './banner.svg';
24
+ // import bannerBG from './banner.svg';
25
25
 
26
26
  const appName = 'datahub';
27
27
 
@@ -33,7 +33,12 @@ function ItemView(props) {
33
33
  const result = useResult(null, docid);
34
34
  const item = result ? result._result : null;
35
35
  const { title, description, raw_value } = item || {}; // readingTime
36
- const { changeDate } = raw_value?.raw || {};
36
+ const { changeDate, resourceIdentifier } = raw_value?.raw || {};
37
+
38
+ const prodID = (resourceIdentifier || []).filter((p) => {
39
+ return p.code.includes('DAT');
40
+ })[0]?.code;
41
+
37
42
  const rawTitle = title?.raw || '';
38
43
 
39
44
  React.useEffect(() => {
@@ -66,55 +71,53 @@ function ItemView(props) {
66
71
  <div className="dataset-view">
67
72
  <Portal node={document.getElementById('page-header')}>
68
73
  <div className="dataset">
69
- <Banner image_url={bannerBG} image>
74
+ <Banner>
70
75
  <Banner.Content>
71
- <Banner.Title>Datahub</Banner.Title>
76
+ <Banner.Subtitle>
77
+ <Link
78
+ to={
79
+ location?.state
80
+ ? { pathname: fromPathname, search: fromSearch }
81
+ : {
82
+ pathname: '/en/datahub/',
83
+ }
84
+ }
85
+ >
86
+ <Icon className="arrow left" />
87
+ Datahub overview
88
+ </Link>
89
+ </Banner.Subtitle>
90
+ <Banner.Title>{title?.raw}</Banner.Title>
91
+ <Banner.Metadata>
92
+ <Banner.MetadataField label="Prod-ID" value={prodID} />
93
+ <Banner.MetadataField
94
+ label="Published"
95
+ type="date"
96
+ value={<DateTime format="DATE_MED" value={result.issued} />}
97
+ />
98
+ <Banner.MetadataField
99
+ label="Last modified"
100
+ type="date"
101
+ value={<DateTime format="DATE_MED" value={changeDate} />}
102
+ />
103
+ {/* <Banner.MetadataField
104
+ label="Reading time"
105
+ value={readingTime?.raw}
106
+ /> */}
107
+ </Banner.Metadata>
72
108
  </Banner.Content>
73
109
  </Banner>
74
110
  </div>
75
111
  </Portal>
76
112
 
77
113
  <div className="dataset-container">
78
- <Link
79
- className="search-link"
80
- to={
81
- location?.state
82
- ? { pathname: fromPathname, search: fromSearch }
83
- : {
84
- pathname: '/en/datahub/',
85
- }
86
- }
87
- >
88
- <Icon className="ri-arrow-go-back-line" />
89
- Back to search
90
- </Link>
91
-
92
- <div className="dataset-header">
93
- <h1>{title?.raw}</h1>
94
- <div className="dataset-header-bottom">
95
- <span className="header-data">Prod-ID: -</span>
96
- {/* <span className="header-data">
97
- Created: <DateTime format="DATE_MED" value={issued?.raw} />
98
- </span> */}
99
- <span className="header-data">
100
- Published: <DateTime format="DATE_MED" value={result.issued} />
101
- </span>
102
- <span className="header-data">
103
- Last modified: <DateTime format="DATE_MED" value={changeDate} />
104
- </span>
105
- {/*<span className="header-data">
106
- Reading time: {readingTime?.raw}
107
- </span>*/}
108
- </div>
109
- </div>
110
-
111
114
  <Callout>{description?.raw}</Callout>
112
115
 
113
116
  <Datasets item={item} appConfig={appConfig} />
114
117
 
115
118
  <MetadataSection item={item} appConfig={appConfig} docid={docid} />
116
119
 
117
- <MoreLikeThis docid={docid} title={title.raw} appConfig={appConfig} />
120
+ <MoreLikeThis docid={docid} title={title?.raw} appConfig={appConfig} />
118
121
  </div>
119
122
 
120
123
  {/* <div className="info-wrapper">
@@ -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,20 +32,21 @@ 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
- setSimilarDocs(resp.body.hits.hits);
49
+ setSimilarDocs(resp.body?.hits?.hits);
49
50
  }
50
51
  getSimilarDocs(docid, title, appConfig);
51
52
  }, [appConfig, docid, title]);
@@ -242,7 +242,7 @@ const LandingPage = (props) => {
242
242
  panes={panes}
243
243
  />
244
244
  {hasOverflow ? (
245
- <div className="info">
245
+ <div className="tab-info">
246
246
  <p>Only first {maxPerSection} items are displayed.</p>
247
247
  </div>
248
248
  ) : null}
@@ -14,13 +14,11 @@ const DatahubCardItem = (props) => {
14
14
  // metaType = 'Others';
15
15
  // }
16
16
 
17
- const [resultId] = (result.href || '').split('/').reverse();
18
-
19
17
  const item = {
20
18
  title: (
21
19
  <Link
22
20
  to={{
23
- pathname: `/en/datahub/datahubitem-view/${resultId}`,
21
+ pathname: result.href,
24
22
  state: {
25
23
  fromPathname: window.location.pathname,
26
24
  fromSearch: window.location.search,
@@ -0,0 +1,96 @@
1
+ import { ResultModel } from '@eeacms/search';
2
+ const path = require('path');
3
+
4
+ export class DatahubResultModel extends ResultModel {
5
+ get href() {
6
+ if (__CLIENT__) {
7
+ return path.join(
8
+ window.location.pathname,
9
+ 'datahubitem-view/',
10
+ this._result.about?.raw,
11
+ );
12
+ } else {
13
+ return ''; //TODO
14
+ }
15
+ }
16
+
17
+ get daysSinceIssued() {
18
+ return super.daysSinceIssued;
19
+ }
20
+
21
+ get id() {
22
+ return super.id;
23
+ }
24
+
25
+ get isNew() {
26
+ return super.isNew;
27
+ }
28
+
29
+ get issued() {
30
+ return super.issued;
31
+ }
32
+
33
+ get expires() {
34
+ return super.expires;
35
+ }
36
+
37
+ get isExpired() {
38
+ return super.isExpired;
39
+ }
40
+
41
+ get metaCategories() {
42
+ return super.metaCategories;
43
+ }
44
+
45
+ get clusterIcon() {
46
+ return super.clusterIcon;
47
+ }
48
+
49
+ get clusterInfo() {
50
+ return super.clusterInfo;
51
+ }
52
+
53
+ get clusterName() {
54
+ return super.clusterName;
55
+ }
56
+
57
+ get source() {
58
+ return super.source;
59
+ }
60
+
61
+ get title() {
62
+ return super.title;
63
+ }
64
+
65
+ get description() {
66
+ return super.description;
67
+ }
68
+
69
+ get hasImage() {
70
+ return super.hasImage;
71
+ }
72
+
73
+ get thumbUrl() {
74
+ return super.thumbUrl;
75
+ }
76
+
77
+ get highlight() {
78
+ return super.highlight;
79
+ }
80
+
81
+ get website() {
82
+ return super.website.website;
83
+ }
84
+
85
+ get tags() {
86
+ return super.tags;
87
+ }
88
+
89
+ get metaTypes() {
90
+ return super.metaTypes;
91
+ }
92
+
93
+ get explanation() {
94
+ return super.explanation;
95
+ }
96
+ }
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import installDatahub from './config';
2
2
  import DatahubCardItem from './components/Result/DatahubCardItem';
3
3
  import DatahubItemView from './components/ItemView/ItemView';
4
+ import { DatahubResultModel } from './config/models';
4
5
 
5
6
  function tweakForNLPService(body, config) {
6
7
  if (!config.enableNLP) {
@@ -20,6 +21,7 @@ const applyConfig = (config) => {
20
21
  } = config.settings.searchlib;
21
22
 
22
23
  resolve.DatahubCardItem = { component: DatahubCardItem };
24
+ resolve.DatahubResultModel = DatahubResultModel;
23
25
 
24
26
  // Tweak the searchlib config to use the middleware instead of the index
25
27
  datahub.elastic_index = '_es/datahub';
@@ -29,6 +31,7 @@ const applyConfig = (config) => {
29
31
  datahub.requestBodyModifiers.push(tweakForNLPService);
30
32
  datahub.indexBaseUrl = 'https://galliwasp.eea.europa.eu';
31
33
  // datahub.resultViews[0].factories.item = "DatahubListingViewItem"
34
+ datahub.resultItemModel.factory = 'DatahubResultModel';
32
35
 
33
36
  config.settings.nonContentRoutes.push(/datahubitem-view\/(.*)/); // \/(.*)\/
34
37
  config.addonRoutes = [