Skip to content

Commit

Permalink
include pluggable component for print (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Mar 15, 2022
1 parent 8e2305c commit 210064e
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 2 deletions.
19 changes: 17 additions & 2 deletions geonode_mapstore_client/client/js/api/geonode/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getUserInfo } from '@js/api/geonode/user';
import { setFilterById } from '@js/utils/SearchUtils';
import { ResourceTypes, availableResourceTypes, setAvailableResourceTypes } from '@js/utils/ResourceUtils';
import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils';
import { mergeConfigsPatch } from '@mapstore/patcher';

/**
* Actions for GeoNode save workflow
Expand Down Expand Up @@ -436,15 +437,29 @@ export const getConfiguration = (configUrl = '/static/mapstore/configs/localConf
return axios.get(configUrl)
.then(({ data }) => {
const geoNodePageConfig = window.__GEONODE_CONFIG__ || {};
const localConfig = mergeWith(
const geoNodePageLocalConfig = geoNodePageConfig.localConfig || {};
const pluginsConfigPatchRules = geoNodePageConfig.pluginsConfigPatchRules || [];

const mergedLocalConfig = mergeWith(
data,
geoNodePageConfig.localConfig || {},
geoNodePageLocalConfig,
(objValue, srcValue) => {
if (isArray(objValue)) {
return [...objValue, ...srcValue];
}
return undefined; // eslint-disable-line consistent-return
});

// change plugins config based on patches provided in settings.py
const plugins = pluginsConfigPatchRules.length > 0
? mergeConfigsPatch(mergedLocalConfig.plugins, pluginsConfigPatchRules)
: mergedLocalConfig.plugins;

const localConfig = {
...mergedLocalConfig,
plugins
};

if (geoNodePageConfig.overrideLocalConfig) {
return geoNodePageConfig.overrideLocalConfig(localConfig, {
mergeWith,
Expand Down
20 changes: 20 additions & 0 deletions geonode_mapstore_client/client/js/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,26 @@ export const plugins = {
}
}
),
PrintTextInputPlugin: toLazyPlugin(
'PrintTextInput',
() => import(/* webpackChunkName: 'plugins/print-text-input-plugin' */ '@mapstore/framework/plugins/print/TextInput')
),
PrintOutputFormatPlugin: toLazyPlugin(
'PrintOutputFormat',
() => import(/* webpackChunkName: 'plugins/print-output-format-plugin' */ '@mapstore/framework/plugins/print/OutputFormat')
),
PrintScalePlugin: toLazyPlugin(
'PrintScale',
() => import(/* webpackChunkName: 'plugins/print-scale-plugin' */ '@mapstore/framework/plugins/print/Scale')
),
PrintProjectionPlugin: toLazyPlugin(
'PrintProjection',
() => import(/* webpackChunkName: 'plugins/print-projection-plugin' */ '@mapstore/framework/plugins/print/Projection')
),
PrintGraticulePlugin: toLazyPlugin(
'PrintGraticule',
() => import(/* webpackChunkName: 'plugins/print-graticule-plugin' */ '@mapstore/framework/plugins/print/Graticule')
),
TimelinePlugin: toLazyPlugin(
'Timeline',
() => import(/* webpackChunkName: 'plugins/timeline-plugin' */ '@mapstore/framework/plugins/Timeline')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,83 @@
"mapWidth": 256
}
},
{
"name": "PrintOutputFormat",
"cfg": {
"allowedFormats": [
{
"value": "pdf",
"name": "PDF"
},
{
"value": "png",
"name": "PNG"
},
{
"value": "jpg",
"name": "JPEG"
}
]
},
"override": {
"Print": {
"target": "left-panel",
"position": 3
}
}
},
{
"name": "PrintScale",
"override": {
"Print": {
"position": 4
}
}
},
{
"name": "PrintGraticule",
"override": {
"Print": {
"position": 5
}
},
"cfg": {
"frame": 0.07,
"style": {
"color": "#000000",
"weight": 1,
"lineDash": [
0.5,
4
],
"opacity": 0.5
},
"frameStyle": {
"color": "#000000",
"weight": 1,
"fillColor": "#FFFFFF"
},
"labelXStyle": {
"color": "#000000",
"font": "sans-serif",
"fontWeight": "bold",
"fontSize": "20",
"labelOutlineColor": "#FFFFFF",
"labelOutlineWidth": 2
},
"labelYStyle": {
"color": "#000000",
"font": "sans-serif",
"fontWeight": "bold",
"fontSize": "20",
"labelOutlineColor": "#FFFFFF",
"labelOutlineWidth": 2,
"rotation": 90,
"verticalAlign": "top",
"textAlign": "center"
}
}
},
{
"name": "ZoomIn",
"override": {
Expand Down Expand Up @@ -1715,6 +1792,83 @@
"mapWidth": 256
}
},
{
"name": "PrintOutputFormat",
"cfg": {
"allowedFormats": [
{
"value": "pdf",
"name": "PDF"
},
{
"value": "png",
"name": "PNG"
},
{
"value": "jpg",
"name": "JPEG"
}
]
},
"override": {
"Print": {
"target": "left-panel",
"position": 3
}
}
},
{
"name": "PrintScale",
"override": {
"Print": {
"position": 4
}
}
},
{
"name": "PrintGraticule",
"override": {
"Print": {
"position": 5
}
},
"cfg": {
"frame": 0.07,
"style": {
"color": "#000000",
"weight": 1,
"lineDash": [
0.5,
4
],
"opacity": 0.5
},
"frameStyle": {
"color": "#000000",
"weight": 1,
"fillColor": "#FFFFFF"
},
"labelXStyle": {
"color": "#000000",
"font": "sans-serif",
"fontWeight": "bold",
"fontSize": "20",
"labelOutlineColor": "#FFFFFF",
"labelOutlineWidth": 2
},
"labelYStyle": {
"color": "#000000",
"font": "sans-serif",
"fontWeight": "bold",
"fontSize": "20",
"labelOutlineColor": "#FFFFFF",
"labelOutlineWidth": 2,
"rotation": 90,
"verticalAlign": "top",
"textAlign": "center"
}
}
},
{
"name": "ZoomAll",
"override": {
Expand Down
2 changes: 2 additions & 0 deletions geonode_mapstore_client/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def resource_urls(request):
'ALLOWED_DOCUMENT_TYPES': getattr(settings, "ALLOWED_DOCUMENT_TYPES", []),
'LANGUAGES': getattr(settings, "LANGUAGES", []),
'TRANSLATIONS_PATH': getattr(settings, "MAPSTORE_TRANSLATIONS_PATH", ['/static/mapstore/ms-translations', '/static/mapstore/gn-translations']),
'PROJECTION_DEFS': getattr(settings, "MAPSTORE_PROJECTION_DEFS", []),
'PLUGINS_CONFIG_PATCH_RULES': getattr(settings, "MAPSTORE_PLUGINS_CONFIG_PATCH_RULES", []),
'TIME_ENABLED': getattr(
settings,
'UPLOADER',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
const timeEnabled = geoNodeSettings.TIME_ENABLED || false;
const allowedDocumentTypes = geoNodeSettings.ALLOWED_DOCUMENT_TYPES || [];
const languages = geoNodeSettings.LANGUAGES;
const projectionDefs = geoNodeSettings.PROJECTION_DEFS || [];
const pluginsConfigPatchRules = geoNodeSettings.PLUGINS_CONFIG_PATCH_RULES || [];
const translationsPath = geoNodeSettings.TRANSLATIONS_PATH;

const isEmbed = checkBoolean('{{ is_embed }}') || false;
Expand All @@ -68,6 +70,7 @@
resourceType: '{{ resource.resource_type|default:"" }}',
isEmbed: isEmbed,
pluginsConfigKey: pluginsConfigKey,
pluginsConfigPatchRules: pluginsConfigPatchRules,
localConfig: {
proxyUrl: {
url: '{{ PROXY_URL|default:"/proxy/?url=" }}',
Expand All @@ -79,6 +82,7 @@
endpointV1: siteUrl + 'api',
endpointV2: siteUrl + 'api/v2'
},
projectionDefs: projectionDefs,
// the properties inside geoNodeSettings are stored in the state
// and accessible by the monitored state with state('settings')
geoNodeSettings: {
Expand Down

0 comments on commit 210064e

Please sign in to comment.