Fixes in info pane and others

This commit is contained in:
phil 2024-03-08 12:09:02 +05:30
parent adba349c38
commit 5f97c58b52
21 changed files with 232 additions and 145 deletions

View file

@ -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<boolean>()
@ -467,6 +468,7 @@ export class InfoDataService {
public taggedLayers$ = this.taggedLayers.asObservable()
getModelInfo(store: string): Observable<ModelInfo> {
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<FeatureInfo> {
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']
)
)
)

View file

@ -14,7 +14,7 @@
</tr>
<tr *ngIf="source.featureInfo.externalRecordUrl">
<td>External link</td>
<span class='link' (click)='source.featureInfo.openExternalRecord()'>{{ source.featureInfo.externalRecordUrl }}</span>
<a class='link' href='window.open(source.featureInfo.externalRecordUrl)' target="_blank">{{ source.featureInfo.externalRecordUrl }}</a>
</tr>
</table>
</mat-tab>

View file

@ -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})
}
}
)

View file

@ -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)

View file

@ -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 {

View file

@ -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',

View file

@ -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
}

View file

@ -101,7 +101,7 @@
(input)="filter()"
(keydown.enter)="mapControlService.zoomToFeatures()"
[(ngModel)]="searchText"/>
<button mat-button matSuffix mat-icon-button
<button matSuffix mat-icon-button
*ngIf="searchText"
aria-label="Clear"
(click)="searchText='';filter()"

View file

