@igo2/geo 21.0.0-next.28 → 21.0.0-next.29

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.
@@ -20,7 +20,7 @@ import html2canvas from 'html2canvas';
20
20
  import jsPDF, { jsPDF as jsPDF$1 } from 'jspdf';
21
21
  import { autoTable } from 'jspdf-autotable';
22
22
  import moment from 'moment';
23
- import { Observable, of, combineLatest, BehaviorSubject, interval, tap, merge, fromEvent, firstValueFrom, Subject, forkJoin, map as map$1, catchError as catchError$1, debounceTime as debounceTime$1, switchMap, EMPTY, timer, filter as filter$1, take, from, pairwise, Subscription, lastValueFrom, throwError, first as first$1, zip } from 'rxjs';
23
+ import { Observable, of, combineLatest, BehaviorSubject, interval, tap, merge, fromEvent, firstValueFrom, Subject, forkJoin, map as map$1, catchError as catchError$1, debounceTime as debounceTime$1, switchMap, EMPTY, timer, filter as filter$1, take, from, Subscription, pairwise, lastValueFrom, throwError, first as first$1, zip } from 'rxjs';
24
24
  import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
25
25
  import { fetchImageFromDepotUrl, ImageErrorDirective, SecureImagePipe } from '@igo2/common/image';
26
26
  import { saveAs } from 'file-saver';
@@ -11979,6 +11979,9 @@ function olLayerFeatureIsQueryable(olLayer) {
11979
11979
  : layerIsQueryable(layer) && layerFeatureIsQueryable(layer);
11980
11980
  }
11981
11981
 
