Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog abstract #799

Merged
merged 5 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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