Refactor temporallast
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
fad04744cf
commit
214dc3ffa1
@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { IItemType } from '../models/item.type';
|
import { IItemType } from '../models/item.type';
|
||||||
import { IItem } from '../models/item';
|
import { IItem } from '../models/item';
|
||||||
|
import { IJsonline } from '../models/json-line';
|
||||||
import { IItemTask } from '../models/itemTask';
|
import { IItemTask } from '../models/itemTask';
|
||||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||||
import { AppConfig } from "../shared/app.config";
|
import { AppConfig } from "../shared/app.config";
|
||||||
@ -135,7 +136,7 @@ export class ItemService {
|
|||||||
return this.httpClient.post<any>(`${this.ApiEndpoint()}/api/v1/items/delete`, itemCodes);
|
return this.httpClient.post<any>(`${this.ApiEndpoint()}/api/v1/items/delete`, itemCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemporalLast(code: string): Observable<any> {
|
getTemporalLast(code: string): Observable<IJsonline> {
|
||||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/last`);
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/last`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { IJsonline } from '../models/json-line';
|
import { IJsonline } from '../models/json-line';
|
||||||
import { ISenMLItem } from '../models/senml-item';
|
import { ISenMLItem } from '../models/senml-item';
|
||||||
import { IDataLayer } from '../models/data.layer';
|
import { IDataLayer } from '../models/data.layer';
|
||||||
|
import { IItem } from '../models/item';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -10,13 +11,21 @@ export class SenmlService {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getSenMLItem(name:string,jsonLine:IJsonline): ISenMLItem {
|
getSenMLItem(layer:IDataLayer,jsonLine:IJsonline): ISenMLItem {
|
||||||
if (jsonLine) {
|
if (jsonLine) {
|
||||||
var senmlPack = jsonLine.data as ISenMLItem[];
|
var senmlPack = jsonLine.data as ISenMLItem[];
|
||||||
var temp = senmlPack.filter((i) => i.u == name);
|
var temp = senmlPack.filter((i) => i.u == layer.indexKey);
|
||||||
if (temp.length == 1) return temp[0];
|
if (temp.length == 1) return temp[0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFirstLayer(item:IItem):IDataLayer {
|
||||||
|
if(item && item.data && item.data["layers"] && item.data["layers"].length > 0 ) {
|
||||||
|
return item.data["layers"][0] as IDataLayer;
|
||||||
|
} else {
|
||||||
|
let retVal:IDataLayer = { name:"Soil moisture",index:0,scale:1,unit:"%",indexKey:"%vol" };
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user