From 26569ff9604a1c9908a2d3d77c3a8112fe6fde95 Mon Sep 17 00:00:00 2001 From: luebke Date: Tue, 2 Jul 2024 19:46:29 +0200 Subject: [PATCH 01/14] CADENZA-36890 Add the object info to cadenza.js and sandbox.html --- sandbox.html | 59 ++++++++++++++++++++++++++++++++++++-------------- src/cadenza.js | 46 +++++++++++++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 20 deletions(-) diff --git a/sandbox.html b/sandbox.html index 2196af3a..76a910ae 100644 --- a/sandbox.html +++ b/sandbox.html @@ -161,9 +161,9 @@ }, setFilter: data => cadenzaClient.setFilter(parseFilterVariables(data.filter)), setLayerVisibility: data => cadenzaClient.setLayerVisibility(JSON.parse(data.layer), data.visibility === 'on'), - setSelection: data => cadenzaClient.setSelection(JSON.parse(data.layer), JSON.parse(data.values)), - addSelection: data => cadenzaClient.addSelection(JSON.parse(data.layer), JSON.parse(data.values)), - removeSelection: data => cadenzaClient.removeSelection(JSON.parse(data.layer), JSON.parse(data.values)), + setSelection: data => cadenzaClient.setSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)), + addSelection: data => cadenzaClient.addSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)), + removeSelection: data => cadenzaClient.removeSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)), createGeometry: data => cadenzaClient.createGeometry(data.embeddingTargetId, data.geometryType, getOptions(data)), editGeometry: ({ geometry, ...data }) => cadenzaClient.editGeometry(data.embeddingTargetId, JSON.parse(geometry), getOptions(data)), selectObjects: data => cadenzaClient.selectObjects(data.embeddingTargetId, getOptions(data)), @@ -171,6 +171,11 @@ console.log('Inspect the fetchData() request in the devtools.'); cadenzaClient.fetchData(data.embeddingTargetId, data.dataType, getOptions(data)); }, + fetchObjectInfo: data => { + console.log('Inspect the fetchObjectInfo() request in the devtools.'); + cadenzaClient.fetchObjectInfo(data.embeddingTargetId, JSON.parse(data.layer), JSON.parse(data.objectIds), getOptions(data)); + + }, downloadData: data => cadenzaClient.downloadData(data.embeddingTargetId, data.dataType, getOptions(data)) }; @@ -216,7 +221,8 @@ parts, layers, simplifiedOperationMode, - useMapSrs + useMapSrs, + fullGeometries }) { return { disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(','), @@ -235,7 +241,8 @@ parts: parts && parts.split(','), ...(simplifiedOperationMode === 'on' && { operationMode: 'simplified' }), layers: layers ? JSON.parse(layers) : undefined, - useMapSrs: useMapSrs === 'on' + useMapSrs: useMapSrs === 'on', + fullGeometries: fullGeometries === 'on' }; } @@ -284,6 +291,7 @@ + @@ -501,8 +509,8 @@

- A JSON value like ["{layerPrintName}",...] or - [["{layerGroupPrintName}","{layerPrintName}"],...] + A JSON value like ["layerPrintName",...] or + [["layerGroupPrintName","layerPrintName"],...]

@@ -517,9 +525,9 @@ - - - + + + - + + @@ -555,8 +555,8 @@

- A JSON value like "layerPrintName" or - ["layerGroupPrintName","layerPrintName"] + A JSON value like "<layerPrintName>" or + ["<layerGroupPrintName>","<layerPrintName>"]

