From a17054c34f9044e49e5a396a444a150483aac3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-=C3=89ric?= Date: Mon, 24 Apr 2017 13:57:32 -0400 Subject: [PATCH] feat(context): context service (#20) * feat(context): context service --- proxy.conf.json | 2 +- src/assets/locale/en.json | 5 +- src/assets/locale/fr.json | 5 +- src/demo-app/app/app.component.html | 4 +- src/demo-app/app/app.component.ts | 121 ++++++++++-------- src/lib/context/index.ts | 1 + src/lib/context/module.ts | 35 +++++ src/lib/context/shared/context.interface.ts | 23 ++++ .../context/shared/context.service.spec.ts | 26 ++++ src/lib/context/shared/context.service.ts | 36 ++++++ src/lib/context/shared/index.ts | 4 + .../shared/layer-context.directive.spec.ts | 25 ++++ .../context/shared/layer-context.directive.ts | 50 ++++++++ .../shared/map-context.directive.spec.ts | 23 ++++ .../context/shared/map-context.directive.ts | 44 +++++++ .../shared/tool-context.directive.spec.ts | 25 ++++ .../context/shared/tool-context.directive.ts | 53 ++++++++ .../feature-list/feature-list.component.ts | 7 + src/lib/feature/module.ts | 4 +- .../time-filter-list.component.ts | 7 + src/lib/index.ts | 1 + .../layer/layer-list/layer-list.component.ts | 7 + src/lib/layer/module.ts | 2 - .../map/map-browser/map-browser.component.ts | 1 - src/lib/module.ts | 3 + src/lib/overlay/module.ts | 4 +- src/lib/query/module.ts | 4 +- src/lib/query/query/query.directive.ts | 4 +- src/lib/search/module.ts | 5 +- .../search-bar/search-bar.component.styl | 1 + src/lib/shared/module.ts | 3 + 31 files changed, 461 insertions(+), 74 deletions(-) create mode 100644 src/lib/context/index.ts create mode 100644 src/lib/context/module.ts create mode 100644 src/lib/context/shared/context.interface.ts create mode 100644 src/lib/context/shared/context.service.spec.ts create mode 100644 src/lib/context/shared/context.service.ts create mode 100644 src/lib/context/shared/index.ts create mode 100644 src/lib/context/shared/layer-context.directive.spec.ts create mode 100644 src/lib/context/shared/layer-context.directive.ts create mode 100644 src/lib/context/shared/map-context.directive.spec.ts create mode 100644 src/lib/context/shared/map-context.directive.ts create mode 100644 src/lib/context/shared/tool-context.directive.spec.ts create mode 100644 src/lib/context/shared/tool-context.directive.ts diff --git a/proxy.conf.json b/proxy.conf.json index 9e26dfeeb6..0967ef424b 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/src/assets/locale/en.json b/src/assets/locale/en.json index 47216af263..0349a64428 100644 --- a/src/assets/locale/en.json +++ b/src/assets/locale/en.json @@ -3,11 +3,14 @@ "endDate": "End Date", "hideLayer": "Hide Layer", "lowerLayer": "Bring layer backward", + "map": "Map", "noLegendText": "No legend available for this layer", "opacity": "Opacity", "raiseLayer": "Bring layer forward", "removeLayer": "Remove this layer from the map", + "searchResults": "Search Results", "showLayer": "Show Layer", - "startDate": "Start Date" + "startDate": "Start Date", + "timeAnalysis": "Time Analysis" } } \ No newline at end of file diff --git a/src/assets/locale/fr.json b/src/assets/locale/fr.json index d166371da6..72e67f6af6 100644 --- a/src/assets/locale/fr.json +++ b/src/assets/locale/fr.json @@ -3,11 +3,14 @@ "endDate": "Date de fin", "hideLayer": "Masquer la couche", "lowerLayer": "Descendre la couche", + "map": "Carte", "noLegendText": "Aucune légende disponible pour cette couche", "opacity": "Opacité", "raiseLayer": "Monter la couche", "removeLayer": "Retirer la couche de la carte", + "searchResults": "Résultats de recherche", "showLayer": "Afficher la couche", - "startDate": "Date de début" + "startDate": "Date de début", + "timeAnalysis": "Analyse Temporelle" } } \ No newline at end of file diff --git a/src/demo-app/app/app.component.html b/src/demo-app/app/app.component.html index 7eb60d8d25..1a260651de 100644 --- a/src/demo-app/app/app.component.html +++ b/src/demo-app/app/app.component.html @@ -36,6 +36,8 @@ @@ -64,7 +66,7 @@ toolbar.component (undefined); public map = new IgoMap(); - public mapView = { - projection: 'EPSG:3857', - center: [-72, 52], - zoom: 6 - }; - public tools = [ - {name: 'tool1', title: 'Tool 1', icon: 'map', tooltip: 'tooltip1'}, - {name: 'tool2', title: 'Tool 2', icon: 'bookmark', tooltip: 'tooltip2'} - ]; - - constructor(public featureService: FeatureService, - public layerService: LayerService, + constructor(public contextService: ContextService, + public featureService: FeatureService, public overlayService: OverlayService, public language: LanguageService) {} ngOnInit() { - this.map.removeLayers(); - - this.layerService.createAsyncLayer({ - type: 'osm', - title: 'OSM' - }).subscribe(layer => this.map.addLayer(layer)); + const projection = 'EPSG:3857'; - this.layerService.createAsyncLayer({ - title: 'MSP DESSERTE MUN 911', - type: 'wms', - source: { - url: '/cgi-wms/igo_gouvouvert.fcgi', - params: { - layers: 'MSP_DESSERTE_MUN_911', - version: '1.3.0' - }, - projection: 'EPSG:3857' + this.contextService.setContext({ + uri: 'qc911', + title: 'Qc-911', + map: { + view: { + projection: projection, + center: [-72, 52], + zoom: 6 + } }, - queryFormat: QueryFormat.GML2, - queryTitle: 'Municipalite' - } as WMSLayerOptions).subscribe(layer => this.map.addLayer(layer)); - - this.layerService.createAsyncLayer({ - title: 'Embâcle', - type: 'wms', - source: { - url: 'http://geoegl.msp.gouv.qc.ca/cgi-wms/igo_gouvouvert.fcgi', - params: { - layers: 'vg_observation_v_inondation_embacle_wmst', - version: '1.3.0' + layers: [ + { + type: 'osm', + title: 'OSM' }, - projection: 'EPSG:3857' - }, - queryFormat: QueryFormat.GML2, - queryTitle: 'Municipalite', - timeFilter: { - min: '2017-01-01', - max: '2018-01-01', - type: 'date', - range: true - } - } as WMSLayerOptions).subscribe(layer => this.map.addLayer(layer)); + { + title: 'MSP DESSERTE MUN 911', + type: 'wms', + source: { + url: '/cgi-wms/igo_gouvouvert.fcgi', + params: { + layers: 'MSP_DESSERTE_MUN_911', + version: '1.3.0' + }, + projection: projection + }, + queryFormat: QueryFormat.GML2, + queryTitle: 'Municipalite' + } as WMSLayerOptions, + { + title: 'Embâcle', + type: 'wms', + source: { + url: 'http://geoegl.msp.gouv.qc.ca/cgi-wms/igo_gouvouvert.fcgi', + params: { + layers: 'vg_observation_v_inondation_embacle_wmst', + version: '1.3.0' + }, + projection: projection + }, + timeFilter: { + min: '2017-01-01', + max: '2018-01-01', + type: 'date', + range: true + } + } as WMSLayerOptions + ], + toolbar: [ + 'featureList', + 'layerList', + 'timeFilter' + ], + tools: [ + { + name: 'featureList' + }, + { + name: 'layerList' + }, + { + name: 'timeFilter' + } + ] + }); } handleSearch(term: string) { diff --git a/src/lib/context/index.ts b/src/lib/context/index.ts new file mode 100644 index 0000000000..20a96c9a59 --- /dev/null +++ b/src/lib/context/index.ts @@ -0,0 +1 @@ +export * from './module'; diff --git a/src/lib/context/module.ts b/src/lib/context/module.ts new file mode 100644 index 0000000000..0d9031ce42 --- /dev/null +++ b/src/lib/context/module.ts @@ -0,0 +1,35 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; + +import { IgoSharedModule } from '../shared'; + +import { ContextService, MapContextDirective, + LayerContextDirective, ToolContextDirective } from './shared'; + + +@NgModule({ + imports: [ + IgoSharedModule + ], + exports: [ + MapContextDirective, + LayerContextDirective, + ToolContextDirective + ], + declarations: [ + MapContextDirective, + LayerContextDirective, + ToolContextDirective + ] +}) +export class IgoContextModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: IgoContextModule, + providers: [ + ContextService + ] + }; + } +} + +export * from './shared'; diff --git a/src/lib/context/shared/context.interface.ts b/src/lib/context/shared/context.interface.ts new file mode 100644 index 0000000000..d177961a1e --- /dev/null +++ b/src/lib/context/shared/context.interface.ts @@ -0,0 +1,23 @@ +import { MapViewOptions } from '../../map'; +import { LayerOptions } from '../../layer'; +import { Tool } from '../../tool/shared/tool.interface'; + + +export interface Context { + title: string; + uri: string; + scope?: 'public' | 'protected' | 'private'; + description?: string; + icon?: string; +} + +export interface DetailedContext extends Context { + map?: MapContext; + layers?: LayerOptions[]; + tools?: Tool[]; + toolbar?: string[]; +} + +export interface MapContext { + view: MapViewOptions; +} diff --git a/src/lib/context/shared/context.service.spec.ts b/src/lib/context/shared/context.service.spec.ts new file mode 100644 index 0000000000..57dcc428d1 --- /dev/null +++ b/src/lib/context/shared/context.service.spec.ts @@ -0,0 +1,26 @@ +import { TestBed, inject } from '@angular/core/testing'; +import { HttpModule } from '@angular/http'; + +import { RequestService, MessageService } from '../../core'; + +import { ContextService } from './context.service'; + + +describe('ContextService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ + HttpModule + ], + providers: [ + ContextService, + MessageService, + RequestService + ] + }); + }); + + it('should ...', inject([ContextService], (service: ContextService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/src/lib/context/shared/context.service.ts b/src/lib/context/shared/context.service.ts new file mode 100644 index 0000000000..89934f7add --- /dev/null +++ b/src/lib/context/shared/context.service.ts @@ -0,0 +1,36 @@ +import { Injectable } from '@angular/core'; +import { Http } from '@angular/http'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +// import { Observable } from 'rxjs/Observable'; + +import { RequestService } from '../../core'; + +import { DetailedContext } from './context.interface'; + + +@Injectable() +export class ContextService { + + public context$ = new BehaviorSubject(undefined); + + constructor(private http: Http, + private requestService: RequestService) { } + + // getContexts(): Observable { + // return this.requestService.register( + // this.http.get(`contexts/_contexts.json`) + // ).map(res => res.json()); + // } + + loadContext(url: string) { + this.requestService.register( + this.http.get(url), 'Context') + .map(res => res.json()) + .subscribe(context => this.setContext(context)); + } + + setContext(context: DetailedContext) { + this.context$.next(context); + } + +} diff --git a/src/lib/context/shared/index.ts b/src/lib/context/shared/index.ts new file mode 100644 index 0000000000..58b3411c5b --- /dev/null +++ b/src/lib/context/shared/index.ts @@ -0,0 +1,4 @@ +export * from './context.service'; +export * from './layer-context.directive'; +export * from './map-context.directive'; +export * from './tool-context.directive'; diff --git a/src/lib/context/shared/layer-context.directive.spec.ts b/src/lib/context/shared/layer-context.directive.spec.ts new file mode 100644 index 0000000000..dbfe1f4ca3 --- /dev/null +++ b/src/lib/context/shared/layer-context.directive.spec.ts @@ -0,0 +1,25 @@ +import { TestBed } from '@angular/core/testing'; + +// import { LayerService } from '../../layer'; +// import { RequestService } from '../../core'; + +// import { ContextService } from './context.service'; +// import { LayerContextDirective } from './layer-context.directive'; + + +describe('LayerContextDirective', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [], + providers: [ + // RequestService, + // ContextService, + // LayerService + ] + }); + }); + + it('should create an instance', () => { + expect(true).toBeTruthy(); + }); +}); diff --git a/src/lib/context/shared/layer-context.directive.ts b/src/lib/context/shared/layer-context.directive.ts new file mode 100644 index 0000000000..fd47bd9ad6 --- /dev/null +++ b/src/lib/context/shared/layer-context.directive.ts @@ -0,0 +1,50 @@ +import { Directive, Self, OnInit, OnDestroy, } from '@angular/core'; +import { Subscription } from 'rxjs/Subscription'; + +import { IgoMap, MapBrowserComponent } from '../../map'; +import { LayerService, LayerOptions } from '../../layer'; + +import { ContextService } from './context.service'; +import { DetailedContext } from './context.interface'; + + +@Directive({ + selector: '[igoLayerContext]' +}) +export class LayerContextDirective implements OnInit, OnDestroy { + + private component: MapBrowserComponent; + private context$$: Subscription; + + get map(): IgoMap { + return this.component.map; + } + + constructor(@Self() component: MapBrowserComponent, + private contextService: ContextService, + private layerService: LayerService) { + this.component = component; + } + + ngOnInit() { + this.context$$ = this.contextService.context$ + .filter(context => context !== undefined) + .subscribe(context => this.handleContextChange(context)); + } + + ngOnDestroy() { + this.context$$.unsubscribe(); + } + + private handleContextChange(context: DetailedContext) { + if (context.layers === undefined) { return; } + + this.map.removeLayers(); + const layerOptions: Array = context.layers; + layerOptions.forEach((options: LayerOptions) => { + this.layerService.createAsyncLayer(options).subscribe( + layer => this.map.addLayer(layer)); + }); + } + +} diff --git a/src/lib/context/shared/map-context.directive.spec.ts b/src/lib/context/shared/map-context.directive.spec.ts new file mode 100644 index 0000000000..4f1ca73bf9 --- /dev/null +++ b/src/lib/context/shared/map-context.directive.spec.ts @@ -0,0 +1,23 @@ +import { TestBed } from '@angular/core/testing'; + +// import { RequestService } from '../../core'; + +// import { ContextService } from './context.service'; +// import { MapContextDirective } from './map-context.directive'; + + +describe('MapContextDirective', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [], + providers: [ + // RequestService, + // ContextService + ] + }); + }); + + it('should create an instance', () => { + expect(true).toBeTruthy(); + }); +}); diff --git a/src/lib/context/shared/map-context.directive.ts b/src/lib/context/shared/map-context.directive.ts new file mode 100644 index 0000000000..2e7504e3c5 --- /dev/null +++ b/src/lib/context/shared/map-context.directive.ts @@ -0,0 +1,44 @@ +import { Directive, Self, OnInit, OnDestroy, } from '@angular/core'; +import { Subscription } from 'rxjs/Subscription'; + +import { IgoMap, MapBrowserComponent, MapViewOptions } from '../../map'; + +import { ContextService } from './context.service'; +import { DetailedContext } from './context.interface'; + + +@Directive({ + selector: '[igoMapContext]' +}) +export class MapContextDirective implements OnInit, OnDestroy { + + private component: MapBrowserComponent; + private context$$: Subscription; + + get map(): IgoMap { + return this.component.map; + } + + constructor(@Self() component: MapBrowserComponent, + private contextService: ContextService) { + this.component = component; + } + + ngOnInit() { + this.context$$ = this.contextService.context$ + .filter(context => context !== undefined) + .subscribe(context => this.handleContextChange(context)); + } + + ngOnDestroy() { + this.context$$.unsubscribe(); + } + + private handleContextChange(context: DetailedContext) { + if (context.map === undefined) { return; } + + const viewOptions: MapViewOptions = context.map.view; + this.component.view = viewOptions; + } + +} diff --git a/src/lib/context/shared/tool-context.directive.spec.ts b/src/lib/context/shared/tool-context.directive.spec.ts new file mode 100644 index 0000000000..b42499e6c7 --- /dev/null +++ b/src/lib/context/shared/tool-context.directive.spec.ts @@ -0,0 +1,25 @@ +import { TestBed } from '@angular/core/testing'; + +// import { RequestService } from '../../core'; +// import { ToolService } from '../../tool'; + +// import { ContextService } from './context.service'; +// import { ToolContextDirective } from './tool-context.directive'; + + +describe('ToolContextDirective', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [], + providers: [ + // RequestService, + // ToolService, + // ContextService + ] + }); + }); + + it('should create an instance', () => { + expect(true).toBeTruthy(); + }); +}); diff --git a/src/lib/context/shared/tool-context.directive.ts b/src/lib/context/shared/tool-context.directive.ts new file mode 100644 index 0000000000..50e522458d --- /dev/null +++ b/src/lib/context/shared/tool-context.directive.ts @@ -0,0 +1,53 @@ +import { Directive, Self, OnInit, OnDestroy, } from '@angular/core'; +import { Subscription } from 'rxjs/Subscription'; + +import { Tool, ToolbarBaseComponent, ToolService } from '../../tool'; + +import { ContextService } from './context.service'; +import { DetailedContext } from './context.interface'; + + +@Directive({ + selector: '[igoToolContext]' +}) +export class ToolContextDirective implements OnInit, OnDestroy { + + private component: ToolbarBaseComponent; + private context$$: Subscription; + + constructor(@Self() component: ToolbarBaseComponent, + private contextService: ContextService, + private toolService: ToolService) { + this.component = component; + } + + ngOnInit() { + this.context$$ = this.contextService.context$ + .filter(context => context !== undefined) + .subscribe(context => this.handleContextChange(context)); + } + + ngOnDestroy() { + this.context$$.unsubscribe(); + } + + private handleContextChange(context: DetailedContext) { + if (context.tools === undefined || context.toolbar === undefined) { + return; + } + + const tools: Tool[] = []; + (context.tools || []).forEach((tool_: Tool) => { + // TODO: Remove the " || {}" when more tool will be defined + const tool = this.toolService.getTool(tool_.name) || {}; + if (tool !== undefined) { + tools.push(Object.assign({ + toolbar: context.toolbar.indexOf(tool_.name) >= 0 + }, tool, tool_)); + } + }); + + this.component.tools = tools; + } + +} diff --git a/src/lib/feature/feature-list/feature-list.component.ts b/src/lib/feature/feature-list/feature-list.component.ts index f47da20958..f08f44c903 100644 --- a/src/lib/feature/feature-list/feature-list.component.ts +++ b/src/lib/feature/feature-list/feature-list.component.ts @@ -1,9 +1,16 @@ import { Component } from '@angular/core'; +import { Register } from '../../tool'; + import { Feature, FeatureService } from '../shared'; import { FeatureListBaseComponent } from './feature-list-base.component'; +@Register({ + name: 'featureList', + title: 'igo.searchResults', + icon: 'search' +}) @Component({ selector: 'igo-feature-list', templateUrl: './feature-list.component.html', diff --git a/src/lib/feature/module.ts b/src/lib/feature/module.ts index cf153d633b..373cac1035 100644 --- a/src/lib/feature/module.ts +++ b/src/lib/feature/module.ts @@ -1,5 +1,4 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; -import { HttpModule } from '@angular/http'; import { IgoSharedModule } from '../shared'; @@ -12,8 +11,7 @@ import { FeatureItemComponent } from './feature-item'; @NgModule({ imports: [ - IgoSharedModule, - HttpModule + IgoSharedModule ], exports: [ FeatureDetailsComponent, diff --git a/src/lib/filter/time-filter-list/time-filter-list.component.ts b/src/lib/filter/time-filter-list/time-filter-list.component.ts index 248999cd29..6f5339d86d 100644 --- a/src/lib/filter/time-filter-list/time-filter-list.component.ts +++ b/src/lib/filter/time-filter-list/time-filter-list.component.ts @@ -1,7 +1,14 @@ import { Component, Input } from '@angular/core'; +import { Register } from '../../tool'; + import { Layer } from '../../layer'; +@Register({ + name: 'timeFilter', + title: 'igo.timeAnalysis', + icon: 'history' +}) @Component({ selector: 'igo-time-filter-list', templateUrl: './time-filter-list.component.html', diff --git a/src/lib/index.ts b/src/lib/index.ts index 7d2288c467..665199710d 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -2,6 +2,7 @@ export * from './core'; export * from './language'; export * from './module'; +export * from './context'; export * from './feature'; export * from './filter'; export * from './layer'; diff --git a/src/lib/layer/layer-list/layer-list.component.ts b/src/lib/layer/layer-list/layer-list.component.ts index dc412c3446..7437a71dae 100644 --- a/src/lib/layer/layer-list/layer-list.component.ts +++ b/src/lib/layer/layer-list/layer-list.component.ts @@ -1,8 +1,15 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; +import { Register } from '../../tool'; + import { Layer } from '../shared'; +@Register({ + name: 'layerList', + title: 'igo.map', + icon: 'map' +}) @Component({ selector: 'igo-layer-list', templateUrl: './layer-list.component.html', diff --git a/src/lib/layer/module.ts b/src/lib/layer/module.ts index 2cc9e87cd9..018c674ff0 100644 --- a/src/lib/layer/module.ts +++ b/src/lib/layer/module.ts @@ -1,5 +1,4 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CommonModule } from '@angular/common'; import { IgoSharedModule } from '../shared'; @@ -10,7 +9,6 @@ import { LayerListComponent } from './layer-list'; @NgModule({ imports: [ - CommonModule, IgoSharedModule ], exports: [ diff --git a/src/lib/map/map-browser/map-browser.component.ts b/src/lib/map/map-browser/map-browser.component.ts index df31309e09..dbd9bc27ec 100644 --- a/src/lib/map/map-browser/map-browser.component.ts +++ b/src/lib/map/map-browser/map-browser.component.ts @@ -30,6 +30,5 @@ export class MapBrowserComponent implements AfterViewInit { ngAfterViewInit(): any { this.map.olMap.setTarget(this.id); - this.map.setView(this.view); } } diff --git a/src/lib/module.ts b/src/lib/module.ts index 2d7b6fb0f7..3f840061f1 100644 --- a/src/lib/module.ts +++ b/src/lib/module.ts @@ -14,6 +14,7 @@ import 'openlayers'; import { IgoCoreModule } from './core/index'; import { IgoLanguageModule } from './language/index'; +import { IgoContextModule } from './context/index'; import { IgoFeatureModule } from './feature/index'; import { IgoFilterModule } from './filter/index'; import { IgoLayerModule } from './layer/index'; @@ -27,6 +28,7 @@ import { IgoToolModule } from './tool/index'; const IGO_MODULES = [ IgoLanguageModule, + IgoContextModule, IgoFeatureModule, IgoFilterModule, IgoLayerModule, @@ -44,6 +46,7 @@ const IGO_MODULES = [ IgoCoreModule.forRoot(), IgoLanguageModule.forRoot(), + IgoContextModule.forRoot(), IgoFeatureModule.forRoot(), IgoFilterModule.forRoot(), IgoLayerModule.forRoot(), diff --git a/src/lib/overlay/module.ts b/src/lib/overlay/module.ts index 45cb7c7d7a..6d70e1642f 100644 --- a/src/lib/overlay/module.ts +++ b/src/lib/overlay/module.ts @@ -1,5 +1,4 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; -import { HttpModule } from '@angular/http'; import { IgoSharedModule } from '../shared'; @@ -9,8 +8,7 @@ import { OverlayDirective } from './overlay'; @NgModule({ imports: [ - IgoSharedModule, - HttpModule + IgoSharedModule ], exports: [ OverlayDirective diff --git a/src/lib/query/module.ts b/src/lib/query/module.ts index d4041a0fb7..dd56b0e122 100644 --- a/src/lib/query/module.ts +++ b/src/lib/query/module.ts @@ -1,5 +1,4 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; -import { HttpModule } from '@angular/http'; import { IgoSharedModule } from '../shared'; @@ -9,8 +8,7 @@ import { QueryDirective } from './query'; @NgModule({ imports: [ - IgoSharedModule, - HttpModule + IgoSharedModule ], exports: [ QueryDirective diff --git a/src/lib/query/query/query.directive.ts b/src/lib/query/query/query.directive.ts index 2d89a651be..a2bc120b30 100644 --- a/src/lib/query/query/query.directive.ts +++ b/src/lib/query/query/query.directive.ts @@ -26,7 +26,7 @@ export class QueryDirective implements AfterViewInit, OnDestroy { ngAfterViewInit() { this.queryLayers$$ = this.component.map.layers$ - .subscribe((layers: Layer[]) => this.handleLayersChanged(layers)); + .subscribe((layers: Layer[]) => this.handleLayersChange(layers)); this.component.map.olMap.on('singleclick', this.handleMapClick, this); } @@ -35,7 +35,7 @@ export class QueryDirective implements AfterViewInit, OnDestroy { this.queryLayers$$.unsubscribe(); } - private handleLayersChanged(layers: Layer[]) { + private handleLayersChange(layers: Layer[]) { this.queryLayers = layers.filter(layer => layer.isQueryable()); } diff --git a/src/lib/search/module.ts b/src/lib/search/module.ts index fef158cc63..7cf64e594d 100644 --- a/src/lib/search/module.ts +++ b/src/lib/search/module.ts @@ -1,5 +1,5 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; -import { HttpModule, Http } from '@angular/http'; +import { Http } from '@angular/http'; import { IgoSharedModule } from '../shared'; @@ -35,8 +35,7 @@ export function provideDefaultSearchSources() { @NgModule({ imports: [ - IgoSharedModule, - HttpModule + IgoSharedModule ], exports: [ SearchBarComponent diff --git a/src/lib/search/search-bar/search-bar.component.styl b/src/lib/search/search-bar/search-bar.component.styl index 410a6c0b6e..0252fd9f52 100644 --- a/src/lib/search/search-bar/search-bar.component.styl +++ b/src/lib/search/search-bar/search-bar.component.styl @@ -1,5 +1,6 @@ :host { position: relative; + display: block; } md-input-container { diff --git a/src/lib/shared/module.ts b/src/lib/shared/module.ts index 521d030150..ce53f9e271 100644 --- a/src/lib/shared/module.ts +++ b/src/lib/shared/module.ts @@ -1,6 +1,7 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { MaterialModule } from '@angular/material'; import { TranslateModule } from '@ngx-translate/core'; @@ -15,12 +16,14 @@ import { ListComponent, ListItemDirective } from './list'; imports: [ CommonModule, FormsModule, + HttpModule, MaterialModule, TranslateModule ], exports: [ CommonModule, FormsModule, + HttpModule, BrowserAnimationsModule, MaterialModule, TranslateModule,