commit d2799ca5d3d53e8717fef1307307c49c2b28fb6c
Author: Jakub Danek <jakub.danek@yoso.fi>
Date:   Thu Oct 10 15:43:05 2019 +0200

    re #37 make UI compatible with new User controller API

diff --git a/webapp/src/app/dashboard/dashboard.component.ts b/webapp/src/app/dashboard/dashboard.component.ts
index ed9248a..7e89a35 100644
--- a/webapp/src/app/dashboard/dashboard.component.ts
+++ b/webapp/src/app/dashboard/dashboard.component.ts
@@ -36,7 +36,7 @@ export class DashboardComponent implements OnInit {
   ngOnInit() {
     this.selectedMonth = this.dateToolsService.toStartOfMonth(new Date());
 
-    this.userService.getLoggedUserProfile()
+    this.usersService.getLoggedUserProfile()
       .subscribe((data: UserProfile) => {
         this.profile = data;
         if (this.isEmployer()) {
@@ -117,7 +117,7 @@ export class DashboardComponent implements OnInit {
   }
 
   private loadProfile() {
-    this.userService.getLoggedUserProfile()
+    this.usersService.getLoggedUserProfile()
       .subscribe((data: UserProfile) => this.profile = data);
   }
 
diff --git a/webapp/src/app/employees/employees-list.component.ts b/webapp/src/app/employees/employees-list.component.ts
index 6239f53..fdea3d1 100644
--- a/webapp/src/app/employees/employees-list.component.ts
+++ b/webapp/src/app/employees/employees-list.component.ts
@@ -106,7 +106,7 @@ export class EmployeesListComponent implements OnInit {
    * @param user user information
    */
   openEditUserDialog(user: User): void {
-    this.userService.getUserProfile(user.id)
+    this.usersService.getUserProfile(user.id)
       .subscribe((userProfile: UserProfile) => {
           const dialogRef = this.dialog.open(EditEmployeeDialogComponent, {
             data: userProfile,
diff --git a/webapp/src/app/employees/user-profile/user-profile-dialog.component.ts b/webapp/src/app/employees/user-profile/user-profile-dialog.component.ts
index b556090..6a2b4dd 100644
--- a/webapp/src/app/employees/user-profile/user-profile-dialog.component.ts
+++ b/webapp/src/app/employees/user-profile/user-profile-dialog.component.ts
@@ -6,6 +6,7 @@ import {RequestStatus} from '../../enums/common.enum';
 import {UserService} from '../../services/api/user.service';
 import {DateToolsService} from '../../services/util/date-tools.service';
 import {LocalizationService} from '../../localization/localization.service';
+import {UsersService} from "../../services/api/users.service";
 
 @Component({
   selector: 'app-user-profile',
@@ -21,6 +22,7 @@ export class UserProfileDialogComponent implements OnInit, AfterViewInit {
     public dialogRef: MatDialogRef<UserProfileDialogComponent>,
     @Inject(MAT_DIALOG_DATA) public data: UserProfileDialogData,
     private userService: UserService,
+    private usersService: UsersService,
     private dateToolsService: DateToolsService,
     private localizationService: LocalizationService
   ) { }
@@ -44,7 +46,7 @@ export class UserProfileDialogComponent implements OnInit, AfterViewInit {
   }
 
   private loadProfile() {
-    this.userService.getUserProfile(this.data.userId)
+    this.usersService.getUserProfile(this.data.userId)
       .subscribe((data: UserProfile) => this.profile = data);
   }
 
diff --git a/webapp/src/app/header/header.component.ts b/webapp/src/app/header/header.component.ts
index c3ad9f8..4132b83 100644
--- a/webapp/src/app/header/header.component.ts
+++ b/webapp/src/app/header/header.component.ts
@@ -4,6 +4,7 @@ import {LocalizationService} from '../localization/localization.service';
 import {UserService} from '../services/api/user.service';
 import {UserProfile} from '../models/user.model';
 import {ProfileSettingsComponent} from '../profile-settings/profile-settings.component';
+import {UsersService} from "../services/api/users.service";
 
 @Component({
   selector: 'app-header',
@@ -17,9 +18,10 @@ export class HeaderComponent {
   constructor(
     private dialog: MatDialog,
     private localizationService: LocalizationService,
-    private userService: UserService
+    private userService: UserService,
+    private usersService: UsersService
     ) {
-    userService.getLoggedUserProfile()
+    usersService.getLoggedUserProfile()
       .subscribe((data: UserProfile) => this.profile = data);
     this.language = this.localizationService.getCurrentLanguage();
   }
@@ -28,7 +30,7 @@ export class HeaderComponent {
     this.language = this.localizationService.switchLocale(language);
   }
   onProfileClick(): void {
-    this.userService.getLoggedUserProfile()
+    this.usersService.getLoggedUserProfile()
       .subscribe((data: UserProfile) => {
         this.profile = data;
 
@@ -47,7 +49,7 @@ export class HeaderComponent {
             },
             this.localizationService.getCurrentLanguage()
           ).subscribe(() => {
-            this.userService.getLoggedUserProfile().subscribe((profile: UserProfile) => this.profile = profile);
+            this.usersService.getLoggedUserProfile().subscribe((profile: UserProfile) => this.profile = profile);
           });
         });
       });
diff --git a/webapp/src/app/services/api/user.service.ts b/webapp/src/app/services/api/user.service.ts
index ca8b0eb..5a3ad6d 100644
--- a/webapp/src/app/services/api/user.service.ts
+++ b/webapp/src/app/services/api/user.service.ts
@@ -6,7 +6,6 @@ import {BasicService} from './basic.service';
 import {catchError} from 'rxjs/operators';
 import {Languages, RequestStatus, RequestTypes} from '../../enums/common.enum';
 import {NotificationSettings, UserSettings} from '../../models/settings.model';
-import {UserProfile} from '../../models/user.model';
 import {UserRequest} from '../../models/requests.model';
 import {MatSnackBar} from '@angular/material';
 import {DateFormatterService} from '../util/date-formatter.service';
@@ -16,50 +15,12 @@ import {TranslateService} from '@ngx-translate/core';
   providedIn: 'root'
 })
 export class UserService extends BasicService { // dost podobny k usersService, mozna zmenit v rest api
-  private _userUrl = this.baseUrl + '/api/user/';
+  private _userUrl = this.baseUrl + '/api/users/';
 
   constructor(protected http: HttpClient, protected snackBar: MatSnackBar, protected translateService: TranslateService, private dateFormater: DateFormatterService) {
     super(http, snackBar, translateService);
   }
 
-  /**
-   * Returns user profile if the user making this call
-   * is logged as admin
-   * UserProfile.notification might be returned as string instead of date
-   * @param id user profile id
-   */
-  getUserProfile(id: number) {
-    return this.makeGetProfileApiCall(id.toString(), null);
-  }
-
-  /**
-   * Overloaded version of getUserProfile to filter profiles
-   * by language
-   * UserProfile.notification might be returned as string instead of date
-   * @param id user profile id
-   * @param language language to filtery by
-   */
-  getUserProfileWithLanguage(id: number, language: Languages) {
-    return this.makeGetProfileApiCall(id.toString(), language);
-  }
-
-  /**
-   * Returns profile of currently logged user
-   * UserProfile.notification might be returned as string instead of date
-   */
-  getLoggedUserProfile() {
-    return this.makeGetProfileApiCall('me', null);
-  }
-
-  /**
-   * Returns profile of currently logged user filtered by language
-   * UserProfile.notification might be returned as string instead of date
-   * @param language filter profile by language
-   */
-  getLoggedUserProfileWithLanguage(language: Languages) {
-    return this.makeGetProfileApiCall('me', language);
-  }
-
   /**
    * Returns vacation and sick days from the given date
    * for logged user
@@ -167,22 +128,6 @@ export class UserService extends BasicService { // dost podobny k usersService,
     return this.makeDeleteCalendarApiCall(id, language);
   }
 
-  /**
-   * Získání profilu aktuálně přihlášeného uživatele nebo uživatele podle zadaného id.
-   * GET /user/<{id} || me>/profile?[lang=<CZ,EN>]
-   * @param id id of profile to get (number or 'me')
-   * @param language filter by language
-   */
-  private makeGetProfileApiCall(id: string, language: string) {
-    const httpParams: HttpParams = this.createParams({lang: language});
-    const options = {params: httpParams};
-
-    return this.http.get<UserProfile>(this._userUrl + id + '/profile', options)
-      .pipe(
-        catchError(err => this.handleError(err))
-      );
-  }
-
   /**
    * Získání dovolené a sick days v zadaném období. Pokud není zadán parameter “to” vrátí všechny dovolené a sick days od “from”. Navíc umožňuje filtrovat pomocí statusu schválení.
    * GET /user/<{id} || me>/calendar?[lang=<CZ,EN>]&from=yyyy/mm/dd, [to=yyyy/mm/dd], [status=<ACCEPTED, PENDING, REJECTED>]
diff --git a/webapp/src/app/services/api/users.service.ts b/webapp/src/app/services/api/users.service.ts
index 7b8c08a..b44798a 100644
--- a/webapp/src/app/services/api/users.service.ts
+++ b/webapp/src/app/services/api/users.service.ts
@@ -6,7 +6,7 @@ import {catchError} from 'rxjs/operators';
 import {AuthorizationRequest, VacationRequest} from '../../models/requests.model';
 import {Languages, ProfileStatus} from '../../enums/common.enum';
 import {Observable} from 'rxjs';
-import {UserBasicInformation} from '../../models/user.model';
+import {UserBasicInformation, UserProfile} from '../../models/user.model';
 import {MatSnackBar} from '@angular/material';
 import {TranslateService} from '@ngx-translate/core';
 
@@ -20,6 +20,44 @@ export class UsersService extends BasicService {
     super(http, snackBar, translateService);
   }
 
+  /**
+   * Returns profile of currently logged user
+   * UserProfile.notification might be returned as string instead of date
+   */
+  getLoggedUserProfile() {
+    return this.makeGetProfileApiCall('current', null);
+  }
+
+  /**
+   * Returns profile of currently logged user filtered by language
+   * UserProfile.notification might be returned as string instead of date
+   * @param language filter profile by language
+   */
+  getLoggedUserProfileWithLanguage(language: Languages) {
+    return this.makeGetProfileApiCall('current', language);
+  }
+
+  /**
+   * Returns user profile if the user making this call
+   * is logged as admin
+   * UserProfile.notification might be returned as string instead of date
+   * @param id user profile id
+   */
+  getUserProfile(id: number) {
+    return this.makeGetProfileApiCall(id.toString(), null);
+  }
+
+  /**
+   * Overloaded version of getUserProfile to filter profiles
+   * by language
+   * UserProfile.notification might be returned as string instead of date
+   * @param id user profile id
+   * @param language language to filtery by
+   */
+  getUserProfileWithLanguage(id: number, language: Languages) {
+    return this.makeGetProfileApiCall(id.toString(), language);
+  }
+
   /**
    * Returns all authorized users
    */
@@ -161,4 +199,21 @@ export class UsersService extends BasicService {
       );
   }
 
+  /**
+   * Získání profilu aktuálně přihlášeného uživatele nebo uživatele podle zadaného id.
+   * GET /user/<{id} || me>/profile?[lang=<CZ,EN>]
+   * @param id id of profile to get (number or 'me')
+   * @param language filter by language
+   */
+  private makeGetProfileApiCall(id: string, language: string) {
+    const httpParams: HttpParams = this.createParams({lang: language});
+    const options = {params: httpParams};
+
+    return this.http.get<UserProfile>(this._usersUrl + "/" + id + '/profile', options)
+      .pipe(
+        catchError(err => this.handleError(err))
+      );
+  }
+
+
 }
diff --git a/webapp/src/app/services/tests/user.service.spec.ts b/webapp/src/app/services/tests/user.service.spec.ts
index 3b7dd41..2a97bdb 100644
--- a/webapp/src/app/services/tests/user.service.spec.ts
+++ b/webapp/src/app/services/tests/user.service.spec.ts
@@ -2,7 +2,7 @@ import {TestBed} from '@angular/core/testing';
 
 import {UserService} from '../api/user.service';
 import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
-import {Languages, RequestStatus, UserType, VacationType} from '../../enums/common.enum';
+import {RequestStatus, VacationType} from '../../enums/common.enum';
 import {environment} from '../../../environments/environment';
 
 describe('UsersService', () => {
@@ -21,62 +21,6 @@ describe('UsersService', () => {
   });
   afterEach(() => httpMock.verify());
 
-  it('getLoggedUser', () => {
-    const dummyData = {
-      id: 1,
-      firstName: 'Tomas',
-      lastName: 'Novak',
-      photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg',
-      vacationCount: 8.5,
-      sickDayCount: 3,
-      status: 'ACCEPTED',
-      role: 'EMPLOYER',
-      notification: '2000/12/01 09:00:00'
-    };
-
-
-    service.getLoggedUserProfile().subscribe((data: any) => {
-      expect(data.id).toBe(1);
-      expect(data.vacationCount).toBe(8.5);
-      expect(data.sickDayCount).toBe(3);
-      expect(data.status).toBe(RequestStatus.ACCEPTED);
-      expect(data.role).toBe(UserType.EMPLOYER);
-      expect(data.notification).toBeDefined();
-    });
-
-    const req = httpMock.expectOne(baseUrl + '/api/user/me/profile');
-    expect(req.request.method).toBe('GET');
-    req.flush(dummyData);
-  });
-
-  it('getLoggedUserWithLanguage', () => {
-    const dummyData = {
-      id: 1,
-      firstName: 'Tomas',
-      lastName: 'Novak',
-      photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg',
-      vacationCount: 8.5,
-      sickDayCount: 3,
-      status: 'ACCEPTED',
-      role: 'EMPLOYER',
-      notification: '2000/12/01 09:00:00'
-    };
-
-
-    service.getLoggedUserProfileWithLanguage(Languages.ENGLISH).subscribe((data: any) => {
-      expect(data.id).toBe(1);
-      expect(data.vacationCount).toBe(8.5);
-      expect(data.sickDayCount).toBe(3);
-      expect(data.status).toBe(RequestStatus.ACCEPTED);
-      expect(data.role).toBe(UserType.EMPLOYER);
-      expect(data.notification).toBeDefined();
-    });
-
-    const req = httpMock.expectOne(baseUrl + '/api/user/me/profile?lang=EN');
-    expect(req.request.method).toBe('GET');
-    req.flush(dummyData);
-  });
-
   it('getLoggedUserCalendar', () => {
     const dummyData = [
       {id: 1, date: '2000/10/10', from: '09:00', to: '13:00', type: 'VACATION'},
diff --git a/webapp/src/app/services/tests/users.service.spec.ts b/webapp/src/app/services/tests/users.service.spec.ts
index 1e184da..54d5a39 100644
--- a/webapp/src/app/services/tests/users.service.spec.ts
+++ b/webapp/src/app/services/tests/users.service.spec.ts
@@ -2,7 +2,7 @@ import {TestBed} from '@angular/core/testing';
 
 import {UsersService} from '../api/users.service';
 import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
-import {RequestStatus, VacationType} from '../../enums/common.enum';
+import {Languages, RequestStatus, UserType, VacationType} from '../../enums/common.enum';
 import {environment} from '../../../environments/environment';
 
 describe('UsersService', () => {
@@ -21,6 +21,61 @@ describe('UsersService', () => {
   });
   afterEach(() => httpMock.verify());
 
+  it('getLoggedUser', () => {
+    const dummyData = {
+      id: 1,
+      firstName: 'Tomas',
+      lastName: 'Novak',
+      photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg',
+      vacationCount: 8.5,
+      sickDayCount: 3,
+      status: 'ACCEPTED',
+      role: 'EMPLOYER',
+      notification: '2000/12/01 09:00:00'
+    };
+
+
+    service.getLoggedUserProfile().subscribe((data: any) => {
+      expect(data.id).toBe(1);
+      expect(data.vacationCount).toBe(8.5);
+      expect(data.sickDayCount).toBe(3);
+      expect(data.status).toBe(RequestStatus.ACCEPTED);
+      expect(data.role).toBe(UserType.EMPLOYER);
+      expect(data.notification).toBeDefined();
+    });
+
+    const req = httpMock.expectOne(baseUrl + '/api/user/me/profile');
+    expect(req.request.method).toBe('GET');
+    req.flush(dummyData);
+  });
+
+  it('getLoggedUserWithLanguage', () => {
+    const dummyData = {
+      id: 1,
+      firstName: 'Tomas',
+      lastName: 'Novak',
+      photo: 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg',
+      vacationCount: 8.5,
+      sickDayCount: 3,
+      status: 'ACCEPTED',
+      role: 'EMPLOYER',
+      notification: '2000/12/01 09:00:00'
+    };
+
+
+    service.getLoggedUserProfileWithLanguage(Languages.ENGLISH).subscribe((data: any) => {
+      expect(data.id).toBe(1);
+      expect(data.vacationCount).toBe(8.5);
+      expect(data.sickDayCount).toBe(3);
+      expect(data.status).toBe(RequestStatus.ACCEPTED);
+      expect(data.role).toBe(UserType.EMPLOYER);
+      expect(data.notification).toBeDefined();
+    });
+
+    const req = httpMock.expectOne(baseUrl + '/api/user/me/profile?lang=EN');
+    expect(req.request.method).toBe('GET');
+    req.flush(dummyData);
+  });
 
   it('getAuthorizationRequests', () => {
     const dummyRequests = [
diff --git a/webapp/src/app/services/util/profile.service.ts b/webapp/src/app/services/util/profile.service.ts
index cedac52..8122fab 100644
--- a/webapp/src/app/services/util/profile.service.ts
+++ b/webapp/src/app/services/util/profile.service.ts
@@ -1,7 +1,7 @@
 import {Injectable} from '@angular/core';
-import {UserService} from '../api/user.service';
 import {UserProfile} from '../../models/user.model';
 import {Observable, of} from 'rxjs';
+import {UsersService} from "../api/users.service";
 
 @Injectable({
   providedIn: 'root'
@@ -9,10 +9,13 @@ import {Observable, of} from 'rxjs';
 export class ProfileService {
   private profile: UserProfile;
 
-  constructor(private userService: UserService) {
+  constructor(private usersService: UsersService) {
 
   }
 
+  //hardcoded username for now, to be replaced after proper authentication is in place
+  public currentUserValue = "testuser@yoso.fi";
+
   /**
    * Returns logged user profile if the server responds
    * with valid profile otherwise observer returns error
@@ -28,7 +31,7 @@ export class ProfileService {
     }
 
     return new Observable<UserProfile>((obs) => {
-      this.userService.getLoggedUserProfile()
+      this.usersService.getLoggedUserProfile()
         .subscribe((userProfile: UserProfile) => {
             this.profile = {...userProfile};
             obs.next(this.profile);
