Update fix measures (WIP)
This commit is contained in:
parent
5f97c58b52
commit
ccf6cfd6e8
10 changed files with 118 additions and 42 deletions
src/app
|
@ -3,18 +3,20 @@ import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { map } from 'rxjs/operators'
|
import { map } from 'rxjs/operators'
|
||||||
|
|
||||||
export class MeasuresItem {
|
import { ApiService, DataProvider, MeasuresItem } from '../openapi'
|
||||||
constructor(
|
|
||||||
public $uri: string,
|
// export class MeasuresItem {
|
||||||
public caption: string,
|
// constructor(
|
||||||
) {}
|
// public $uri: string,
|
||||||
get id(): string {
|
// public caption: string,
|
||||||
return this.$uri.substr(this.$uri.lastIndexOf('/') + 1)
|
// ) {}
|
||||||
}
|
// get id(): string {
|
||||||
get name(): string {
|
// return this.$uri.substr(this.$uri.lastIndexOf('/') + 1)
|
||||||
return this.caption || this.id
|
// }
|
||||||
}
|
// get name(): string {
|
||||||
}
|
// return this.caption || this.id
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
export class MeasuresItemsList {
|
export class MeasuresItemsList {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -25,18 +27,16 @@ export class MeasuresItemsList {
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DataService {
|
export class DataService {
|
||||||
constructor(private _http: HttpClient){ }
|
constructor(
|
||||||
|
public api: ApiService,
|
||||||
|
) {}
|
||||||
|
|
||||||
getResources(): Observable<Object[]> {
|
getResources(): Observable<DataProvider[]> {
|
||||||
return this._http.get<Object[]>('/api/list')
|
return this.api.listDataProvidersApiDataProvidersGet()
|
||||||
}
|
}
|
||||||
|
|
||||||
getList(store: string): Observable<MeasuresItem[]> {
|
getList(store: string): Observable<MeasuresItem[]> {
|
||||||
return this._http.get<MeasuresItem[]>('/api/' + store).pipe(
|
return this.api.getModelListApiDataProviderStoreGet({store: store})
|
||||||
map(res => res.map(
|
|
||||||
item => new MeasuresItem(item['$uri'], item['caption'])
|
|
||||||
))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getValues(
|
getValues(
|
||||||
|
@ -55,18 +55,17 @@ export class DataService {
|
||||||
p['time'] = {"$between": [rangeFrom, rangeTo]}
|
p['time'] = {"$between": [rangeFrom, rangeTo]}
|
||||||
}
|
}
|
||||||
s['time'] = false
|
s['time'] = false
|
||||||
let params = new HttpParams()
|
// let params = new HttpParams()
|
||||||
.set('where', JSON.stringify(p))
|
// .set('where', JSON.stringify(p))
|
||||||
.set('sort', JSON.stringify(s))
|
// .set('sort', JSON.stringify(s))
|
||||||
.set('resample', sampling)
|
// .set('resample', sampling)
|
||||||
.set('format', format)
|
// .set('format', format)
|
||||||
// FIXME: add the name of the value to fetch
|
// FIXME: add the name of the value to fetch
|
||||||
return this._http.get<Object>(
|
return this.api.getModelValuesApiStoreNameValuesValueGet({
|
||||||
'/api/' + store + '/values/' + value,
|
storeName: store,
|
||||||
{
|
value: value,
|
||||||
params: params,
|
where: JSON.stringify(p),
|
||||||
observe: 'response'
|
resample: sampling
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,12 @@ export class MeasuresHomeComponent implements OnInit {
|
||||||
private router: Router
|
private router: Router
|
||||||
) {}
|
) {}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const defaultStore = this.configService.conf['measures']['defaultStore']
|
this.configService.conf.subscribe(
|
||||||
if (defaultStore) {
|
conf => {
|
||||||
this.router.navigate(['/measures', defaultStore])
|
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 { Observable, of, EMPTY, forkJoin } from 'rxjs'
|
||||||
import { map, mergeMap, take, first } from 'rxjs/operators'
|
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()
|
@Injectable()
|
||||||
export class MeasuresListResolver {
|
export class MeasuresListResolver {
|
||||||
|
|
|
@ -5,8 +5,9 @@ import { ActivatedRoute, Router, ParamMap } from '@angular/router'
|
||||||
import { Observable, of } from 'rxjs'
|
import { Observable, of } from 'rxjs'
|
||||||
import { map, startWith, switchMap } from 'rxjs/operators'
|
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 { ConfigService } from '../../config.service'
|
||||||
|
import { MeasuresItem, DataProvider } from '../../openapi'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gisaf-measures-list',
|
selector: 'gisaf-measures-list',
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<mat-drawer opened=true mode='side'>
|
<mat-drawer opened=true mode='side'>
|
||||||
<mat-list-item *ngFor="let store of stores">
|
<mat-list-item *ngFor="let store of stores">
|
||||||
<button mat-button
|
<button mat-button
|
||||||
matTooltip="{{ store['name'] }}"
|
matTooltip="{{ store.name }}"
|
||||||
matTooltipPosition="right"
|
matTooltipPosition="right"
|
||||||
[routerLink]="store['store']" routerLinkActive="active">
|
[routerLink]="store.store" routerLinkActive="active">
|
||||||
{{ store['name'] }}
|
{{ store.name }}
|
||||||
</button>
|
</button>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Observable, of } from 'rxjs'
|
||||||
|
|
||||||
import { DataService } from '../_services/data.service'
|
import { DataService } from '../_services/data.service'
|
||||||
import { ConfigService } from '../config.service'
|
import { ConfigService } from '../config.service'
|
||||||
|
import { DataProvider } from '../openapi'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'gisaf-measures',
|
selector: 'gisaf-measures',
|
||||||
|
@ -15,7 +16,7 @@ import { ConfigService } from '../config.service'
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MeasuresComponent implements OnInit {
|
export class MeasuresComponent implements OnInit {
|
||||||
stores: Array<Object> = []
|
stores: DataProvider[] = []
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public configService: ConfigService,
|
public configService: ConfigService,
|
||||||
|
|
|
@ -35,6 +35,7 @@ export type { Map } from './models/Map';
|
||||||
export type { MapInitData } from './models/MapInitData';
|
export type { MapInitData } from './models/MapInitData';
|
||||||
export type { MaplibreStyle } from './models/MaplibreStyle';
|
export type { MaplibreStyle } from './models/MaplibreStyle';
|
||||||
export type { Measures } from './models/Measures';
|
export type { Measures } from './models/Measures';
|
||||||
|
export type { MeasuresItem } from './models/MeasuresItem';
|
||||||
export type { ModelAction } from './models/ModelAction';
|
export type { ModelAction } from './models/ModelAction';
|
||||||
export type { ModelInfo } from './models/ModelInfo';
|
export type { ModelInfo } from './models/ModelInfo';
|
||||||
export type { ModelValue } from './models/ModelValue';
|
export type { ModelValue } from './models/ModelValue';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export type DataProvider = {
|
export type DataProvider = {
|
||||||
|
store: string;
|
||||||
name: string;
|
name: string;
|
||||||
values: Array<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 { CategoryRead } from '../models/CategoryRead';
|
||||||
import type { DataProvider } from '../models/DataProvider';
|
import type { DataProvider } from '../models/DataProvider';
|
||||||
import type { FeatureInfo } from '../models/FeatureInfo';
|
import type { FeatureInfo } from '../models/FeatureInfo';
|
||||||
|
import type { MeasuresItem } from '../models/MeasuresItem';
|
||||||
import type { ModelInfo } from '../models/ModelInfo';
|
import type { ModelInfo } from '../models/ModelInfo';
|
||||||
import type { Project } from '../models/Project';
|
import type { Project } from '../models/Project';
|
||||||
import type { RoleRead } from '../models/RoleRead';
|
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
|
* Get Stores
|
||||||
* @returns Store Successful Response
|
* @returns Store Successful Response
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue