Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option: "Download as pdf" #538

Merged
merged 44 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
911477c
Add pdf download format management
volterra79 Jan 9, 2024
afc6868
Merge branch 'dev' into issue_537
Raruto Jan 16, 2024
6e7a2ba
jsdoc
Raruto Jan 16, 2024
0ac49ef
Update src/app/core/layers/mixins/download.js
volterra79 Jan 16, 2024
4f7ff91
Merge branch 'dev' into issue_537
volterra79 Jan 17, 2024
a72aae5
Merge branch 'issue_537' of https://github.com/g3w-suite/g3w-client i…
volterra79 Jan 17, 2024
301d3dd
Merge branch 'dev' into issue_537
volterra79 Jan 29, 2024
74a4b5c
Clean code
volterra79 Jan 29, 2024
b530a38
Clean code
volterra79 Jan 29, 2024
b3fdbce
Add getLayerDownloads to filter download formats enable of layer level
volterra79 Jan 29, 2024
b1b5615
Clean code
volterra79 Jan 29, 2024
03090d8
Filter 'pdf' downloadformats config attribute, because it used only f…
volterra79 Jan 29, 2024
f4624c0
Clean code
volterra79 Jan 29, 2024
fa3ae39
Clean code
volterra79 Jan 29, 2024
59422ca
Clean code
volterra79 Jan 29, 2024
00bcc77
change from v-if to v-show to pass all html dom element for pdf downl…
volterra79 Jan 29, 2024
3aa81f9
Add i18n translation
volterra79 Jan 29, 2024
bd2a98d
Add feature-html-content attribute to estract contento of single hmtl…
volterra79 Jan 29, 2024
ecda233
Clean code
volterra79 Jan 30, 2024
73ed3a0
Clean code
volterra79 Jan 30, 2024
72c3d96
Change pdf api url
volterra79 Jan 30, 2024
a76ba6f
Chnage pdf POST parameter name to html
volterra79 Jan 30, 2024
0ec9f92
Merge branch 'dev' into issue_537
volterra79 Jan 31, 2024
28f4f5e
DEV: Force download_pdf config layer to true. Fox Development only pu…
volterra79 Jan 31, 2024
a15816f
Merge branch 'dev' into issue_537
volterra79 Jan 31, 2024
38a75c2
Merge branch 'dev' into issue_537
Raruto Feb 1, 2024
b66d246
Merge branch 'dev' into issue_537
volterra79 Feb 7, 2024
b3abf5a
Merge branch 'issue_537' of https://github.com/g3w-suite/g3w-client i…
volterra79 Feb 7, 2024
e0aa8de
Merge branch 'dev' into issue_537
Raruto Feb 14, 2024
e7e127a
Merge branch 'dev' into issue_537
volterra79 Mar 18, 2024
a0ad6fe
Merge branch 'issue_537' of https://github.com/g3w-suite/g3w-client i…
volterra79 Mar 18, 2024
06c3ac8
Merge branch 'dev' into issue_537
Raruto Apr 15, 2024
800467c
Merge branch 'dev' into issue_537
volterra79 May 6, 2024
404382e
Fix delete feature-html-content attr after merging with dev brach
volterra79 May 6, 2024
30595a8
Remove DEV code
volterra79 May 6, 2024
6ffa38a
Merge branch 'dev' into issue_537
volterra79 May 8, 2024
7e0270a
Merge branch 'dev' into issue_537
volterra79 May 13, 2024
3e39f4c
Clean code - spaces
volterra79 May 13, 2024
5c55c44
Add parameter for POST method request
volterra79 May 13, 2024
8ca79bc
Use downloadFile utils intead $.fileDownload jquery plugin to downloa…
volterra79 May 13, 2024
bb7a365
simplify `layer.config` and `getDownloadFilefromDownloadDataType`
Raruto May 14, 2024
2011be4
Clean code - Spaces
volterra79 May 14, 2024
900ec21
:bug: download pdf format in case of single format
volterra79 May 14, 2024
471b75f
Filter pdf format from layer.downloads format array.
volterra79 May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/app/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export const DOWNLOAD_FORMATS = {
download_raster: {
format: 'geotiff',
url: 'geotiff'
}
},
download_pdf: {
format: 'pdf',
url: 'pdf'
},
};

/**
Expand Down
196 changes: 60 additions & 136 deletions src/app/core/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,180 +21,104 @@ const deprecate = require('util-deprecate');
// Base Class of all Layer
function Layer(config={}, options={}) {

this.config = config;

// assign some attribute
config.id = config.id || 'Layer';
config.title = config.title || config.name;
config.download = !!config.download;
config.geolayer = false;
config.baselayer = !!config.baselayer;
config.fields = config.fields || {};
config.urls = {
query: (config.infourl && '' !== config.infourl ? config.infourl : config.wmsUrl),
...(config.urls || {})
};

//get current project object
const {
project = ProjectsRegistry.getCurrentProject()
} = options;

/** @deprecated since 3.10.0. Will be removed in v.4.x. */
this.config.search_endpoint = 'api';
const project = options.project || ProjectsRegistry.getCurrentProject();
const suffixUrl = config.baselayer ? '' : `${project.getType()}/${project.getId()}/${config.id}/`;
const vectorUrl = config.baselayer ? '' : project.getVectorUrl();
const rasterUrl = config.baselayer ? '' : project.getRasterUrl();

// assign some attributes

this.config = Object.assign(config, {
id: config.id || 'Layer',
title: config.title || config.name,
download: !!config.download,
geolayer: false,
baselayer: !!config.baselayer,
fields: config.fields || {},
// URLs to get various type of data
urls: {
query: config.infourl || config.wmsUrl,
...(config.urls || {}),
...(config.baselayer ? {} : {
filtertoken: `${vectorUrl}filtertoken/${suffixUrl}`,
data: `${vectorUrl}data/${suffixUrl}`,
shp: `${vectorUrl}shp/${suffixUrl}`,
csv: `${vectorUrl}csv/${suffixUrl}`,
xls: `${vectorUrl}xls/${suffixUrl}`,
gpx: `${vectorUrl}gpx/${suffixUrl}`,
gpkg: `${vectorUrl}gpkg/${suffixUrl}`,
geotiff: `${rasterUrl}geotiff/${suffixUrl}`,
editing: `${vectorUrl}editing/${suffixUrl}`,
commit: `${vectorUrl}commit/${suffixUrl}`,
config: `${vectorUrl}config/${suffixUrl}`,
unlock: `${vectorUrl}unlock/${suffixUrl}`,
widget: {
unique: `${vectorUrl}widget/unique/data/${suffixUrl}`
},
/** @since 3.8.0 */
featurecount: project.getUrl('featurecount'),
/** @since 3.10.0 */
pdf: `/html2pdf/`,
})
},
/** Custom parameters based on a project qgis version */
...(config.baselayer ? {} : { searchParams: { I: 0, J: 0 } }),
/** @deprecated since 3.10.0. Will be removed in v.4.x. */
search_endpoint: 'api',
});

// create relations
this._relations = this._createRelations(project.getRelations());

// set URLs to get varios type of data
if (!this.isBaseLayer()) {
//suffix url
const suffixUrl = `${project.getType()}/${project.getId()}/${config.id}/`;
//get vector url
const vectorUrl = project.getVectorUrl();
//get raster url
const rasterUrl = project.getRasterUrl();

this.config.urls.filtertoken = `${vectorUrl}filtertoken/${suffixUrl}`;
this.config.urls.data = `${vectorUrl}data/${suffixUrl}`;
this.config.urls.shp = `${vectorUrl}shp/${suffixUrl}`;
this.config.urls.csv = `${vectorUrl}csv/${suffixUrl}`;
this.config.urls.xls = `${vectorUrl}xls/${suffixUrl}`;
this.config.urls.gpx = `${vectorUrl}gpx/${suffixUrl}`;
this.config.urls.gpkg = `${vectorUrl}gpkg/${suffixUrl}`;
this.config.urls.geotiff = `${rasterUrl}geotiff/${suffixUrl}`;
this.config.urls.editing = `${vectorUrl}editing/${suffixUrl}`;
this.config.urls.commit = `${vectorUrl}commit/${suffixUrl}`;
this.config.urls.config = `${vectorUrl}config/${suffixUrl}`;
this.config.urls.unlock = `${vectorUrl}unlock/${suffixUrl}`;
this.config.urls.widget = {
unique: `${vectorUrl}widget/unique/data/${suffixUrl}`
};

/**
* Store feature count url to get features count of a layer
*
* @since 3.8.0
*/
this.config.urls.featurecount = project.getUrl('featurecount');

/**
* Custom parameters based on a project qgis version
*/
this.config.searchParams = { I: 0, J: 0 };
}

