Skip to content

Commit

Permalink
#1908: Update print plugins and configurations (#1929) (#1932)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9e79006)

Co-authored-by: Suren <dsuren1@gmail.com>
  • Loading branch information
github-actions[bot] and dsuren1 authored Dec 19, 2024
1 parent 48eab71 commit 31f7b7b
Show file tree
Hide file tree
Showing 19 changed files with 337 additions and 2 deletions.
55 changes: 55 additions & 0 deletions geonode_mapstore_client/client/js/plugins/Print/Author.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { useEffect } from "react";
import { connect } from "react-redux";
import get from "lodash/get";

import { createPlugin } from "@mapstore/framework/utils/PluginsUtils";
import { setPrintParameter } from "@mapstore/framework/actions/print";
import printReducer from "@mapstore/framework/reducers/print";
import { TextInput } from "@mapstore/framework/plugins/print/TextInput";
import { addTransformer } from "@mapstore/framework/utils/PrintUtils";

const authorTransformer = (state, spec) => {
return Promise.resolve({
...spec,
author: get(state, "print.spec.author", "")
});
};

const Author = (props) => {
useEffect(() => {
addTransformer("author", authorTransformer, 6);
}, []);
return <TextInput {...props} />;
};

export default createPlugin("PrintAuthor", {
component: connect(
(state) => ({
spec: state.print?.spec || {},
additionalProperty: false,
property: "author",
path: "",
label: "viewer.print.author",
placeholder: "viewer.print.authorPlaceholder"
}),
{
onChangeParameter: setPrintParameter
}
)(Author),
reducers: { print: printReducer },
containers: {
Print: {
priority: 1,
target: "left-panel",
position: 6
}
}
});
55 changes: 55 additions & 0 deletions geonode_mapstore_client/client/js/plugins/Print/Copyright.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { useEffect } from "react";
import { connect } from "react-redux";
import get from "lodash/get";

import { createPlugin } from "@mapstore/framework/utils/PluginsUtils";
import { setPrintParameter } from "@mapstore/framework/actions/print";
import printReducer from "@mapstore/framework/reducers/print";
import { TextInput } from "@mapstore/framework/plugins/print/TextInput";
import { addTransformer } from "@mapstore/framework/utils/PrintUtils";

const copyrightTransformer = (state, spec) => {
return Promise.resolve({
...spec,
copyright: get(state, "print.spec.copyright", "")
});
};

const Copyright = (props) => {
useEffect(() => {
addTransformer("copyright", copyrightTransformer, 7);
}, []);
return <TextInput {...props} />;
};

export default createPlugin("PrintCopyright", {
component: connect(
(state) => ({
spec: state.print?.spec || {},
additionalProperty: false,
property: "copyright",
path: "",
label: "viewer.print.copyright",
placeholder: "viewer.print.copyrightPlaceholder"
}),
{
onChangeParameter: setPrintParameter
}
)(Copyright),
reducers: { print: printReducer },
containers: {
Print: {
priority: 1,
target: "left-panel",
position: 7
}
}
});
8 changes: 8 additions & 0 deletions geonode_mapstore_client/client/js/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ export const plugins = {
SettingsPlugin: toModulePlugin(
'Settings',
() => import(/* webpackChunkName: 'plugins/settings' */ '@mapstore/framework/plugins/Settings')
),
PrintAuthorPlugin: toModulePlugin(
'PrintAuthor',
() => import(/* webpackChunkName: 'plugins/print-author' */ '@js/plugins/Print/Author')
),
PrintCopyrightPlugin: toModulePlugin(
'PrintCopyright',
() => import(/* webpackChunkName: 'plugins/print-copyright' */ '@js/plugins/Print/Copyright')
)
};

Expand Down
11 changes: 11 additions & 0 deletions geonode_mapstore_client/client/themes/geonode/less/ms-theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,14 @@ div#mapstore-globalspinner {
.glyphicon {
top: 0;
}