11982
+ function isWmsDataSourceOptions(sourceOptions) {
11983
+ return sourceOptions.type === 'wms';
11984
+ }
11982
11985
  class LayerLegendComponent {
11983
11986
  capabilitiesService = inject(CapabilitiesService);
11984
11987
  languageService = inject(LanguageService);
@@ -11998,12 +12001,10 @@ class LayerLegendComponent {
11998
12001
  /**
11999
12002
  * The available styles
12000
12003
  */
12001
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12002
12004
  styles;
12003
12005
  /**
12004
12006
  * The style used to make the legend
12005
12007
  */
12006
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12007
12008
  currentStyle;
12008
12009
  /**
12009
12010
  * The extent used to make the legend
@@ -12029,11 +12030,12 @@ class LayerLegendComponent {
12029
12030
  let lastlLegend = this.layer().legend;
12030
12031
  this.styles = this.listStyles();
12031
12032
  const sourceOptions = this.layer().options.source?.options;
12032
- if (sourceOptions && sourceOptions.params && sourceOptions.params.STYLES) {
12033
+ const wmsSourceOptions = sourceOptions && isWmsDataSourceOptions(sourceOptions)
12034
+ ? sourceOptions
12035
+ : undefined;
12036
+ if (wmsSourceOptions?.params.STYLES) {
12033
12037
  // if a styles is provided into the layers wms params
12034
- this.currentStyle = this.styles.find(
12035
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12036
- (style) => style.name === sourceOptions.params.STYLES)?.name;
12038
+ this.currentStyle = this.styles?.find((style) => style.name === wmsSourceOptions.params.STYLES)?.name;
12037
12039
  }
12038
12040
  else if (!lastlLegend) {
12039
12041
  // if no legend is manually provided
@@ -12058,7 +12060,7 @@ class LayerLegendComponent {
12058
12060
  lastlLegend = layer.dataSource.getLegend(this.currentStyle, this.view);
12059
12061
  }
12060
12062
  if (this.updateLegendOnResolutionChange() ||
12061
- sourceOptions.contentDependentLegend) {
12063
+ wmsSourceOptions?.contentDependentLegend) {
12062
12064
  const state$ = layer.map.viewController.state$;
12063
12065
  this.state$$ = state$.subscribe(() => this.onViewControllerStateChange());
12064
12066
  }
@@ -12141,18 +12143,23 @@ class LayerLegendComponent {
12141
12143
  }
12142
12144
  return outLegends;
12143
12145
  }
12144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12145
12146
  computeItemTitle(layerLegend) {
12146
- const layerOptions = this.layer().dataSource.options;
12147
- if (layerOptions.type !== 'wms') {
12148
- return of(layerLegend.title);
12147
+ const layerLegendTitle = layerLegend.title ?? '';
12148
+ const sourceOptions = this.layer().dataSource.options;
12149
+ if (!isWmsDataSourceOptions(sourceOptions)) {
12150
+ return of(layerLegendTitle);
12149
12151
  }
12150
- const layers = layerOptions.params.LAYERS.split(',');
12151
- const localLayerOptions = JSON.parse(JSON.stringify(layerOptions)); // to avoid to alter the original options.
12152
- localLayerOptions.params.LAYERS = layers.find(
12153
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12154
- (layer) => layer === layerLegend.title);
12155
- return this.capabilitiesService.getWMSOptions(localLayerOptions).pipe(map((wmsDataSourceOptions) => {
12152
+ const layers = sourceOptions.params.LAYERS.split(',');
12153
+ const layersName = layers.find((layer) => layer === layerLegendTitle) ?? layerLegendTitle;
12154
+ return this.capabilitiesService
12155
+ .getWMSOptions({
12156
+ ...sourceOptions,
12157
+ params: {
12158
+ ...sourceOptions.params,
12159
+ LAYERS: layersName
12160
+ }
12161
+ })
12162
+ .pipe(map((wmsDataSourceOptions) => {
12156
12163
  return wmsDataSourceOptions._layerOptionsFromSource.title;
12157
12164
  }));
12158
12165
  }
@@ -21206,8 +21213,6 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21206
21213
  * Subscription to the store's OL source changes
21207
21214
  */
21208
21215
  stores$$ = new Map();
21209
- resolution$$ = [];
21210
- empty$$;
21211
21216
  constructor(options) {
21212
21217
  super(options);
21213
21218
  this.options = options;
@@ -21222,7 +21227,6 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21222
21227
  if (this.active === true) {
21223
21228
  this.watchStore(featureStore);
21224
21229
  }
21225
- this.empty$$ = featureStore.empty$.subscribe(() => this.updateEntitiesInResolution(featureStore, featureStore.layer.map.viewController.getResolution()));
21226
21230
  }
21227
21231
  /**
21228
21232
  * Unbind this strategy from a store and stop watching for Ol source changes
@@ -21230,10 +21234,7 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21230
21234
  */
21231
21235
  unbindStore(store) {
21232
21236
  super.unbindStore(store);
21233
- const featureStore = store;
21234
- if (this.active === true) {
21235
- this.unwatchStore(featureStore);
21236
- }
21237
+ this.unwatchStore(store);
21237
21238
  }
21238
21239
  /**
21239
21240
  * Start watching all stores already bound to that strategy at once.
@@ -21257,12 +21258,15 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21257
21258
  if (this.stores$$.has(store)) {
21258
21259
  return;
21259
21260
  }
21260
- this.updateEntitiesInResolution(store, store.layer.map.viewController.getResolution());
21261
- this.resolution$$.push(store.layer
21262
- .map.viewController.resolution$.pipe(debounceTime$1(250))
21261
+ this.updateEntitiesInResolution(store, store.map.viewController.getResolution());
21262
+ const subscription = new Subscription();
21263
+ subscription.add(store.map.viewController.resolution$
21264
+ .pipe(debounceTime$1(250))
21263
21265
  .subscribe((res) => {
21264
21266
  this.updateEntitiesInResolution(store, res);
21265
21267
  }));
21268
+ subscription.add(store.empty$.subscribe(() => this.updateEntitiesInResolution(store, store.map.viewController.getResolution())));
21269
+ this.stores$$.set(store, subscription);
21266
21270
  }
21267
21271
  updateEntitiesInResolution(store, mapResolution) {
21268
21272
  if ((mapResolution ?? 0) > store.layer.minResolution &&
@@ -21278,8 +21282,9 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21278
21282
  * @param store Feature store
21279
21283
  */
21280
21284
  unwatchStore(store) {
21281
- const key = this.stores$$.get(store);
21282
- if (key !== undefined) {
21285
+ const subscription = this.stores$$.get(store);
21286
+ if (subscription !== undefined) {
21287
+ subscription.unsubscribe();
21283
21288
  this.stores$$.delete(store);
21284
21289
  }
21285
21290
  }
@@ -21287,11 +21292,7 @@ class FeatureStoreInMapResolutionStrategy extends EntityStoreStrategy {
21287
21292
  * Stop watching for OL source changes in all stores.
21288
21293
  */
21289
21294
  unwatchAll() {
21290
- this.stores$$.clear();
21291
- this.resolution$$.map((state) => state.unsubscribe());
21292
- if (this.empty$$) {
21293
- this.empty$$.unsubscribe();
21294
- }
21295
+ Array.from(this.stores$$.keys()).forEach((store) => this.unwatchStore(store));
21295
21296
  }
21296
21297
  }
21297
21298
 
@@ -35924,7 +35925,6 @@ class EditionWorkspace extends Workspace {
35924
35925
  enabled: false
35925
35926
  }
35926
35927
  });
35927
- this.map.layerController.remove(this.olDrawingLayer);
35928
35928
  }
