Skip to content

Commit

Permalink
Merge pull request #867 from gisaia/feature/newSearchContrib
Browse files Browse the repository at this point in the history
Feat: use new search contributor
  • Loading branch information
mbarbet authored Sep 3, 2024
2 parents 98e1b7c + 34c20f0 commit 3853714
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<arlas-top-menu [wuiName]="'ARLAS WUI'" [version]="version">
<div left-menu class="top-left-menu">
<img src="assets/logo-only.png" [matTooltip]="appName | translate" class="img" alt="'ARLAS-wui logo' | translate">
<arlas-search *ngIf="chipsSearchContributor" #search id="search" class="arlas-search"
[searchContributor]="chipsSearchContributor" [dialogPositionLeft]="42" [dialogPositionTop]="-2"></arlas-search>
<mat-divider *ngIf="chipsSearchContributor" vertical class="vertical-divider" id="menuDivider"></mat-divider>
<arlas-search *ngIf="searchContributors" #search id="search" class="arlas-search"
[searchContributors]="searchContributors" [dialogPositionLeft]="42" [dialogPositionTop]="-2"></arlas-search>
<mat-divider *ngIf="searchContributors" vertical class="vertical-divider" id="menuDivider"></mat-divider>
<arlas-filter class="arlas-filters-chips-top" [showZoomToData]="showZoomToData" [zoomToStrategy]="zoomToStrategy"
[collectionToDescription]="collectionToDescription" (zoomEvent)="zoomToData($event)" [availableSpace]="availableSpaceCounts" [spacing]="spacing">
</arlas-filter>
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/arlas-wui-root/arlas-wui-root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ import {
} from 'arlas-web-components';
import {
AnalyticsContributor,
ChipsSearchContributor,
ElementIdentifier,
FeatureRenderMode,
MapContributor,
ResultListContributor
ResultListContributor,
SearchContributor
} from 'arlas-web-contributors';
import { LegendData } from 'arlas-web-contributors/contributors/MapContributor';
import {
Expand Down Expand Up @@ -116,7 +116,7 @@ export class ArlasWuiRootComponent implements OnInit, AfterViewInit, OnDestroy {
public coordinatesHaveSpace = true;
public modeEnum = ModeEnum;
public mapglContributors: Array<MapContributor> = new Array();
public chipsSearchContributor: ChipsSearchContributor;
public searchContributors: SearchContributor[];
public resultlistContributors: Array<ResultListContributor> = new Array();
public analyticsContributor: AnalyticsContributor;

Expand Down Expand Up @@ -429,7 +429,7 @@ export class ArlasWuiRootComponent implements OnInit, AfterViewInit, OnDestroy {
};
}));

this.chipsSearchContributor = this.contributorService.getChipSearchContributor();
this.searchContributors = this.contributorService.getSearchContributors();
const ids = new Set(this.resultListsConfig.map(c => c.contributorId));
this.arlasStartUpService.contributorRegistry.forEach((v, k) => {
if (v instanceof ResultListContributor) {
Expand Down
31 changes: 21 additions & 10 deletions src/app/services/contributors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { Injectable } from '@angular/core';
import { ChipsSearchContributor, MapContributor } from 'arlas-web-contributors';
import { SearchContributor, MapContributor } from 'arlas-web-contributors';
import { Contributor } from 'arlas-web-core';
import {
ArlasCollaborativesearchService,
Expand All @@ -36,7 +36,7 @@ export class ContributorService {
public ID_PATH = 'arlas-wui.web.app.idFieldName';
public DEFAULT_CHART_HEIGHT = 70;
public MAPCONTRIBUTOR_ID = 'mapbox';
public CHIPSSEARCH_ID = 'chipssearch';
public SEARCH_TYPE = 'search';

public constructor(
private configService: ArlasConfigService,
Expand Down Expand Up @@ -72,15 +72,20 @@ export class ContributorService {
return mapcontributors;
}

public getChipSearchContributor(): ChipsSearchContributor {
const chipssearchContributorConfig = this.getContributorConfig(this.CHIPSSEARCH_ID);
let chipsSearchContributor: ChipsSearchContributor;
if (chipssearchContributorConfig !== undefined) {
chipsSearchContributor = this.arlasStartupService.contributorRegistry.get(this.CHIPSSEARCH_ID) as ChipsSearchContributor;
this.arlasContributors.set(this.CHIPSSEARCH_ID, chipsSearchContributor);
this.contributorsIcons.set(this.CHIPSSEARCH_ID, chipssearchContributorConfig.icon);
public getSearchContributors(): Array<SearchContributor> {
const searchContributorsConfig = this.getSearchContributorsConfigs();
const searchContributors = new Array<SearchContributor>();
if (searchContributorsConfig !== undefined) {
searchContributorsConfig
.forEach((config: { identifier: string; icon: string; }) => {
const contrib = this.arlasStartupService.contributorRegistry.get(config.identifier) as SearchContributor;

this.arlasContributors.set(config.identifier, contrib);
this.contributorsIcons.set(config.identifier, config.icon);
searchContributors.push(contrib);
});
}
return chipsSearchContributor;
return searchContributors;
}

public getArlasContributors(): Map<string, Contributor> {
Expand Down Expand Up @@ -114,4 +119,10 @@ export class ContributorService {
contrib => (contrib.type === 'map')
);
}

private getSearchContributorsConfigs() {
return this.arlasStartupService.emptyMode ? undefined : !!this.configService.getValue('arlas') ?
this.configService.getValue('arlas')['web']['contributors'].filter(
(contrib: { type: string; }) => (contrib.type === this.SEARCH_TYPE || contrib.type === 'chipssearch')) : undefined;
}
}

0 comments on commit 3853714

Please sign in to comment.