@eeacms/volto-clms-theme 1.0.49 → 1.0.53
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 +62 -0
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/actions/datasets_by_uid/datasets_by_uid.js +20 -0
- package/src/actions/downloadtool/delete_downloadtool.js +3 -3
- package/src/actions/downloadtool/get_downloadtool.js +2 -2
- package/src/actions/downloadtool/post_downloadtool.js +3 -1
- package/src/actions/format_conversion_table/get_format_conversion_table.js +20 -0
- package/src/actions/index.js +12 -0
- package/src/actions/projections/get_projections.js +20 -0
- package/src/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselView.jsx +3 -3
- package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/CclCarouselView.jsx +10 -9
- package/src/components/CLMSDatasetDetailView/CLMSDatasetDetailView.jsx +1 -1
- package/src/components/CLMSDownloadCartView/CLMSCartContent.jsx +329 -0
- package/src/components/CLMSDownloadCartView/CLMSDownloadCartView.jsx +11 -235
- package/src/components/CLMSDownloadCartView/CLMSTasksInProgress.jsx +81 -61
- package/src/components/CLMSDownloadCartView/cartUtils.js +75 -0
- package/src/components/CLMSDownloadCartView/conversion.js +28 -0
- package/src/components/CclButton/CclButton.jsx +13 -6
- package/src/components/CclDownloadTable/CclDownloadTable.jsx +14 -7
- package/src/components/CclTab/CclTab.jsx +6 -3
- package/src/components/CclTab/CclTabs.jsx +17 -11
- package/src/components/Widgets/DownloadableFilesWidget.jsx +32 -5
- package/src/customizations/volto/components/theme/Header/Header.jsx +15 -15
- package/src/customizations/volto/components/theme/Navigation/Navigation.jsx +5 -5
- package/src/reducers/datasets_by_uid/datasets_by_uid.js +43 -0
- package/src/reducers/downloadtool/downloadtool_reducer.js +60 -2
- package/src/reducers/index.js +2 -0
- package/theme/clms/css/header.css +3 -1
- package/theme/clms/css/styles.less +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,70 @@ 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.53](https://github.com/eea/volto-clms-theme/compare/1.0.52...1.0.53)
|
|
8
|
+
|
|
9
|
+
- update volto-clms-utils [`cec467f`](https://github.com/eea/volto-clms-theme/commit/cec467fb01bdc59cd1ac86edebb2618f86b16c4e)
|
|
10
|
+
|
|
11
|
+
#### [1.0.52](https://github.com/eea/volto-clms-theme/compare/1.0.51...1.0.52)
|
|
12
|
+
|
|
13
|
+
> 22 December 2021
|
|
14
|
+
|
|
15
|
+
- Download cart last modifications [`#164`](https://github.com/eea/volto-clms-theme/pull/164)
|
|
16
|
+
- Download cart [`#163`](https://github.com/eea/volto-clms-theme/pull/163)
|
|
17
|
+
- fixes [`c783f5d`](https://github.com/eea/volto-clms-theme/commit/c783f5de953c79dfe4934ce2dc0fdf472d951753)
|
|
18
|
+
- use dataset information from direct attribute [`b56e96b`](https://github.com/eea/volto-clms-theme/commit/b56e96b2d3c58bfb23994f4c8ef53f85eba7fdf1)
|
|
19
|
+
- debug lint [`74e8e2c`](https://github.com/eea/volto-clms-theme/commit/74e8e2c9857031e636b54826ee9f1c6d384100ab)
|
|
20
|
+
- code refractoring [`79979ed`](https://github.com/eea/volto-clms-theme/commit/79979ed79049e9b600f3b377ae746af6a77903a4)
|
|
21
|
+
- downloadtool post body_extras [`fc15d56`](https://github.com/eea/volto-clms-theme/commit/fc15d56040e5711cde05417f8e7a54c331b93ff1)
|
|
22
|
+
- the format selector always draws according to the api @format_conversion_table [`03e1bd9`](https://github.com/eea/volto-clms-theme/commit/03e1bd9ef7ff276e7006e0d09dea300d38530e99)
|
|
23
|
+
- format and projection selector only available for mapviewer sources [`b86dca7`](https://github.com/eea/volto-clms-theme/commit/b86dca7229d4ce957488166fe800d9ffdaa105f7)
|
|
24
|
+
- view the source in the cart (Pre-packaged or Map viewer) [`cb65dc7`](https://github.com/eea/volto-clms-theme/commit/cb65dc7664d68926e8ae0a481969c82105a6f402)
|
|
25
|
+
- if the cart is empty, dont show the table [`c482e18`](https://github.com/eea/volto-clms-theme/commit/c482e1855eebd57866761759019b79bdc7c182a7)
|
|
26
|
+
- cart items from mapviewer [`d7da742`](https://github.com/eea/volto-clms-theme/commit/d7da74202701703b0c0e2053a42e4dff1d0745f2)
|
|
27
|
+
- fix going back error [`9a24291`](https://github.com/eea/volto-clms-theme/commit/9a24291dcf5bbff3a33ad68b1b06726fda855aa0)
|
|
28
|
+
- added to cart message style [`6a2efdb`](https://github.com/eea/volto-clms-theme/commit/6a2efdb9a0b44f15c3b9e1963dd1434d5f7f7c5c)
|
|
29
|
+
|
|
30
|
+
#### [1.0.51](https://github.com/eea/volto-clms-theme/compare/1.0.50...1.0.51)
|
|
31
|
+
|
|
32
|
+
> 20 December 2021
|
|
33
|
+
|
|
34
|
+
- Cart Download tool [`#162`](https://github.com/eea/volto-clms-theme/pull/162)
|
|
35
|
+
- Download cart [`#160`](https://github.com/eea/volto-clms-theme/pull/160)
|
|
36
|
+
- download cart projections [`#161`](https://github.com/eea/volto-clms-theme/pull/161)
|
|
37
|
+
- Download cart format [`#159`](https://github.com/eea/volto-clms-theme/pull/159)
|
|
38
|
+
- update selected projection option [`6107574`](https://github.com/eea/volto-clms-theme/commit/6107574aa8990b9e431bae8b57069d33b66e9f49)
|
|
39
|
+
- control if downloadtool tasks have been canceled [`0719593`](https://github.com/eea/volto-clms-theme/commit/0719593d211e0b6ef8b156a84fbd512fc09737b8)
|
|
40
|
+
- loading icon and cclbutton isButton option [`807d376`](https://github.com/eea/volto-clms-theme/commit/807d3768beb17cb61a018c21ae490911fe389d95)
|
|
41
|
+
- adapted downloadtool post request [`fc2a2b3`](https://github.com/eea/volto-clms-theme/commit/fc2a2b3ccbee922cd30f5dd62c4583be621391cc)
|
|
42
|
+
- merge develop into download-cart branch [`758ced7`](https://github.com/eea/volto-clms-theme/commit/758ced7ae94351ab9b25b6b6b98ca07821a233ca)
|
|
43
|
+
- add selector to downloadable files editor [`9f05582`](https://github.com/eea/volto-clms-theme/commit/9f05582ed60e9136cc451543a906afa32fef89aa)
|
|
44
|
+
- add action.error on FAIL [`dcf64ac`](https://github.com/eea/volto-clms-theme/commit/dcf64ac1a5cb25092fac1d9aae992c8e783dc85b)
|
|
45
|
+
- basic format selector [`07202c4`](https://github.com/eea/volto-clms-theme/commit/07202c4f548c98df4a74b1058ed24eea88d13425)
|
|
46
|
+
- header nav active border [`037be91`](https://github.com/eea/volto-clms-theme/commit/037be91b4dda6221005dd730fb9d16a862044f87)
|
|
47
|
+
- new volto-clms-utils release [`fca4d27`](https://github.com/eea/volto-clms-theme/commit/fca4d2777ecbd0222fb34c543771f14e5af38fa3)
|
|
48
|
+
- task in progress url changed [`9c23caa`](https://github.com/eea/volto-clms-theme/commit/9c23caa53fc3a61773307f1f3a5b7f6338ecbc69)
|
|
49
|
+
- save endpoint json [`26eb803`](https://github.com/eea/volto-clms-theme/commit/26eb80316a117e7cb2375f10c7100406fbc90308)
|
|
50
|
+
- start Downloading to function [`782e41e`](https://github.com/eea/volto-clms-theme/commit/782e41e71a34492cacc7dc6007d5772db8bbeba9)
|
|
51
|
+
- cartContent remove element [`155bf2d`](https://github.com/eea/volto-clms-theme/commit/155bf2d6e4eb9867a7b6c7b16b01c2f7b433080a)
|
|
52
|
+
- removed unique_id to session_cart [`b4d1ea7`](https://github.com/eea/volto-clms-theme/commit/b4d1ea7e0032b76ee03ad4b44a351d1028f13f42)
|
|
53
|
+
- select all cart elements bug fixed [`0c703f2`](https://github.com/eea/volto-clms-theme/commit/0c703f29aec3c85cb149d89dc64344ade060eba5)
|
|
54
|
+
- cart list from api request [`eeb24e8`](https://github.com/eea/volto-clms-theme/commit/eeb24e88e26d51c82ceda3840ef6f5dc78416d2f)
|
|
55
|
+
- header cart counter always visible [`ac262b1`](https://github.com/eea/volto-clms-theme/commit/ac262b145adff04ca3084ec1bda2387aa03914da)
|
|
56
|
+
|
|
57
|
+
#### [1.0.50](https://github.com/eea/volto-clms-theme/compare/1.0.49...1.0.50)
|
|
58
|
+
|
|
59
|
+
> 17 December 2021
|
|
60
|
+
|
|
61
|
+
- Develop [`#158`](https://github.com/eea/volto-clms-theme/pull/158)
|
|
62
|
+
- cart icon with 0 items [`477f1ef`](https://github.com/eea/volto-clms-theme/commit/477f1efa39d6d5e4adede1b3c4f15e2b524dbcf5)
|
|
63
|
+
- add routing to dataset view [`e65a730`](https://github.com/eea/volto-clms-theme/commit/e65a7304fc338b3262b7f9dad9b5c5029391f3c1)
|
|
64
|
+
- add option without routing [`9675773`](https://github.com/eea/volto-clms-theme/commit/9675773a9531a98cee7f9735b09ebc6c3cfcd6fe)
|
|
65
|
+
|
|
7
66
|
#### [1.0.49](https://github.com/eea/volto-clms-theme/compare/1.0.48...1.0.49)
|
|
8
67
|
|
|
68
|
+
> 17 December 2021
|
|
69
|
+
|
|
70
|
+
- DataSet Metadata view [`#157`](https://github.com/eea/volto-clms-theme/pull/157)
|
|
9
71
|
- labels and conformity pass [`59be2fd`](https://github.com/eea/volto-clms-theme/commit/59be2fd5034fdfed211c4e0b0872504432e254e9)
|
|
10
72
|
- image [`47cc7dc`](https://github.com/eea/volto-clms-theme/commit/47cc7dc37974848f2d90cdf6a035970620489cf8)
|
|
11
73
|
|
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ Demo GIF
|
|
|
63
63
|
|
|
64
64
|
* The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
|
|
65
65
|
* It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
|
|
66
|
-
* The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the
|
|
66
|
+
* The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the `README.md` badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
|
|
67
67
|
* Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
|
|
68
68
|
* As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
|
|
69
69
|
* The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-clms-theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "volto-clms-theme: Volto theme for CLMS site",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "CodeSyntax for the European Environment Agency",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-svg": "14.0.4",
|
|
50
50
|
"@eeacms/volto-arcgis-block": "*",
|
|
51
51
|
"react-native-mime-types": "2.3.0",
|
|
52
|
-
"@eeacms/volto-clms-utils": "0.1.
|
|
52
|
+
"@eeacms/volto-clms-utils": "0.1.3",
|
|
53
53
|
"volto-form-block": "2.1.0",
|
|
54
54
|
"@eeacms/volto-taxonomy": "^1.0.0"
|
|
55
55
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get cart selection to downloadtool.
|
|
3
|
+
* @module actions/getDatasetsByUid
|
|
4
|
+
*/
|
|
5
|
+
export const DATASETS_BY_UID = 'DATASETS_BY_UID';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get cart selection to downloadtool.
|
|
9
|
+
* @function GetDatasetsByUid
|
|
10
|
+
* @returns {Object} Get extra items action.
|
|
11
|
+
*/
|
|
12
|
+
export function getDatasetsByUid(uids) {
|
|
13
|
+
return {
|
|
14
|
+
type: DATASETS_BY_UID,
|
|
15
|
+
request: {
|
|
16
|
+
op: 'get',
|
|
17
|
+
path: '/@datasets_by_uid?UID=' + uids,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -9,13 +9,13 @@ export const DELETE_DOWNLOADTOOL = 'DELETE_DOWNLOADTOOL';
|
|
|
9
9
|
* @function deleteDownloadtool
|
|
10
10
|
* @returns {Object} Get extra items action.
|
|
11
11
|
*/
|
|
12
|
-
export function deleteDownloadtool(
|
|
12
|
+
export function deleteDownloadtool(task_id, user_id) {
|
|
13
13
|
return {
|
|
14
14
|
type: DELETE_DOWNLOADTOOL,
|
|
15
15
|
request: {
|
|
16
16
|
op: 'del',
|
|
17
|
-
data: {
|
|
18
|
-
path:
|
|
17
|
+
data: { TaskID: task_id },
|
|
18
|
+
path: `/@datarequest_delete`,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -9,12 +9,12 @@ export const GET_DOWNLOADTOOL = 'GET_DOWNLOADTOOL';
|
|
|
9
9
|
* @function GetDownloadtool
|
|
10
10
|
* @returns {Object} Get extra items action.
|
|
11
11
|
*/
|
|
12
|
-
export function getDownloadtool(
|
|
12
|
+
export function getDownloadtool() {
|
|
13
13
|
return {
|
|
14
14
|
type: GET_DOWNLOADTOOL,
|
|
15
15
|
request: {
|
|
16
16
|
op: 'get',
|
|
17
|
-
path: `/@datarequest_search?
|
|
17
|
+
path: `/@datarequest_search?status=In_progress`,
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -9,7 +9,8 @@ export const POST_DOWNLOADTOOL = 'POST_DOWNLOADTOOL';
|
|
|
9
9
|
* @function PostDownloadtool
|
|
10
10
|
* @returns {Object} Get extra items action.
|
|
11
11
|
*/
|
|
12
|
-
export function postDownloadtool(item) {
|
|
12
|
+
export function postDownloadtool(item, unique_ids) {
|
|
13
|
+
// console.log("unique_ids: ", unique_ids);
|
|
13
14
|
return {
|
|
14
15
|
type: POST_DOWNLOADTOOL,
|
|
15
16
|
request: {
|
|
@@ -17,5 +18,6 @@ export function postDownloadtool(item) {
|
|
|
17
18
|
data: item,
|
|
18
19
|
path: '/@datarequest_post',
|
|
19
20
|
},
|
|
21
|
+
unique_ids: unique_ids,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get cart selection to downloadtool.
|
|
3
|
+
* @module actions/getFormatConversionTable
|
|
4
|
+
*/
|
|
5
|
+
export const GET_FORMATCONVERSIONTABLE = 'GET_FORMATCONVERSIONTABLE';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get cart selection to downloadtool.
|
|
9
|
+
* @function GetFormatConversionTable
|
|
10
|
+
* @returns {Object} Get extra items action.
|
|
11
|
+
*/
|
|
12
|
+
export function getFormatConversionTable() {
|
|
13
|
+
return {
|
|
14
|
+
type: GET_FORMATCONVERSIONTABLE,
|
|
15
|
+
request: {
|
|
16
|
+
op: 'get',
|
|
17
|
+
path: '/@format_conversion_table',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/actions/index.js
CHANGED
|
@@ -47,6 +47,18 @@ export {
|
|
|
47
47
|
deleteDownloadtool,
|
|
48
48
|
} from './downloadtool/delete_downloadtool';
|
|
49
49
|
|
|
50
|
+
export {
|
|
51
|
+
GET_FORMATCONVERSIONTABLE,
|
|
52
|
+
getFormatConversionTable,
|
|
53
|
+
} from './format_conversion_table/get_format_conversion_table';
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
DATASETS_BY_UID,
|
|
57
|
+
getDatasetsByUid,
|
|
58
|
+
} from './datasets_by_uid/datasets_by_uid';
|
|
59
|
+
|
|
60
|
+
export { GET_PROJECTIONS, getProjections } from './projections/get_projections';
|
|
61
|
+
|
|
50
62
|
export { GET_REGISTRY, getRegistry } from './registry/registry';
|
|
51
63
|
|
|
52
64
|
export {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get cart selection to downloadtool.
|
|
3
|
+
* @module actions/getProjections
|
|
4
|
+
*/
|
|
5
|
+
export const GET_PROJECTIONS = 'GET_PROJECTIONS';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get cart selection to downloadtool.
|
|
9
|
+
* @function GetProjections
|
|
10
|
+
* @returns {Object} Get extra items action.
|
|
11
|
+
*/
|
|
12
|
+
export function getProjections() {
|
|
13
|
+
return {
|
|
14
|
+
type: GET_PROJECTIONS,
|
|
15
|
+
request: {
|
|
16
|
+
op: 'get',
|
|
17
|
+
path: '/@projections',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -23,10 +23,10 @@ const TextLinkCarouselView = (props) => {
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<>
|
|
26
|
-
<div
|
|
26
|
+
<div className="ccl-container">
|
|
27
27
|
<Slider {...settings} ref={slider} className="text-carousel">
|
|
28
|
-
{data?.textLink?.items.map((
|
|
29
|
-
<div className="text-link-carousel-block" key={
|
|
28
|
+
{data?.textLink?.items.map((key, item) => (
|
|
29
|
+
<div className="text-link-carousel-block" key={key}>
|
|
30
30
|
<div className="text-link-carousel-block-content">
|
|
31
31
|
<a href={'' + item?.link?.[0]?.['@id']}>{item.text}</a>
|
|
32
32
|
</div>
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { connect } from 'react-redux';
|
|
3
|
-
import { compose } from 'redux';
|
|
4
|
-
import { withRouter } from 'react-router';
|
|
5
|
-
import loadable from '@loadable/component';
|
|
6
|
-
import { RenderBlocks } from '@plone/volto/components';
|
|
7
|
-
import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
|
|
8
1
|
import './custom.less';
|
|
9
|
-
import cx from 'classnames';
|
|
10
2
|
import 'slick-carousel/slick/slick.css';
|
|
11
3
|
import 'slick-carousel/slick/slick-theme.css';
|
|
12
4
|
import '@eeacms/volto-tabs-block/less/carousel.less';
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { RenderBlocks } from '@plone/volto/components';
|
|
8
|
+
import { compose } from 'redux';
|
|
9
|
+
import { connect } from 'react-redux';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
import loadable from '@loadable/component';
|
|
12
|
+
import { withRouter } from 'react-router';
|
|
13
|
+
import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
|
|
13
14
|
const Slider = loadable(() => import('react-slick'));
|
|
14
15
|
|
|
15
16
|
const View = (props) => {
|
|
@@ -32,7 +33,7 @@ const View = (props) => {
|
|
|
32
33
|
speed: 2000,
|
|
33
34
|
fade: true,
|
|
34
35
|
cssEase: 'linear',
|
|
35
|
-
autoplay:
|
|
36
|
+
autoplay: true,
|
|
36
37
|
autoplaySpeed: 5000,
|
|
37
38
|
beforeChange: (oldIndex, index) => {
|
|
38
39
|
setActiveTab(tabsList[index]);
|
|
@@ -190,7 +190,7 @@ const CLMSDatasetDetailView = ({ content, token }) => {
|
|
|
190
190
|
})}
|
|
191
191
|
</Segment.Group>
|
|
192
192
|
)}
|
|
193
|
-
<CclTabs>
|
|
193
|
+
<CclTabs routing={true}>
|
|
194
194
|
<div tabTitle="General Info">{DataSetInfoContent(content)}</div>
|
|
195
195
|
<div tabTitle="Metadata">{MetadataContent(content)}</div>
|
|
196
196
|
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
/**
|
|
3
|
+
* CLMSCartContent container.
|
|
4
|
+
* @module components/CLMSDownloadCartView/CLMSCartContent
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import {
|
|
9
|
+
getCartObjectFromMapviewer,
|
|
10
|
+
getCartObjectFromPrepackaged,
|
|
11
|
+
getDownloadToolPostBody,
|
|
12
|
+
} from './cartUtils';
|
|
13
|
+
import {
|
|
14
|
+
getDatasetsByUid,
|
|
15
|
+
getDownloadtool,
|
|
16
|
+
getFormatConversionTable,
|
|
17
|
+
getProjections,
|
|
18
|
+
postDownloadtool,
|
|
19
|
+
} from '../../actions';
|
|
20
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
21
|
+
|
|
22
|
+
import { CART_SESSION_KEY } from '@eeacms/volto-clms-utils/cart/useCartState';
|
|
23
|
+
import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
|
|
24
|
+
import { Checkbox } from 'semantic-ui-react';
|
|
25
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
26
|
+
import { Select } from 'semantic-ui-react';
|
|
27
|
+
import { cleanDuplicatesEntries } from '@eeacms/volto-clms-utils/utils';
|
|
28
|
+
import { getAvailableConversion } from './conversion';
|
|
29
|
+
import useCartState from '@eeacms/volto-clms-utils/cart/useCartState';
|
|
30
|
+
|
|
31
|
+
const CLMSCartContent = (props) => {
|
|
32
|
+
const dispatch = useDispatch();
|
|
33
|
+
const { cart, removeCartItem } = useCartState();
|
|
34
|
+
const [cartSelection, setCartSelection] = useState([]);
|
|
35
|
+
const post_download_in_progress = useSelector(
|
|
36
|
+
(state) => state.downloadtool.post_download_in_progress,
|
|
37
|
+
);
|
|
38
|
+
const user_id = useSelector((state) => state.users.user.id);
|
|
39
|
+
const datasets = useSelector((state) => state.datasetsByUid.datasets.items);
|
|
40
|
+
const formatConversionTable = useSelector(
|
|
41
|
+
(state) => state.downloadtool.format_conversion_table_in_progress,
|
|
42
|
+
);
|
|
43
|
+
const projections = useSelector(
|
|
44
|
+
(state) => state.downloadtool.projections_in_progress,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const [cartItems, setCartItems] = useState([]);
|
|
48
|
+
const [localSessionCart, setLocalSessionCart] = useState([]);
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
dispatch(getProjections());
|
|
52
|
+
dispatch(getFormatConversionTable());
|
|
53
|
+
}, [dispatch]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const CART_SESSION_USER_KEY = CART_SESSION_KEY.concat(`_${user_id}`);
|
|
57
|
+
setLocalSessionCart(
|
|
58
|
+
JSON.parse(localStorage.getItem(CART_SESSION_USER_KEY)) || [],
|
|
59
|
+
);
|
|
60
|
+
}, [user_id]);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (localSessionCart?.length !== 0) {
|
|
64
|
+
const uidsList = [
|
|
65
|
+
...new Set(localSessionCart.map((item) => item.UID || item.id)),
|
|
66
|
+
];
|
|
67
|
+
dispatch(getDatasetsByUid(uidsList));
|
|
68
|
+
}
|
|
69
|
+
}, [localSessionCart, dispatch]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (datasets?.length > 0) {
|
|
73
|
+
concatRequestedCartItem();
|
|
74
|
+
}
|
|
75
|
+
}, [datasets]);
|
|
76
|
+
|
|
77
|
+
function concatRequestedCartItem() {
|
|
78
|
+
localSessionCart.forEach((localItem) => {
|
|
79
|
+
const requestedItem = datasets.find(
|
|
80
|
+
(requestedItem) => requestedItem.UID === localItem.UID,
|
|
81
|
+
);
|
|
82
|
+
if (requestedItem) {
|
|
83
|
+
const file_data = requestedItem?.downloadable_files?.items.find(
|
|
84
|
+
(item) => item['@id'] === localItem.file_id,
|
|
85
|
+
);
|
|
86
|
+
if (file_data) {
|
|
87
|
+
cartItems.push(
|
|
88
|
+
getCartObjectFromPrepackaged(file_data, requestedItem),
|
|
89
|
+
);
|
|
90
|
+
setCartItems(cleanDuplicatesEntries(cartItems));
|
|
91
|
+
} else if (localItem.area) {
|
|
92
|
+
cartItems.push(getCartObjectFromMapviewer(localItem, requestedItem));
|
|
93
|
+
setCartItems(cleanDuplicatesEntries(cartItems));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const selectAllCart = (checked) => {
|
|
100
|
+
if (checked) {
|
|
101
|
+
setCartSelection(
|
|
102
|
+
cartItems
|
|
103
|
+
.filter((item) => item.task_in_progress === false)
|
|
104
|
+
.map((item, key) => item.unique_id),
|
|
105
|
+
);
|
|
106
|
+
} else {
|
|
107
|
+
setCartSelection([]);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const selectCart = (id, checked) => {
|
|
112
|
+
if (checked) setCartSelection(cartSelection.concat(id));
|
|
113
|
+
else setCartSelection(cartSelection.filter((arr_id) => arr_id !== id));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const getSelectedCartItems = () => {
|
|
117
|
+
return cartItems.filter(
|
|
118
|
+
(item) => cartSelection.indexOf(item.unique_id) > -1,
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
const setCartItemInProgress = (in_progress_unique_ids) => {
|
|
124
|
+
let started_processing_items = cartItems.filter((r) =>
|
|
125
|
+
in_progress_unique_ids.includes(r['unique_id']),
|
|
126
|
+
);
|
|
127
|
+
started_processing_items.forEach((item) => {
|
|
128
|
+
if (item['unique_id']) {
|
|
129
|
+
removeCartItem(item['unique_id'], user_id);
|
|
130
|
+
dispatch(getFormatConversionTable());
|
|
131
|
+
dispatch(getDownloadtool());
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
setCartItemInProgress(post_download_in_progress['unique_ids']);
|
|
138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
139
|
+
}, [post_download_in_progress]);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
const array_ids = cart?.map((item) => item.unique_id);
|
|
143
|
+
const newCart = cartItems.filter((item) =>
|
|
144
|
+
array_ids.includes(item.unique_id),
|
|
145
|
+
);
|
|
146
|
+
setCartItems(newCart);
|
|
147
|
+
}, [cart]);
|
|
148
|
+
|
|
149
|
+
function startDownloading() {
|
|
150
|
+
let selectedItems = getSelectedCartItems();
|
|
151
|
+
const body = getDownloadToolPostBody(selectedItems);
|
|
152
|
+
const unique_ids = selectedItems.map((item) => item.unique_id);
|
|
153
|
+
dispatch(postDownloadtool(body, unique_ids));
|
|
154
|
+
}
|
|
155
|
+
const setProjectionValue = (unique_id, value) => {
|
|
156
|
+
const objIndex = cartItems.findIndex((obj) => obj.unique_id === unique_id);
|
|
157
|
+
cartItems[objIndex].projection = value;
|
|
158
|
+
setCartItems([...cartItems]);
|
|
159
|
+
};
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
{localSessionCart?.length !== 0 ? (
|
|
163
|
+
<div className="custom-table cart-table">
|
|
164
|
+
<h2>My cart</h2>
|
|
165
|
+
<table>
|
|
166
|
+
<thead>
|
|
167
|
+
<tr>
|
|
168
|
+
<th className="table-th-warning"></th>
|
|
169
|
+
<th className="table-th-checkbox">
|
|
170
|
+
<div className="ccl-form">
|
|
171
|
+
<div className="ccl-form-group">
|
|
172
|
+
<Checkbox
|
|
173
|
+
onChange={(e, data) => selectAllCart(data.checked)}
|
|
174
|
+
checked={
|
|
175
|
+
cartItems
|
|
176
|
+
? cartItems
|
|
177
|
+
.filter(
|
|
178
|
+
(item) => item.task_in_progress === false,
|
|
179
|
+
)
|
|
180
|
+
.map((item, key) => item.unique_id)
|
|
181
|
+
.every(function (val) {
|
|
182
|
+
return cartSelection.indexOf(val) !== -1;
|
|
183
|
+
})
|
|
184
|
+
: false
|
|
185
|
+
}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</th>
|
|
190
|
+
<th>Name</th>
|
|
191
|
+
<th>Source</th>
|
|
192
|
+
<th>Area</th>
|
|
193
|
+
{/* <th>Year</th>
|
|
194
|
+
<th>Resolution</th> */}
|
|
195
|
+
<th>Type</th>
|
|
196
|
+
<th>Format</th>
|
|
197
|
+
<th>Projection</th>
|
|
198
|
+
<th>Version</th>
|
|
199
|
+
<th>Size</th>
|
|
200
|
+
<th></th>
|
|
201
|
+
</tr>
|
|
202
|
+
</thead>
|
|
203
|
+
<tbody>
|
|
204
|
+
{cartItems &&
|
|
205
|
+
cartItems.map((item, key) => (
|
|
206
|
+
<tr
|
|
207
|
+
key={key}
|
|
208
|
+
style={
|
|
209
|
+
item.task_in_progress
|
|
210
|
+
? { opacity: 0.5, backgroundColor: '#f5f5f5' }
|
|
211
|
+
: {}
|
|
212
|
+
}
|
|
213
|
+
>
|
|
214
|
+
<td className="table-td-warning hidden-warning">
|
|
215
|
+
{!!item.warning && (
|
|
216
|
+
<span
|
|
217
|
+
className="info-icon"
|
|
218
|
+
tooltip={item.warning}
|
|
219
|
+
direction="up"
|
|
220
|
+
>
|
|
221
|
+
<FontAwesomeIcon
|
|
222
|
+
icon={['fas', 'exclamation-triangle']}
|
|
223
|
+
/>
|
|
224
|
+
</span>
|
|
225
|
+
)}
|
|
226
|
+
</td>
|
|
227
|
+
<td className="table-td-checkbox">
|
|
228
|
+
<div className="ccl-form">
|
|
229
|
+
<div className="ccl-form-group">
|
|
230
|
+
<Checkbox
|
|
231
|
+
onChange={(e, data) =>
|
|
232
|
+
selectCart(item.unique_id, data.checked)
|
|
233
|
+
}
|
|
234
|
+
checked={cartSelection.includes(item.unique_id)}
|
|
235
|
+
disabled={item.task_in_progress}
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</td>
|
|
240
|
+
<td>{item.name || '-'}</td>
|
|
241
|
+
<td>{item.source || '-'}</td>
|
|
242
|
+
<td>{item.area.type || '-'}</td>
|
|
243
|
+
{/* <td>{item.year || '-'}</td>
|
|
244
|
+
<td>{item.resolution || '-'}</td> */}
|
|
245
|
+
<td>
|
|
246
|
+
<span className={'tag tag-' + item?.type?.toLowerCase()}>
|
|
247
|
+
{item.type || '-'}
|
|
248
|
+
</span>
|
|
249
|
+
</td>
|
|
250
|
+
<td className="table-td-format">
|
|
251
|
+
{!item.file_id ? (
|
|
252
|
+
<Select
|
|
253
|
+
placeholder="Select format"
|
|
254
|
+
value={item.format?.token || item.format}
|
|
255
|
+
options={getAvailableConversion(
|
|
256
|
+
formatConversionTable,
|
|
257
|
+
item.format?.token || item.format,
|
|
258
|
+
)}
|
|
259
|
+
onChange={(e, data) => {
|
|
260
|
+
const objIndex = cartItems.findIndex(
|
|
261
|
+
(obj) => obj.unique_id === item.unique_id,
|
|
262
|
+
);
|
|
263
|
+
cartItems[objIndex].format = data.value;
|
|
264
|
+
setCartItems([...cartItems]);
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
) : (
|
|
268
|
+
item.format?.token || item.format
|
|
269
|
+
)}
|
|
270
|
+
</td>
|
|
271
|
+
<td className="table-td-projections">
|
|
272
|
+
{!item.file_id ? (
|
|
273
|
+
<Select
|
|
274
|
+
placeholder="Select projection"
|
|
275
|
+
value={
|
|
276
|
+
item.projection ||
|
|
277
|
+
setProjectionValue(item.unique_id, projections[0])
|
|
278
|
+
}
|
|
279
|
+
options={projections.map((item) => {
|
|
280
|
+
return {
|
|
281
|
+
key: item,
|
|
282
|
+
value: item,
|
|
283
|
+
text: item,
|
|
284
|
+
};
|
|
285
|
+
})}
|
|
286
|
+
onChange={(e, data) => {
|
|
287
|
+
setProjectionValue(item.unique_id, data.value);
|
|
288
|
+
}}
|
|
289
|
+
/>
|
|
290
|
+
) : (
|
|
291
|
+
item.projection
|
|
292
|
+
)}
|
|
293
|
+
</td>
|
|
294
|
+
<td>{item.version}</td>
|
|
295
|
+
<td>{item.size}</td>
|
|
296
|
+
<td>
|
|
297
|
+
{item.task_in_progress ? (
|
|
298
|
+
<FontAwesomeIcon icon="spinner" spin />
|
|
299
|
+
) : (
|
|
300
|
+
<FontAwesomeIcon
|
|
301
|
+
icon={['fas', 'trash']}
|
|
302
|
+
style={{ cursor: 'pointer' }}
|
|
303
|
+
onClick={() => {
|
|
304
|
+
removeCartItem(item.unique_id);
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
)}
|
|
308
|
+
</td>
|
|
309
|
+
</tr>
|
|
310
|
+
))}
|
|
311
|
+
</tbody>
|
|
312
|
+
</table>
|
|
313
|
+
</div>
|
|
314
|
+
) : (
|
|
315
|
+
<h2 style={{ textAlign: 'center' }}>Empty cart</h2>
|
|
316
|
+
)}
|
|
317
|
+
{localSessionCart?.length !== 0 && (
|
|
318
|
+
<CclButton
|
|
319
|
+
onClick={() => startDownloading()}
|
|
320
|
+
disabled={cartSelection.length === 0}
|
|
321
|
+
>
|
|
322
|
+
Start downloading
|
|
323
|
+
</CclButton>
|
|
324
|
+
)}
|
|
325
|
+
</>
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export default CLMSCartContent;
|