aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/app/_elements/form-dataset/form-dataset.component.ts4
-rw-r--r--frontend/src/app/_services/datasets.service.ts29
-rw-r--r--frontend/src/app/_services/models.service.ts15
3 files changed, 24 insertions, 24 deletions
diff --git a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
index 1a29f74e..8714ae7f 100644
--- a/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
+++ b/frontend/src/app/_elements/form-dataset/form-dataset.component.ts
@@ -89,7 +89,7 @@ export class FormDatasetComponent {
update() {
this.firstInput = true;
- if (this.files.length < 1){
+ if (this.files.length < 1) {
this.loadExisting();
return;
}
@@ -158,7 +158,7 @@ export class FormDatasetComponent {
return;
}
- return this.modelsService.uploadData(this.files[0]).subscribe((file) => {
+ return this.datasetsService.uploadData(this.files[0]).subscribe((file) => {
this.dataset._id = "";
this.dataset.fileId = file._id;
this.dataset.uploaderId = shared.userId;
diff --git a/frontend/src/app/_services/datasets.service.ts b/frontend/src/app/_services/datasets.service.ts
index 2775613c..42fa5e55 100644
--- a/frontend/src/app/_services/datasets.service.ts
+++ b/frontend/src/app/_services/datasets.service.ts
@@ -1,4 +1,4 @@
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Configuration } from './configuration.service';
@@ -12,6 +12,21 @@ 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() });
}
@@ -31,10 +46,10 @@ export class DatasetsService {
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){
+ 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){
+ 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> {
@@ -44,15 +59,15 @@ export class DatasetsService {
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'});
+ 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' });
+ downloadFile(id: string): Observable<Blob> {
+ return this.http.get(`${Configuration.settings.apiURL}/file/Download?id=` + id, { headers: this.authService.authHeader(), responseType: 'blob' });
}
}
diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts
index 2b8fe8f2..016fa9bc 100644
--- a/frontend/src/app/_services/models.service.ts
+++ b/frontend/src/app/_services/models.service.ts
@@ -13,21 +13,6 @@ export class ModelsService {
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);
- }
-
addModel(model: Model): Observable<any> {
return this.http.post(`${Configuration.settings.apiURL}/model/add`, model, { headers: this.authService.authHeader() });
}