Revize 79d7de40
Přidáno uživatelem Hung Hoang před téměř 6 roky(ů)
webapp/src/app/employees/edit-employee-dialog/edit-employee-dialog.component.html | ||
---|---|---|
1 |
<h1 mat-dialog-title> |
|
2 |
<img |
|
3 |
[src]="data.imageLink" |
|
4 |
alt="photo" |
|
5 |
style="width: 35px; height: 35px; margin-right: 5px" |
|
6 |
> |
|
7 |
{{data.name}} |
|
8 |
</h1> |
|
9 |
<hr> |
|
10 |
<div mat-dialog-content> |
|
11 |
<div> |
|
12 |
<mat-radio-group |
|
13 |
aria-labelledby="example-radio-group-label" |
|
14 |
class="example-radio-group" |
|
15 |
[(ngModel)]="userType" |
|
16 |
> |
|
17 |
<mat-radio-button |
|
18 |
class="example-radio-button" |
|
19 |
*ngFor="let season of _userTypes" [value]="season" |
|
20 |
> |
|
21 |
{{season}} |
|
22 |
</mat-radio-button> |
|
23 |
</mat-radio-group> |
|
24 |
</div> |
|
25 |
<div> |
|
26 |
<mat-form-field class="example-margin"> |
|
27 |
<input |
|
28 |
matInput |
|
29 |
type="number" |
|
30 |
placeholder="Sickdays" |
|
31 |
min="1" |
|
32 |
value="20" |
|
33 |
[(ngModel)]="_sickDaysCount" |
|
34 |
> |
|
35 |
</mat-form-field> |
|
36 |
</div> |
|
37 |
<div> |
|
38 |
|
|
39 |
</div> |
|
40 |
<mat-form-field class="example-margin"> |
|
41 |
<input |
|
42 |
matInput |
|
43 |
type="number" |
|
44 |
placeholder="Dovolená" |
|
45 |
min="1" |
|
46 |
value="20" |
|
47 |
[(ngModel)]="_vacationDaysCount" |
|
48 |
> |
|
49 |
</mat-form-field> |
|
50 |
</div> |
|
51 |
<div mat-dialog-actions> |
|
52 |
<button class="btn btn-primary" style="margin-right: 5px" (click)="onConfirmClick()">Potvrdit</button> |
|
53 |
<button class="btn btn-danger" (click)="onCloseClick()">Zavřít</button> |
|
54 |
</div> |
webapp/src/app/employees/edit-employee-dialog/edit-employee-dialog.component.sass | ||
---|---|---|
1 |
.example-radio-group |
|
2 |
display: flex |
|
3 |
flex-direction: column |
|
4 |
|
|
5 |
|
|
6 |
.example-radio-button |
|
7 |
margin: 5px |
webapp/src/app/employees/edit-employee-dialog/edit-employee-dialog.component.ts | ||
---|---|---|
1 |
import {Component, Inject, Input, OnInit} from '@angular/core'; |
|
2 |
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material'; |
|
3 |
import {User} from '../user.model'; |
|
4 |
import {UserType} from '../../enums/common.enum'; |
|
5 |
|
|
6 |
|
|
7 |
@Component({ |
|
8 |
selector: 'app-edit-employee-dialog', |
|
9 |
templateUrl: './edit-employee-dialog.component.html', |
|
10 |
styleUrls: ['./edit-employee-dialog.component.sass'] |
|
11 |
}) |
|
12 |
export class EditEmployeeDialogComponent implements OnInit { |
|
13 |
readonly _userTypes: string[] = ['Zaměstnanec', 'Zaměstnavatel']; |
|
14 |
private _sickDaysCount: number; |
|
15 |
private _vacationDaysCount: number; |
|
16 |
private _userType: UserType; |
|
17 |
|
|
18 |
constructor(public dialogRef: MatDialogRef<EditEmployeeDialogComponent>, |
|
19 |
@Inject(MAT_DIALOG_DATA) public data: User) { |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
ngOnInit() { |
|
24 |
} |
|
25 |
|
|
26 |
@Input() |
|
27 |
set userType(userType: string) { |
|
28 |
this._userType = UserType.EMPLOYEE; |
|
29 |
console.log('intercepted ' + this._userType); |
|
30 |
} |
|
31 |
|
|
32 |
onConfirmClick(): void { |
|
33 |
this.dialogRef.close(); |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
onCloseClick(): void { |
|
38 |
this.dialogRef.close(); |
|
39 |
} |
|
40 |
|
|
41 |
} |
webapp/src/app/employees/employees-list.component.html | ||
---|---|---|
14 | 14 |
</thead> |
15 | 15 |
<tbody> |
16 | 16 |
<tr *ngFor="let user of users"> |
17 |
<th scope="row">{{user.name}}</th> |
|
17 |
<th scope="row"> |
|
18 |
<img |
|
19 |
alt="photo" |
|
20 |
[src]="user.imageLink" |
|
21 |
style="width: 35px; height: 35px; margin-right: 5px" |
|
22 |
> |
|
23 |
{{user.name}} |
|
24 |
</th> |
|
18 | 25 |
<td *ngFor="let date of user.dates"> |
19 | 26 |
|
20 | 27 |
<div |
... | ... | |
25 | 32 |
</div> |
26 | 33 |
</td> |
27 | 34 |
<td> |
28 |
<span class="material-icons" style="font-size: small">edit</span> |
|
35 |
<span class="material-icons" style="font-size: small" (click)="openDialog(user)">edit</span>
|
|
29 | 36 |
</td> |
30 | 37 |
</tr> |
31 | 38 |
</tbody> |
webapp/src/app/employees/employees-list.component.ts | ||
---|---|---|
2 | 2 |
import {UserBasicInformation} from '../models/user-basic-information.model'; |
3 | 3 |
import {UsersService} from '../services/users.service'; |
4 | 4 |
import {VacationType} from '../enums/common.enum'; |
5 |
|
|
6 |
class DayInfo { |
|
7 |
date: Date; |
|
8 |
type: VacationType; |
|
9 |
} |
|
10 |
|
|
11 |
class User { |
|
12 |
id: number; |
|
13 |
name: string; |
|
14 |
dates: DayInfo[]; |
|
15 |
} |
|
5 |
import {MatDialog} from '@angular/material'; |
|
6 |
import {EditEmployeeDialogComponent} from './edit-employee-dialog/edit-employee-dialog.component'; |
|
7 |
import {DayInfo, User} from './user.model'; |
|
16 | 8 |
|
17 | 9 |
const daysOfWeek: string[] = [ |
18 | 10 |
'po', |
... | ... | |
30 | 22 |
styleUrls: ['./employees-list.component.sass'] |
31 | 23 |
}) |
32 | 24 |
export class EmployeesListComponent implements OnInit { |
33 |
private users: User[];
|
|
34 |
private days: string[];
|
|
35 |
private dates: Date[]; |
|
36 |
private employeesBasicInformation: UserBasicInformation[] = []; |
|
37 |
readonly todayDate: Date = new Date(); |
|
25 |
days: string[];
|
|
26 |
private _users: User[];
|
|
27 |
private _dates: Date[];
|
|
28 |
private _employeesBasicInformation: UserBasicInformation[] = [];
|
|
29 |
readonly _todayDate: Date = new Date();
|
|
38 | 30 |
|
39 |
constructor(private usersService: UsersService) { |
|
31 |
constructor(private usersService: UsersService, public dialog: MatDialog) {
|
|
40 | 32 |
this.generateDays(); |
41 | 33 |
this.generateDates(); |
42 | 34 |
this.editDates(); |
43 | 35 |
} |
44 | 36 |
|
37 |
openDialog(user: User): void { |
|
38 |
this.dialog.open(EditEmployeeDialogComponent, { |
|
39 |
data: user, |
|
40 |
}); |
|
41 |
} |
|
42 |
|
|
45 | 43 |
private generateDays(): void { |
46 | 44 |
this.days = []; |
47 | 45 |
|
48 |
for (let i = this.todayDate.getDay() - 8; i < this.todayDate.getDay() + 7; i++) {
|
|
46 |
for (let i = this._todayDate.getDay() - 8; i < this._todayDate.getDay() + 7; i++) {
|
|
49 | 47 |
this.days.push(daysOfWeek[((i % 7) + 7) % 7]); |
50 | 48 |
} |
51 | 49 |
} |
52 | 50 |
|
53 |
private generateDates() { |
|
54 |
this.dates = []; |
|
51 |
private generateDates(): void {
|
|
52 |
this._dates = [];
|
|
55 | 53 |
for (let i = 0; i < 15; i++) { |
56 |
this.dates.push(new Date()); |
|
54 |
this._dates.push(new Date());
|
|
57 | 55 |
} |
58 | 56 |
} |
59 | 57 |
|
... | ... | |
62 | 60 |
let date: Date; |
63 | 61 |
|
64 | 62 |
for (let i = -7; i < 8; i++) { |
65 |
date = this.dates[j++]; |
|
63 |
date = this._dates[j++];
|
|
66 | 64 |
date.setDate(date.getDate() + i); |
67 | 65 |
} |
68 | 66 |
} |
69 | 67 |
|
70 | 68 |
private mapUsers(): void { |
71 | 69 |
let user: User; |
72 |
this.users = []; |
|
70 |
this._users = [];
|
|
73 | 71 |
|
74 |
for (const info of this.employeesBasicInformation) { |
|
72 |
for (const info of this._employeesBasicInformation) {
|
|
75 | 73 |
user = new User(); |
76 | 74 |
user.name = info.name.first + ' ' + info.name.last; |
77 | 75 |
user.id = info.id; |
76 |
user.imageLink = info.photo; |
|
78 | 77 |
user.dates = this.mapDays(info); |
79 |
this.users.push(user); |
|
78 |
this._users.push(user);
|
|
80 | 79 |
} |
81 | 80 |
} |
82 | 81 |
|
83 | 82 |
private mapDays(user: UserBasicInformation): DayInfo[] { |
84 | 83 |
const dayInfo: DayInfo[] = []; |
85 | 84 |
|
86 |
for (const date of this.dates) { |
|
85 |
for (const date of this._dates) {
|
|
87 | 86 |
const day: DayInfo = new DayInfo(); |
88 | 87 |
day.type = VacationType.NONE; |
89 | 88 |
|
... | ... | |
106 | 105 |
this.usersService.getAuthorizedUsers() |
107 | 106 |
.subscribe((data: UserBasicInformation[]) => { |
108 | 107 |
for (const entry of data) { |
109 |
this.employeesBasicInformation.push(entry); |
|
108 |
this._employeesBasicInformation.push(entry);
|
|
110 | 109 |
} |
111 | 110 |
this.mapUsers(); |
112 |
console.log(this.users); |
|
111 |
console.log(this._users);
|
|
113 | 112 |
}); |
114 | 113 |
} |
115 | 114 |
|
webapp/src/app/employees/employees.module.ts | ||
---|---|---|
1 | 1 |
import { NgModule } from '@angular/core'; |
2 | 2 |
import { CommonModule } from '@angular/common'; |
3 | 3 |
import {EmployeesListComponent} from './employees-list.component'; |
4 |
import {MatTableModule} from '@angular/material'; |
|
4 |
import {MatDialogModule, MatFormFieldModule, MatInputModule, MatRadioModule, MatTableModule} from '@angular/material'; |
|
5 |
import {EditEmployeeDialogComponent} from './edit-employee-dialog/edit-employee-dialog.component'; |
|
6 |
import {FormsModule} from '@angular/forms'; |
|
5 | 7 |
|
6 | 8 |
@NgModule({ |
7 | 9 |
declarations: [ |
8 | 10 |
EmployeesListComponent, |
11 |
EditEmployeeDialogComponent |
|
9 | 12 |
], |
10 | 13 |
imports: [ |
11 | 14 |
CommonModule, |
12 |
MatTableModule |
|
15 |
MatTableModule, |
|
16 |
MatFormFieldModule, |
|
17 |
FormsModule, |
|
18 |
MatInputModule, |
|
19 |
MatDialogModule, |
|
20 |
MatRadioModule |
|
21 |
], |
|
22 |
entryComponents: [ |
|
23 |
EditEmployeeDialogComponent, |
|
13 | 24 |
] |
14 | 25 |
}) |
15 | 26 |
export class EmployeesModule { } |
webapp/src/app/employees/user.model.ts | ||
---|---|---|
1 |
import {VacationType} from '../enums/common.enum'; |
|
2 |
|
|
3 |
export class DayInfo { |
|
4 |
date: Date; |
|
5 |
type: VacationType; |
|
6 |
} |
|
7 |
|
|
8 |
export class User { |
|
9 |
id: number; |
|
10 |
name: string; |
|
11 |
imageLink: string; |
|
12 |
dates: DayInfo[]; |
|
13 |
} |
|
14 |
|
webapp/src/app/menu/menu.component.html | ||
---|---|---|
1 | 1 |
<div class="navigation"> |
2 | 2 |
<nav class="navbar"> |
3 | 3 |
<ul class="navbar-nav"> |
4 |
<li *ngFor="let item of menuItems" |
|
5 |
[class.selected]="item === selectedMenuItem" |
|
4 |
<li *ngFor="let item of _menuItems"
|
|
5 |
[class.selected]="item === _selectedMenuItem"
|
|
6 | 6 |
(click)="onSelect(item)" |
7 | 7 |
class="nav-item"> |
8 | 8 |
<a routerLink="{{item.routePath}}"><div>{{item.name}}</div></a> |
webapp/src/app/menu/menu.component.ts | ||
---|---|---|
8 | 8 |
styleUrls: ['./menu.component.sass'] |
9 | 9 |
}) |
10 | 10 |
export class MenuComponent implements OnInit { |
11 |
menuItems: MenuItem[]; |
|
12 |
selectedMenuItem: MenuItem; |
|
11 |
_menuItems: MenuItem[];
|
|
12 |
private _selectedMenuItem: MenuItem;
|
|
13 | 13 |
|
14 | 14 |
|
15 | 15 |
getMenuItems(): void { |
16 | 16 |
this.menuService.getMenuItems() |
17 |
.subscribe(menuItems => this.menuItems = menuItems); |
|
17 |
.subscribe(menuItems => this._menuItems = menuItems);
|
|
18 | 18 |
} |
19 | 19 |
|
20 | 20 |
onSelect(menuItem: MenuItem): void { |
21 |
this.selectedMenuItem = menuItem; |
|
21 |
this._selectedMenuItem = menuItem;
|
|
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
constructor(private menuService: MenuService) { } |
webapp/src/app/services/user.service.ts | ||
---|---|---|
12 | 12 |
providedIn: 'root' |
13 | 13 |
}) |
14 | 14 |
export class UserService extends BasicService { // dost podobny k usersService, mozna zmenit v rest api |
15 |
private calendarUrl = this.baseUrl + '/user/calendar'; |
|
16 |
private postRequestUrl = this.baseUrl + '/user/requests?type='; |
|
17 |
private userUrl = this.baseUrl + '/user/'; |
|
15 |
private _calendarUrl = this.baseUrl + '/user/calendar';
|
|
16 |
private _postRequestUrl = this.baseUrl + '/user/requests?type=';
|
|
17 |
private _userUrl = this.baseUrl + '/user/';
|
|
18 | 18 |
|
19 | 19 |
getEmployeeProfile(id: number) { // najit jinej zpusob formatovani stringu, prasarna |
20 |
return this.http.get<UserProfile>(this.userUrl + id + '/profile'); |
|
20 |
return this.http.get<UserProfile>(this._userUrl + id + '/profile');
|
|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
getMonthlyCalendar(value: number) { |
... | ... | |
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
private getCalendar(viewType: string, value: number) { |
32 |
return this.http.get<Calendar[]>(this.calendarUrl + '?viewType=' + viewType + '&value=' + value) |
|
32 |
return this.http.get<Calendar[]>(this._calendarUrl + '?viewType=' + viewType + '&value=' + value)
|
|
33 | 33 |
.pipe( |
34 | 34 |
catchError(err => this.handleError(err)) |
35 | 35 |
); |
... | ... | |
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
private postCalendarWithOptions(calendar: Calendar[], options: any) { |
47 |
return this.http.post<Calendar[]>(this.calendarUrl, calendar, options) |
|
47 |
return this.http.post<Calendar[]>(this._calendarUrl, calendar, options)
|
|
48 | 48 |
.pipe( |
49 | 49 |
catchError(err => this.handleError(err)) |
50 | 50 |
); |
... | ... | |
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
private postRequestWithTypeAndOptions(request: PostRequest, type: string, options: any) { |
70 |
return this.http.post<PostRequest>(this.postRequestUrl + type, request, options) |
|
70 |
return this.http.post<PostRequest>(this._postRequestUrl + type, request, options)
|
|
71 | 71 |
.pipe( |
72 | 72 |
catchError(err => this.handleError(err)) |
73 | 73 |
); |
... | ... | |
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
private postUserSettingsWithOptions(id: number, settings: PostSettings, options: any) { |
85 |
return this.http.post<PostSettings>(this.userUrl + id + '/settings', settings, options) |
|
85 |
return this.http.post<PostSettings>(this._userUrl + id + '/settings', settings, options)
|
|
86 | 86 |
.pipe( |
87 | 87 |
catchError(err => this.handleError(err)) |
88 | 88 |
); |
webapp/src/app/services/users.service.ts | ||
---|---|---|
1 | 1 |
import { Injectable } from '@angular/core'; |
2 | 2 |
import { HttpClient } from '@angular/common/http'; |
3 | 3 |
import { BasicService } from './basic.service'; |
4 |
import {catchError, map} from 'rxjs/operators';
|
|
4 |
import {catchError} from 'rxjs/operators'; |
|
5 | 5 |
|
6 | 6 |
import {UserBasicInformation} from '../models/user-basic-information.model'; |
7 | 7 |
import { Requests } from '../models/requests.model'; |
... | ... | |
12 | 12 |
providedIn: 'root' |
13 | 13 |
}) |
14 | 14 |
export class UsersService extends BasicService { |
15 |
private usersUrl = this.baseUrl + '/users?status='; |
|
16 |
private requestsUrl = this.baseUrl + '/users/requests?type='; |
|
15 |
private _usersUrl = this.baseUrl + '/users?status=';
|
|
16 |
private _requestsUrl = this.baseUrl + '/users/requests?type=';
|
|
17 | 17 |
|
18 | 18 |
getAuthorizedUsers() { |
19 | 19 |
return this.getUsersWithStatus(ProfileStatus.AUTHORIZED); |
... | ... | |
28 | 28 |
} |
29 | 29 |
|
30 | 30 |
private getUsersWithStatus(status: string): Observable<UserBasicInformation[]> { |
31 |
console.log(this.usersUrl + status); |
|
32 |
return this.http.get<UserBasicInformation[]>(this.usersUrl + status) |
|
31 |
console.log(this._usersUrl + status);
|
|
32 |
return this.http.get<UserBasicInformation[]>(this._usersUrl + status)
|
|
33 | 33 |
.pipe( |
34 | 34 |
catchError(err => this.handleError(err)) |
35 | 35 |
); |
... | ... | |
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
private getRequestsWithType(type: string) { |
47 |
return this.http.get<Requests>(this.requestsUrl + type) |
|
47 |
return this.http.get<Requests>(this._requestsUrl + type)
|
|
48 | 48 |
.pipe( |
49 | 49 |
catchError(err => this.handleError(err)) |
50 | 50 |
); |
Také k dispozici: Unified diff
Re#7459 Implemented first popup