// dinamic layer values useful for layerstree
const defaultstyle = config.styles && config.styles.find(style => style.current).name;
const defaultstyle = config.styles && config.styles.find(s => s.current).name;

/**
* @TODO make it simpler, `this.config` and `this.state` are essentially duplicated data
*/
this.state = {

id: config.id,

title: config.title,

selected: config.selected || false,

disabled: config.disabled || false,

metadata: config.metadata,

metadata_querable: this.isBaseLayer() ? false: this.isQueryable({onMap:false}),

openattributetable: this.isBaseLayer() ? false: this.canShowTable(),

removable: config.removable || false,

downloadable: this.isDownloadable(),

source: config.source,

styles: config.styles,

defaultstyle,

/**
* state of if is in editing (setted by editing plugin)
*/
inediting: false,

infoformat: this.getInfoFormat(),

infoformats: this.config.infoformats || [],

projectLayer: true,

geolayer: false,

/**
* Reactive selection attribute
*/
attributetable: { pageLength: null },
visible: config.visible || false,
tochighlightable: false,
/** state of if is in editing (setted by editing plugin) */
inediting: false,
/** Reactive selection attribute */
selection: { active: false },

/**
* Reactive filter attribute
*/
/** Reactive filter attribute */
filter: {
active: false,

/**
* @since 3.9.0 whether filter is set from a previously saved filter
*/
/** @since 3.9.0 whether filter is set from a previously saved filter */
current: null,
},

/**
* @type { Array<{{ id: string, name: string }}> } array of saved filters
*
* @since 3.9.0
*/
/** @type { Array<{{ id: string, name: string }}> } since 3.9.0 - array of saved filters */
filters: config.filters || [],

attributetable: { pageLength: null },


visible: config.visible || false,

tochighlightable: false,

/**
* @type {number}
*
* @since 3.8.0
*/
/** @type {number} since 3.8.0 */
featurecount: config.featurecount,

/**
* @type { boolean | Object<number, number> }
*
* @since 3.8.0
*/
/** @type { boolean | Object<number, number> } since 3.8.0 */
stylesfeaturecount: config.featurecount && defaultstyle && { [defaultstyle]: config.featurecount },

/**
* @type { string }
*
* @since 3.10.0
*/
/** @type { string } since 3.10.0 */
name: config.name,

/**
* @type { boolean }
*
* @since 3.10.0
*/
/** @type { boolean } since 3.10.0 */
expanded: config.expanded,

/**
* @type { boolean } whether to show layer on TOC (default: true)
*
* @since 3.10.0
*/
/** @type { boolean } since 3.10.0 - whether to show layer on TOC (default: true) */
toc: 'boolean' === typeof config.toc ? config.toc: true,

};

/**
Expand Down
18 changes: 9 additions & 9 deletions src/app/core/layers/map/maplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const { base, inherit } = require('utils');
const G3WObject = require('core/g3wobject');

function MapLayer(config={}) {
this.config = config;
this.id = config.id;
this.iframe_internal = config.iframe_internal || false;
this.extent = config.extent;
this.projection = config.projection;
this.layer = null;
this.layers = config.layers || []; // store all enabled layers
this.allLayers = []; // store all layers
this.config = config;
this.id = config.id;
this.iframe_internal = config.iframe_internal || false;
this.extent = config.extent;
this.projection = config.projection;
this.layer = null;
this.layers = config.layers || []; // store all enabled layers
this.allLayers = []; // store all layers
this.showSpinnerWhenLoading = true;
base(this);
}
Expand Down Expand Up @@ -40,7 +40,7 @@ proto.checkLayersDisabled = function(resolution, mapUnits) {
this.allLayers.forEach(layer => this.checkLayerDisabled(layer, resolution, mapUnits));
};

proto.setupCustomMapParamsToLegendUrl = function(params={}){
proto.setupCustomMapParamsToLegendUrl = function(params={}) {
//to owerwrite for each map layer subclass
};

Expand Down
Loading