Projekt

Obecné

Profil

« Předchozí | Další » 

Revize d2799ca5

Přidáno uživatelem Jakub Danek před více než 5 roky(ů)

re #37 make UI compatible with new User controller API

Zobrazit rozdíly:

webapp/src/app/services/api/users.service.ts
6 6
import {AuthorizationRequest, VacationRequest} from '../../models/requests.model';
7 7
import {Languages, ProfileStatus} from '../../enums/common.enum';
8 8
import {Observable} from 'rxjs';
9
import {UserBasicInformation} from '../../models/user.model';
9
import {UserBasicInformation, UserProfile} from '../../models/user.model';
10 10
import {MatSnackBar} from '@angular/material';
11 11
import {TranslateService} from '@ngx-translate/core';
12 12

  
......
20 20
    super(http, snackBar, translateService);
21 21
  }
22 22

  
23
  /**
24
   * Returns profile of currently logged user
25
   * UserProfile.notification might be returned as string instead of date
26
   */
27
  getLoggedUserProfile() {
28
    return this.makeGetProfileApiCall('current', null);
29
  }
30

  
31
  /**
32
   * Returns profile of currently logged user filtered by language
33
   * UserProfile.notification might be returned as string instead of date
34
   * @param language filter profile by language
35
   */
36
  getLoggedUserProfileWithLanguage(language: Languages) {
37
    return this.makeGetProfileApiCall('current', language);
38
  }
39

  
40
  /**
41
   * Returns user profile if the user making this call
42
   * is logged as admin
43
   * UserProfile.notification might be returned as string instead of date
44
   * @param id user profile id
45
   */
46
  getUserProfile(id: number) {
47
    return this.makeGetProfileApiCall(id.toString(), null);
48
  }
49

  
50
  /**
51
   * Overloaded version of getUserProfile to filter profiles
52
   * by language
53
   * UserProfile.notification might be returned as string instead of date
54
   * @param id user profile id
55
   * @param language language to filtery by
56
   */
57
  getUserProfileWithLanguage(id: number, language: Languages) {
58
    return this.makeGetProfileApiCall(id.toString(), language);
59
  }
60

  
23 61
  /**
24 62
   * Returns all authorized users
25 63
   */
......
161 199
      );
162 200
  }
163 201

  
202
  /**
203
   * Získání profilu aktuálně přihlášeného uživatele nebo uživatele podle zadaného id.
204
   * GET /user/<{id} || me>/profile?[lang=<CZ,EN>]
205
   * @param id id of profile to get (number or 'me')
206
   * @param language filter by language
207
   */
208
  private makeGetProfileApiCall(id: string, language: string) {
209
    const httpParams: HttpParams = this.createParams({lang: language});
210
    const options = {params: httpParams};
211

  
212
    return this.http.get<UserProfile>(this._usersUrl + "/" + id + '/profile', options)
213
      .pipe(
214
        catchError(err => this.handleError(err))
215
      );
216
  }
217

  
218

  
164 219
}

Také k dispozici: Unified diff