Refactor to range requests
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2021-02-02 17:09:03 +01:00
parent f26ececb9b
commit cb222770d8

View File

@ -5,7 +5,7 @@ import { IItemType } from '../models/item.type';
import { IItem } from '../models/item'; import { IItem } from '../models/item';
import { IJsonline } from '../models/json-line'; 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,HttpHeaders } from "@angular/common/http";
import { AppConfig } from "../shared/app.config"; import { AppConfig } from "../shared/app.config";
import {ItemTypeService} from './itemtype.service'; import {ItemTypeService} from './itemtype.service';
@ -61,10 +61,10 @@ export class ItemService {
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`); return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`);
} }
getItemData(code: string,limit?:number): Observable<ArrayBuffer> { getItemData(code: string,start?:number,size?:number): Observable<ArrayBuffer> {
var params = new HttpParams(); var headers = new HttpHeaders();
if(limit) params=params.append("limit", limit.toString()); if(start && size) headers=headers.append("Range",`bytes=${start}-${size-1}`);
return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/data`,{ params: params,responseType: 'arraybuffer' }); return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/data`,{ headers: headers,responseType: 'arraybuffer' });
} }
getItemByCodeAndType(code: string, itemType: string): Observable<IItem> { getItemByCodeAndType(code: string, itemType: string): Observable<IItem> {