Skip to content

Commit

Permalink
feat(catalog): allow to use abstract a meta when metadata url is unde…
Browse files Browse the repository at this point in the history
…fined (#799)

* feat(catalog): use abstract if metadata url is undefined

* WIP

* feat(catalog): allow to use abstract a meta when metadata url is undefined

* lint
  • Loading branch information
PhilippeLafreniere18 authored Jan 18, 2021
1 parent 76748c4 commit 7535b09
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/geo/src/lib/catalog/shared/catalog.abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export abstract class Catalog implements ICatalog {
id: string;
title: string;
url: string;
abstract?: string;
forcedProperties?: any[];
items?: CatalogItem[];
type?: TypeCatalogStrings;
Expand Down
42 changes: 39 additions & 3 deletions packages/geo/src/lib/catalog/shared/catalog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export class CatalogService {
return this.getCatalogCapabilities(catalog).pipe(
map((capabilities: any) => {
const items = [];
if (capabilities.Service && capabilities.Service.Abstract && capabilities.Service.Abstract.length) {
catalog.abstract = capabilities.Service.Abstract;
}

this.includeRecursiveItems(
catalog,
capabilities.Capability.Layer,
Expand Down Expand Up @@ -363,6 +367,13 @@ export class CatalogService {
}
}

let abstract;
if (layer.Abstract) {
abstract = layer.Abstract;
} else if (!layer.Abstract && catalog.abstract) {
abstract = catalog.abstract;
}

const layerPrepare = {
id: generateIdFromSourceOptions(sourceOptions),
type: CatalogItemType.Layer,
Expand All @@ -374,7 +385,8 @@ export class CatalogService {
metadata: {
url: metadata ? metadata.OnlineResource : undefined,
extern: metadata ? true : undefined,
abstract: layer.Abstract
abstract,
type: baseSourceOptions.type
},
legendOptions,
tooltip: { type: catalog.tooltipType },
Expand Down Expand Up @@ -497,6 +509,13 @@ export class CatalogService {
(pattern: string) => new RegExp(pattern)
);

if (
capabilities.ServiceIdentification &&
capabilities.ServiceIdentification.Abstract &&
capabilities.ServiceIdentification.Abstract.length) {
catalog.abstract = capabilities.ServiceIdentification.Abstract;
}

return layers
.map((layer: any) => {
let forcedTitle;
Expand Down Expand Up @@ -538,7 +557,13 @@ export class CatalogService {
title: forcedTitle !== undefined ? forcedTitle : layer.Title,
address: catalog.id,
options: {
sourceOptions
sourceOptions,
metadata: {
url: undefined,
extern: undefined,
abstract: catalog.abstract,
type: baseSourceOptions.type
}
}
});
})
Expand All @@ -554,6 +579,11 @@ export class CatalogService {
(pattern: string) => new RegExp(pattern)
);

let abstract;
if (capabilities.serviceDescription && capabilities.serviceDescription.length) {
abstract = capabilities.serviceDescription;
}

return layers
.map((layer: any) => {
let forcedTitle;
Expand Down Expand Up @@ -590,7 +620,13 @@ export class CatalogService {
title: forcedTitle !== undefined ? forcedTitle : layer.name,
address: catalog.id,
options: {
sourceOptions
sourceOptions,
metadata: {
url: undefined,
extern: undefined,
abstract,
type: baseSourceOptions.type
}
}
});
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h2 mat-dialog-title>{{ data.layerTitle }}</h2>
<button class="close-button" mat-button mat-dialog-close>X</button>
<mat-dialog-content *ngIf="data.type !== 'arcgisrest'" class="mat-typography">
<h3>{{ data.abstract }}</h3>
</mat-dialog-content>
<mat-dialog-content *ngIf="data.type === 'arcgisrest'" class="mat-typography">
<h3 [innerHTML]="data.abstract"></h3>
</mat-dialog-content>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.close-button {
top: 5px;
right: 5px;
padding: 7px;
line-height: 10px;
position: absolute !important;
min-width: auto;
}

mat-dialog-container {
position: relative;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<button
*ngIf="options && options.metadata && options.metadata.url"
*ngIf="(options && options.metadata && options.metadata.url) || (options && options.metadata && options.metadata.abstract)"
mat-icon-button
tooltip-position="below"
matTooltipShowDelay="500"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { Component, Input, ChangeDetectionStrategy, Inject, ViewEncapsulation } from '@angular/core';
import { MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';

import { Layer } from '../../layer/shared/layers/layer';

Expand Down Expand Up @@ -33,10 +34,22 @@ export class MetadataButtonComponent {
}
private _color = 'primary';

constructor(private metadataService: MetadataService) {}
constructor(
private metadataService: MetadataService,
private dialog: MatDialog) {}

openMetadata(metadata: MetadataOptions) {
this.metadataService.open(metadata);
if (metadata.extern) {
this.metadataService.open(metadata);
} else if (!metadata.extern && metadata.abstract) {
this.dialog.open(MetadataAbstractComponent, {
data: {
layerTitle: this.layer.title,
abstract: metadata.abstract,
type: metadata.type
}
});
}
}

get options(): MetadataLayerOptions {
Expand All @@ -46,3 +59,13 @@ export class MetadataButtonComponent {
return this.layer.options;
}
}

@Component({
selector: 'igo-metadata-abstract',
templateUrl: './metadata-abstract.component.html',
styleUrls: ['./metadata-abstract.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class MetadataAbstractComponent {
constructor(@Inject(MAT_DIALOG_DATA) public data: MetadataOptions) {}
}
14 changes: 10 additions & 4 deletions packages/geo/src/lib/metadata/metadata.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MatDialogModule } from '@angular/material/dialog';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';

Expand All @@ -7,18 +8,23 @@ import { MatTooltipModule } from '@angular/material/tooltip';

import { IgoLanguageModule } from '@igo2/core';

import { MetadataButtonComponent } from './metadata-button/metadata-button.component';
import { MetadataButtonComponent, MetadataAbstractComponent } from './metadata-button/metadata-button.component';

@NgModule({
imports: [
CommonModule,
MatIconModule,
MatButtonModule,
MatTooltipModule,
IgoLanguageModule
IgoLanguageModule,
MatDialogModule
],
exports: [MetadataButtonComponent],
declarations: [MetadataButtonComponent]
exports: [
MetadataButtonComponent,
MetadataAbstractComponent],
declarations: [
MetadataButtonComponent,
MetadataAbstractComponent]
})
export class IgoMetadataModule {
static forRoot(): ModuleWithProviders<IgoMetadataModule> {
Expand Down
3 changes: 3 additions & 0 deletions packages/geo/src/lib/metadata/shared/metadata.interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { TypeCatalogStrings } from '../../catalog';
import { LayerOptions } from '../../layer/shared/layers/layer.interface';

export interface MetadataOptions {
url: string;
extern?: boolean;
abstract?: string;
keywordList?: string[];
layerTitle?: string;
type?: TypeCatalogStrings;
}

export interface MetadataLayerOptions extends LayerOptions {
Expand Down

0 comments on commit 7535b09

Please sign in to comment.