qwc2 2025.4.9 → 2025.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/plugins/API.js
CHANGED
|
@@ -25,6 +25,8 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
25
25
|
* });
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
+
* Note: You can also write the plugin in JSX syntax, and transpile to plain JS using babel.
|
|
29
|
+
*
|
|
28
30
|
* All following action functions are available:
|
|
29
31
|
*
|
|
30
32
|
* - [display](https://github.com/qgis/qwc2/blob/master/actions/display.js)
|
package/plugins/Print.js
CHANGED
|
@@ -9,10 +9,11 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
|
|
|
9
9
|
*
|
|
10
10
|
* Uses the print layouts defined in the QGIS project.
|
|
11
11
|
*/var Print=/*#__PURE__*/function(_React$Component){function Print(props){var _this;_classCallCheck(this,Print);_this=_callSuper(this,Print,[props]);_defineProperty(_this,"state",{center:null,extents:[],layout:null,rotation:0,scale:0,dpi:300,grid:false,legend:false,minimized:false,printOutputVisible:false,outputLoaded:false,printing:false,atlasFeatures:[],geoPdf:false,selectedFormat:"",printOutputData:undefined,pdfData:null,pdfDataUrl:null,downloadMode:"onepdf",printSeriesEnabled:false,printSeriesOverlap:0,printSeriesSelected:[]});_defineProperty(_this,"onShow",function(){// setup initial extent
|
|
12
|
-
var scale=Math.round(MapUtils.computeForZoom(_this.props.map.scales,_this.props.map.zoom)*_this.props.defaultScaleFactor);if(_this.props.theme.printScales&&_this.props.theme.printScales.length>0){var closestVal=Math.abs(scale-_this.props.theme.printScales[0]);var closestIdx=0;for(var i=1;i<_this.props.theme.printScales.length;++i){var currVal=Math.abs(scale-_this.props.theme.printScales[i]);if(currVal<closestVal){closestVal=currVal;closestIdx=i}}scale=_this.props.theme.printScales[closestIdx]}var bounds=_this.props.map.bbox.bounds;var center=_this.state.center||[0,0];var resetCenter=center[0]<bounds[0]||center[0]>bounds[2]||center[1]<bounds[1]||center[1]>bounds[3];var resetScale=_this.state.scale/scale<0.01||_this.state.scale/scale>10;if(resetCenter||resetScale){_this.setState({center:null,rotation:0,scale:scale})}_this.props.setSnappingConfig(false,false)});_defineProperty(_this,"onHide",function(){_this.setState({minimized:false,printSeriesEnabled:false,atlasFeatures:[]})});_defineProperty(_this,"renderBody",function(){var _this$state$extents$a;if(!_this.state.layout){return/*#__PURE__*/React.createElement("div",{className:"print-body",role:"body"},LocaleUtils.tr("print.nolayouts"))}var themeLayers=_this.props.layers.filter(function(layer){return layer.role===LayerRole.THEME});if(!_this.props.theme||!_this.props.printExternalLayers&&isEmpty(themeLayers)){return/*#__PURE__*/React.createElement("div",{className:"print-body",role:"body"},LocaleUtils.tr("print.notheme"))}var formvisibility="hidden";var mapCrs=_this.props.map.projection;var version=_this.props.theme.version;var mapName=_this.state.layout.map.name;var formattedExtent=_this.formatExtent((_this$state$extents$a=_this.state.extents.at(0))!==null&&_this$state$extents$a!==void 0?_this$state$extents$a:[0,0,0,0]);if(!isEmpty(_this.state.atlasFeatures)){formattedExtent=""}var scaleChooser=/*#__PURE__*/React.createElement(NumberInput,{min:1,mobile:true,name:mapName+":scale",onChange:_this.changeScale,prefix:"1 : ",value:_this.state.scale||null});if(_this.props.theme.printScales&&_this.props.theme.printScales.length>0){scaleChooser=/*#__PURE__*/React.createElement(InputContainer,null,/*#__PURE__*/React.createElement("span",{role:"prefix"},"1\xA0:\xA0"),/*#__PURE__*/React.createElement(EditableSelect,{name:mapName+":scale",onChange:_this.changeScale,options:_this.props.theme.printScales,role:"input",value:_this.state.scale||""}))}var resolutionChooser=null;var resolutionInput=null;if(!isEmpty(_this.props.theme.printResolutions)){if(_this.props.theme.printResolutions.length>1){resolutionChooser=/*#__PURE__*/React.createElement("select",{name:"DPI",onChange:function onChange(ev){return _this.changeResolution(ev.target.value)},value:_this.state.dpi||""},_this.props.theme.printResolutions.map(function(res){return/*#__PURE__*/React.createElement("option",{key:res,value:res},res," dpi")}))}else{resolutionInput=/*#__PURE__*/React.createElement("input",{name:"DPI",readOnly:true,type:formvisibility,value:_this.props.theme.printResolutions[0]})}}else{resolutionChooser=/*#__PURE__*/React.createElement(NumberInput,{max:1200,min:50,mobile:true,name:"DPI",onChange:_this.changeResolution,suffix:" dpi",value:_this.state.dpi||""})}var rotationInput=null;if(_this.props.displayRotation){rotationInput=/*#__PURE__*/React.createElement(NumberInput,{decimals:1,mobile:true,name:mapName+":rotation",onChange:_this.changeRotation,role:"input",value:_this.state.rotation})}var gridIntervalX=null;var gridIntervalY=null;var printGrid=_this.props.theme.printGrid;if(printGrid&&printGrid.length>0&&_this.state.scale&&_this.state.grid){var cur=0;while(cur<printGrid.length-1&&_this.state.scale<printGrid[cur].s){cur+=1}gridIntervalX=/*#__PURE__*/React.createElement("input",{name:mapName+":GRID_INTERVAL_X",readOnly:true,type:formvisibility,value:printGrid[cur].x});gridIntervalY=/*#__PURE__*/React.createElement("input",{name:mapName+":GRID_INTERVAL_Y",readOnly:true,type:formvisibility,value:printGrid[cur].y})}var printLegend=_this.state.layout.legendLayout;var overlapChooser=null;if(_this.props.displayPrintSeries){overlapChooser=/*#__PURE__*/React.createElement("input",{disabled:!_this.state.printSeriesEnabled,max:"20",min:"0",onChange:_this.changeSeriesOverlap,role:"input",type:"range",value:_this.state.printSeriesOverlap})}var downloadModeChooser=null;if(_this.props.displayPrintSeries&&!_this.props.inlinePrintOutput){downloadModeChooser=/*#__PURE__*/React.createElement("select",{disabled:!_this.state.printSeriesEnabled,onChange:_this.changeDownloadMode,role:"input",value:_this.state.downloadMode||""},/*#__PURE__*/React.createElement("option",{key:"onepdf",value:"onepdf"},LocaleUtils.tr("print.download_as_onepdf")),/*#__PURE__*/React.createElement("option",{key:"onezip",value:"onezip"},LocaleUtils.tr("print.download_as_onezip")),/*#__PURE__*/React.createElement("option",{key:"single",value:"single"},LocaleUtils.tr("print.download_as_single")))}var labels=_this.state.layout&&_this.state.layout.labels?_this.state.layout.labels:[];var layouts=_this.props.theme.print.filter(function(l){return l.map}).sort(function(a,b){return a.name.localeCompare(b.name,undefined,{numeric:true})});var formatMap={"application/pdf":"PDF","image/jpeg":"JPEG","image/png":"PNG","image/svg":"SVG"};var pdfFormatSelected=_this.state.selectedFormat==="application/pdf";return/*#__PURE__*/React.createElement("div",{className:"print-body"},/*#__PURE__*/React.createElement("form",{action:_this.props.theme.printUrl,method:"POST",onSubmit:_this.print,ref:function ref(el){_this.printForm=el}},/*#__PURE__*/React.createElement("input",{name:"TEMPLATE",type:"hidden",value:printLegend&&_this.state.legend?printLegend:_this.state.layout.name}),/*#__PURE__*/React.createElement("table",{className:"options-table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.layout")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:_this.changeLayout,value:_this.state.layout.name},layouts.filter(function(l){return l.map}).map(function(item){return/*#__PURE__*/React.createElement("option",{key:item.name,value:item.name},item.name.split("/").pop())})))),_this.props.formats.length>1?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.format")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{disabled:_this.state.printSeriesEnabled,name:"FORMAT",onChange:_this.formatChanged,value:_this.state.selectedFormat},_this.props.formats.map(function(format){return/*#__PURE__*/React.createElement("option",{key:format,value:format},formatMap[format]||format)})))):null,_this.state.layout.atlasCoverageLayer&&!_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.atlasfeature")),/*#__PURE__*/React.createElement("td",null,!isEmpty(_this.state.atlasFeatures)?/*#__PURE__*/React.createElement("div",{className:"print-atlas-features"},_this.state.atlasFeatures.map(function(feature){return/*#__PURE__*/React.createElement("span",{key:feature.id},/*#__PURE__*/React.createElement("span",null,feature.properties[feature.displayfield]),/*#__PURE__*/React.createElement(Icon,{icon:"remove",onClick:function onClick(){return _this.deselectAtlasFeature(feature)}}))}),/*#__PURE__*/React.createElement("input",{name:"ATLAS_PK",type:"hidden",value:_this.state.atlasFeatures.map(function(feature){var _feature$properties$_;return(_feature$properties$_=feature.properties[_this.state.layout.atlas_pk])!==null&&_feature$properties$_!==void 0?_feature$properties$_:feature.id}).join(",")})):/*#__PURE__*/React.createElement("input",{disabled:true,placeholder:LocaleUtils.tr("print.pickatlasfeature",_this.state.layout.atlasCoverageLayer),type:"text"}))):null,isEmpty(_this.state.atlasFeatures)?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.scale")),/*#__PURE__*/React.createElement("td",null,scaleChooser)):null,resolutionChooser?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.resolution")),/*#__PURE__*/React.createElement("td",null,resolutionChooser)):null,rotationInput?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.rotation")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(InputContainer,null,rotationInput,/*#__PURE__*/React.createElement("span",{role:"suffix",style:{transform:"rotate(-"+_this.state.rotation+"deg)"}},/*#__PURE__*/React.createElement(Icon,{icon:"arrow-up",onClick:function onClick(){return _this.setState({rotation:0})},title:LocaleUtils.tr("map.resetrotation")}))))):null,printGrid?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.grid")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.grid,onChange:function onChange(newstate){return _this.setState({grid:newstate})}}))):null,printLegend?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.legend")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.legend,onChange:function onChange(newstate){return _this.setState({legend:newstate})}}))):null,_this.props.displayPrintSeries?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.series")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.printSeriesEnabled,onChange:function onChange(newstate){return _this.setState({printSeriesEnabled:newstate,atlasFeatures:[]})}}))):null,overlapChooser&&_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.overlap")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(InputContainer,null,overlapChooser,/*#__PURE__*/React.createElement("span",{role:"suffix"},_this.state.printSeriesOverlap,"\xA0%")))):null,downloadModeChooser&&_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.download")),/*#__PURE__*/React.createElement("td",null,downloadModeChooser)):null,(labels||[]).map(function(label){var _this$props$theme$pri;// Omit labels which start with __
|
|
13
|
-
if(label.startsWith("__")){return null}var opts=_objectSpread({rows:1,name:label.toUpperCase()},(_this$props$theme$pri=_this.props.theme.printLabelConfig)===null||_this$props$theme$pri===void 0?void 0:_this$props$theme$pri[label]);return _this.renderPrintLabelField(label,opts)}),pdfFormatSelected&&_this.props.allowGeoPdfExport?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,"GeoPDF"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.geoPdf,onChange:function onChange(newstate){return _this.setState({geoPdf:newstate})}}))):null)),/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("input",{name:"csrf_token",type:"hidden",value:MiscUtils.getCsrfToken()}),/*#__PURE__*/React.createElement("input",{name:mapName+":extent",readOnly:true,type:formvisibility,value:formattedExtent}),/*#__PURE__*/React.createElement("input",{name:"SERVICE",readOnly:true,type:formvisibility,value:"WMS"}),/*#__PURE__*/React.createElement("input",{name:"VERSION",readOnly:true,type:formvisibility,value:version}),/*#__PURE__*/React.createElement("input",{name:"REQUEST",readOnly:true,type:formvisibility,value:"GetPrint"}),/*#__PURE__*/React.createElement("input",{name:"FORMAT",readOnly:true,type:formvisibility,value:_this.state.selectedFormat}),/*#__PURE__*/React.createElement("input",{name:"TRANSPARENT",readOnly:true,type:formvisibility,value:"true"}),/*#__PURE__*/React.createElement("input",{name:"SRS",readOnly:true,type:formvisibility,value:mapCrs}),/*#__PURE__*/React.createElement("input",{name:"CONTENT_DISPOSITION",readOnly:true,type:formvisibility,value:_this.props.inlinePrintOutput?"inline":"attachment"}),pdfFormatSelected&&_this.props.allowGeoPdfExport?/*#__PURE__*/React.createElement("input",{name:"FORMAT_OPTIONS",readOnly:true,type:formvisibility,value:_this.state.geoPdf?"WRITE_GEO_PDF:true":"WRITE_GEO_PDF:false"}):null,
|
|
12
|
+
var scale=Math.round(MapUtils.computeForZoom(_this.props.map.scales,_this.props.map.zoom)*_this.props.defaultScaleFactor);if(_this.props.theme.printScales&&_this.props.theme.printScales.length>0){var closestVal=Math.abs(scale-_this.props.theme.printScales[0]);var closestIdx=0;for(var i=1;i<_this.props.theme.printScales.length;++i){var currVal=Math.abs(scale-_this.props.theme.printScales[i]);if(currVal<closestVal){closestVal=currVal;closestIdx=i}}scale=_this.props.theme.printScales[closestIdx]}var bounds=_this.props.map.bbox.bounds;var center=_this.state.center||[0,0];var resetCenter=center[0]<bounds[0]||center[0]>bounds[2]||center[1]<bounds[1]||center[1]>bounds[3];var resetScale=_this.state.scale/scale<0.01||_this.state.scale/scale>10;if(resetCenter||resetScale){_this.setState({center:null,rotation:0,scale:scale})}_this.props.setSnappingConfig(false,false)});_defineProperty(_this,"onHide",function(){_this.setState({minimized:false,printSeriesEnabled:false,atlasFeatures:[]})});_defineProperty(_this,"renderBody",function(){var _this$state$extents$a;if(!_this.state.layout){return/*#__PURE__*/React.createElement("div",{className:"print-body",role:"body"},LocaleUtils.tr("print.nolayouts"))}var themeLayers=_this.props.layers.filter(function(layer){return layer.role===LayerRole.THEME});if(!_this.props.theme||!_this.props.printExternalLayers&&isEmpty(themeLayers)){return/*#__PURE__*/React.createElement("div",{className:"print-body",role:"body"},LocaleUtils.tr("print.notheme"))}var formvisibility="hidden";var mapCrs=_this.props.map.projection;var version=_this.props.theme.version;var mapName=_this.state.layout.map.name;var formattedExtent=_this.formatExtent((_this$state$extents$a=_this.state.extents.at(0))!==null&&_this$state$extents$a!==void 0?_this$state$extents$a:[0,0,0,0]);if(!isEmpty(_this.state.atlasFeatures)){formattedExtent=""}var scaleChooser=/*#__PURE__*/React.createElement(NumberInput,{min:1,mobile:true,name:mapName+":scale",onChange:_this.changeScale,prefix:"1 : ",value:_this.state.scale||null});if(_this.props.theme.printScales&&_this.props.theme.printScales.length>0){scaleChooser=/*#__PURE__*/React.createElement(InputContainer,null,/*#__PURE__*/React.createElement("span",{role:"prefix"},"1\xA0:\xA0"),/*#__PURE__*/React.createElement(EditableSelect,{name:mapName+":scale",onChange:_this.changeScale,options:_this.props.theme.printScales,role:"input",value:_this.state.scale||""}))}var resolutionChooser=null;var resolutionInput=null;if(!isEmpty(_this.props.theme.printResolutions)){if(_this.props.theme.printResolutions.length>1){resolutionChooser=/*#__PURE__*/React.createElement("select",{name:"DPI",onChange:function onChange(ev){return _this.changeResolution(ev.target.value)},value:_this.state.dpi||""},_this.props.theme.printResolutions.map(function(res){return/*#__PURE__*/React.createElement("option",{key:res,value:res},res," dpi")}))}else{resolutionInput=/*#__PURE__*/React.createElement("input",{name:"DPI",readOnly:true,type:formvisibility,value:_this.props.theme.printResolutions[0]})}}else{resolutionChooser=/*#__PURE__*/React.createElement(NumberInput,{max:1200,min:50,mobile:true,name:"DPI",onChange:_this.changeResolution,suffix:" dpi",value:_this.state.dpi||""})}var rotationInput=null;if(_this.props.displayRotation){rotationInput=/*#__PURE__*/React.createElement(NumberInput,{decimals:1,mobile:true,name:mapName+":rotation",onChange:_this.changeRotation,role:"input",value:_this.state.rotation})}var printLegend=_this.state.layout.legendLayout;var overlapChooser=null;if(_this.props.displayPrintSeries){overlapChooser=/*#__PURE__*/React.createElement("input",{disabled:!_this.state.printSeriesEnabled,max:"20",min:"0",onChange:_this.changeSeriesOverlap,role:"input",type:"range",value:_this.state.printSeriesOverlap})}var downloadModeChooser=null;if(_this.props.displayPrintSeries&&!_this.props.inlinePrintOutput){downloadModeChooser=/*#__PURE__*/React.createElement("select",{disabled:!_this.state.printSeriesEnabled,onChange:_this.changeDownloadMode,role:"input",value:_this.state.downloadMode||""},/*#__PURE__*/React.createElement("option",{key:"onepdf",value:"onepdf"},LocaleUtils.tr("print.download_as_onepdf")),/*#__PURE__*/React.createElement("option",{key:"onezip",value:"onezip"},LocaleUtils.tr("print.download_as_onezip")),/*#__PURE__*/React.createElement("option",{key:"single",value:"single"},LocaleUtils.tr("print.download_as_single")))}var labels=_this.state.layout&&_this.state.layout.labels?_this.state.layout.labels:[];var layouts=_this.props.theme.print.filter(function(l){return l.map}).sort(function(a,b){return a.name.localeCompare(b.name,undefined,{numeric:true})});var formatMap={"application/pdf":"PDF","image/jpeg":"JPEG","image/png":"PNG","image/svg":"SVG"};var pdfFormatSelected=_this.state.selectedFormat==="application/pdf";return/*#__PURE__*/React.createElement("div",{className:"print-body"},/*#__PURE__*/React.createElement("form",{action:_this.props.theme.printUrl,method:"POST",onSubmit:_this.print,ref:function ref(el){_this.printForm=el}},/*#__PURE__*/React.createElement("input",{name:"TEMPLATE",type:"hidden",value:printLegend&&_this.state.legend?printLegend:_this.state.layout.name}),/*#__PURE__*/React.createElement("table",{className:"options-table"},/*#__PURE__*/React.createElement("tbody",null,/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.layout")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{onChange:_this.changeLayout,value:_this.state.layout.name},layouts.filter(function(l){return l.map}).map(function(item){return/*#__PURE__*/React.createElement("option",{key:item.name,value:item.name},item.name.split("/").pop())})))),_this.props.formats.length>1?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.format")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{disabled:_this.state.printSeriesEnabled,name:"FORMAT",onChange:_this.formatChanged,value:_this.state.selectedFormat},_this.props.formats.map(function(format){return/*#__PURE__*/React.createElement("option",{key:format,value:format},formatMap[format]||format)})))):null,_this.state.layout.atlasCoverageLayer&&!_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.atlasfeature")),/*#__PURE__*/React.createElement("td",null,!isEmpty(_this.state.atlasFeatures)?/*#__PURE__*/React.createElement("div",{className:"print-atlas-features"},_this.state.atlasFeatures.map(function(feature){return/*#__PURE__*/React.createElement("span",{key:feature.id},/*#__PURE__*/React.createElement("span",null,feature.properties[feature.displayfield]),/*#__PURE__*/React.createElement(Icon,{icon:"remove",onClick:function onClick(){return _this.deselectAtlasFeature(feature)}}))}),/*#__PURE__*/React.createElement("input",{name:"ATLAS_PK",type:"hidden",value:_this.state.atlasFeatures.map(function(feature){var _feature$properties$_;return(_feature$properties$_=feature.properties[_this.state.layout.atlas_pk])!==null&&_feature$properties$_!==void 0?_feature$properties$_:feature.id}).join(",")})):/*#__PURE__*/React.createElement("input",{disabled:true,placeholder:LocaleUtils.tr("print.pickatlasfeature",_this.state.layout.atlasCoverageLayer),type:"text"}))):null,isEmpty(_this.state.atlasFeatures)?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.scale")),/*#__PURE__*/React.createElement("td",null,scaleChooser)):null,resolutionChooser?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.resolution")),/*#__PURE__*/React.createElement("td",null,resolutionChooser)):null,rotationInput?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.rotation")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(InputContainer,null,rotationInput,/*#__PURE__*/React.createElement("span",{role:"suffix",style:{transform:"rotate(-"+_this.state.rotation+"deg)"}},/*#__PURE__*/React.createElement(Icon,{icon:"arrow-up",onClick:function onClick(){return _this.setState({rotation:0})},title:LocaleUtils.tr("map.resetrotation")}))))):null,!isEmpty(_this.props.theme.printGrid)?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.grid")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.grid,onChange:function onChange(newstate){return _this.setState({grid:newstate})}}))):null,printLegend?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.legend")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.legend,onChange:function onChange(newstate){return _this.setState({legend:newstate})}}))):null,_this.props.displayPrintSeries?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.series")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.printSeriesEnabled,onChange:function onChange(newstate){return _this.setState({printSeriesEnabled:newstate,atlasFeatures:[]})}}))):null,overlapChooser&&_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.overlap")),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(InputContainer,null,overlapChooser,/*#__PURE__*/React.createElement("span",{role:"suffix"},_this.state.printSeriesOverlap,"\xA0%")))):null,downloadModeChooser&&_this.state.printSeriesEnabled?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,LocaleUtils.tr("print.download")),/*#__PURE__*/React.createElement("td",null,downloadModeChooser)):null,(labels||[]).map(function(label){var _this$props$theme$pri;// Omit labels which start with __
|
|
13
|
+
if(label.startsWith("__")){return null}var opts=_objectSpread({rows:1,name:label.toUpperCase()},(_this$props$theme$pri=_this.props.theme.printLabelConfig)===null||_this$props$theme$pri===void 0?void 0:_this$props$theme$pri[label]);return _this.renderPrintLabelField(label,opts)}),pdfFormatSelected&&_this.props.allowGeoPdfExport?/*#__PURE__*/React.createElement("tr",null,/*#__PURE__*/React.createElement("td",null,"GeoPDF"),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement(ToggleSwitch,{active:_this.state.geoPdf,onChange:function onChange(newstate){return _this.setState({geoPdf:newstate})}}))):null)),/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("input",{name:"csrf_token",type:"hidden",value:MiscUtils.getCsrfToken()}),/*#__PURE__*/React.createElement("input",{name:mapName+":extent",readOnly:true,type:formvisibility,value:formattedExtent}),/*#__PURE__*/React.createElement("input",{name:"SERVICE",readOnly:true,type:formvisibility,value:"WMS"}),/*#__PURE__*/React.createElement("input",{name:"VERSION",readOnly:true,type:formvisibility,value:version}),/*#__PURE__*/React.createElement("input",{name:"REQUEST",readOnly:true,type:formvisibility,value:"GetPrint"}),/*#__PURE__*/React.createElement("input",{name:"FORMAT",readOnly:true,type:formvisibility,value:_this.state.selectedFormat}),/*#__PURE__*/React.createElement("input",{name:"TRANSPARENT",readOnly:true,type:formvisibility,value:"true"}),/*#__PURE__*/React.createElement("input",{name:"SRS",readOnly:true,type:formvisibility,value:mapCrs}),/*#__PURE__*/React.createElement("input",{name:"CONTENT_DISPOSITION",readOnly:true,type:formvisibility,value:_this.props.inlinePrintOutput?"inline":"attachment"}),pdfFormatSelected&&_this.props.allowGeoPdfExport?/*#__PURE__*/React.createElement("input",{name:"FORMAT_OPTIONS",readOnly:true,type:formvisibility,value:_this.state.geoPdf?"WRITE_GEO_PDF:true":"WRITE_GEO_PDF:false"}):null,resolutionInput),/*#__PURE__*/React.createElement("div",{className:"button-bar"},/*#__PURE__*/React.createElement("button",{className:"button",disabled:_this.state.printing,type:"submit"},_this.state.printing?/*#__PURE__*/React.createElement("span",{className:"print-wait"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("print.wait")):LocaleUtils.tr("print.submit")))))});_defineProperty(_this,"renderPrintLabelField",function(label,opts){var defaultValue=opts.defaultValue||"";var autopopulated=false;if(label===_this.props.theme.printLabelForSearchResult){defaultValue=_this.getSearchMarkerLabel();autopopulated=true}else if(label===_this.props.theme.printLabelForAttribution){defaultValue=_this.getAttributionLabel();autopopulated=true}if(autopopulated&&_this.props.hideAutopopulatedFields){return/*#__PURE__*/React.createElement("tr",{key:"label."+label},/*#__PURE__*/React.createElement("td",{colSpan:"2"},/*#__PURE__*/React.createElement("input",{defaultValue:defaultValue,name:opts.name,type:"hidden"})))}else{if(opts.options){return/*#__PURE__*/React.createElement("tr",{key:"label."+label},/*#__PURE__*/React.createElement("td",null,MiscUtils.capitalizeFirst(label)),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("select",{defaultValue:defaultValue,name:opts.name},opts.options.map(function(value){return/*#__PURE__*/React.createElement("option",{key:value,value:value},value)}))))}else{var style={};if(opts.rows||opts.cols){style.resize="none"}if(opts.cols){style.width="initial"}return/*#__PURE__*/React.createElement("tr",{key:"label."+label},/*#__PURE__*/React.createElement("td",null,MiscUtils.capitalizeFirst(label)),/*#__PURE__*/React.createElement("td",null,/*#__PURE__*/React.createElement("textarea",_extends({},opts,{defaultValue:defaultValue,readOnly:autopopulated,style:style}))))}}});_defineProperty(_this,"getSearchMarkerLabel",function(){var _feature$properties;var searchsellayer=_this.props.layers.find(function(layer){return layer.id==="searchselection"});var feature=((searchsellayer===null||searchsellayer===void 0?void 0:searchsellayer.features)||[]).find(function(f){return f.id==="searchmarker"});return(feature===null||feature===void 0||(_feature$properties=feature.properties)===null||_feature$properties===void 0?void 0:_feature$properties.label)||""});_defineProperty(_this,"getAttributionLabel",function(){var copyrights=_this.props.layers.reduce(function(res,layer){return _objectSpread(_objectSpread({},res),LayerUtils.getAttribution(layer,_this.props.map))},{});var el=document.createElement("span");return Object.entries(copyrights).map(function(_ref){var _ref2=_slicedToArray(_ref,2),key=_ref2[0],value=_ref2[1];if(value.title){el.innerHTML=value.title;return el.innerText}else{el.innerHTML=key;return el.innerText}}).join(" | ")});_defineProperty(_this,"renderPrintSelection",function(){var printSelection=null;if(_this.state.layout&&isEmpty(_this.state.atlasFeatures)){var frame={width:_this.state.layout.map.width,height:_this.state.layout.map.height};printSelection=/*#__PURE__*/React.createElement(PrintSelection,{allowRotation:_this.props.displayRotation&&!_this.state.printSeriesEnabled,allowScaling:!_this.state.printSeriesEnabled,allowTranslation:!_this.state.printSeriesEnabled,center:_this.state.center||_this.props.map.center,fixedFrame:frame,geometryChanged:_this.geometryChanged,key:"PrintSelection",printSeriesChanged:_this.printSeriesChanged,printSeriesEnabled:_this.props.displayPrintSeries&&_this.state.printSeriesEnabled,printSeriesOverlap:_this.state.printSeriesOverlap/100,printSeriesSelected:_this.state.printSeriesSelected,rotation:_this.state.rotation,scale:_this.state.scale})}return printSelection});_defineProperty(_this,"formatExtent",function(extent){var mapCrs=_this.props.map.projection;var version=_this.props.theme.version;if(CoordinatesUtils.getAxisOrder(mapCrs).substring(0,2)==="ne"&&version==="1.3.0"){return extent[1]+","+extent[0]+","+extent[3]+","+extent[2]}return extent.join(",")});_defineProperty(_this,"geometryChanged",function(center,extents,rotation,scale){_this.setState({center:center,extents:extents,rotation:rotation,scale:scale})});_defineProperty(_this,"printSeriesChanged",function(selected){_this.setState({printSeriesSelected:selected})});_defineProperty(_this,"renderPrintOutputWindow",function(){var extraControls=[{icon:"save",title:LocaleUtils.tr("print.save"),callback:_this.savePrintOutput}];return/*#__PURE__*/React.createElement(ResizeableWindow,{extraControls:extraControls,icon:"print",initialHeight:0.75*window.innerHeight,initialWidth:0.5*window.innerWidth,key:"PrintOutputWindow",onClose:function onClose(){return _this.setState({printOutputVisible:false,outputLoaded:false,pdfData:null,pdfDataUrl:null})},title:LocaleUtils.tr("print.output"),visible:_this.state.printOutputVisible},/*#__PURE__*/React.createElement("div",{className:"print-output-window-body",role:"body"},!_this.state.outputLoaded?/*#__PURE__*/React.createElement("span",{className:"print-output-window-wait"},/*#__PURE__*/React.createElement(Spinner,null)," ",LocaleUtils.tr("print.wait")):null,/*#__PURE__*/React.createElement("iframe",{name:"print-output-window",onLoad:function onLoad(){return _this.setState({outputLoaded:true})},src:_this.state.pdfDataUrl})))});_defineProperty(_this,"savePrintOutput",function(){FileSaver.saveAs(_this.state.pdfData.content,_this.state.pdfData.fileName)});_defineProperty(_this,"selectAtlasFeature",function(layer,feature){if(!feature){return}_this.setState(function(state){var index=state.atlasFeatures.findIndex(function(f){return f.id===feature.id});if(index>=0){var newAtlasFeatures=state.atlasFeatures.slice(0);newAtlasFeatures.splice(index,1);return{atlasFeatures:newAtlasFeatures}}else{return{atlasFeatures:[].concat(_toConsumableArray(state.atlasFeatures),[feature])}}})});_defineProperty(_this,"deselectAtlasFeature",function(feature){_this.setState(function(state){var index=state.atlasFeatures.find(function(f){return f.id===feature.id});var newAtlasFeatures=state.atlasFeatures.slice(0);newAtlasFeatures.splice(index,1);return{atlasFeatures:newAtlasFeatures}})});_defineProperty(_this,"changeLayout",function(ev){var layout=_this.props.theme.print.find(function(item){return item.name===ev.target.value});_this.setState({layout:layout,atlasFeature:null})});_defineProperty(_this,"changeScale",function(value){_this.setState({scale:Math.max(1,parseInt(value,10)||0)})});_defineProperty(_this,"changeResolution",function(value){_this.setState({dpi:value||300})});_defineProperty(_this,"changeRotation",function(value){var angle=value||0;_this.setState({rotation:(angle%360+360)%360})});_defineProperty(_this,"changeSeriesOverlap",function(ev){_this.setState({printSeriesOverlap:parseInt(ev.target.value,10)||0})});_defineProperty(_this,"changeDownloadMode",function(ev){_this.setState({downloadMode:ev.target.value})});_defineProperty(_this,"formatChanged",function(ev){_this.setState({selectedFormat:ev.target.value})});_defineProperty(_this,"print",function(ev){ev.preventDefault();_this.setState({printing:true});if(_this.props.inlinePrintOutput){_this.setState({printOutputVisible:true,outputLoaded:false})}var formData=formDataEntries(new FormData(_this.printForm));var mapCrs=_this.props.map.projection;var mapName=_this.state.layout.map.name;// Add base print params
|
|
14
14
|
var printParams=LayerUtils.collectPrintParams(_this.props.layers,_this.props.theme,_this.state.scale,mapCrs,_this.props.printExternalLayers);Object.entries(printParams).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];formData[key]=value});formData[mapName+":LAYERS"]=printParams.LAYERS;formData[mapName+":STYLES"]=printParams.STYLES;formData[mapName+":FILTER"]=printParams.FILTER;formData[mapName+":FILTER_GEOM"]=printParams.FILTER_GEOM;// Add highlight params
|
|
15
|
-
var printDpi=parseInt(_this.state.dpi,10)||0;var highlightParams=VectorLayerUtils.createPrintHighlighParams(_this.props.layers,mapCrs,_this.state.scale,printDpi,_this.props.scaleFactor);formData[mapName+":HIGHLIGHT_GEOM"]=highlightParams.geoms.join(";");formData[mapName+":HIGHLIGHT_SYMBOL"]=highlightParams.styles.join(";");formData[mapName+":HIGHLIGHT_LABELSTRING"]=highlightParams.labels.join(";");formData[mapName+":HIGHLIGHT_LABELCOLOR"]=highlightParams.labelFillColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERCOLOR"]=highlightParams.labelOutlineColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERSIZE"]=highlightParams.labelOutlineSizes.join(";");formData[mapName+":HIGHLIGHT_LABELSIZE"]=highlightParams.labelSizes.join(";");formData[mapName+":HIGHLIGHT_LABEL_DISTANCE"]=highlightParams.labelDist.join(";");formData[mapName+":HIGHLIGHT_LABEL_ROTATION"]=highlightParams.labelRotations.join(";");// Add
|
|
15
|
+
var printDpi=parseInt(_this.state.dpi,10)||0;var highlightParams=VectorLayerUtils.createPrintHighlighParams(_this.props.layers,mapCrs,_this.state.scale,printDpi,_this.props.scaleFactor);formData[mapName+":HIGHLIGHT_GEOM"]=highlightParams.geoms.join(";");formData[mapName+":HIGHLIGHT_SYMBOL"]=highlightParams.styles.join(";");formData[mapName+":HIGHLIGHT_LABELSTRING"]=highlightParams.labels.join(";");formData[mapName+":HIGHLIGHT_LABELCOLOR"]=highlightParams.labelFillColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERCOLOR"]=highlightParams.labelOutlineColors.join(";");formData[mapName+":HIGHLIGHT_LABELBUFFERSIZE"]=highlightParams.labelOutlineSizes.join(";");formData[mapName+":HIGHLIGHT_LABELSIZE"]=highlightParams.labelSizes.join(";");formData[mapName+":HIGHLIGHT_LABEL_DISTANCE"]=highlightParams.labelDist.join(";");formData[mapName+":HIGHLIGHT_LABEL_ROTATION"]=highlightParams.labelRotations.join(";");// Add grid params
|
|
16
|
+
var printGrid=_this.props.theme.printGrid;if(!isEmpty(printGrid)){if(_this.state.grid){var cur=0;while(cur<printGrid.length-1&&_this.state.scale<printGrid[cur].s){cur+=1}formData[mapName+":GRID_INTERVAL_X"]=printGrid[cur].x;formData[mapName+":GRID_INTERVAL_Y"]=printGrid[cur].y}else{formData[mapName+":GRID_INTERVAL_X"]=0;formData[mapName+":GRID_INTERVAL_Y"]=0}}// Add dimension values
|
|
16
17
|
_this.props.layers.forEach(function(layer){if(layer.role===LayerRole.THEME){Object.entries(layer.dimensionValues||{}).forEach(function(_ref5){var _ref6=_slicedToArray(_ref5,2),key=_ref6[0],value=_ref6[1];if(value!==undefined){formData[key]=value}})}});// Add extra print parameters
|
|
17
18
|
var extraOptions=Object.fromEntries((_this.props.theme.extraPrintParameters||"").split("&").filter(Boolean).map(function(entry){return entry.split("=")}));Object.entries(extraOptions).forEach(function(_ref7){var _ref8=_slicedToArray(_ref7,2),key=_ref8[0],value=_ref8[1];formData[key]=value});var pages=[formData];if(_this.state.printSeriesEnabled){pages=_this.state.extents.map(function(extent,index){var fd=structuredClone(formData);fd.name=(index+1).toString().padStart(2,"0");fd[_this.state.layout.map.name+":extent"]=_this.formatExtent(extent);return fd})}var timestamp=dayjs(new Date).format("YYYYMMDD_HHmmss");var fileName=_this.props.fileNameTemplate.replace("{username}",ConfigUtils.getConfigProp("username",null,"")).replace("{tenant}",ConfigUtils.getConfigProp("tenant",null,"")).replace("{theme}",_this.props.theme.id).replace("{timestamp}",timestamp);// batch print all pages
|
|
18
19
|
_this.batchPrint(pages,fileName)["catch"](function(e){_this.setState({outputLoaded:true,printOutputVisible:false});if(e.response){/* eslint-disable-next-line */console.warn(new TextDecoder().decode(e.response.data))}/* eslint-disable-next-line */alert("Print failed")})["finally"](function(){_this.setState({printing:false})})});_this.printForm=null;_this.state.grid=props.gridInitiallyEnabled;_this.state.dpi=props.defaultDpi;_this.state.selectedFormat=props.formats[0];return _this}_inherits(Print,_React$Component);return _createClass(Print,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps,prevState){if(prevProps.theme!==this.props.theme){if(this.props.theme&&!isEmpty(this.props.theme.print)){var layouts=this.props.theme.print.filter(function(l){return l.map}).sort(function(a,b){return a.name.localeCompare(b.name,undefined,{numeric:true})});var layout=layouts.find(function(l){return l["default"]})||layouts[0];this.setState({layout:layout,atlasFeatures:[]})}else{this.setState({layout:null,atlasFeatures:[]})}}if(this.state.atlasFeatures!==prevState.atlasFeatures){if(!isEmpty(this.state.atlasFeatures)){var layer={id:"print-pick-selection",role:LayerRole.SELECTION,skipPrint:true};this.props.addLayerFeatures(layer,this.state.atlasFeatures,true)}else if(!isEmpty(prevState.atlasFeatures)){this.props.clearLayer("print-pick-selection")}}if(this.state.printSeriesEnabled&&this.state.selectedFormat!=="application/pdf"){this.setState({selectedFormat:"application/pdf"})}}},{key:"render",value:function render(){var _this2=this;var minMaxTooltip=this.state.minimized?LocaleUtils.tr("print.maximize"):LocaleUtils.tr("print.minimize");var extraTitlebarContent=/*#__PURE__*/React.createElement(Icon,{className:"print-minimize-maximize",icon:this.state.minimized?"chevron-down":"chevron-up",onClick:function onClick(){return _this2.setState(function(state){return{minimized:!state.minimized}})},title:minMaxTooltip});return[/*#__PURE__*/React.createElement(SideBar,{extraTitlebarContent:extraTitlebarContent,icon:"print",id:"Print",key:"Print",onHide:this.onHide,onShow:this.onShow,side:this.props.side,title:LocaleUtils.tr("appmenu.items.Print"),width:"20em"},function(){return{body:_this2.state.minimized?null:_this2.renderBody(),extra:[_this2.renderPrintSelection()]}}),this.renderPrintOutputWindow(),this.props.active&&this.state.layout&&this.state.layout.atlasCoverageLayer&&!this.state.printSeriesEnabled?/*#__PURE__*/React.createElement(PickFeature,{featurePicked:this.selectAtlasFeature,key:"FeaturePicker",layer:this.state.layout.atlasCoverageLayer}):null]}},{key:"batchPrint",value:function(){var _batchPrint=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(pages,fileName){var _this3=this;var promises,docs,files,file,fileURL,_iterator,_step,_file;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:// Print pages on server
|