Skip to content

Commit

Permalink
feat(metadata): add metadata for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed May 31, 2017
1 parent 9c11f37 commit 10c2694
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/demo-app/contexts/embacle.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"width" : 3
},
"fill": {
"color": "rgba(140, 140, 255, 0.3)"
"color": "rgba(140, 140, 255, 0.3)"
}
},
"version" : "1.3.0",
Expand Down Expand Up @@ -57,6 +57,10 @@
},
"projection": "EPSG:3857"
},
"metadata": {
"url": "https://www.donneesquebec.ca/recherche/fr/dataset/historique-publique-d-embacles-repertories-au-msp",
"extern": true
},
"timeFilter": {
"min": "2017-01-01",
"max": "2018-01-01",
Expand Down
2 changes: 2 additions & 0 deletions src/lib/datasource/shared/datasources/datasource.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TimeFilterOptions } from '../../../filter';
import { QueryFormat, QueryOptions } from '../../../query';
import { MetadataOptions } from '../../../metadata';

import { DataSource } from './datasource';

Expand All @@ -8,6 +9,7 @@ export interface DataSourceOptions {
title: string;
alias?: string;
legend?: DataSourceLegendOptions;
metadata?: MetadataOptions;
}

export interface DataSourceContext extends DataSourceOptions {
Expand Down
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './filter';
export * from './form';
export * from './layer';
export * from './map';
export * from './metadata';
export * from './overlay';
export * from './query';
export * from './search';
Expand Down
4 changes: 4 additions & 0 deletions src/lib/language.extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import { _ } from '@biesbjerg/ngx-translate-extract';

_('igo.map');
_('igo.searchResults');
_('igo.contexts');
_('igo.timeAnalysis');
_('igo.landscape');
_('igo.portrait');
_('igo.orientation');
10 changes: 10 additions & 0 deletions src/lib/layer/layer-item/layer-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ <h4 md-line>{{layer.title}}</h4>

<div class="igo-col igo-col-60 igo-col-100-m">
<div class="igo-layer-button-group">
<button
*ngIf="layer.options.metadata"
md-icon-button
tooltip-position="below"
[md-tooltip]="'igo.showMetadata' | translate"
[color]="color"
(click)="openMetadata(layer.options.metadata)">
<md-icon>info_outline</md-icon>
</button>

<button
md-icon-button
tooltip-position="below"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/layer/layer-item/layer-item.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IgoTestModule } from '../../../test/module';
import { IgoSharedModule } from '../../shared';
import { OSMDataSource } from '../../datasource';
import { MetadataService } from '../../metadata';

import { TileLayer } from '../shared';
import { LayerItemComponent } from './layer-item.component';
Expand All @@ -21,6 +22,9 @@ describe('LayerItemComponent', () => {
declarations: [
LayerItemComponent,
LayerLegendComponent
],
providers: [
MetadataService
]
})
.compileComponents();
Expand Down
6 changes: 5 additions & 1 deletion src/lib/layer/layer-item/layer-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';

import { MetadataService, MetadataOptions } from '../../metadata';
import { Layer } from '../shared/layers/layer';

@Component({
Expand Down Expand Up @@ -48,7 +49,7 @@ export class LayerItemComponent {
this.layer.opacity = opacity / 100;
}

constructor() { }
constructor(private metadataService: MetadataService) { }

toggleLegend(collapsed: boolean) {
this.layer.collapsed = collapsed;
Expand All @@ -61,4 +62,7 @@ export class LayerItemComponent {
}
}

openMetadata(metadata: MetadataOptions) {
this.metadataService.open(metadata);
}
}
2 changes: 2 additions & 0 deletions src/lib/metadata/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './module';
export * from './shared';
24 changes: 24 additions & 0 deletions src/lib/metadata/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NgModule, ModuleWithProviders } from '@angular/core';

import { IgoSharedModule } from '../shared';

import { MetadataService } from './shared';


