Skip to content

Commit 5618f01

Browse files
Update the layout of the dataset viewer for the non-spatial dataset (#2357)
--------- Co-authored-by: allyoucanmap <stefano.bovio@geosolutionsgroup.com>
1 parent 0b80b21 commit 5618f01

File tree

9 files changed

+428
-21
lines changed

9 files changed

+428
-21
lines changed

geonode_mapstore_client/client/js/epics/gnresource.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import {
100100
getCataloguePath,
101101
isDefaultDatasetSubtype,
102102
resourceHasPermission,
103+
checkIfGeometryAttributeIsNull,
103104
canEditMap
104105
} from '@js/utils/ResourceUtils';
105106
import {
@@ -182,6 +183,7 @@ const resourceTypes = {
182183
const [mapConfig, gnLayer, newLayer] = response;
183184
const {minx, miny, maxx, maxy } = newLayer?.bbox?.bounds || {};
184185
const extent = newLayer?.bbox?.bounds && [minx, miny, maxx, maxy ];
186+
const hasNoGeometry = checkIfGeometryAttributeIsNull(gnLayer.attribute_set);
185187
const hasDownloadPermission = gnLayer?.perms?.includes('download_resourcebase');
186188
return Observable.of(
187189
configureMap({
@@ -206,9 +208,9 @@ const resourceTypes = {
206208
setControlProperty('toolbar', 'expanded', false),
207209
forceUpdateMapLayout(),
208210
selectNode(newLayer.id, 'layer', false),
209-
...(!options?.isSamePreviousResource ? [setResource(gnLayer)] : []),
211+
...(!options?.isSamePreviousResource ? [setResource({...gnLayer, hasNoGeometry})] : []),
210212
setResourceId(pk),
211-
...(page === 'dataset_edit_data_viewer'
213+
...((hasNoGeometry || page === 'dataset_edit_data_viewer')
212214
? [
213215
browseData(newLayer),
214216
...(hasDownloadPermission ? [] : [setDatasetEditPermissionsError('gnviewer.noEditPermissions')])

geonode_mapstore_client/client/js/plugins/ResourceDetails/ResourceDetails.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import gnresource from '@js/reducers/gnresource';
3838
import useDetectClickOut from '@js/hooks/useDetectClickOut';
3939
import tabComponents from '@js/plugins/ResourceDetails/containers/tabComponents';
4040
import DetailsPanel from '@js/plugins/ResourceDetails/containers/DetailsPanel';
41+
import { toggleEditMode } from '@mapstore/framework/actions/featuregrid';
4142

4243
/**
4344
* @module ResourceDetails
@@ -219,7 +220,8 @@ function ResourceDetailsPanel({
219220
"type": "locations",
220221
"id": "locations",
221222
"labelId": "gnviewer.locations",
222-
"items": "{getExtentObject(state('gnResourceData'))}"
223+
"items": "{getExtentObject(state('gnResourceData'))}",
224+
"disableIf": "{context.get(state('gnResourceData'), 'hasNoGeometry')}"
223225
},
224226
{
225227
"type": "relations",
@@ -453,6 +455,18 @@ export default createPlugin('ResourceDetails', {
453455
}),
454456
priority: 1,
455457
doNotHide: true
458+
}, {
459+
name: 'EditDataActionButton',
460+
Component: connect(
461+
() => ({}),
462+
{ onClick: toggleEditMode }
463+
)(({ onClick, size }) => {
464+
return <Button size={size} onClick={onClick}>
465+
<Message msgId="gnviewer.editData" />
466+
</Button>;
467+
}),
468+
priority: 1,
469+
doNotHide: true
456470
}],
457471
ResourcesGrid: {
458472
priority: 2,

geonode_mapstore_client/client/js/routes/Viewer.jsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getPlugins } from '@mapstore/framework/utils/ModulePluginsUtils';
2525
import MapViewerLayout from '@mapstore/framework/containers/MapViewerLayout';
2626

2727
const urlQuery = url.parse(window.location.href, true).query;
28+
const DATASET_VIEWER = 'dataset_viewer';
2829

2930
const ConnectedPluginsContainer = connect(
3031
createShallowSelector(
@@ -55,6 +56,15 @@ function getPluginsConfiguration(name, pluginsConfig) {
5556
return pluginsConfig[name] || DEFAULT_PLUGINS_CONFIG;
5657
}
5758

59+
function getPluginName(name, options = {}) {
60+
const { hasNoGeometry } = options;
61+
const isDatasetViewer = name === DATASET_VIEWER;
62+
if (isDatasetViewer && typeof hasNoGeometry === 'boolean' && hasNoGeometry) {
63+
return `${name}_non_spatial`;
64+
}
65+
return name;
66+
}
67+
5868
function ViewerRoute({
5969
name,
6070
pluginsConfig: propPluginsConfig,
@@ -70,11 +80,18 @@ function ViewerRoute({
7080
loadingConfig,
7181
configError,
7282
loaderStyle,
83+
loading: isResourceLoading,
7384
datasetEditPermissionError
7485
}) {
75-
7686
const { pk } = match.params || {};
77-
const pluginsConfig = getPluginsConfiguration(name, propPluginsConfig);
87+
88+
// determine the plugins name based on the view, resource type and geometry field
89+
const pluginsName = getPluginName(name, { hasNoGeometry: resource?.hasNoGeometry });
90+
const shouldInitPlugins = !isResourceLoading && (resource || name === DATASET_VIEWER);
91+
// get the plugins configuration
92+
const pluginsConfig = shouldInitPlugins
93+
? getPluginsConfiguration(pluginsName, propPluginsConfig)
94+
: DEFAULT_PLUGINS_CONFIG;
7895
const pluginsCfgLength = pluginsConfig?.length;
7996

8097
const { plugins: loadedPlugins, pending } = useModulePlugins({
@@ -109,7 +126,7 @@ function ViewerRoute({
109126
}
110127
}, [pluginLoading, pk]);
111128

112-
const loading = loadingConfig || pluginLoading;
129+
const isLoading = isResourceLoading || loadingConfig || pluginLoading;
113130
const parsedPlugins = useMemo(() => ({ ...loadedPlugins, ...getPlugins(plugins) }), [loadedPlugins]);
114131
const Loader = loaderComponent;
115132
const className = `page-${resourceType || name}-viewer page-viewer`;
@@ -123,7 +140,7 @@ function ViewerRoute({
123140
contentURL={resource?.detail_url}
124141
content={resource?.abstract}
125142
/>}
126-
<ConnectedPluginsContainer
143+
{!isLoading ? <ConnectedPluginsContainer
127144
key={className}
128145
id={className}
129146
className={className}
@@ -132,8 +149,8 @@ function ViewerRoute({
132149
plugins={parsedPlugins}
133150
allPlugins={plugins}
134151
params={params}
135-
/>
136-
{loading && Loader && <Loader style={loaderStyle}/>}
152+
/> : null}
153+
{isLoading && Loader && <Loader style={loaderStyle}/>}
137154
{(configError || datasetEditPermissionError) && <MainEventView msgId={configError || datasetEditPermissionError}/>}
138155
</>
139156
);
@@ -149,12 +166,14 @@ const ConnectedViewerRoute = connect(
149166
state => state?.gnsettings?.siteName || 'GeoNode',
150167
state => state?.gnresource?.loadingResourceConfig,
151168
state => state?.gnresource?.configError,
169+
state => state?.gnresource?.loading,
152170
state => state?.gnresource?.datasetEditPermissionError
153-
], (resource, siteName, loadingConfig, configError, datasetEditPermissionError) => ({
171+
], (resource, siteName, loadingConfig, configError, loading, datasetEditPermissionError) => ({
154172
resource,
155173
siteName,
156174
loadingConfig,
157175
configError,
176+
loading,
158177
datasetEditPermissionError
159178
})),
160179
{

geonode_mapstore_client/client/js/utils/ResourceUtils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { excludeGoogleBackground, extractTileMatrixFromSources, ServerTypes } fr
1717
import { getGeoNodeLocalConfig, parseDevHostname } from '@js/utils/APIUtils';
1818
import { ProcessTypes, ProcessStatus } from '@js/utils/ResourceServiceUtils';
1919
import { determineResourceType } from '@js/utils/FileUtils';
20+
import { isGeometryType } from '@mapstore/framework/utils/ogc/WFS/base';
21+
2022
import { createDefaultStyle } from '@mapstore/framework/utils/StyleUtils';
2123
/**
2224
* @module utils/ResourceUtils
@@ -994,6 +996,10 @@ export const canAccessPermissions = (resource) => {
994996
return perms?.includes('change_resourcebase_permissions');
995997
};
996998

999+
export const checkIfGeometryAttributeIsNull = (attributeSet) => {
1000+
return isEmpty(attributeSet?.find(attribute => isGeometryType({ type: attribute.attribute_type })));
1001+
};
1002+
9971003
/**
9981004
* Check if the resource can be edited (for map resources)
9991005
* @param {Object} gnresource - The state of the resource

geonode_mapstore_client/client/themes/geonode/less/_base.less

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ body {
141141
}
142142

143143
.page-geostory-viewer {
144-
.gn-viewer-layout-center {
144+
.gn-viewer-layout-center,
145+
.ms-map-viewer-layout-content {
145146
position: relative;
146147
.ms-geostory {
147148
position: absolute;
@@ -158,7 +159,8 @@ body {
158159

159160
.page-dataset-viewer,
160161
.page-map-viewer {
161-
.gn-viewer-layout-body {
162+
.gn-viewer-layout-body,
163+
.ms-map-viewer-layout-body {
162164
// needed to compute the position of ma toolbar and background selector
163165
// when the attribute table is open
164166
transform: translate(0, 0);
@@ -178,7 +180,8 @@ body {
178180
}
179181

180182
.page-dashboard-viewer {
181-
.gn-viewer-layout-center {
183+
.gn-viewer-layout-center,
184+
.ms-map-viewer-layout-content {
182185
overflow-y: auto;
183186
overflow-x: hidden;
184187
z-index: 1;

geonode_mapstore_client/client/themes/geonode/less/_operation.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
background-color: rgba(0, 0, 0, 0.6);
3939
}
4040
.gn-upload-processing,
41-
.gn-viewer-right-column {
41+
.gn-viewer-right-column,
42+
.ms-map-viewer-layout-right-column {
4243
--gn-button-color: #eeeeee;
4344
--gn-button-bg: transparent;
4445
--gn-button-action-border-color: transparent;

geonode_mapstore_client/client/themes/geonode/less/ms-theme.less

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ div#mapstore-globalspinner {
384384
top: 0;
385385
}
386386

387-
.gn-viewer-layout-body {
387+
.gn-viewer-layout-body,
388+
.ms-map-viewer-layout-body {
388389
#mapstore-print-panel {
389390
&.modal-dialog {
390391
margin: 0;
@@ -393,6 +394,12 @@ div#mapstore-globalspinner {
393394
max-height: calc(100vh - 220px);
394395
}
395396
}
397+
&:has(.ms-featuregrid-container) {
398+
.ms-map-viewer-layout-bottom,
399+
.ms-featuregrid-container {
400+
height: 100%;
401+
}
402+
}
396403
}
397404
.gn-dataset-layersettings {
398405
.ms-header {

0 commit comments

Comments
 (0)