aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_services
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_services')
-rw-r--r--frontend/src/app/_services/auth.service.ts3
-rw-r--r--frontend/src/app/_services/models.service.ts30
2 files changed, 25 insertions, 8 deletions
diff --git a/frontend/src/app/_services/auth.service.ts b/frontend/src/app/_services/auth.service.ts
index afc1567b..20ff45f3 100644
--- a/frontend/src/app/_services/auth.service.ts
+++ b/frontend/src/app/_services/auth.service.ts
@@ -46,7 +46,7 @@ export class AuthService {
this.http.post(`${API_SETTINGS.apiURL}/auth/renewJwt`, {}, { headers: this.authHeader(), responseType: 'text' }).subscribe((response) => {
this.authenticate(response);
});
- }, exp.getTime() - new Date().getTime());
+ }, exp.getTime() - new Date().getTime() - 60000);
}
authenticate(token: string) {
@@ -62,6 +62,7 @@ export class AuthService {
if (this.cookie.check('token')) {
const token = this.cookie.get('token');
this.shared.loggedIn = this.isAuthenticated();
+ this.shared.username = jwtHelper.decodeToken(token).name;
this.enableAutoRefresh();
}
}
diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts
index 80dc1ae3..8299016b 100644
--- a/frontend/src/app/_services/models.service.ts
+++ b/frontend/src/app/_services/models.service.ts
@@ -1,9 +1,10 @@
-import { HttpClient } from '@angular/common/http';
+import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import Model from '../_data/Model';
import { AuthService } from './auth.service';
import { API_SETTINGS } from 'src/config';
import Dataset from '../_data/Dataset';
+import { Observable } from 'rxjs';
@Injectable({
@@ -13,13 +14,28 @@ export class ModelsService {
constructor(private http: HttpClient, private authService: AuthService) { }
- addModel(model: Model) {
- return this.http.post(`${API_SETTINGS.apiURL}/model/add`, model, { headers: this.authService.authHeader(), responseType: 'text' });
+ 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(`${API_SETTINGS.apiURL}/file/csv`, formData, options);
+ }
+
+ addModel(model: Model): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/model/add`, model, { headers: this.authService.authHeader() });
}
- addDataset(dataset: Dataset) {
- return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader(), responseType: 'text' });
+ addDataset(dataset: Dataset): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
}
- trainModel(modelId: string) {
- return this.http.post(`${API_SETTINGS.apiURL}/model/train`, modelId, { headers: this.authService.authHeader(), responseType: 'text' });
+ trainModel(modelId: string): Observable<any> {
+ return this.http.post(`${API_SETTINGS.apiURL}/model/train`, modelId, { headers: this.authService.authHeader() });
}
}