.gn-viewer-layout-body {
#mapstore-print-panel {
&.modal-dialog {
margin: 0;
}
.modal-body {
max-height: calc(100vh - 220px);
}
}
}
50 changes: 48 additions & 2 deletions geonode_mapstore_client/static/mapstore/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@
"name": "Print",
"cfg": {
"useFixedScales": true,
"mapWidth": 256,
"outputFormatOptions": {
"allowedFormats": [
{
Expand All @@ -923,6 +922,14 @@
{
"value": "jpg",
"name": "JPEG"
},
{
"value": "gif",
"name": "GIF"
},
{
"value": "tiff",
"name": "TIFF"
}
]
}
Expand Down Expand Up @@ -980,6 +987,22 @@
}
}
},
{
"name": "PrintAuthor",
"override": {
"Print": {
"position": 6
}
}
},
{
"name": "PrintCopyright",
"override": {
"Print": {
"position": 7
}
}
},
{
"name": "ZoomIn",
"override": {
Expand Down Expand Up @@ -1792,7 +1815,6 @@
"name": "Print",
"cfg": {
"useFixedScales": true,
"mapWidth": 256,
"outputFormatOptions": {
"allowedFormats": [
{
Expand All @@ -1806,6 +1828,14 @@
{
"value": "jpg",
"name": "JPEG"
},
{
"value": "gif",
"name": "GIF"
},
{
"value": "tiff",
"name": "TIFF"
}
]
}
Expand Down Expand Up @@ -1863,6 +1893,22 @@
}
}
},
{
"name": "PrintAuthor",
"override": {
"Print": {
"position": 6
}
}
},
{
"name": "PrintCopyright",
"override": {
"Print": {
"position": 7
}
}
},
{
"name": "ZoomAll",
"override": {
Expand Down
82 changes: 82 additions & 0 deletions geonode_mapstore_client/static/mapstore/configs/pluginsConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,90 @@
"description": "plugins.Print.description",
"dependencies": [
"SidebarMenu"
],
"children": [
"PrintScale",
"PrintGraticule",
"PrintAuthor",
"PrintCopyright"
],
"autoEnableChildren": [
"PrintScale",
"PrintAuthor",
"PrintCopyright"
]
},
{
"name": "PrintScale",
"override": {
"Print": {
"position": 4
}
},
"hidden": true
},
{
"name": "PrintGraticule",
"override": {
"Print": {
"position": 5
}
},
"defaultConfig": {
"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": "PrintAuthor",
"override": {
"Print": {
"position": 6
}
},
"hidden": true
},
{
"name": "PrintCopyright",
"override": {
"Print": {
"position": 7
}
},
"hidden": true
},
{
"name": "MousePosition",
"glyph": "mouse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
},
"errors": {
"noPermissions": "Sie sind nicht berechtigt eine GeoStory hinzuzufügen"
},
"print": {
"author": "Autor",
"authorPlaceholder": "Geben Sie einen Autorennamen ein...",
"copyright": "Urheberrecht",
"copyrightPlaceholder": "Geben Sie ein Urheberrecht ein..."
}
},
"gnviewer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
},
"errors": {
"noPermissions": "You dont have permissions to add a geostory"
},
"print": {
"author": "Author",
"authorPlaceholder": "Enter an author name...",
"copyright": "Copyright",
"copyrightPlaceholder": "Enter a copyright..."
}
},
"gnviewer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
},
"errors": {
"noPermissions": "No tienes permisos para agregar una geohistoria"
},
"print": {
"author": "Autor",
"authorPlaceholder": "Ingrese un nombre de autor...",
"copyright": "Derechos de autor",
"copyrightPlaceholder": "Ingrese un derecho de autor..."
}
},
"gnviewer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
},
"errors": {
"noPermissions": "You dont have permissions to add a geostory"
},
"print": {
"author": "Author",
"authorPlaceholder": "Enter an author name...",
"copyright": "Copyright",
"copyrightPlaceholder": "Enter a copyright..."
}
},
"gnviewer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
},
"errors": {
"noPermissions": "Vous n'êtes pas autorisé à ajouter une geostory"
},
"print": {
"author": "Auteur",
"authorPlaceholder": "Entrez un nom d'auteur...",
"copyright": "Droits d'auteur",
"copyrightPlaceholder": "Entrez des droits d'auteur..."
}
},
"gnviewer": {
Expand Down
Loading

0 comments on commit 31f7b7b

Please sign in to comment.