1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Configuration } from './configuration.service';
import Dataset from '../_data/Dataset';
import { AuthService } from './auth.service';
@Injectable({
providedIn: 'root'
})
export class DatasetsService {
constructor(private http: HttpClient, private authService: AuthService) { }
uploadData(file: File): Observable<any> {
let formData = new FormData();
formData.append('file', file, file.name);
let params = new HttpParams();
const options = {
params: params,
reportProgress: false,
headers: this.authService.authHeader()
};
return this.http.post(`${Configuration.settings.apiURL}/file/csv`, formData, options);
}
getPublicDatasets(): Observable<Dataset[]> {
return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/publicdatasets`, { headers: this.authService.authHeader() });
}
getMyDatasets(): Observable<Dataset[]> {
return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });
}
addDataset(dataset: Dataset): Observable<any> {
return this.http.post(`${Configuration.settings.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
}
stealDataset(dataset: Dataset): Observable<any> {
return this.http.post(`${Configuration.settings.apiURL}/dataset/stealDs`, dataset, { headers: this.authService.authHeader() });
}
getDatasetFile(fileId: any): any {
return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/-1/11`, { headers: this.authService.authHeader(), responseType: 'text' });
}
getDatasetFilePaging(fileId: any, begin: any, end: any) {
return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/${begin}/${end}`, { headers: this.authService.authHeader(), responseType: 'text' });
}
getDatasetHeader(fileId: any) {
return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/-1/1`, { headers: this.authService.authHeader(), responseType: 'text' });
}
getDatasetFilePartial(fileId: any, startRow: number, rowNum: number): Observable<any> {
return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/${fileId}/${startRow}/${rowNum}`, { headers: this.authService.authHeader(), responseType: 'text' });
}
getDatasetById(datasetId: string): Observable<Dataset> {
return this.http.get<Dataset>(`${Configuration.settings.apiURL}/dataset/get/${datasetId}`, { headers: this.authService.authHeader() });
}
editDataset(dataset: Dataset) {
return this.http.put(`${Configuration.settings.apiURL}/dataset/` + dataset._id, dataset, { headers: this.authService.authHeader(), responseType: 'text' });
}
deleteDataset(dataset: Dataset) {
return this.http.delete(`${Configuration.settings.apiURL}/dataset/` + dataset._id, { headers: this.authService.authHeader(), responseType: "text" });
}
downloadFile(id: string): Observable<Blob> {
return this.http.get(`${Configuration.settings.apiURL}/file/Download?id=` + id, { headers: this.authService.authHeader(), responseType: 'blob' });
}
updateDatasetAccessibleByLink(id: string, acessibleByLink: boolean) {
return this.http.put(`${Configuration.settings.apiURL}/dataset/updateAccessibleByLink/` + id, acessibleByLink, { headers: this.authService.authHeader(), responseType: 'text' });
}
updateDatasetIsPublic(id: string, isPublic: boolean) {
return this.http.put(`${Configuration.settings.apiURL}/dataset/updateIsPublic/` + id, isPublic, { headers: this.authService.authHeader(), responseType: 'text' });
}
}
|