Revize f4bbdb70
Přidáno uživatelem Václav Jirák před téměř 6 roky(ů)
webapp/src/app/dashboard/employer-dashboard/employer-dashboard.component.html | ||
---|---|---|
36 | 36 |
<div class="col-lg-4 right-panel"> |
37 | 37 |
|
38 | 38 |
<div class="days-off-info" *ngIf="profile"> |
39 |
<app-days-off-info
|
|
39 |
<app-vacation-info
|
|
40 | 40 |
[sickDaysRemaining]="profile.sickdayCount" |
41 | 41 |
[extraVacationRemaining]="profile.vacationCount" |
42 |
></app-days-off-info>
|
|
42 |
></app-vacation-info>
|
|
43 | 43 |
</div> |
44 | 44 |
|
45 | 45 |
</div> |
webapp/src/app/dashboard/employer-dashboard/employer-dashboard.component.ts | ||
---|---|---|
9 | 9 |
import {RequestStatus, RequestTypes} from '../../enums/common.enum'; |
10 | 10 |
import {Calendar} from '../../models/calendar.model'; |
11 | 11 |
import {DateToolsService} from '../../services/util/date-tools.service'; |
12 |
import {EditVacationDialogComponent} from "../../edit-vacation-dialog/edit-vacation-dialog.component"; |
|
13 | 12 |
|
14 | 13 |
@Component({ |
15 | 14 |
selector: 'app-employer-dashboard', |
... | ... | |
22 | 21 |
private profile: UserProfile; |
23 | 22 |
private authorizationRequests: AuthorizationRequest[]; |
24 | 23 |
private vacationRequests: VacationRequest[]; |
25 |
private currentMonthVacation: Calendar[]; |
|
26 | 24 |
private oncomingVacation: Calendar[]; |
27 | 25 |
|
28 | 26 |
constructor( |
webapp/src/app/day-picker/day-picker.component.ts | ||
---|---|---|
43 | 43 |
private localizationService: LocalizationService, |
44 | 44 |
private dateToolsService: DateToolsService) { |
45 | 45 |
|
46 |
this.locale = localizationService.defaultLanguage;
|
|
46 |
this.locale = localizationService.getCurrentLocale();
|
|
47 | 47 |
localizationService.currentLanguageSubject |
48 | 48 |
.subscribe((data) => { |
49 | 49 |
this.locale = data; |
webapp/src/app/employees/employees-list.component.html | ||
---|---|---|
55 | 55 |
</div> |
56 | 56 |
</td> |
57 | 57 |
<td> |
58 |
<span class="material-icons" style="font-size: small" (click)="openUserProfile(user)">visibility</span> |
|
58 | 59 |
<span class="material-icons" style="font-size: small" (click)="openEditUserDialog(user)">edit</span> |
59 | 60 |
</td> |
60 | 61 |
</tr> |
webapp/src/app/employees/employees-list.component.ts | ||
---|---|---|
13 | 13 |
import {DateFormatterService} from '../services/util/date-formatter.service'; |
14 | 14 |
import {FileService} from '../services/api/file.service'; |
15 | 15 |
import {ProfileService} from '../services/util/profile.service'; |
16 |
import {UserProfileDialogComponent} from "./user-profile/user-profile-dialog.component"; |
|
16 | 17 |
|
17 | 18 |
const daysOfWeek: string[] = [ |
18 | 19 |
'po', |
... | ... | |
83 | 84 |
); |
84 | 85 |
} |
85 | 86 |
|
87 |
openUserProfile(user: User): void { |
|
88 |
this.dialog.open(UserProfileDialogComponent, { |
|
89 |
data: { |
|
90 |
userId: user.id |
|
91 |
}, |
|
92 |
width: '1100px' |
|
93 |
}); |
|
94 |
} |
|
95 |
|
|
86 | 96 |
/** |
87 | 97 |
* Opens a dialog to edit users settings after closing |
88 | 98 |
* the dialog if user clicked to confirm new settings |
webapp/src/app/employees/employees.module.ts | ||
---|---|---|
17 | 17 |
import {NgbTimepickerModule} from '@ng-bootstrap/ng-bootstrap'; |
18 | 18 |
import {SharedModule} from '../shared/shared.module'; |
19 | 19 |
import { UserProfileDialogComponent } from './user-profile/user-profile-dialog.component'; |
20 |
import {DayPickerModule} from '../day-picker/day-picker.module'; |
|
21 |
import {VacationInfoModule} from '../vacation-info/vacation-info.module'; |
|
20 | 22 |
|
21 | 23 |
@NgModule({ |
22 | 24 |
declarations: [ |
... | ... | |
36 | 38 |
MatDatepickerModule, |
37 | 39 |
NgbTimepickerModule, |
38 | 40 |
MatButtonModule, |
39 |
SharedModule |
|
41 |
DayPickerModule, |
|
42 |
SharedModule, |
|
43 |
VacationInfoModule |
|
40 | 44 |
], |
41 | 45 |
entryComponents: [ |
42 | 46 |
EditEmployeeDialogComponent, |
webapp/src/app/employees/user-profile/user-profile-dialog.component.html | ||
---|---|---|
1 |
<p> |
|
2 |
user-profile works! |
|
3 |
</p> |
|
1 |
<div mat-dialog-content style="height: 100%"> |
|
2 |
<div class="row"> |
|
3 |
<div class="col-md-9"> |
|
4 |
<app-day-picker #dayPicker |
|
5 |
(selectedMonth)="onSelectedMonthChange($event)" |
|
6 |
> |
|
7 |
</app-day-picker> |
|
8 |
</div> |
|
9 |
<div class="col-md-3" *ngIf="profile"> |
|
10 |
<div class="user-info"> |
|
11 |
<img class="user-photo" src="{{profile.photo}}" /> |
|
12 |
<span class="user-name">{{profile.firstName}} {{profile.lastName}}</span> |
|
13 |
</div> |
|
14 |
<app-vacation-info |
|
15 |
[sickDaysRemaining]="profile.sickdayCount" |
|
16 |
[extraVacationRemaining]="profile.vacationCount" |
|
17 |
></app-vacation-info> |
|
18 |
</div> |
|
19 |
</div> |
|
20 |
</div> |
|
21 |
|
|
22 |
<div mat-dialog-actions align="end"> |
|
23 |
<button mat-raised-button color="basic" (click)="onCloseClick()">Zavřít</button> |
|
24 |
</div> |
webapp/src/app/employees/user-profile/user-profile-dialog.component.sass | ||
---|---|---|
1 |
@import '../../../common-styles/basic-component' |
|
2 |
|
|
3 |
.user-info |
|
4 |
@extend .basic-component |
|
5 |
margin-bottom: 10px |
|
6 |
|
|
7 |
.user-photo |
|
8 |
width: 35px |
|
9 |
height: 35px |
|
10 |
border-radius: 20px |
|
11 |
|
|
12 |
.user-name |
|
13 |
font-weight: bold |
|
14 |
margin-left: 10px |
webapp/src/app/employees/user-profile/user-profile-dialog.component.ts | ||
---|---|---|
1 |
import {Component, Inject, OnInit} from '@angular/core';
|
|
1 |
import {AfterViewInit, Component, Inject, OnInit, ViewChild} from '@angular/core';
|
|
2 | 2 |
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material'; |
3 | 3 |
import {UserProfile} from '../../models/user.model'; |
4 | 4 |
import {Calendar} from '../../models/calendar.model'; |
5 |
import {RequestStatus} from '../../enums/common.enum'; |
|
6 |
import {UserService} from '../../services/api/user.service'; |
|
7 |
import {DateToolsService} from '../../services/util/date-tools.service'; |
|
8 |
import {LocalizationService} from '../../localization/localization.service'; |
|
5 | 9 |
|
6 | 10 |
@Component({ |
7 | 11 |
selector: 'app-user-profile', |
8 | 12 |
templateUrl: './user-profile-dialog.component.html', |
9 | 13 |
styleUrls: ['./user-profile-dialog.component.sass'] |
10 | 14 |
}) |
11 |
export class UserProfileDialogComponent implements OnInit { |
|
15 |
export class UserProfileDialogComponent implements OnInit, AfterViewInit { |
|
16 |
@ViewChild('dayPicker') calendar; |
|
17 |
|
|
18 |
private profile: UserProfile; |
|
12 | 19 |
|
13 | 20 |
constructor( |
14 | 21 |
public dialogRef: MatDialogRef<UserProfileDialogComponent>, |
15 |
@Inject(MAT_DIALOG_DATA) public data: UserProfileDialogData |
|
22 |
@Inject(MAT_DIALOG_DATA) public data: UserProfileDialogData, |
|
23 |
private userService: UserService, |
|
24 |
private dateToolsService: DateToolsService, |
|
25 |
private localizationService: LocalizationService |
|
16 | 26 |
) { } |
17 | 27 |
|
18 | 28 |
ngOnInit() { |
29 |
|
|
30 |
} |
|
31 |
|
|
32 |
|
|
33 |
ngAfterViewInit(): void { |
|
34 |
this.loadProfile(); |
|
35 |
this.loadMonthVacation(this.dateToolsService.toStartOfMonth(new Date())); |
|
36 |
} |
|
37 |
|
|
38 |
onSelectedMonthChange(monthStart: Date) { |
|
39 |
this.loadMonthVacation(monthStart); |
|
19 | 40 |
} |
20 | 41 |
|
21 | 42 |
onCloseClick(): void { |
22 |
this.dialogRef.close({ |
|
23 |
isConfirmed: false |
|
24 |
}); |
|
43 |
this.dialogRef.close(); |
|
44 |
} |
|
45 |
|
|
46 |
private loadProfile() { |
|
47 |
this.userService.getUserProfile(this.data.userId) |
|
48 |
.subscribe((data: UserProfile) => this.profile = data); |
|
49 |
} |
|
50 |
|
|
51 |
private loadMonthVacation(month: Date) { |
|
52 |
const fromDate = this.dateToolsService.toStartOfMonth(month); |
|
53 |
const toDate = this.dateToolsService.toEndOfMonth(fromDate); |
|
54 |
|
|
55 |
this.userService.getUserCalendarWithOptions(String(this.data.userId), fromDate, toDate, this.localizationService.getCurrentLanguage(), RequestStatus.ACCEPTED) |
|
56 |
.subscribe((data: Calendar[]) => { |
|
57 |
if (data) { |
|
58 |
this.calendar.setVacation(data); |
|
59 |
} |
|
60 |
}); |
|
25 | 61 |
} |
26 | 62 |
} |
27 | 63 |
|
28 | 64 |
export class UserProfileDialogData { |
29 |
profile: UserProfile; |
|
30 |
calendar: Calendar[]; |
|
65 |
userId: number; |
|
31 | 66 |
} |
webapp/src/app/localization/localization.service.ts | ||
---|---|---|
40 | 40 |
return Languages.ENGLISH; |
41 | 41 |
} |
42 | 42 |
} |
43 |
|
|
44 |
getCurrentLocale(): string { |
|
45 |
return this.currentLanguage; |
|
46 |
} |
|
43 | 47 |
} |
webapp/src/app/vacation-info/vacation-info.component.ts | ||
---|---|---|
1 | 1 |
import { Component, Input } from '@angular/core'; |
2 |
import {TimeUnit} from '../enums/common.enum'; |
|
3 | 2 |
import {LocalizationService} from '../localization/localization.service'; |
4 | 3 |
|
5 | 4 |
@Component({ |
6 |
selector: 'app-days-off-info',
|
|
5 |
selector: 'app-vacation-info',
|
|
7 | 6 |
templateUrl: './vacation-info.component.html', |
8 | 7 |
styleUrls: ['./vacation-info.component.sass'] |
9 | 8 |
}) |
Také k dispozici: Unified diff
Re #7499 User profile component implemented + refactor