diff --git a/geonode_mapstore_client/client/js/plugins/TabularCollectionViewer.jsx b/geonode_mapstore_client/client/js/plugins/TabularCollectionViewer.jsx index 735c819e6f..276451eed2 100644 --- a/geonode_mapstore_client/client/js/plugins/TabularCollectionViewer.jsx +++ b/geonode_mapstore_client/client/js/plugins/TabularCollectionViewer.jsx @@ -2,44 +2,21 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import { Tabs, Tab } from 'react-bootstrap'; import { createPlugin } from '@mapstore/framework/utils/PluginsUtils'; -import { describeFeatureType, getFeatureSimple } from '@mapstore/framework/api/WFS'; -import Table from '@js/components/Table'; import resourceReducer from '@js/reducers/gnresource'; import { layersSelector } from '@mapstore/framework/selectors/layers'; -import TabularPreview, { TableComponent } from './TabularPreview'; +import { TableComponent } from './TabularPreview'; function propertyToKey(property, index) { return `${property}`; }; -function headerFromFeatures(data) { - const feature = data.features[0] || [] - const properties = feature.properties; - return Object.keys(properties).map((p, index) => ({ value: p, key: propertyToKey(p, index) })); -}; - -function rowsFromFeatures(data) { - const features = data.features || [] - // [{col1: "value"}] - return features.map((feature, index) => { - const row = {} - const properties = feature.properties - Object.keys(properties) - .forEach(name => Object.assign(row, { [propertyToKey(name, index)]: properties[name] })) - return row; - }); -}; - - - - function TabbedTablesComponent({ owsUrl, tableLayers }) { - const [header, setHeader] = useState(); - const [rows, setRows] = useState(); - const [error, setError] = useState(); + const [tabs, setTabs] = useState([]) + const [key, setKey] = useState(0); if (tableLayers && tableLayers.length == 1) { const typeName = tableLayers[0].name; @@ -48,34 +25,25 @@ function TabbedTablesComponent({ owsUrl, tableLayers }) { ) } - // useEffect(() => { - // const getFeatures = async () => { - // try { - // const data = await getFeatureSimple(owsUrl, { typeName }); - // setHeader(headerFromFeatures(data)); - // setRows(rowsFromFeatures(data)); - // } catch(error) { - // setError(error) - // } - // } - // if (owsUrl) { - // getFeatures() - // } - // }, [owsUrl, typeName]) + useEffect(() => { + setTabs(tableLayers.map((layer, i) => { + return ( + + + + ) + })); + }, [owsUrl, tableLayers]); - if (error) { - console.error(error); - } - if (!rows) { - return
No data available!
- } return ( -
-
- {/* */} - Hello Tabbed Tables! - - + setKey(k) } + > + {tabs} + ); }; diff --git a/geonode_mapstore_client/client/themes/geonode/less/geonode.less b/geonode_mapstore_client/client/themes/geonode/less/geonode.less index 329eb3c622..cd92bd621f 100644 --- a/geonode_mapstore_client/client/themes/geonode/less/geonode.less +++ b/geonode_mapstore_client/client/themes/geonode/less/geonode.less @@ -43,6 +43,14 @@ #gn-base-components-theme(@gn-theme-vars); #gn-components-theme(@gn-theme-vars); +#tabular-data-collection-tabs { + ul[role=tablist] { + li.active > a { + background-color: darkgray; + } + } +} + #tabular-preview { div {