Update fix measures (WIP)
This commit is contained in:
parent
5f97c58b52
commit
ccf6cfd6e8
10 changed files with 118 additions and 42 deletions
|
@ -3,18 +3,20 @@ import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'
|
|||
import { Observable } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
|
||||
export class MeasuresItem {
|
||||
constructor(
|
||||
public $uri: string,
|
||||
public caption: string,
|
||||
) {}
|
||||
get id(): string {
|
||||
return this.$uri.substr(this.$uri.lastIndexOf('/') + 1)
|
||||
}
|
||||
get name(): string {
|
||||
return this.caption || this.id
|
||||
}
|
||||
}
|
||||
import { ApiService, DataProvider, MeasuresItem } from '../openapi'
|
||||
|
||||
// export class MeasuresItem {
|
||||
// constructor(
|
||||
// public $uri: string,
|
||||
// public caption: string,
|
||||
// ) {}
|
||||
// get id(): string {
|
||||
// return this.$uri.substr(this.$uri.lastIndexOf('/') + 1)
|
||||
// }
|
||||
// get name(): string {
|
||||
// return this.caption || this.id
|
||||
// }
|
||||
// }
|
||||
|
||||
export class MeasuresItemsList {
|
||||
constructor(
|
||||
|
@ -25,18 +27,16 @@ export class MeasuresItemsList {
|
|||
|
||||
@Injectable()
|
||||
export class DataService {
|
||||
constructor(private _http: HttpClient){ }
|
||||
constructor(
|
||||
public api: ApiService,
|
||||
) {}
|
||||
|
||||
getResources(): Observable<Object[]> {
|
||||
return this._http.get<Object[]>('/api/list')
|
||||
getResources(): Observable<DataProvider[]> {
|
||||
return this.api.listDataProvidersApiDataProvidersGet()
|
||||
}
|
||||
|
||||
getList(store: string): Observable<MeasuresItem[]> {
|
||||
return this._http.get<MeasuresItem[]>('/api/' + store).pipe(
|
||||
map(res => res.map(
|
||||
item => new MeasuresItem(item['$uri'], item['caption'])
|
||||
))
|
||||
)
|
||||
return this.api.getModelListApiDataProviderStoreGet({store: store})
|
||||
}
|
||||
|
||||
getValues(
|
||||
|
@ -55,18 +55,17 @@ export class DataService {
|
|||
p['time'] = {"$between": [rangeFrom, rangeTo]}
|
||||
}
|
||||
s['time'] = false
|
||||
let params = new HttpParams()
|
||||
.set('where', JSON.stringify(p))
|
||||
.set('sort', JSON.stringify(s))
|
||||
.set('resample', sampling)
|
||||
.set('format', format)
|
||||
// let params = new HttpParams()
|
||||
// .set('where', JSON.stringify(p))
|
||||
// .set('sort', JSON.stringify(s))
|
||||
// .set('resample', sampling)
|
||||
// .set('format', format)
|
||||
// FIXME: add the name of the value to fetch
|
||||
return this._http.get<Object>(
|
||||
'/api/' + store + '/values/' + value,
|
||||
{
|
||||
params: params,
|
||||
observe: 'response'
|
||||
}
|
||||
)
|
||||
return this.api.getModelValuesApiStoreNameValuesValueGet({
|
||||
storeName: store,
|
||||
value: value,
|
||||
where: JSON.stringify(p),
|
||||
resample: sampling
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,12 @@ export class MeasuresHomeComponent implements OnInit {
|
|||
private router: Router
|
||||
) {}
|
||||
ngOnInit() {
|
||||
const defaultStore = this.configService.conf['measures']['defaultStore']
|
||||
if (defaultStore) {
|
||||
this.router.navigate(['/measures', defaultStore])
|
||||
}
|
||||
this.configService.conf.subscribe(
|
||||
conf => {
|
||||
if (conf.measures) {
|
||||
this.router.navigate(['/measures', conf.measures['defaultStore']])
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
|
@ -3,7 +3,8 @@ import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/ro
|
|||
import { Observable, of, EMPTY, forkJoin } from 'rxjs'
|
||||
import { map, mergeMap, take, first } from 'rxjs/operators'
|
||||
|
||||
import { DataService, MeasuresItem } from '../../_services/data.service'
|
||||
import { DataService } from '../../_services/data.service'
|
||||
import { MeasuresItem } from '../../openapi'
|
||||
|
||||
@Injectable()
|
||||
export class MeasuresListResolver {
|
||||
|
|
|
@ -5,8 +5,9 @@ import { ActivatedRoute, Router, ParamMap } from '@angular/router'
|
|||
import { Observable, of } from 'rxjs'
|
||||
import { map, startWith, switchMap } from 'rxjs/operators'
|
||||
|
||||
import { MeasuresItem, DataService } from '../../_services/data.service'
|
||||
import { DataService } from '../../_services/data.service'
|
||||
import { ConfigService } from '../../config.service'
|
||||
import { MeasuresItem, DataProvider } from '../../openapi'
|
||||
|
||||
@Component({
|
||||
selector: 'gisaf-measures-list',
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<mat-drawer opened=true mode='side'>
|
||||
<mat-list-item *ngFor="let store of stores">
|
||||
<button mat-button
|
||||
matTooltip="{{ store['name'] }}"
|
||||
matTooltip="{{ store.name }}"
|
||||
matTooltipPosition="right"
|
||||
[routerLink]="store['store']" routerLinkActive="active">
|
||||
{{ store['name'] }}
|
||||
[routerLink]="store.store" routerLinkActive="active">
|
||||
{{ store.name }}
|
||||
</button>
|
||||
</mat-list-item>
|
||||
</mat-drawer>
|
||||
|
|
|
@ -7,6 +7,7 @@ import { Observable, of } from 'rxjs'
|
|||
|
||||
import { DataService } from '../_services/data.service'
|
||||
import { ConfigService } from '../config.service'
|
||||
import { DataProvider } from '../openapi'
|
||||
|
||||
@Component({
|
||||
selector: 'gisaf-measures',
|
||||
|
@ -15,7 +16,7 @@ import { ConfigService } from '../config.service'
|
|||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class MeasuresComponent implements OnInit {
|
||||
stores: Array<Object> = []
|
||||
stores: DataProvider[] = []
|
||||
|
||||
constructor(
|
||||
public configService: ConfigService,
|
||||
|
|
|
@ -35,6 +35,7 @@ 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 { MeasuresItem } from './models/MeasuresItem';
|
||||
export type { ModelAction } from './models/ModelAction';
|
||||
export type { ModelInfo } from './models/ModelInfo';
|
||||
export type { ModelValue } from './models/ModelValue';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type DataProvider = {
|
||||
store: string;
|
||||
name: string;
|
||||
values: Array<string>;
|
||||
};
|
||||
|
|
9
src/app/openapi/models/MeasuresItem.ts
Normal file
9
src/app/openapi/models/MeasuresItem.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* generated using openapi-typescript-codegen -- do no edit */
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type MeasuresItem = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
|
@ -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 { MeasuresItem } from '../models/MeasuresItem';
|
||||
import type { ModelInfo } from '../models/ModelInfo';
|
||||
import type { Project } from '../models/Project';
|
||||
import type { RoleRead } from '../models/RoleRead';
|
||||
|
@ -147,6 +148,65 @@ export class ApiService {
|
|||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get Model List
|
||||
* Json REST store API compatible with Flask Potion and Angular
|
||||
* Get the list of items (used for making the list of items in measures)
|
||||
* Filter only items with at least one measure
|
||||
* @returns MeasuresItem Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public getModelListApiDataProviderStoreGet({
|
||||
store,
|
||||
}: {
|
||||
store: string,
|
||||
}): Observable<Array<MeasuresItem>> {
|
||||
return __request(OpenAPI, this.http, {
|
||||
method: 'GET',
|
||||
url: '/api/data-provider/{store}',
|
||||
path: {
|
||||
'store': store,
|
||||
},
|
||||
errors: {
|
||||
404: `Not found`,
|
||||
422: `Validation Error`,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get Model Values
|
||||
* Get values
|
||||
* @returns any Successful Response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public getModelValuesApiStoreNameValuesValueGet({
|
||||
storeName,
|
||||
value,
|
||||
where,
|
||||
resample,
|
||||
}: {
|
||||
storeName: string,
|
||||
value: string,
|
||||
where: string,
|
||||
resample?: (string | null),
|
||||
}): Observable<any> {
|
||||
return __request(OpenAPI, this.http, {
|
||||
method: 'GET',
|
||||
url: '/api/{store_name}/values/{value}',
|
||||
path: {
|
||||
'store_name': storeName,
|
||||
'value': value,
|
||||
},
|
||||
query: {
|
||||
'where': where,
|
||||
'resample': resample,
|
||||
},
|
||||
errors: {
|
||||
404: `Not found`,
|
||||
422: `Validation Error`,
|
||||
},
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get Stores
|
||||
* @returns Store Successful Response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue