Skip to content

Commit

Permalink
Merge pull request #48 from eea/develop
Browse files Browse the repository at this point in the history
have data query from context and custom on block
  • Loading branch information
andreiggr authored Nov 16, 2022
2 parents 0f0fdad + 8e2b040 commit 0aead1b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 81 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [5.0.2](https://github.com/eea/volto-plotlycharts/compare/5.0.1...5.0.2) - 9 November 2022
### [5.0.3](https://github.com/eea/volto-plotlycharts/compare/5.0.2...5.0.3) - 16 November 2022

#### :hammer_and_wrench: Others

- data query updates [andreiggr - [`db6a18c`](https://github.com/eea/volto-plotlycharts/commit/db6a18c5cc310877fdb589aef2a6ac84a35920c5)]
- have data query from context and custom on block [andreiggr - [`7224436`](https://github.com/eea/volto-plotlycharts/commit/72244367c71ce5534d3d21c18b0ee06bc8583194)]
### [5.0.2](https://github.com/eea/volto-plotlycharts/compare/5.0.1...5.0.2) - 10 November 2022

#### :hammer_and_wrench: Others

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-plotlycharts",
"version": "5.0.2",
"version": "5.0.3",
"description": "Plotly Charts and Editor integration for Volto",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -25,20 +25,20 @@
"@eeacms/volto-block-style"
],
"dependencies": {
"@eeacms/volto-block-style": "4.1.0",
"@eeacms/volto-datablocks": "*",
"@eeacms/volto-matomo": "*",
"@plone/scripts": "*",
"plotly.js": "^2.9.0",
"@eeacms/volto-block-style": "4.1.0",
"react-chart-editor": "0.45.0",
"react-colorscales": "0.7.3",
"react-inspector": "5.1.1",
"react-json-editor-ajrm": "2.5.13",
"react-plotly.js": "2.5.1"
},
"devDependencies": {
"@plone/scripts": "*",
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
"babel-plugin-transform-class-properties": "^6.24.1",
"md5": "^2.3.0"
},
Expand Down
2 changes: 0 additions & 2 deletions src/Blocks/EmbedEEAVisualization/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const Edit = (props) => {
data_query: data.data_query,
download_button: data.download_button,
has_data_query_by_context: data.has_data_query_by_context,
has_data_query_by_provider: data.has_data_query_by_provider,
use_live_data: true,
vis_url: data.vis_url,
with_sources: data.show_sources,
include_sources_download: data?.include_sources_download,
Expand Down
15 changes: 4 additions & 11 deletions src/Blocks/EmbedEEAVisualization/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ const Schema = (props) => {
{
id: 'data_query',
title: 'Data query',
fields: [
'has_data_query_by_context',
'has_data_query_by_provider',
'data_query',
],
fields: ['has_data_query_by_context', 'data_query'],
},
],

Expand Down Expand Up @@ -132,13 +128,10 @@ const Schema = (props) => {
description: 'Will use Criteria queries from context (this page)',
type: 'boolean',
},
has_data_query_by_provider: {
title: 'Use queries from visualization',
description: 'Will use Criteria queries from visualization',
type: 'boolean',
},
data_query: {
title: 'Query',
title: 'Block Query',
description:
'Query data on this block. If context queries are present, block queries will be overridden.',
widget: 'data_query',
},
},
Expand Down
19 changes: 10 additions & 9 deletions src/ConnectedChart2/ConnectedChart2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function ConnectedChart2(props) {
provider_data,
provider_metadata,
visualization,
visualization_data,
width,
height = 450,
id,
Expand All @@ -49,11 +48,9 @@ function ConnectedChart2(props) {
other_organisations,
temporal_coverage,
} = props;
const use_live_data = props.data?.use_live_data ?? true;
const with_sources = props?.withSources ?? false;

const chartData =
visualization?.chartData || visualization_data?.chartData || {};
const chartData = visualization || {};

React.useEffect(() => {
if (props.data?.vis_url) {
Expand Down Expand Up @@ -103,11 +100,12 @@ function ConnectedChart2(props) {
'',
};
}

let data =
provider_data && use_live_data
? updateChartDataFromProvider(chartData.data || [], provider_data)
: chartData.data || [];
// console.log(provider_data, ' provider_data');
// console.log(props.data.data_query, ' props.data.data_query');
// console.log(chartData, ' chartData');
let data = provider_data
? updateChartDataFromProvider(chartData.data || [], provider_data)
: chartData.data || [];

data = data.map((trace) => ({
...trace,
Expand Down Expand Up @@ -194,6 +192,9 @@ export default compose(
connect(
(state, props) => ({
//mapped core metadata data to props. Include more if needed
subreq: state.content.subrequests?.[props.id]?.data,
visualization:
state.content.subrequests?.[props.id]?.data?.visualization?.chartData,
temporal_coverage:
state.content.subrequests?.[props.id]?.data?.temporal_coverage,
other_organisations:
Expand Down
50 changes: 0 additions & 50 deletions src/Widgets/DataQueryWidget.jsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/Widgets/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import VisualizationWidget from './VisualizationWidget';
import DataQueryWidget from './DataQueryWidget';

export { VisualizationWidget, DataQueryWidget };
export { VisualizationWidget };
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VisualizationView } from './Views';
import { DataQueryWidget, VisualizationWidget } from './Widgets';
import { VisualizationWidget } from './Widgets';
import installEmbedVisualization from './Blocks/EmbedVisualization';

//TODO: this will replace the current embed viz
Expand Down Expand Up @@ -34,8 +34,6 @@ const applyConfig = (config) => {
...addonReducers,
};

config.widgets.widget.data_query_widget = DataQueryWidget;

return [
installEmbedVisualization,
//first one here ^^ will get old and be removed in time TODO:
Expand Down

0 comments on commit 0aead1b

Please sign in to comment.