Skip to content

Commit

Permalink
feat: integrate devs of wui 26.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia authored and QuCMGisaia committed Dec 19, 2024
1 parent f861bae commit 7e543aa
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 43 deletions.
22 changes: 17 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## [v26.1.0](https://github.com/gisaia/ARLAS-WUI/tree/v26.1.0) (2024-12-02)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v26.1.0-rc.3...v26.1.0)

## [v26.1.0-rc.3](https://github.com/gisaia/ARLAS-WUI/tree/v26.1.0-rc.3) (2024-11-27)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v26.1.0-rc.2...v26.1.0-rc.3)

## [v26.1.0-rc.2](https://github.com/gisaia/ARLAS-WUI/tree/v26.1.0-rc.2) (2024-11-26)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v26.1.0-rc.1...v26.1.0-rc.2)

## [v26.1.0-rc.1](https://github.com/gisaia/ARLAS-WUI/tree/v26.1.0-rc.1) (2024-11-26)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v26.0.8...v26.1.0-rc.1)
Expand Down Expand Up @@ -949,19 +961,19 @@

## [v15.0.0](https://github.com/gisaia/ARLAS-WUI/tree/v15.0.0) (2021-02-18)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v15.0.0-beta.1...v15.0.0)
[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v15.0.0-beta.0...v15.0.0)

**Fixed bugs:**