35929
35929
  getDeleteUrl(feature) {
35930
35930
  let url;
@@ -36367,8 +36367,7 @@ class EditionWorkspaceService {
36367
36367
  layer.options.linkedLayers.links = clonedLinks;
36368
36368
  layer.createLink();
36369
36369
  let wks;
36370
- this.layerService
36371
- .createAsyncLayer({
36370
+ const options = {
36372
36371
  title: layer.title,
36373
36372
  parentId: layer.options.parentId,
36374
36373
  visible: layer.visible,
@@ -36410,22 +36409,22 @@ class EditionWorkspaceService {
36410
36409
  sourceFields: dataSource.options.sourceFields || undefined,
36411
36410
  edition: dataSource.options.edition
36412
36411
  }
36413
- })
36414
- .subscribe((layer) => {
36415
- const workspaceLayer = layer;
36416
- if (!workspaceLayer)
36412
+ };
36413
+ this.layerService.createAsyncLayer(options).subscribe((createdLayer) => {
36414
+ if (!createdLayer)
36417
36415
  return;
36416
+ const workspaceLayer = createdLayer;
36418
36417
  map.layerController.add(workspaceLayer);
36419
- layer.ol.setProperties({
36418
+ workspaceLayer.ol.setProperties({
36420
36419
  linkedLayers: {
36421
- linkId: layer.options.linkedLayers.linkId,
36420
+ linkId: workspaceLayer.options.linkedLayers.linkId,
36422
36421
  links: clonedLinks
36423
36422
  }
36424
36423
  }, false);
36425
36424
  workspaceLayer.dataSource.ol.refresh();
36426
36425
  wks = new EditionWorkspace(this.configService, this.adding$, this.layerService, {
36427
36426
  id: layer.id,
36428
- title: layer.title,
36427
+ title: workspaceLayer.title,
36429
36428
  layer: workspaceLayer,
36430
36429
  map,
36431
36430
  entityStore: this.createFeatureStore(workspaceLayer, map),
@@ -36436,9 +36435,7 @@ class EditionWorkspaceService {
36436
36435
  });
36437
36436
  this.createTableTemplate(wks, workspaceLayer);
36438
36437
  workspaceLayer.options.workspace.workspaceId = workspaceLayer.id;
36439
- layer.options.workspace = Object.assign({}, layer.options.workspace, {
36440
- wksConfig
36441
- });
36438
+ workspaceLayer.options.workspace = Object.assign({}, workspaceLayer.options.workspace, { wksConfig });
36442
36439
  delete dataSource.options.download;
36443
36440
  });
36444
36441
  return wks;
@@ -36765,47 +36762,49 @@ class EditionWorkspaceService {
36765
36762
  // WORKAROUND to handle PostgrestApi specificity
36766
36763
  const properties = this.parseFeature(feature, workspace.meta.tableTemplate.columns);
36767
36764
  this.loading = true;
36768
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36769
- const baseRequest = this.http[protocole];
36770
- baseRequest(`${url}`, properties, {
36765
+ this.http
36766
+ .request(protocole, `${url}`, {
36767
+ body: properties,
36771
36768
  headers: headers
36772
- }).subscribe(() => {
36773
- this.loading = false;
36774
- this.cancelEdit(feature, workspace, true);
36775
- this.messageService.success('igo.geo.workspace.modifySuccess');
36776
- this.refreshMap(workspace.layer, workspace.layer.map);
36777
- const relationLayers = [];
36778
- workspace.layer.options.sourceOptions.relations?.forEach((relation) => {
36779
- workspace.map.layerController.all.forEach((layer) => {
36780
- if (isLayerItem(layer) && layer.title === relation.title) {
36781
- relationLayers.push(layer);
36782
- layer.dataSource.ol.refresh();
36783
- }
36769
+ })
36770
+ .subscribe({
36771
+ next: () => {
36772
+ this.loading = false;
36773
+ this.cancelEdit(feature, workspace, true);
36774
+ this.messageService.success('igo.geo.workspace.modifySuccess');
36775
+ this.refreshMap(workspace.layer, workspace.layer.map);
36776
+ const relationLayers = [];
36777
+ workspace.layer.options.sourceOptions.relations?.forEach((relation) => {
36778
+ workspace.map.layerController.all.forEach((layer) => {
36779
+ if (isLayerItem(layer) && layer.title === relation.title) {
36780
+ relationLayers.push(layer);
36781
+ layer.dataSource.ol.refresh();
36782
+ }
36783
+ });
36784
36784
  });
36785
- });
36786
- this.relationLayers$.next(relationLayers);
36787
- },
36788
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36789
- (error) => {
36790
- this.loading = false;
36791
- error.error.caught = true;
36792
- const messages = dataSourceOptions.edition.messages;
36793
- if (messages) {
36794
- let text;
36795
- messages.forEach((message) => {
36796
- const key = Object.keys(message)[0];
36797
- if (error.error.message.includes(key)) {
36798
- text = message[key];
36799
- this.messageService.error(text);
36785
+ this.relationLayers$.next(relationLayers);
36786
+ },
36787
+ error: (error) => {
36788
+ this.loading = false;
36789
+ error.error.caught = true;
36790
+ const messages = dataSourceOptions.edition.messages;
36791
+ if (messages) {
36792
+ let text;
36793
+ messages.forEach((message) => {
36794
+ const key = Object.keys(message)[0];
36795
+ if (error.error.message.includes(key)) {
36796
+ text = message[key];
36797
+ this.messageService.error(text);
36798
+ }
36799
+ });
36800
+ if (!text) {
36801
+ this.messageService.error('igo.geo.workspace.addError');
36800
36802
  }
36801
- });
36802
- if (!text) {
36803
+ }
36804
+ else {
36803
36805
  this.messageService.error('igo.geo.workspace.addError');
36804
36806
  }
36805
36807
  }
36806
- else {
36807
- this.messageService.error('igo.geo.workspace.addError');
36808
- }
36809
36808
  });
36810
36809
  }
36811
36810
  cleanFeatureProperties(feature, dataSourceOptions) {