diff --git a/src/cadenza.js b/src/cadenza.js index 1a882f1a..1dbfb9df 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -61,7 +61,7 @@ globalThis.cadenza = Object.assign( * The idea is to have a specific type e.g. for the {@link EmbeddingTargetId} instead of a plain `string`. * You don't need to _actually_ add that `__type` property. In TS code, just use a * [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions) - * (e.g. `cadenzaClient.show('{embeddingTargetId}' as EmbeddingTargetId)`). + * (e.g. `cadenzaClient.show('' as EmbeddingTargetId)`). */ /** @@ -83,7 +83,7 @@ globalThis.cadenza = Object.assign( * * You get the `repositoryName` and `externalLinkId` from the URL of the external link's page in the Cadenza management center: * ``` - * {baseUrl}/admin/repositories/{repositoryName}/external-links/{externalLinkId}?... + * /admin/repositories//external-links/?... * ``` * * @property {string} repositoryName - The name of the link's repository diff --git a/src/docs.md b/src/docs.md index 2fcc65f0..31296163 100644 --- a/src/docs.md +++ b/src/docs.md @@ -37,7 +37,7 @@ Create an instance of the Cadenza client by calling `cadenza()` with the base UR ```javascript import { cadenza } from '@disy/cadenza.js'; -const cadenzaClient = cadenza('{baseUrl}', { +const cadenzaClient = cadenza('', { iframe: 'cadenza-iframe', }); ``` @@ -51,7 +51,7 @@ _Tip:_ If you develop your application in TypeScript - Cadenza JS is typed using ``` ```javascript -const cadenzaClient = window.cadenza('{baseUrl}', ...); +const cadenzaClient = window.cadenza('', ...); ``` The `type="module"` has the effect that script execution is [deferred](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#defer). You might need to wait for the `DOMContentLoaded` event in order to use Cadenza JS. @@ -90,7 +90,7 @@ Show an embedding target in an iframe and ... - Set the filter variable "var1" to "foo". ```javascript -cadenzaClient.show('{embeddingTargetId}', { +cadenzaClient.show('', { hideMainHeaderAndFooter: true, hideWorkbookToolBar: true, operationMode: 'simplified', @@ -109,7 +109,7 @@ cadenzaClient.show('{embeddingTargetId}', { Views of type "JasperReports report" can be shown in an iframe like any other view. Additionally, there is an option to show only the generated PDF without any Cadenza footers or headers. This is done by setting the "dataType" option to "pdf". ```javascript -cadenzaClient.show('{embeddingTargetId}', { +cadenzaClient.show('', { dataType: 'pdf' }); ``` @@ -121,7 +121,7 @@ Cadenza JS uses the [AbortController Web API](https://developer.mozilla.org/en-U ```javascript const abortController = new AbortController(); try { - await cadenzaClient.show('{embeddingTargetId}', { signal: abortController.signal }); + await cadenzaClient.show('', { signal: abortController.signal }); } catch (error) { if (error.name === 'AbortError') { console.log('Iframe loading was aborted'); @@ -141,7 +141,7 @@ _Tip:_ You can use the same `AbortController` to abort multiple requests, e.g. w Set filter variables using a mapping of variable names to values. ```javascript -cadenzaClient.setFilter({ 'my-variable': 'value' }); +cadenzaClient.setFilter({ '': 'value' }); ``` --> @@ -157,7 +157,7 @@ Show the embedding target of a workbook map view in an iframe and ... The coordinates of extent and geometry are in the map's SRS (`useMapSrs: true`). ```javascript -cadenzaClient.showMap('{embeddingTargetId}', { +cadenzaClient.showMap('', { useMapSrs: true, mapExtent: [ -572_513.341856, 5_211_017.966314, 916_327.095083, 6_636_950.728974, @@ -172,7 +172,7 @@ cadenzaClient.showMap('{embeddingTargetId}', { #### Initialize the Map Extent by Setting the Location Finder ```javascript -cadenzaClient.showMap('{embeddingTargetId}', { +cadenzaClient.showMap('', { locationFinder: 'Karlsruhe', }); ``` @@ -185,7 +185,7 @@ cadenzaClient.showMap('{embeddingTargetId}', { To set the visibility of a layer in the currently shown map, pass the layer path or print name and the desired visibility. ```javascript -cadenzaClient.setLayerVisibility('{layerPrintName}', false); +cadenzaClient.setLayerVisibility('', false); ``` --> @@ -214,7 +214,7 @@ const geometry = { type: 'Point', coordinates: [328_627.563458, 5_921_296.662223], }; -cadenzaClient.editGeometry('{embeddingTargetId}', geometry, { +cadenzaClient.editGeometry('', geometry, { useMapSrs: true, }); @@ -246,7 +246,7 @@ unsubscribe(); Edit a GeoJSON point geometry with a workbook map view in the background. The geometry coordinates are in the map's SRS (`useMapSrs: true`). ```javascript -cadenzaClient.createGeometry('{embeddingTargetId}', 'Point', { +cadenzaClient.createGeometry('', 'Point', { useMapSrs: true, }); @@ -265,10 +265,10 @@ That's why the events use the `editGeometry` prefix. Ask the user to select objects in a workbook map view. In the example the selection is restricted to specific layers. For layers in groups, pass the layer path. ```javascript -cadenzaClient.selectObjects('{embeddingTargetId}', { +cadenzaClient.selectObjects('', { layers: [ - [ '{layerGroupPrintName}', '{layerPrintName}' ], - [ '{layerPrintName}' ] + [ '', '' ], + [ '' ] ] }); @@ -286,7 +286,7 @@ Set the selection in the currently shown workbook map view using a list of objec ```javascript cadenzaClient.setSelection( - layer: '{layerPrintName}', + layer: '', values: [ 'objectId', ... ] ); ``` @@ -303,7 +303,7 @@ You can also add to or remove from the current selection: Show an embedding target in an iframe and highlight an item in the navigator. Additionally, expand the navigator tree. ```javascript -cadenzaClient.show('{embeddingTargetId}', {expandNavigator: true, highlightGlobalId: 'ROOT.MyFolder'}); +cadenzaClient.show('', {expandNavigator: true, highlightGlobalId: 'ROOT.MyFolder'}); ``` #### Highlight an Item in the Navigator on the Welcome Page @@ -333,7 +333,7 @@ cadenzaClient.expandNavigator(); Fetch data from a workbook view in CSV format. ```javascript -const response = await cadenzaClient.fetchData('{embeddingTargetId}', 'csv'); +const response = await cadenzaClient.fetchData('', 'csv'); const text = await response.text(); ... @@ -344,7 +344,7 @@ const text = await response.text(); Fetch data from a workbook view in JSON format and include only the data values and the aggregation totals. (Do not include the column names.) ```javascript -const response = await cadenzaClient.fetchData('{embeddingTargetId}', 'json', { +const response = await cadenzaClient.fetchData('', 'json', { parts: ['values', 'totals'] }); @@ -376,7 +376,7 @@ Download data from a workbook view in Excel format. This triggers the browser's ```javascript const button = document.createElement('button'); button.textContent = 'Download Excel'; -button.onclick = () => cadenzaClient.downloadData('{embeddingTargetId}', 'excel'); +button.onclick = () => cadenzaClient.downloadData('', 'excel'); ``` ### Reload the Views of a Worksheet From ef43844354f104ca9cd92ffa604570ca44a152be Mon Sep 17 00:00:00 2001 From: kissel Date: Fri, 12 Jul 2024 13:57:50 +0200 Subject: [PATCH 06/14] add support for dataType=pdf in CadenzaClient#downloadData and #fetchData --- CHANGELOG.md | 2 +- sandbox.html | 1 + src/cadenza.js | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 522ffab4..8a71dacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added +- Support for `dataType=pdf` in `CadenzaClient#downloadData` and `CadenzaClient#fetchData` - `CadenzaClient#fetchObjectInfo` ### Fixed - Make Cadenza return an error instead of showing an error page. - ## 2.10.0 - 2024-06-11 ### Added - `CadenzaClient#destroy` diff --git a/sandbox.html b/sandbox.html index ee4eaf6f..ec05a6b2 100644 --- a/sandbox.html +++ b/sandbox.html @@ -397,6 +397,7 @@ +
diff --git a/src/cadenza.js b/src/cadenza.js index 1dbfb9df..be20cdae 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -826,9 +826,9 @@ export class CadenzaClient { * Fetch data from a workbook view. * * @param {EmbeddingTargetId} source - The workbook view to fetch data from. - * Currently only table and indicator views are supported. * @param {DataType} dataType - The data type you want to get back from the server. - * Currently, `"csv"`, `"excel"` and `"json"` are supported. + * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views + * and `"pdf"` for views of type "JasperReports report". * @param {object} [options] - Options * @param {FilterVariables} [options.filter] - Filter variables * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported. @@ -839,7 +839,7 @@ export class CadenzaClient { */ fetchData(source, dataType, { filter, parts, signal } = {}) { this.#log('CadenzaClient#fetchData', ...arguments); - assertSupportedDataType(dataType, ['csv', 'excel', 'json']); + assertSupportedDataType(dataType, ['csv', 'excel', 'json', 'pdf']); const params = createParams({ dataType, filter, parts }); return this.#fetch(resolvePath(source), params, signal); } @@ -910,10 +910,10 @@ export class CadenzaClient { * * _Note:_ The file name, if not provided, is generated from the name of the workbook view and the current date. * - * @param {EmbeddingTargetId} source - The workbook view to download data from. - * Currently only table and indicator views are supported. + * @param {EmbeddingTargetId} source - The workbook view to fetch data from. * @param {DataType} dataType - The data type you want to get back from the server. - * Currently, `"csv"`, `"excel"` and `"json"` are supported. + * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views + * and `"pdf"` for views of type "JasperReports report". * @param {object} [options] - Options * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza. * @param {FilterVariables} [options.filter] - Filter variables @@ -923,7 +923,7 @@ export class CadenzaClient { */ downloadData(source, dataType, { fileName, filter, parts } = {}) { this.#log('CadenzaClient#downloadData', ...arguments); - assertSupportedDataType(dataType, ['csv', 'excel', 'json']); + assertSupportedDataType(dataType, ['csv', 'excel', 'json', 'pdf']); const params = createParams({ dataType, fileName, filter, parts }); this.#download(resolvePath(source), params); } From 1877487288edc6a056fe323f97f6678c5db5874c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Jul 2024 12:07:05 +0000 Subject: [PATCH 07/14] chore: release v2.11.0 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a71dacd..d5be1a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + +## 2.11.0 - 2024-07-12 ### Added - Support for `dataType=pdf` in `CadenzaClient#downloadData` and `CadenzaClient#fetchData` - `CadenzaClient#fetchObjectInfo` diff --git a/package.json b/package.json index 03346d8d..f2bbf0bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "2.10.0", + "version": "2.11.0", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From cec64933eb84cb6091591232bccbf2d88c9c57ab Mon Sep 17 00:00:00 2001 From: kissel Date: Sun, 14 Jul 2024 22:08:08 +0200 Subject: [PATCH 08/14] include version --- typedoc.config.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/typedoc.config.cjs b/typedoc.config.cjs index 38ad7633..720dda22 100644 --- a/typedoc.config.cjs +++ b/typedoc.config.cjs @@ -1,6 +1,7 @@ /** @type {import('typedoc').TypeDocOptions} */ module.exports = { name: 'Cadenza JS', + includeVersion: true, readme: './src/docs.md', entryPoints: ['./src/cadenza.js'], out: './apidoc', From 1fce5fe16c69ee14d903f60b50e7e3690880d68d Mon Sep 17 00:00:00 2001 From: luebke Date: Thu, 11 Jul 2024 20:56:08 +0200 Subject: [PATCH 09/14] CADENZA-36890 Add to CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5be1a84..7eb1aa96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added +- `CadenzaClient#fetchObjectInfo` ## 2.11.0 - 2024-07-12 ### Added From ff9a4bd72db307ee3bec85df70fdb898483c0719 Mon Sep 17 00:00:00 2001 From: luebke Date: Thu, 18 Jul 2024 11:36:47 +0200 Subject: [PATCH 10/14] CADENZA-36890 Review changes --- sandbox.html | 10 +++++----- src/cadenza.js | 32 ++++++++++++++++++-------------- src/docs.md | 4 ++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/sandbox.html b/sandbox.html index ec05a6b2..204951f8 100644 --- a/sandbox.html +++ b/sandbox.html @@ -173,8 +173,8 @@ }, fetchObjectInfo: data => { console.log('Inspect the fetchObjectInfo() request in the devtools.'); - cadenzaClient.fetchObjectInfo(data.embeddingTargetId, JSON.parse(data.layer), JSON.parse(data.objectIds), getOptions(data)); - + cadenzaClient.fetchObjectInfo(data.embeddingTargetId, JSON.parse(data.layer), JSON.parse(data.objectIds), getOptions(data)) + .then(oi => console.log(oi)); }, downloadData: data => cadenzaClient.downloadData(data.embeddingTargetId, data.dataType, getOptions(data)) }; @@ -542,7 +542,7 @@ diff --git a/src/cadenza.js b/src/cadenza.js index be20cdae..3aa0231b 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -133,6 +133,18 @@ globalThis.cadenza = Object.assign( * _Note:_ Since numbers in JavaScript are Double values ([more info on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_encoding)), * for Long variables, the API is currently limited to the Double value range. */ +/** + * @typedef Feature - A [GeoJSON](https://geojson.org/) feature object + * @property {any[]} id - The id of the feature + * @property {Geometry} geometry - The geometry + * @property {Record} properties - The properties + * @property {Number | undefined} area - The area of the polygon + * @property {Number | undefined} length - The length of the line + */ +/** + * @typedef FeatureCollection - A [GeoJSON](https://geojson.org/) feature collection object + * @property {Feature[]} features - The type of the geometry + */ let hasCadenzaSession = false; @@ -845,10 +857,9 @@ export class CadenzaClient { } /** - * Fetch object info from a workbook view. + * Fetch object info from a workbook map view. * * @param {EmbeddingTargetId} source - The workbook view to fetch object info from. - * Currently only map views are supported. * @param {(WorkbookLayerPath | string)[]} [layerPath] - Layer path to identify the layer * (identified using layer paths or print names) * @param {unknown[][]} objectIds - The IDs of the objects to select @@ -857,7 +868,7 @@ export class CadenzaClient { * @param {AbortSignal} [options.signal] - A signal to abort the data fetching * @param {Boolean} [options.useMapSrs] - Use the map SRS instead of WGS84 * @param {Boolean} [options.fullGeometries] - Return non-simplified geometries - * @return {Promise} A `Promise` for the fetch response + * @return {Promise} A `Promise` for the fetch response * @throws For invalid arguments */ fetchObjectInfo(source, layerPath, objectIds, { filter, signal, useMapSrs, fullGeometries } = {}) { @@ -868,8 +879,8 @@ export class CadenzaClient { resolvePath(source) + "/objectinfo" , params, signal, - JSON.stringify({ objectIds, layerPath: array(layerPath), useMapSrs, fullGeometries}), - "application/json"); + JSON.stringify({ objectIds, layerPath: array(layerPath), useMapSrs, fullGeometries})) + .then(response => response.json()); } async #fetch( @@ -877,15 +888,14 @@ export class CadenzaClient { /** @type URLSearchParams */ params, /** @type AbortSignal | undefined */ signal, /** @type String | undefined If body is set, the fetch will be a post.*/ body, - /** @type String | undefined Has to be set if body is set.*/ bodyContentType, ) { const url = this.#createUrl(path, params); this.#log('Fetch', url.toString()); const method = body ? "POST" : undefined; const headers = new Headers(); headers.set('X-Requested-With', 'XMLHttpRequest'); - if (bodyContentType) { - headers.set('Content-Type', bodyContentType); + if (body) { + headers.set('Content-Type', "application/json"); } const res = await fetch(url, { signal, @@ -1093,7 +1103,6 @@ function assertSupportedDataType( * @param {TablePart[]} [params.parts] * @param {'MAP'} [params.targetType] * @param {boolean} [params.useMapSrs] - * @param {unknown[][]} [params.objectIds] * @return {URLSearchParams} */ function createParams({ @@ -1116,7 +1125,6 @@ function createParams({ parts, targetType, useMapSrs, - objectIds, }) { if (disabledUiFeatures) { disabledUiFeatures.forEach((feature) => @@ -1169,10 +1177,6 @@ function createParams({ layers.length && { layers: JSON.stringify(layers), }), - ...(objectIds && - objectIds.length && { - objectids: JSON.stringify(objectIds), - }), ...(locationFinder && { locationFinder }), ...(mapExtent && { mapExtent: mapExtent.join() }), ...(minScale && { minScale: String(minScale) }), diff --git a/src/docs.md b/src/docs.md index 31296163..18f8c46c 100644 --- a/src/docs.md +++ b/src/docs.md @@ -352,7 +352,7 @@ const tableData = await response.json(); ... ``` -### Download the Object Info from a Workbook Map View +### Fetch the Object Info from a Workbook Map View API: [CadenzaClient#fetchObjectInfo(./classes/CadenzaClient.html#fetchObjectInfo) @@ -364,7 +364,7 @@ const response = await cadenzaClient.fetchObjectInfo('embeddingTargetId', 'layer fullGeometries: true }); -const objectInfo = await response.json(); +const objectInfo = await response; ``` ### Download Data From a Workbook View From c0b7ad42dc4540fde94d872e59978fa8e226ac56 Mon Sep 17 00:00:00 2001 From: luebke Date: Mon, 29 Jul 2024 13:58:56 +0200 Subject: [PATCH 11/14] CADENZA-36890 Review changes --- CHANGELOG.md | 1 - src/cadenza.js | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eb1aa96..eb7c6969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 2.11.0 - 2024-07-12 ### Added - Support for `dataType=pdf` in `CadenzaClient#downloadData` and `CadenzaClient#fetchData` -- `CadenzaClient#fetchObjectInfo` ### Fixed - Make Cadenza return an error instead of showing an error page. diff --git a/src/cadenza.js b/src/cadenza.js index 3aa0231b..d0c51550 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -135,15 +135,15 @@ globalThis.cadenza = Object.assign( */ /** * @typedef Feature - A [GeoJSON](https://geojson.org/) feature object - * @property {any[]} id - The id of the feature + * @property {any[]} cadenzaObjectId - The id of the feature * @property {Geometry} geometry - The geometry - * @property {Record} properties - The properties - * @property {Number | undefined} area - The area of the polygon - * @property {Number | undefined} length - The length of the line + * @property {Record} properties - The formated properties + * @property {number} [area] - The area of a `Polygon` feature + * @property {number} [length] - The area of a `LineString` feature */ /** * @typedef FeatureCollection - A [GeoJSON](https://geojson.org/) feature collection object - * @property {Feature[]} features - The type of the geometry + * @property {Feature[]} features - The features within this collection */ let hasCadenzaSession = false; @@ -876,7 +876,7 @@ export class CadenzaClient { const params = createParams({ filter}); return this.#fetch( - resolvePath(source) + "/objectinfo" , + resolvePath(source) + '/objectinfo', params, signal, JSON.stringify({ objectIds, layerPath: array(layerPath), useMapSrs, fullGeometries})) @@ -895,7 +895,7 @@ export class CadenzaClient { const headers = new Headers(); headers.set('X-Requested-With', 'XMLHttpRequest'); if (body) { - headers.set('Content-Type', "application/json"); + headers.set('Content-Type', 'application/json'); } const res = await fetch(url, { signal, From a9624bc2274d1738c48a1f6e133a358911e9d3ae Mon Sep 17 00:00:00 2001 From: luebke Date: Mon, 29 Jul 2024 15:16:37 +0200 Subject: [PATCH 12/14] CADENZA-36890 changed the name of the feature id --- src/cadenza.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cadenza.js b/src/cadenza.js index d0c51550..28669078 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -134,15 +134,15 @@ globalThis.cadenza = Object.assign( * for Long variables, the API is currently limited to the Double value range. */ /** - * @typedef Feature - A [GeoJSON](https://geojson.org/) feature object - * @property {any[]} cadenzaObjectId - The id of the feature + * @typedef Feature - A adapted [GeoJSON](https://geojson.org/) feature object. + * @property {any[]} objectId - The id of the feature * @property {Geometry} geometry - The geometry * @property {Record} properties - The formated properties * @property {number} [area] - The area of a `Polygon` feature * @property {number} [length] - The area of a `LineString` feature */ /** - * @typedef FeatureCollection - A [GeoJSON](https://geojson.org/) feature collection object + * @typedef FeatureCollection - A adapted [GeoJSON](https://geojson.org/) feature collection object * @property {Feature[]} features - The features within this collection */ From 88ca55eeba82cdf979c462ebd3261654d99352fd Mon Sep 17 00:00:00 2001 From: luebke Date: Tue, 30 Jul 2024 10:19:53 +0200 Subject: [PATCH 13/14] CADENZA-36890 layerPath is not optional for fetchObjectInfo --- src/cadenza.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cadenza.js b/src/cadenza.js index 28669078..b7a476f7 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -860,7 +860,7 @@ export class CadenzaClient { * Fetch object info from a workbook map view. * * @param {EmbeddingTargetId} source - The workbook view to fetch object info from. - * @param {(WorkbookLayerPath | string)[]} [layerPath] - Layer path to identify the layer + * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer * (identified using layer paths or print names) * @param {unknown[][]} objectIds - The IDs of the objects to select * @param {object} [options] - Options From 34e6aa2a1a94afc94416922649a4852f4cecd756 Mon Sep 17 00:00:00 2001 From: luebke Date: Tue, 30 Jul 2024 20:59:11 +0200 Subject: [PATCH 14/14] CADENZA-36890 code format --- src/cadenza.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cadenza.js b/src/cadenza.js index b7a476f7..17056ee0 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -871,16 +871,27 @@ export class CadenzaClient { * @return {Promise} A `Promise` for the fetch response * @throws For invalid arguments */ - fetchObjectInfo(source, layerPath, objectIds, { filter, signal, useMapSrs, fullGeometries } = {}) { + fetchObjectInfo( + source, + layerPath, + objectIds, + { filter, signal, useMapSrs, fullGeometries } = {}, + ) { this.#log('CadenzaClient#fetchObjectInfo', ...arguments); const params = createParams({ - filter}); + filter, + }); return this.#fetch( resolvePath(source) + '/objectinfo', params, signal, - JSON.stringify({ objectIds, layerPath: array(layerPath), useMapSrs, fullGeometries})) - .then(response => response.json()); + JSON.stringify({ + objectIds, + layerPath: array(layerPath), + useMapSrs, + fullGeometries, + }), + ).then((response) => response.json()); } async #fetch( @@ -891,7 +902,7 @@ export class CadenzaClient { ) { const url = this.#createUrl(path, params); this.#log('Fetch', url.toString()); - const method = body ? "POST" : undefined; + const method = body ? 'POST' : undefined; const headers = new Headers(); headers.set('X-Requested-With', 'XMLHttpRequest'); if (body) {