Refactor Date to string
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit

This commit is contained in:
Willem Dantuma
2020-07-07 09:24:45 +02:00
parent 263fb6c3d4
commit 4af6b2937c
9 changed files with 30 additions and 48 deletions

View File

@@ -15,10 +15,10 @@ export class Item implements IItem {
public geometry?:any;
public url?: string;
public name?: string;
public created?: Date;
public updated?: Date;
public dataDate?: Date;
public dataEndDate?: Date;
public created?: string;
public updated?: string;
public dataDate?: string;
public dataEndDate?: string;
public itemType?: string;
public sourceTask?: string;
public size?: number;

View File

@@ -2,10 +2,10 @@ export interface IListItem {
url?: string;
code?: string;
name?: string;
created?: Date;
updated?: Date;
dataDate?: Date;
dataEndDate?: Date;
created?: string;
updated?: string;
dataDate?: string;
dataEndDate?: string;
itemType?: string;
sourceTask?: string;
size?: number;

View File

@@ -18,40 +18,32 @@ export class FolderService {
return this.appConfig.getConfig("apiEndPoint");
}
parseDates(item: any): IListItem {
item.created = new Date(Date.parse(item.created));
item.updated = new Date(Date.parse(item.updated));
item.dataDate = new Date(Date.parse(item.dataDate));
item.dataEndDate = new Date(Date.parse(item.dataEndDate));
return item;
}
getFolder(code: string): Observable<IListItem> {
return this.httpClient.get<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/${code}`).pipe(map(i => this.parseDates(i)));
getFolder(code: string): Observable<IListItem> {
return this.httpClient.get<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/${code}`);
}
getMyRoots(): Observable<IListItem[]> {
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/my_roots`).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/my_roots`);
}
getFolderParents(code: string): Observable<IListItem[]> {
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`);
}
getChildFolders(code: string): Observable<IListItem[]> {
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`);
}
getItems(code: string,skip:number, take:number): Observable<IListItem[]> {
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`);
}
moveItem(itemCode: string, newParentCode: string): Observable<IListItem> {
const body = { itemCode: itemCode,newParentCode: newParentCode };
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/items/move`, body).pipe(map(i => this.parseDates(i)));
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/items/move`, body);
}
createFolder(folder: IItem): Observable<IListItem> {
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/`, folder).pipe(map(i => this.parseDates(i)));
return this.httpClient.post<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/`, folder);
}
}

View File

@@ -20,14 +20,6 @@ export class ItemService {
return this.appConfig.getConfig("apiEndPoint");
}
parseDates(item: any): IItem {
item.created = new Date(Date.parse(item.created));
item.updated = new Date(Date.parse(item.updated));
item.dataDate = new Date(Date.parse(item.dataDate));
item.dataEndDate = new Date(Date.parse(item.dataEndDate));
return item;
}
getItemTypes(): Observable<{ [id: string]: IItemType }> {
return this.httpClient.get<{ [id: string]: IItemType }>(`${this.ApiEndpoint()}/api/v1/itemtypes/`);
}
@@ -60,7 +52,7 @@ export class ItemService {
}
getItem(code: string): Observable<IItem> {
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`).pipe(map(i => this.parseDates(i)));
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`);
}
getItemByCodeAndType(code: string, itemType: string): Observable<IItem> {
@@ -74,7 +66,7 @@ export class ItemService {
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
if(indexed) params = params.append("ind",indexed?"true":"false");
if(level) params = params.append("lvl", level.toFixed());
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params });
}
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level: number = 1, deep: boolean = true): Observable<IItem[]> {
@@ -87,7 +79,7 @@ export class ItemService {
}
params = params.append("lvl", level.toString());
params = params.append("deep", deep.toString());
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
}
getChildItemListCount(parentcode: string, itemType: string): Observable<Number> {
@@ -105,7 +97,7 @@ export class ItemService {
params = params.append("df", JSON.stringify(dataFilter));
}
params = params.append("lvl", level.toString());
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
}
getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable<any> {
@@ -154,6 +146,6 @@ export class ItemService {
getItemTaskList(itemcode: string, unfinishedOnly?: boolean): Observable<IItemTask[]> {
var params = new HttpParams();
if (unfinishedOnly) params = params.append("unfinishedOnly", unfinishedOnly.toString());
return this.httpClient.get<IItemTask[]>(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i))));
return this.httpClient.get<IItemTask[]>(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params });
}
}