src.app.core.services.dataset.service.ts Maven / Gradle / Ivy
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from '@env/environment';
import { Dataset, KeyValue } from '@model';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class DataSetService {
private resourceUrl = '/api/v1/datasets';
constructor(private httpClient: HttpClient) { }
findAll(): Observable> {
return this.httpClient.get>(environment.backend + this.resourceUrl)
.pipe(map((res: Array) => {
res = res.map(dto => new Dataset(
dto.name,
dto.description,
dto.tags,
dto.lastUpdated,
[],
[],
dto.version,
dto.id
));
return res;
}));
}
findById(id: string): Observable {
return this.httpClient.get(environment.backend + this.resourceUrl + '/' + id)
.pipe(
map(dto => this.fromDto(dto))
);
}
save(dataset: Dataset): Observable {
if (dataset.id && dataset.id.length > 0) {
return this.httpClient.put(environment.backend + this.resourceUrl, dataset)
.pipe(
map(dto => this.fromDto(dto))
);
} else {
return this.httpClient.post(environment.backend + this.resourceUrl, dataset)
.pipe(
map(dto => this.fromDto(dto))
);
}
}
delete(id: String): Observable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy