From 5f97c58b527fba42da811a7011f0d900cbde9919 Mon Sep 17 00:00:00 2001 From: phil Date: Fri, 8 Mar 2024 12:09:02 +0530 Subject: [PATCH] Fixes in info pane and others --- src/app/info/info-data.service.ts | 119 +++++++++--------- .../info/info-misc/info-misc.component.html | 2 +- .../info/info-tags/tag-action.component.ts | 2 +- src/app/info/info-tags/tag.component.ts | 4 +- src/app/info/info-tags/tags.service.ts | 8 +- .../info/info-tools/downloader.component.ts | 3 +- src/app/info/info-tools/tools.component.ts | 17 ++- .../map/controls/map-controls.component.html | 2 +- src/app/map/map-data.service.ts | 70 +---------- src/app/openapi/index.ts | 9 ++ src/app/openapi/models/Downloader.ts | 10 ++ src/app/openapi/models/FeatureInfo.ts | 5 +- src/app/openapi/models/FormField.ts | 11 ++ src/app/openapi/models/LegendItem.ts | 9 ++ src/app/openapi/models/ModelAction.ts | 11 ++ src/app/openapi/models/ModelInfo.ts | 24 ++++ src/app/openapi/models/ModelValue.ts | 12 ++ src/app/openapi/models/Tag.ts | 9 ++ src/app/openapi/models/TagAction.ts | 12 ++ src/app/openapi/models/TagActions.ts | 11 ++ src/app/openapi/services/ApiService.ts | 27 +++- 21 files changed, 232 insertions(+), 145 deletions(-) create mode 100644 src/app/openapi/models/Downloader.ts create mode 100644 src/app/openapi/models/FormField.ts create mode 100644 src/app/openapi/models/LegendItem.ts create mode 100644 src/app/openapi/models/ModelAction.ts create mode 100644 src/app/openapi/models/ModelInfo.ts create mode 100644 src/app/openapi/models/ModelValue.ts create mode 100644 src/app/openapi/models/Tag.ts create mode 100644 src/app/openapi/models/TagAction.ts create mode 100644 src/app/openapi/models/TagActions.ts diff --git a/src/app/info/info-data.service.ts b/src/app/info/info-data.service.ts index 4c6ac2c..b597e29 100644 --- a/src/app/info/info-data.service.ts +++ b/src/app/info/info-data.service.ts @@ -12,6 +12,7 @@ import { Tag, TagAction } from './info-tags/tags.service' import { ConfigService } from '../config.service' import { DataService } from '../_services/data.service' +import { ApiService, ModelInfo, FeatureInfo } from '../openapi' // const getModelInfoQuery = gql` // query modelInfo ($store: String!) { @@ -302,12 +303,12 @@ export class ModelValue { ) {} } -export class Downloader { - constructor( - public name: string, - public icon: string, - ) {} -} +// export class Downloader { +// constructor( +// public name: string, +// public icon: string, +// ) {} +// } export class LegendItem { constructor( @@ -316,34 +317,34 @@ export class LegendItem { ) {} } -export class ModelInfo { - constructor( - public store: string, - public modelName: string, - public symbol: string, - public values: ModelValue[], - public actions: ModelAction[], - public formName: string, - public formFields: FormField[], - public tagPlugins: String[], - public tagActions: TagAction[], - public downloaders: Downloader[], - public legend: LegendItem[], - ) {} +// export class ModelInfo { +// constructor( +// public store: string, +// public modelName: string, +// public symbol: string, +// public values: ModelValue[], +// public actions: ModelAction[], +// public formName: string, +// public formFields: FormField[], +// public tagPlugins: String[], +// public tagActions: TagAction[], +// public downloaders: Downloader[], +// public legend: LegendItem[], +// ) {} - getFormFields(formGroup: UntypedFormGroup, fullInfo: FullInfo): object[] { - // Return the form fields and build the FormGroup controls accordingly - let formFields = [] - fullInfo.modelInfo.formFields.forEach( - field => { - let control = new UntypedFormControl(field.name) //, field.validator) - formGroup.addControl(field.name, control) - formFields.push(field) - } - ) - return formFields - } -} +// getFormFields(formGroup: UntypedFormGroup, fullInfo: FullInfo): object[] { +// // Return the form fields and build the FormGroup controls accordingly +// let formFields = [] +// fullInfo.modelInfo.formFields.forEach( +// field => { +// let control = new UntypedFormControl(field.name) //, field.validator) +// formGroup.addControl(field.name, control) +// formFields.push(field) +// } +// ) +// return formFields +// } +// } export class PlotBaseLine { constructor( @@ -414,24 +415,24 @@ export class FeatureWithField { ) {} } -export class FeatureInfo { - constructor( - public id: string, - public itemName: string, - public geoInfoItems: InfoItem[], - public surveyInfoItems: InfoItem[], - public infoItems: InfoItem[], - public categorizedInfoItems: InfoCategory[], - public tags: Tag[], - public graph?: string, - public files?: Attachment[], - public images?: Attachment[], - public externalRecordUrl?: string - ) {} - openExternalRecord() { - window.open(this.externalRecordUrl) - } -} +// export class FeatureInfo { +// constructor( +// public id: string, +// public itemName: string, +// public geoInfoItems: InfoItem[], +// public surveyInfoItems: InfoItem[], +// public infoItems: InfoItem[], +// public categorizedInfoItems: InfoCategory[], +// public tags: Tag[], +// public graph?: string, +// public files?: Attachment[], +// public images?: Attachment[], +// public externalRecordUrl?: string +// ) {} +// openExternalRecord() { +// window.open(this.externalRecordUrl) +// } +// } export class FullInfo { constructor( @@ -448,9 +449,9 @@ export class FullInfo { export class InfoDataService { constructor( public configService: ConfigService, - // private apollo: Apollo, public mapControlService: MapControlService, protected dataService: DataService, + private api: ApiService, ) {} public refresh = new Subject() @@ -467,6 +468,7 @@ export class InfoDataService { public taggedLayers$ = this.taggedLayers.asObservable() getModelInfo(store: string): Observable { + return this.api.getModelInfoApiModelInfoStoreGet({store: store}) console.warn('Migrate Graphql') return observableOf() // return this.apollo.query({ @@ -586,8 +588,10 @@ export class InfoDataService { } getFeatureInfo(store: string, id: string): Observable { - console.warn('Migrate Graphql') - return observableOf() + return this.api.getFeatureInfoApiFeatureInfoStoreIdGet({ + store: store, + id: id + }) // return this.apollo.query({ // query: getFeatureInfoQuery, // variables: { @@ -677,7 +681,8 @@ export class InfoDataService { // tag can be FeatureTree, but circular dependencies: // import { FeatureTree } from './info-selection/info-selection-tags.component' let variables: Object - if (tag instanceof Tag) { + if (!tag.id) { + // A Tag, really variables = { 'store': fullInfo.modelInfo.store, 'id': fullInfo.featureInfo.id, @@ -727,9 +732,7 @@ export class InfoDataService { feature['id'], feature['lon'], feature['lat'], - feature['tags'].map( - tag => new Tag(tag['key'], tag['value']) - ) + feature['tags'] ) ) ) diff --git a/src/app/info/info-misc/info-misc.component.html b/src/app/info/info-misc/info-misc.component.html index 125dac9..8e3252e 100644 --- a/src/app/info/info-misc/info-misc.component.html +++ b/src/app/info/info-misc/info-misc.component.html @@ -14,7 +14,7 @@ External link - {{ source.featureInfo.externalRecordUrl }} + {{ source.featureInfo.externalRecordUrl }} diff --git a/src/app/info/info-tags/tag-action.component.ts b/src/app/info/info-tags/tag-action.component.ts index 9df7138..026b320 100644 --- a/src/app/info/info-tags/tag-action.component.ts +++ b/src/app/info/info-tags/tag-action.component.ts @@ -62,7 +62,7 @@ export class TagActionComponent { this.infoDataService.dataProviderService.next(this.source) } else { - this.source.featureInfo.tags.push(new Tag(tag.key, tag.value)) + this.source.featureInfo.tags.push({key: tag.key, value: tag.value}) } } ) diff --git a/src/app/info/info-tags/tag.component.ts b/src/app/info/info-tags/tag.component.ts index bea2d05..4f0abc6 100644 --- a/src/app/info/info-tags/tag.component.ts +++ b/src/app/info/info-tags/tag.component.ts @@ -82,9 +82,7 @@ export class TagComponent implements OnInit { delete() { this.infoDataService.deleteTag(this.tag, this.source).subscribe({ next: res => { - const tags = res['data']['deleteTag']['tags'].map( - ii => new Tag(ii['key'], ii['value']) - ) + const tags = res['data']['deleteTag']['tags'] this.source.featureInfo.tags = tags this.infoDataService.dataProviderService.next(this.source) this.mapControlService.search.next(true) diff --git a/src/app/info/info-tags/tags.service.ts b/src/app/info/info-tags/tags.service.ts index 78e4b96..3c68100 100644 --- a/src/app/info/info-tags/tags.service.ts +++ b/src/app/info/info-tags/tags.service.ts @@ -66,11 +66,9 @@ import { map } from 'rxjs/operators' // } // ` -export class Tag { - constructor( - public key: string, - public value: string, - ) {} +export type Tag = { + key: string + value: string } export class TagAction { diff --git a/src/app/info/info-tools/downloader.component.ts b/src/app/info/info-tools/downloader.component.ts index 29c68a9..bfd3de7 100644 --- a/src/app/info/info-tools/downloader.component.ts +++ b/src/app/info/info-tools/downloader.component.ts @@ -2,7 +2,8 @@ import { Component, Input, OnInit } from '@angular/core' import { MatSnackBar } from '@angular/material/snack-bar' -import { FullInfo, Downloader } from '../info-data.service' +import { FullInfo } from '../info-data.service' +import { Downloader } from '../../openapi' @Component({ selector: 'gisaf-downloader', diff --git a/src/app/info/info-tools/tools.component.ts b/src/app/info/info-tools/tools.component.ts index 88ba76a..8c9d0cc 100644 --- a/src/app/info/info-tools/tools.component.ts +++ b/src/app/info/info-tools/tools.component.ts @@ -1,6 +1,6 @@ import { Component, Input, Output, EventEmitter } from '@angular/core' -import { UntypedFormGroup, FormControl } from '@angular/forms' +import { UntypedFormGroup, UntypedFormControl } from '@angular/forms' import { MatSnackBar } from '@angular/material/snack-bar' import { DataService } from '../../_services/data.service' @@ -39,7 +39,7 @@ export class ToolsComponent { (source: FullInfo) => { this._source = source this.formGroup = new UntypedFormGroup({}) - source.modelInfo.getFormFields(this.formGroup, source) + this.getFormFields(this.formGroup, source) } ) this.actionsService.actionsProviderService$.subscribe( @@ -52,6 +52,19 @@ export class ToolsComponent { ) } + getFormFields(formGroup: UntypedFormGroup, fullInfo: FullInfo): object[] { + // Return the form fields and build the FormGroup controls accordingly + let formFields = [] + fullInfo.modelInfo.formFields.forEach( + field => { + let control = new UntypedFormControl(field.name) //, field.validator) + formGroup.addControl(field.name, control) + formFields.push(field) + } + ) + return formFields + } + get isAuthorized() { return this.authenticationService.user.value } diff --git a/src/app/map/controls/map-controls.component.html b/src/app/map/controls/map-controls.component.html index 19375b9..0dc3fe5 100644 --- a/src/app/map/controls/map-controls.component.html +++ b/src/app/map/controls/map-controls.component.html @@ -101,7 +101,7 @@ (input)="filter()" (keydown.enter)="mapControlService.zoomToFeatures()" [(ngModel)]="searchText"/> -