@NgModule({
imports: [
IgoSharedModule
],
exports: [],
declarations: []
})
export class IgoMetadataModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: IgoMetadataModule,
providers: [
MetadataService
]
};
}
}
2 changes: 2 additions & 0 deletions src/lib/metadata/shared/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './metadata.service';
export * from './metadata.interface';
4 changes: 4 additions & 0 deletions src/lib/metadata/shared/metadata.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface MetadataOptions {
url: string;
extern?: boolean;
}
21 changes: 21 additions & 0 deletions src/lib/metadata/shared/metadata.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { TestBed, inject } from '@angular/core/testing';

import { IgoCoreModule } from '../../core';
import { MetadataService } from './metadata.service';

describe('MetadataService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
IgoCoreModule.forRoot()
],
providers: [
MetadataService
]
});
});

it('should ...', inject([MetadataService], (service: MetadataService) => {
expect(service).toBeTruthy();
}));
});
16 changes: 16 additions & 0 deletions src/lib/metadata/shared/metadata.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Injectable } from '@angular/core';

import { MetadataOptions } from '.';

@Injectable()
export class MetadataService {

constructor() { }

open(metadata: MetadataOptions) {
if (metadata.extern) {
window.open(metadata.url, '_blank');
}
}

}
31 changes: 17 additions & 14 deletions src/lib/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ import 'rxjs/add/operator/do';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/combineLatest';

import { IgoCoreModule } from './core/index';
import { IgoContextModule } from './context/index';
import { IgoDataSourceModule } from './datasource/index';
import { IgoFeatureModule } from './feature/index';
import { IgoFormModule } from './form/index';
import { IgoFilterModule } from './filter/index';
import { IgoLayerModule } from './layer/index';
import { IgoMapModule } from './map/index';
import { IgoOverlayModule } from './overlay/index';
import { IgoPrintModule } from './print/index';
import { IgoQueryModule } from './query/index';
import { IgoSearchModule } from './search/index';
import { IgoSharedModule } from './shared/index';
import { IgoToolModule } from './tool/index';
import { IgoCoreModule } from './core';
import { IgoContextModule } from './context';
import { IgoDataSourceModule } from './datasource';
import { IgoFeatureModule } from './feature';
import { IgoFormModule } from './form';
import { IgoFilterModule } from './filter';
import { IgoLayerModule } from './layer';
import { IgoMapModule } from './map';
import { IgoMetadataModule } from './metadata';
import { IgoOverlayModule } from './overlay';
import { IgoPrintModule } from './print';
import { IgoQueryModule } from './query';
import { IgoSearchModule } from './search';
import { IgoSharedModule } from './shared';
import { IgoToolModule } from './tool';

const IGO_MODULES = [
IgoCoreModule,
Expand All @@ -37,6 +38,7 @@ const IGO_MODULES = [
IgoFilterModule,
IgoLayerModule,
IgoMapModule,
IgoMetadataModule,
IgoOverlayModule,
IgoPrintModule,
IgoQueryModule,
Expand All @@ -57,6 +59,7 @@ const IGO_MODULES = [
IgoFilterModule.forRoot(),
IgoLayerModule.forRoot(),
IgoMapModule.forRoot(),
IgoMetadataModule.forRoot(),
IgoOverlayModule.forRoot(),
IgoPrintModule.forRoot(),
IgoQueryModule.forRoot(),
Expand Down
3 changes: 2 additions & 1 deletion src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"resolution": "Resolution",
"searchResults": "Search Results",
"showLayer": "Show Layer",
"showMetadata": "Show metadata",
"startDate": "Start Date",
"timeAnalysis": "Time Analysis",
"title": "Title"
}
}
}
3 changes: 2 additions & 1 deletion src/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"resolution": "Resolution",
"searchResults": "Résultats de recherche",
"showLayer": "Afficher la couche",
"showMetadata": "Montrer les métadonnées",
"startDate": "Date de début",
"timeAnalysis": "Analyse Temporelle",
"title": "Titre"
}
}
}

0 comments on commit 10c2694

Please sign in to comment.