- Wrong css applied in details section in resultlist [\#268](https://github.com/gisaia/ARLAS-wui/issues/268)

## [v15.0.0-beta.1](https://github.com/gisaia/ARLAS-WUI/tree/v15.0.0-beta.1) (2021-02-04)
## [v15.0.0-beta.0](https://github.com/gisaia/ARLAS-WUI/tree/v15.0.0-beta.0) (2021-02-04)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v15.0.0-beta.0...v15.0.0-beta.1)
[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v15.0.0-beta.1...v15.0.0-beta.0)

## [v15.0.0-beta.0](https://github.com/gisaia/ARLAS-WUI/tree/v15.0.0-beta.0) (2021-02-04)
## [v15.0.0-beta.1](https://github.com/gisaia/ARLAS-WUI/tree/v15.0.0-beta.1) (2021-02-04)

[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v14.3.1...v15.0.0-beta.0)
[Full Changelog](https://github.com/gisaia/ARLAS-WUI/compare/v14.3.1...v15.0.0-beta.1)

## [v14.3.1](https://github.com/gisaia/ARLAS-WUI/tree/v14.3.1) (2021-02-03)

Expand Down
1 change: 1 addition & 0 deletions src/app/components/arlas-list/arlas-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
(geoSortEvent)="geoSort(list, $event)"
(geoAutoSortEvent)="geoAutoSort(list, $event)"
(consultedItemEvent)="consultItem(list, $event)"
(selectedItemsEvent)="selectItems(list, $event)"
(actionOnItemEvent)="applyActionOnItem(list, $event)"
(globalActionEvent)="applyGlobalAction(list, $event)"
(changeResultMode)="changeListResultMode($event, list.identifier)"
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/arlas-map/arlas-map.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
[margePanForLoad]="mapComponentConfig?.margePanForLoad"
[margePanForTest]="mapComponentConfig?.margePanForTest" [initCenter]="mapComponentConfig?.initCenter"
[drawData]="geojsondraw"
[transformRequest]="transformMapRequest"
[initZoom]="mapComponentConfig?.initZoom" [minZoom]="mapComponentConfig?.minZoom"
[maxZoom]="mapComponentConfig?.maxZoom" [displayScale]="mapComponentConfig?.displayScale"
[displayCurrentCoordinates]="mapComponentConfig?.displayCurrentCoordinates"
[maxWidthScale]="mapComponentConfig?.maxWidthScale" [unitScale]="mapComponentConfig?.unitScale"
[idFeatureField]="mapComponentConfig?.idFieldName" [mapLayers]="mapComponentConfig?.mapLayers"
[mapSources]="mapComponentConfig?.mapSources"
[featureToHightLight]="mapService.featureToHightLight" [featuresToSelect]="featuresToSelect"
[featureToHightLight]="mapService.featureToHightLight" [featuresToSelect]="mapService.featuresToSelect"
[boundsToFit]="visualizeService.fitbounds" [drawPolygonVerticesLimit]="nbVerticesLimit"
[drawButtonEnabled]="false" [mapAttributionPosition]="mapAttributionPosition"
(onAoiChanged)="onChangeAoi($event)"
Expand Down
85 changes: 78 additions & 7 deletions src/app/components/arlas-map/arlas-map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import {
import { ElementIdentifier, MapContributor } from 'arlas-web-contributors';
import { LegendData } from 'arlas-web-contributors/contributors/MapContributor';
import {
ArlasCollaborativesearchService, ArlasCollectionService, ArlasConfigService, ArlasMapService,
ArlasMapSettings, ArlasSettingsService, ArlasStartupService, getParamValue
ArlasCollaborativesearchService, ArlasCollectionService, ArlasConfigService, ArlasIamService, ArlasMapService,
ArlasMapSettings, ArlasSettingsService, ArlasStartupService, AuthentificationService, getParamValue
} from 'arlas-wui-toolkit';
import * as mapboxgl from 'mapbox-gl';
import { BehaviorSubject, debounceTime, fromEvent, merge, mergeMap, Observable, of, Subject, takeUntil } from 'rxjs';
Expand All @@ -61,9 +61,6 @@ export class ArlasMapComponent implements OnInit {
public mapAttributionPosition: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' = 'top-right';
public mapLoaded = false;

/** Map interactions */
public featuresToSelect: Array<ElementIdentifier> = [];

/** Map move */
public fitbounds: Array<Array<number>> = [];
public recalculateExtent = true;
Expand All @@ -85,6 +82,9 @@ export class ArlasMapComponent implements OnInit {
public mapRedrawSources;
public mapLegendUpdater = new Subject<Map<string, Map<string, LegendData>>>();
public mapVisibilityUpdater;

/** Map Url enricher */
public transformMapRequest;
/** Visibility status of layers on the map */
public layersVisibilityStatus: Map<string, boolean> = new Map();

Expand Down Expand Up @@ -131,7 +131,9 @@ export class ArlasMapComponent implements OnInit {
private snackbar: MatSnackBar,
private iconRegistry: MatIconRegistry,
private domSanitizer: DomSanitizer,
private collectionService: ArlasCollectionService
private collectionService: ArlasCollectionService,
private authentService: AuthentificationService,
private arlasIamService: ArlasIamService
) {
if (this.arlasStartupService.shouldRunApp && !this.arlasStartupService.emptyMode) {
/** resize the map */
Expand Down Expand Up @@ -222,6 +224,9 @@ export class ArlasMapComponent implements OnInit {
// eslint-disable-next-line max-len
this.iconRegistry.addSvgIconLiteral('import_polygon', this.domSanitizer.bypassSecurityTrustHtml('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24pt" height="24pt" viewBox="0 0 24 24" version="1.1"><g id="surface1"><path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 9 16 L 15 16 L 15 10 L 19 10 L 12 3 L 5 10 L 9 10 Z M 5 18 L 19 18 L 19 20 L 5 20 Z M 5 18 "/></g></svg>'));
}

this.updateMapTransformRequest();

}

public ngAfterViewInit() {
Expand All @@ -243,13 +248,79 @@ export class ArlasMapComponent implements OnInit {
}
}

/** Updates the map url headers at each refresh.*/
public updateMapTransformRequest() {
const authentMode = !!this.settingsService.getAuthentSettings() ? this.settingsService.getAuthentSettings().auth_mode : undefined;
const isAuthentActivated = !!this.settingsService.getAuthentSettings() && !!this.settingsService.getAuthentSettings().use_authent;
if (isAuthentActivated) {
if (authentMode === 'iam') {
this.arlasIamService.tokenRefreshed$.pipe(takeUntil(this._onDestroy$)).subscribe({
next: (loginData) => {
if (!!loginData) {
const org = this.arlasIamService.getOrganisation();
const iamHeader = {
Authorization: 'Bearer ' + loginData.access_token,
};
// Set the org filter only if the organisation is defined
if (!!org) {
iamHeader['arlas-org-filter'] = org;
}
this.setMapTransformRequest(iamHeader);
} else {
this.setMapTransformRequest();
}
}
});
} else {
this.authentService.canActivateProtectedRoutes.pipe(takeUntil(this._onDestroy$)).subscribe(isConnected => {
if (isConnected) {
const headers = {
Authorization: 'Bearer ' + this.authentService.accessToken
};
this.setMapTransformRequest(headers);
} else {
this.setMapTransformRequest();
}
});
}
} else {
this.setMapTransformRequest();
}
}

/** Enriches map url by an ARLAS header only if the map url is provided by ARLAS. */
public setMapTransformRequest(headers?: any) {
this.transformMapRequest = (url, resourceType) => {
/** Wrapping with a try block because the URL() mdn docs says : 'Throws if the passed arguments don't define a valid URL.' */
try {
const mapServiceUrl = new URL(url);
const appUrl = new URL(window.location.href);
const mapServiceOrigin = mapServiceUrl.origin;
const appOrigin = appUrl.origin;
/** We enrich map url by an ARLAS header only if the map url is provided by ARLAS. */
if (appOrigin === mapServiceOrigin && !!headers) {
return ({
url,
headers,
});
} else {
return ({ url });
}
} catch {
return ({ url });
}
};
}


/**
* Wait until the map component is loaded before fetching the data
* @param isLoaded Whether the map has loaded
*/
public onMapLoaded(isLoaded: boolean): void {
if (isLoaded && !this.arlasStartupService.emptyMode) {
this.mapLoaded = true;

this.mapService.setMapComponent(this.mapglComponent);
this.toolkitMapService.setMap(this.mapglComponent.map);
this.visualizeService.setMap(this.mapglComponent.map);
Expand Down Expand Up @@ -277,7 +348,7 @@ export class ArlasMapComponent implements OnInit {
});

if (!!this.resultlistService.previewListContrib && this.resultlistService.previewListContrib.data.length > 0 &&
this.mapComponentConfig.mapLayers.events.onHover.filter(l => this.mapglComponent.map.getLayer(l)).length > 0) {
this.mapComponentConfig.mapLayers.events.onHover.filter(l => this.mapglComponent.map.getLayer(l)).length > 0) {
this.resultlistService.updateVisibleItems();
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/app/services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class MapService {
private mapComponentConfig: any;
public mapContributors: Array<MapContributor> = new Array();
public centerLatLng: { lat: number; lng: number; } = { lat: 0, lng: 0 };

public featureToHightLight: FeatureHover;
public featuresToSelect: Array<ElementIdentifier> = [];

public coordinatesHaveSpace: boolean;

public constructor() { }
Expand All @@ -46,7 +49,7 @@ export class MapService {
public selectFeatures(idPath: string, ids: string[] | number[], mapContributor: MapContributor) {
if (!!this.mapComponent && !!mapContributor) {
if (ids.length > 0) {
const featuresToSelect = ids.map(id => {
this.featuresToSelect = ids.map(id => {
let idFieldName = idPath;
if (mapContributor.isFlat) {
idFieldName = idFieldName.replace(/\./g, '_');
Expand All @@ -56,7 +59,7 @@ export class MapService {
idValue: id
};
});
this.mapComponent.selectFeaturesByCollection(featuresToSelect, mapContributor.collection);
this.mapComponent.selectFeaturesByCollection(this.featuresToSelect, mapContributor.collection);
} else {
this.mapComponent.selectFeaturesByCollection([], mapContributor.collection);
}
Expand Down
Loading

0 comments on commit 7e543aa

Please sign in to comment.