From c3b3dc5432bc523f211abfecad151839293c26e3 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 20 Feb 2024 15:09:50 -0500 Subject: [PATCH] =?UTF-8?q?Integration=20des=20commentaires=20Fix=20pour?= =?UTF-8?q?=20charts:[]=20dans=20configuration=20par=20d=C3=A9faut=20du=20?= =?UTF-8?q?GeoChart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/utils/config/config-validation.ts | 19 ++++++------------- .../utils/config/reader/uuid-config-reader.ts | 6 +++++- .../geoview-core/src/core/utils/constant.ts | 6 ++++++ .../src/geo/layer/other/geocore.ts | 9 ++++----- .../default-config-geochart.json | 3 ++- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/packages/geoview-core/src/core/utils/config/config-validation.ts b/packages/geoview-core/src/core/utils/config/config-validation.ts index 365a0db4cdf..148bf715652 100644 --- a/packages/geoview-core/src/core/utils/config/config-validation.ts +++ b/packages/geoview-core/src/core/utils/config/config-validation.ts @@ -6,9 +6,6 @@ import { AnyValidateFunction } from 'ajv/dist/types'; import defaultsDeep from 'lodash/defaultsDeep'; -import { generateId, replaceParams, getLocalizedMessage, showError } from '../utilities'; - -import schema from '../../../../schema.json'; import { TypeBasemapId, TypeBasemapOptions, VALID_BASEMAP_ID } from '@/geo/layer/basemap/basemap-types'; import { geoviewEntryIsWMS } from '@/geo/layer/geoview-layers/raster/wms'; import { geoviewEntryIsImageStatic } from '@/geo/layer/geoview-layers/raster/image-static'; @@ -42,10 +39,13 @@ import { TypeEsriImageLayerEntryConfig, } from '@/geo/map/map-schema-types'; import { Cast, toJsonObject, TypeJsonObject, TypeMapFeaturesConfig } from '@/core/types/global-types'; - import { CONST_GEOVIEW_SCHEMA_BY_TYPE, TypeGeoviewLayerType } from '@/geo/layer/geoview-layers/abstract-geoview-layers'; import { geoviewEntryIsEsriImage } from '@/geo/layer/geoview-layers/raster/esri-image'; import { logger } from '@/core/utils/logger'; +import { CONFIG_GEOCORE_URL, CONFIG_GEOLOCATOR_URL } from '@/app'; + +import { generateId, replaceParams, getLocalizedMessage, showError } from '../utilities'; +import schema from '../../../../schema.json'; // ****************************************************************************************************************************** // ****************************************************************************************************************************** @@ -65,13 +65,6 @@ export class ConfigValidation { /** The language that will be used to display the GeoView layer. */ private _displayLanguage: TypeDisplayLanguage; - // TODO: Refactor - Environment - How to edit this configuration easily per environment? - /** The default geocore url */ - static CONFIG_GEOCORE_URL = 'https://geocore-stage.api.geo.ca'; - - /** The default geolocator url */ - static CONFIG_GEOLOCATOR_URL = 'https://geolocator.api.geo.ca?keys=geonames,nominatim,locate'; - /** default configuration if provided configuration is missing or wrong */ private _defaultMapFeaturesConfig: TypeMapFeaturesConfig = { mapId: '', @@ -99,8 +92,8 @@ export class ConfigValidation { corePackages: [], overviewMap: undefined, serviceUrls: { - geocoreUrl: ConfigValidation.CONFIG_GEOCORE_URL, - geolocator: ConfigValidation.CONFIG_GEOLOCATOR_URL, + geocoreUrl: CONFIG_GEOCORE_URL, + geolocator: CONFIG_GEOLOCATOR_URL, }, displayLanguage: 'en', triggerReadyCallback: false, diff --git a/packages/geoview-core/src/core/utils/config/reader/uuid-config-reader.ts b/packages/geoview-core/src/core/utils/config/reader/uuid-config-reader.ts index 9b462a9070f..6a7e4f51ed1 100644 --- a/packages/geoview-core/src/core/utils/config/reader/uuid-config-reader.ts +++ b/packages/geoview-core/src/core/utils/config/reader/uuid-config-reader.ts @@ -30,6 +30,8 @@ export type GeoChartGeoCoreConfig = TypeJsonObject & { }; }; // TypeJsonObject, because the definition is in the external package +// #region GeoChart Config types + // The GeoChart Json object expected by GeoView export type GeoChartConfig = TypeJsonObject & { layers: [ @@ -45,6 +47,8 @@ export type UUIDmapConfigReaderResponse = { geocharts?: GeoChartConfig[]; }; +// #endregion + /** * A class to generate GeoView layers config from a URL using a UUID. * @exports @@ -351,7 +355,7 @@ export class UUIDmapConfigReader { } /** - * Generates GeoView layers and geocharts configurations, from GeoCore API, using a list of UUIDs. + * Generates GeoView layers and package configurations (i.e. geochart), from GeoCore API, using a list of UUIDs. * @param {string} baseUrl the base url of GeoCore API * @param {string} lang the language to get the config for * @param {string[]} uuids a list of uuids to get the configurations for diff --git a/packages/geoview-core/src/core/utils/constant.ts b/packages/geoview-core/src/core/utils/constant.ts index ca5010e1a6f..25ac92e51d1 100644 --- a/packages/geoview-core/src/core/utils/constant.ts +++ b/packages/geoview-core/src/core/utils/constant.ts @@ -7,6 +7,12 @@ export const GEO_URL_TEXT = { text: 'Geo.ca', }; +/** The default geocore url */ +export const CONFIG_GEOCORE_URL = 'https://geocore-stage.api.geo.ca'; + +/** The default geolocator url */ +export const CONFIG_GEOLOCATOR_URL = 'https://geolocator.api.geo.ca?keys=geonames,nominatim,locate'; + // OpenLayer constants export const OL_ZOOM_DURATION = 500; diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index 4efdf7da3c2..78046d5483a 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -123,15 +123,14 @@ export class GeoCore { // Get the language const lang = api.maps[this.mapId].getDisplayLanguage(); - // Generate the url - // TODO: Check - Is the metadataAccessPath still used? Because it seems to be incompatible with the rest now? + // Generate the url using metadataAccessPath when specified or using the geocore url const url = geocoreLayerConfig.metadataAccessPath?.[lang] || `${mapConfig!.serviceUrls.geocoreUrl}`; - const uuids = [layerConfig.layerId]; + const uuid = layerConfig.layerId; try { // Get the GV config from UUID and await even if within loop // eslint-disable-next-line no-await-in-loop - const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, uuids); + const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, [uuid]); // Cumulate listOfLayerCreated.push(response.layers); @@ -149,7 +148,7 @@ export class GeoCore { }); } catch (error) { // Log - logger.logError(`Failed to get the GeoView layer from UUI ${uuids}`, error); + logger.logError(`Failed to get the GeoView layer from UUI ${uuid}`, error); const message = replaceParams([error as TypeJsonValue, this.mapId], getLocalizedMessage(this.mapId, 'validation.layer.loadfailed')); showError(this.mapId, message); } diff --git a/packages/geoview-geochart/default-config-geochart.json b/packages/geoview-geochart/default-config-geochart.json index 6071cd842dc..30150f9fa7d 100644 --- a/packages/geoview-geochart/default-config-geochart.json +++ b/packages/geoview-geochart/default-config-geochart.json @@ -1,3 +1,4 @@ { - "supportedLanguages": ["en", "fr"] + "supportedLanguages": ["en", "fr"], + "charts": [] } \ No newline at end of file