aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_services
diff options
context:
space:
mode:
authorDanijel Anđelković <adanijel99@gmail.com>2022-04-14 00:16:50 +0200
committerDanijel Anđelković <adanijel99@gmail.com>2022-04-14 00:16:50 +0200
commit8733ac0770aab10231b59d0398acd33765936247 (patch)
tree1d19233278ce9822c13f5482f96c5e52532fc1b7 /frontend/src/app/_services
parent62939a4639c8bef9c520ac0a30613f16a65f4df1 (diff)
Dodao servis za citanje konfiguracije tako da moze da se promeni u buildovanoj angular aplikaciji.
Diffstat (limited to 'frontend/src/app/_services')
-rw-r--r--frontend/src/app/_services/auth.service.ts10
-rw-r--r--frontend/src/app/_services/datasets.service.ts14
-rw-r--r--frontend/src/app/_services/experiments.service.ts6
-rw-r--r--frontend/src/app/_services/models.service.ts19
-rw-r--r--frontend/src/app/_services/predictors.service.ts15
-rw-r--r--frontend/src/app/_services/signal-r.service.ts4
-rw-r--r--frontend/src/app/_services/user-info.service.ts10
7 files changed, 37 insertions, 41 deletions
diff --git a/frontend/src/app/_services/auth.service.ts b/frontend/src/app/_services/auth.service.ts
index e474d436..92cebe7f 100644
--- a/frontend/src/app/_services/auth.service.ts
+++ b/frontend/src/app/_services/auth.service.ts
@@ -2,8 +2,8 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { JwtHelperService } from '@auth0/angular-jwt';
import { CookieService } from 'ngx-cookie-service';
-import API_SETTINGS from '../../config.json';
import shared from '../Shared';
+import { Configuration } from '../configuration.service';
const jwtHelper = new JwtHelperService();
@@ -17,15 +17,15 @@ export class AuthService {
constructor(private http: HttpClient, private cookie: CookieService) { }
login(username: string, password: string) {
- return this.http.post(`${API_SETTINGS.apiURL}/auth/login`, { username, password }, { responseType: 'text' });
+ return this.http.post(`${Configuration.settings.apiURL}/auth/login`, { username, password }, { responseType: 'text' });
}
register(user: any) {
- return this.http.post(`${API_SETTINGS.apiURL}/auth/register`, { ...user }, { responseType: 'text' });
+ return this.http.post(`${Configuration.settings.apiURL}/auth/register`, { ...user }, { responseType: 'text' });
}
getGuestToken() {
- return this.http.post(`${API_SETTINGS.apiURL}/auth/guestToken`, {}, { responseType: 'text' });
+ return this.http.post(`${Configuration.settings.apiURL}/auth/guestToken`, {}, { responseType: 'text' });
}
isAuthenticated(): boolean {
@@ -52,7 +52,7 @@ export class AuthService {
var username = property['name'];
if (username != "") {
this.refresher = setTimeout(() => {
- this.http.post(`${API_SETTINGS.apiURL}/auth/renewJwt`, {}, { headers: this.authHeader(), responseType: 'text' }).subscribe((response) => {
+ this.http.post(`${Configuration.settings.apiURL}/auth/renewJwt`, {}, { headers: this.authHeader(), responseType: 'text' }).subscribe((response) => {
this.authenticate(response);
});
}, exp.getTime() - new Date().getTime() - 60000);
diff --git a/frontend/src/app/_services/datasets.service.ts b/frontend/src/app/_services/datasets.service.ts
index 9a718e7c..c3281be6 100644
--- a/frontend/src/app/_services/datasets.service.ts
+++ b/frontend/src/app/_services/datasets.service.ts
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
-import API_SETTINGS from '../../config.json';
+import { Configuration } from '../configuration.service';
import Dataset from '../_data/Dataset';
import { AuthService } from './auth.service';
@@ -13,26 +13,26 @@ export class DatasetsService {
constructor(private http: HttpClient, private authService: AuthService) { }
getPublicDatasets(): Observable<Dataset[]> {
- return this.http.get<Dataset[]>(`${API_SETTINGS.apiURL}/dataset/publicdatasets`, { headers: this.authService.authHeader() });
+ return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/publicdatasets`, { headers: this.authService.authHeader() });
}
getMyDatasets(): Observable<Dataset[]> {
- return this.http.get<Dataset[]>(`${API_SETTINGS.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });
+ return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });
}
addDataset(dataset: Dataset): Observable<any> {
- return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
+ return this.http.post(`${Configuration.settings.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
}
getDatasetFile(fileId: any): any {
- return this.http.get(`${API_SETTINGS.apiURL}/file/csvRead/true/${fileId}`, { headers: this.authService.authHeader(), responseType: 'text' });
+ return this.http.get(`${Configuration.settings.apiURL}/file/csvRead/true/${fileId}`, { headers: this.authService.authHeader(), responseType: 'text' });
}
editDataset(dataset: Dataset): Observable<Dataset> {
- return this.http.put<Dataset>(`${API_SETTINGS.apiURL}/dataset/`, dataset, { headers: this.authService.authHeader() });
+ return this.http.put<Dataset>(`${Configuration.settings.apiURL}/dataset/`, dataset, { headers: this.authService.authHeader() });
}
deleteDataset(dataset: Dataset) {
- return this.http.delete(`${API_SETTINGS.apiURL}/dataset/` + dataset.name, { headers: this.authService.authHeader(), responseType: "text" });
+ return this.http.delete(`${Configuration.settings.apiURL}/dataset/` + dataset.name, { headers: this.authService.authHeader(), responseType: "text" });
}
}
diff --git a/frontend/src/app/_services/experiments.service.ts b/frontend/src/app/_services/experiments.service.ts
index 7462cd14..0d0d372b 100644
--- a/frontend/src/app/_services/experiments.service.ts
+++ b/frontend/src/app/_services/experiments.service.ts
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
-import API_SETTINGS from '../../config.json';
+import { Configuration } from '../configuration.service';
import Experiment from '../_data/Experiment';
import { AuthService } from './auth.service';
@@ -13,10 +13,10 @@ export class ExperimentsService {
constructor(private http: HttpClient, private authService: AuthService) { }
addExperiment(experiment: Experiment): Observable<any> {
- return this.http.post(`${API_SETTINGS.apiURL}/experiment/add`, experiment, { headers: this.authService.authHeader() });
+ return this.http.post(`${Configuration.settings.apiURL}/experiment/add`, experiment, { headers: this.authService.authHeader() });
}
getMyExperiments(): Observable<Experiment[]> {
- return this.http.get<Experiment[]>(`${API_SETTINGS.apiURL}/experiment/getmyexperiments`, { headers: this.authService.authHeader() });
+ return this.http.get<Experiment[]>(`${Configuration.settings.apiURL}/experiment/getmyexperiments`, { headers: this.authService.authHeader() });
}
}
diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts
index 1314589a..44383828 100644
--- a/frontend/src/app/_services/models.service.ts
+++ b/frontend/src/app/_services/models.service.ts
@@ -2,10 +2,9 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import Model from '../_data/Model';
import { AuthService } from './auth.service';
-import API_SETTINGS from '../../config.json';
import { Observable } from 'rxjs';
import Dataset from '../_data/Dataset';
-
+import { Configuration } from '../configuration.service';
@Injectable({
providedIn: 'root'
@@ -26,32 +25,32 @@ export class ModelsService {
headers: this.authService.authHeader()
};
- return this.http.post(`${API_SETTINGS.apiURL}/file/csv`, formData, options);
+ return this.http.post(`${Configuration.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() });
+ return this.http.post(`${Configuration.settings.apiURL}/model/add`, model, { headers: this.authService.authHeader() });
}
addDataset(dataset: Dataset): Observable<any> {
- return this.http.post(`${API_SETTINGS.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
+ return this.http.post(`${Configuration.settings.apiURL}/dataset/add`, dataset, { headers: this.authService.authHeader() });
}
trainModel(modelId: string, experimentId: string): Observable<any> {
- return this.http.post(`${API_SETTINGS.apiURL}/model/trainmodel`, { ModelId: modelId, ExperimentId: experimentId }, { headers: this.authService.authHeader(), responseType: 'text' });
+ return this.http.post(`${Configuration.settings.apiURL}/model/trainmodel`, { ModelId: modelId, ExperimentId: experimentId }, { headers: this.authService.authHeader(), responseType: 'text' });
}
getMyDatasets(): Observable<Dataset[]> {
- return this.http.get<Dataset[]>(`${API_SETTINGS.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });
+ return this.http.get<Dataset[]>(`${Configuration.settings.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });
}
getMyModels(): Observable<Model[]> {
- return this.http.get<Model[]>(`${API_SETTINGS.apiURL}/model/mymodels`, { headers: this.authService.authHeader() });
+ return this.http.get<Model[]>(`${Configuration.settings.apiURL}/model/mymodels`, { headers: this.authService.authHeader() });
}
editModel(model: Model): Observable<Model> {
- return this.http.put<Model>(`${API_SETTINGS.apiURL}/model/`, model, { headers: this.authService.authHeader() });
+ return this.http.put<Model>(`${Configuration.settings.apiURL}/model/`, model, { headers: this.authService.authHeader() });
}
deleteModel(model: Model) {
- return this.http.delete(`${API_SETTINGS.apiURL}/model/` + model.name, { headers: this.authService.authHeader(), responseType: "text" });
+ return this.http.delete(`${Configuration.settings.apiURL}/model/` + model.name, { headers: this.authService.authHeader(), responseType: "text" });
}
}
diff --git a/frontend/src/app/_services/predictors.service.ts b/frontend/src/app/_services/predictors.service.ts
index 909d1a49..9e8383aa 100644
--- a/frontend/src/app/_services/predictors.service.ts
+++ b/frontend/src/app/_services/predictors.service.ts
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
-import API_SETTINGS from '../../config.json';
+import { Configuration } from '../configuration.service';
import Predictor from '../_data/Predictor';
import { Column } from '../_pages/predict/predict.component';
import { AuthService } from './auth.service';
@@ -10,27 +10,24 @@ import { AuthService } from './auth.service';
providedIn: 'root'
})
export class PredictorsService {
-
-
-
constructor(private http: HttpClient, private authService: AuthService) { }
getPublicPredictors(): Observable<Predictor[]> {
- return this.http.get<Predictor[]>(`${API_SETTINGS.apiURL}/predictor/publicpredictors`, { headers: this.authService.authHeader() });
+ return this.http.get<Predictor[]>(`${Configuration.settings.apiURL}/predictor/publicpredictors`, { headers: this.authService.authHeader() });
}
getPredictor(id: String): Observable<Predictor> {
- return this.http.get<Predictor>(`${API_SETTINGS.apiURL}/predictor/getpredictor/` + id, { headers: this.authService.authHeader() });
+ return this.http.get<Predictor>(`${Configuration.settings.apiURL}/predictor/getpredictor/` + id, { headers: this.authService.authHeader() });
}
usePredictor(predictor: Predictor, inputs: Column[]) {
- return this.http.post(`${API_SETTINGS.apiURL}/predictor/usepredictor/` + predictor._id, inputs, { headers: this.authService.authHeader() });
+ return this.http.post(`${Configuration.settings.apiURL}/predictor/usepredictor/` + predictor._id, inputs, { headers: this.authService.authHeader() });
}
deletePredictor(predictor: Predictor) {
- return this.http.delete(`${API_SETTINGS.apiURL}/predictor/` + predictor.name, { headers: this.authService.authHeader(), responseType: "text" });
+ return this.http.delete(`${Configuration.settings.apiURL}/predictor/` + predictor.name, { headers: this.authService.authHeader(), responseType: "text" });
}
getMyPredictors(): Observable<Predictor[]> {
- return this.http.get<Predictor[]>(`${API_SETTINGS.apiURL}/predictor/mypredictors`, { headers: this.authService.authHeader() });
+ return this.http.get<Predictor[]>(`${Configuration.settings.apiURL}/predictor/mypredictors`, { headers: this.authService.authHeader() });
}
}
diff --git a/frontend/src/app/_services/signal-r.service.ts b/frontend/src/app/_services/signal-r.service.ts
index 2a6e5d78..b279b5ca 100644
--- a/frontend/src/app/_services/signal-r.service.ts
+++ b/frontend/src/app/_services/signal-r.service.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import * as signalR from "@microsoft/signalr";
-import Shared from '../Shared';
import { CookieService } from 'ngx-cookie-service';
+import { Configuration } from '../configuration.service';
@Injectable({
providedIn: 'root'
})
@@ -10,7 +10,7 @@ export class SignalRService {
public startConnection = () => {
this.hubConnection = new signalR.HubConnectionBuilder()
- .withUrl('http://localhost:5283/chatHub', {
+ .withUrl(Configuration.settings.apiWSUrl, {
accessTokenFactory: () => this.cookie.get("token"),
withCredentials: false
}).build();
diff --git a/frontend/src/app/_services/user-info.service.ts b/frontend/src/app/_services/user-info.service.ts
index 16fc90a2..5d3394f6 100644
--- a/frontend/src/app/_services/user-info.service.ts
+++ b/frontend/src/app/_services/user-info.service.ts
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
-import API_SETTINGS from '../../config.json';
+import { Configuration } from '../configuration.service';
import User from '../_data/User';
import { AuthService } from './auth.service';
@@ -13,18 +13,18 @@ export class UserInfoService {
constructor(private http: HttpClient, private authService: AuthService) { }
getUserInfo(): Observable<User> {
- return this.http.get<User>(`${API_SETTINGS.apiURL}/user/myprofile`, { headers: this.authService.authHeader() });
+ return this.http.get<User>(`${Configuration.settings.apiURL}/user/myprofile`, { headers: this.authService.authHeader() });
}
changeUserInfo(user: User): any {
- return this.http.put(`${API_SETTINGS.apiURL}/user/changeinfo`, user, { headers: this.authService.authHeader() });
+ return this.http.put(`${Configuration.settings.apiURL}/user/changeinfo`, user, { headers: this.authService.authHeader() });
}
changeUserPassword(passwordArray: string[]): any {
- return this.http.put(`${API_SETTINGS.apiURL}/user/changepass`, passwordArray, { headers: this.authService.authHeader(), responseType: 'text' });
+ return this.http.put(`${Configuration.settings.apiURL}/user/changepass`, passwordArray, { headers: this.authService.authHeader(), responseType: 'text' });
}
deleteUser(): any {
- return this.http.delete(`${API_SETTINGS.apiURL}/user/deleteprofile`, { headers: this.authService.authHeader() });
+ return this.http.delete(`${Configuration.settings.apiURL}/user/deleteprofile`, { headers: this.authService.authHeader() });
}
}