diff options
Diffstat (limited to 'frontend/src/app/_services')
-rw-r--r-- | frontend/src/app/_services/models.service.ts | 2 | ||||
-rw-r--r-- | frontend/src/app/_services/user-info.service.spec.ts | 16 | ||||
-rw-r--r-- | frontend/src/app/_services/user-info.service.ts | 26 |
3 files changed, 43 insertions, 1 deletions
diff --git a/frontend/src/app/_services/models.service.ts b/frontend/src/app/_services/models.service.ts index 30d63956..f629fd2a 100644 --- a/frontend/src/app/_services/models.service.ts +++ b/frontend/src/app/_services/models.service.ts @@ -40,6 +40,6 @@ export class ModelsService { } getMyDatasets(): Observable<Dataset[]> { - return this.http.get<Dataset[]>(`${API_SETTINGS.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() });//responsetype text da l treba?? + return this.http.get<Dataset[]>(`${API_SETTINGS.apiURL}/dataset/mydatasets`, { headers: this.authService.authHeader() }); } } diff --git a/frontend/src/app/_services/user-info.service.spec.ts b/frontend/src/app/_services/user-info.service.spec.ts new file mode 100644 index 00000000..a181223a --- /dev/null +++ b/frontend/src/app/_services/user-info.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { UserInfoService } from './user-info.service'; + +describe('UserInfoService', () => { + let service: UserInfoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(UserInfoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/_services/user-info.service.ts b/frontend/src/app/_services/user-info.service.ts new file mode 100644 index 00000000..b66a73e1 --- /dev/null +++ b/frontend/src/app/_services/user-info.service.ts @@ -0,0 +1,26 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { API_SETTINGS } from 'src/config'; +import User from '../_data/User'; +import { AuthService } from './auth.service'; + +@Injectable({ + providedIn: 'root' +}) +export class UserInfoService { + + constructor(private http: HttpClient, private authService: AuthService) { } + + getUsersInfo(): Observable<User> { + return this.http.get<User>(`${API_SETTINGS.apiURL}/user/myprofile`, { headers: this.authService.authHeader() }); + } + + changeUserInfo(user: User): any { + return this.http.put(`${API_SETTINGS.apiURL}/user/${user._id}`, user, { headers: this.authService.authHeader() }); + } + + changeUserPassword(oldPassword: string, newPassword: string): Observable<User> { + return this.http.put<User>(`${API_SETTINGS.apiURL}/user/`, { oldPassword, newPassword }, { headers: this.authService.authHeader() }); + } +} |