@ -4,7 +4,6 @@ import { map } from 'rxjs/operators'
import { StyleSpecification } from 'maplibre-gl'
// import { TreeData, PrimaryGroupNode, LayerNode } from './models'
import { MapControlService } from './map-control.service'
import { MapService, MapInitData, BaseMapWithStores, BaseStyle as OApiBaseStyle } from '../openapi'
@ -15,12 +14,6 @@ export class BaseStyle {
) {}
}
// export class Store {
// constructor(
// public name: string,
// ) {}
// }
@Injectable()
export class MapDataService {
constructor(
@ -46,57 +39,6 @@ export class MapDataService {
return this.mapService.getInitDataApiMapInitDataGet().pipe(map(
data => this.mapInitData = data
))
// return this.apollo.query({
// query: mapInitDataQuery,
// ).pipe(map(
// mid => {
// this.mapInitData = mid
// const baseMaps = mid.baseMaps.map(
// bm => new BaseMap(
// bm.name,
// bm.stores.map(
// (store: object) => new Store(store['name'])
// )
// )
// )
// const baseStyles = mid.baseStyles.map(
// baseStyle => new BaseStyle(baseStyle.name)
// )
// const groups = mid.groups.map(
// gg => new PrimaryGroupNode(
// gg.name,
// gg.title,
// gg.description
// )
// )
// const stores = mid.stores.map(
// layer => new LayerNode(
// layer['name'],
// layer['group'],
// layer['icon'],
// layer['symbol'] || gisTypeSymbolMap[layer['gisType']],
// layer['store'],
// layer['rawSurveyStore'],
// layer['type'],
// layer['gisType'],
// layer.style,
// layer['zIndex'],
// layer['count'],
// layer['description'],
// layer['live'],
// layer['custom'],
// layer['tagPlugins'],
// layer['viewableRole']
// )
// )
// return new MapInitData(
// baseStyles,
// baseMaps,
// groups,
// stores,
// )
// }
// ))
}
// getBaseMaps(): Observable<BaseMap[]> {
@ -118,7 +60,7 @@ export class MapDataService {
// }
public createBaseMap(baseMapName: string, stores: string[]): Observable<BaseMapWithStores> {
console.log('TODO: createBaseMap')
console.log('TODO: Migrate Graphql createBaseMap')
return of({name: '', stores:[]})
// return this.apollo.mutate({
// mutation: createBaseMapQuery,
@ -147,19 +89,9 @@ export class MapDataService {
// }
getBaseStyle(styleName: string): Observable<BaseStyle> {
console.log('TODO: getBaseStyle')
return this.mapService.getBaseStyleApiMapBaseStyleNameGet({name: styleName}).pipe(map(
data => new BaseStyle(data.name, <any>data.style)
))
// return this.apollo.query({
// query: baseStyleQuery,
// variables: {
// name: styleName
// }
// }).pipe(map(
// data => new BaseStyle(data['data']['base_style']['name'],
// JSON.parse(data['data']['base_style']['style']))
// ))
}
// getStores(): Observable<LayerNode[]> {

View file

@ -21,17 +21,23 @@ export type { DashboardGroup } from './models/DashboardGroup';
export type { DashboardHome } from './models/DashboardHome';
export type { DashboardPage_ } from './models/DashboardPage_';
export type { DataProvider } from './models/DataProvider';
export type { Downloader } from './models/Downloader';
export type { Equipment } from './models/Equipment';
export type { FeatureInfo } from './models/FeatureInfo';
export type { FileImport } from './models/FileImport';
export type { FormField } from './models/FormField';
export type { Geo } from './models/Geo';
export type { HTTPValidationError } from './models/HTTPValidationError';
export type { InfoCategory } from './models/InfoCategory';
export type { InfoItem } from './models/InfoItem';
export type { LegendItem } from './models/LegendItem';
export type { Map } from './models/Map';
export type { MapInitData } from './models/MapInitData';
export type { MaplibreStyle } from './models/MaplibreStyle';
export type { Measures } from './models/Measures';
export type { ModelAction } from './models/ModelAction';
export type { ModelInfo } from './models/ModelInfo';
export type { ModelValue } from './models/ModelValue';
export type { PlotBaseLine } from './models/PlotBaseLine';
export type { PlotBgShape } from './models/PlotBgShape';
export type { PlotParams } from './models/PlotParams';
@ -44,6 +50,9 @@ export type { Store } from './models/Store';
export type { StoreNameOnly } from './models/StoreNameOnly';
export type { SurveyMeta } from './models/SurveyMeta';
export type { Surveyor } from './models/Surveyor';
export type { Tag } from './models/Tag';
export type { TagAction } from './models/TagAction';
export type { TagActions } from './models/TagActions';
export type { TileServer } from './models/TileServer';
export type { Token } from './models/Token';
export type { UserRead } from './models/UserRead';

View file

@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type Downloader = {
roles?: Array<string>;
name: string;
icon?: (string | null);
};

View file

@ -6,14 +6,15 @@ import type { Attachment } from './Attachment';
import type { InfoCategory } from './InfoCategory';
import type { InfoItem } from './InfoItem';
import type { PlotParams } from './PlotParams';
import type { Tag } from './Tag';
export type FeatureInfo = {
id: string;
itemName: string;
geoInfoItems?: Array<InfoItem>;
surveyInfoItems?: Array<InfoItem>;
infoItems?: Array<InfoItem>;
categorizedInfoItems?: Array<InfoCategory>;
tags?: Array<InfoItem>;
categorizedInfoItems?: (Array<InfoCategory> | null);
tags?: Array<Tag>;
graph?: (string | null);
plotParams?: (PlotParams | null);
files?: Array<Attachment>;

View file

@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type FormField = {
name: string;
type: string;
dflt?: (string | null);
value?: (string | null);
};

View file

@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type LegendItem = {
key: string;
value: string;
};

View file

@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { FormField } from './FormField';
export type ModelAction = {
name: string;
icon: string;
formFields: Array<FormField>;
};

View file

@ -0,0 +1,24 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Downloader } from './Downloader';
import type { FormField } from './FormField';
import type { LegendItem } from './LegendItem';
import type { ModelAction } from './ModelAction';
import type { ModelValue } from './ModelValue';
import type { TagActions } from './TagActions';
export type ModelInfo = {
store: string;
modelName: string;
symbol?: (string | null);
values?: Array<ModelValue>;
actions?: Array<ModelAction>;
formName?: (string | null);
formFields?: Array<FormField>;
tagPlugins?: Array<string>;
tagActions?: Array<TagActions>;
downloaders?: Array<Downloader>;
legend?: Array<LegendItem>;
};

View file

@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type ModelValue = {
name: string;
title: string;
unit: string;
chartType?: string;
chartColor?: string;
};

View file

@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type Tag = {
key: string;
value: string;
};

View file

@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type TagAction = {
name: string;
action: string;
roles?: (Array<string> | null);
link?: (string | null);
save?: boolean;
};

View file

@ -0,0 +1,11 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TagAction } from './TagAction';
export type TagActions = {
domain: string;
key: string;
actions: Array<TagAction>;
};

View file

@ -10,6 +10,7 @@ import type { BootstrapData } from '../models/BootstrapData';
import type { CategoryRead } from '../models/CategoryRead';
import type { DataProvider } from '../models/DataProvider';
import type { FeatureInfo } from '../models/FeatureInfo';
import type { ModelInfo } from '../models/ModelInfo';
import type { Project } from '../models/Project';
import type { RoleRead } from '../models/RoleRead';
import type { Store } from '../models/Store';
@ -190,7 +191,7 @@ export class ApiService {
}
/**
* Get Feature Info
* @returns FeatureInfo Successful Response
* @returns any Successful Response
* @throws ApiError
*/
public getFeatureInfoApiFeatureInfoStoreIdGet({
@ -199,7 +200,7 @@ export class ApiService {
}: {
store: string,
id: string,
}): Observable<FeatureInfo> {
}): Observable<(FeatureInfo | null)> {
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/feature-info/{store}/{id}',
@ -213,4 +214,26 @@ export class ApiService {
},
});
}
/**
* Get Model Info
* @returns ModelInfo Successful Response
* @throws ApiError
*/
public getModelInfoApiModelInfoStoreGet({
store,
}: {
store: string,
}): Observable<ModelInfo> {
return __request(OpenAPI, this.http, {
method: 'GET',
url: '/api/model-info/{store}',
path: {
'store': store,
},
errors: {
404: `Not found`,
422: `Validation Error`,
},
});
}
}