Revize f8b40fd5
Přidáno uživatelem Hung Hoang před téměř 6 roky(ů)
webapp/package.json | ||
---|---|---|
30 | 30 |
"core-js": "^2.5.4", |
31 | 31 |
"date-fns": "^1.30.1", |
32 | 32 |
"flatpickr": "^4.5.7", |
33 |
"fsevents": "^2.0.7", |
|
34 | 33 |
"rxjs": "~6.3.3", |
35 | 34 |
"tslib": "^1.9.0", |
36 | 35 |
"zone.js": "~0.8.26" |
webapp/src/app/employees/edit-employee-dialog/edit-employee-dialog.component.html | ||
---|---|---|
1 | 1 |
<h1 mat-dialog-title> |
2 | 2 |
<img |
3 |
[src]="data.imageLink"
|
|
3 |
[src]="data.photo"
|
|
4 | 4 |
alt="photo" |
5 | 5 |
style="width: 35px; height: 35px; margin-right: 5px" |
6 | 6 |
> |
7 |
{{data.name}}
|
|
7 |
{{data.firstName + ' ' + data.lastName}}
|
|
8 | 8 |
</h1> |
9 | 9 |
<hr> |
10 | 10 |
<div mat-dialog-content> |
... | ... | |
12 | 12 |
<mat-radio-group |
13 | 13 |
aria-labelledby="example-radio-group-label" |
14 | 14 |
class="example-radio-group" |
15 |
[(ngModel)]="userType" |
|
15 |
[(ngModel)]="_userType"
|
|
16 | 16 |
> |
17 | 17 |
<mat-radio-button |
18 | 18 |
class="example-radio-button" |
19 |
*ngFor="let season of _userTypes" [value]="season"
|
|
19 |
*ngFor="let type of _userTypes" [value]="type"
|
|
20 | 20 |
> |
21 |
{{season}}
|
|
21 |
{{type}}
|
|
22 | 22 |
</mat-radio-button> |
23 | 23 |
</mat-radio-group> |
24 | 24 |
</div> |
... | ... | |
29 | 29 |
type="number" |
30 | 30 |
placeholder="Sickdays" |
31 | 31 |
min="1" |
32 |
value="20"
|
|
32 |
step="0.5"
|
|
33 | 33 |
[(ngModel)]="_sickDaysCount" |
34 | 34 |
> |
35 | 35 |
</mat-form-field> |
... | ... | |
43 | 43 |
type="number" |
44 | 44 |
placeholder="Dovolená" |
45 | 45 |
min="1" |
46 |
value="20"
|
|
46 |
step="0.5"
|
|
47 | 47 |
[(ngModel)]="_vacationDaysCount" |
48 | 48 |
> |
49 | 49 |
</mat-form-field> |
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'; |
|
1 |
import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core'; |
|
2 |
import {MAT_DIALOG_DATA, MatDialogRef, MatSnackBar} from '@angular/material'; |
|
4 | 3 |
import {UserType} from '../../enums/common.enum'; |
4 |
import {UserProfile} from '../../models/user.model'; |
|
5 |
import {UserSettings} from '../../models/settings.model'; |
|
5 | 6 | |
6 | 7 | |
7 | 8 |
@Component({ |
... | ... | |
10 | 11 |
styleUrls: ['./edit-employee-dialog.component.sass'] |
11 | 12 |
}) |
12 | 13 |
export class EditEmployeeDialogComponent implements OnInit { |
13 |
readonly _userTypes: string[] = ['Zaměstnanec', 'Zaměstnavatel'];
|
|
14 |
readonly _userTypes: string[] = ['EMPLOYER', 'EMPLOYEE'];
|
|
14 | 15 |
private _sickDaysCount: number; |
15 | 16 |
private _vacationDaysCount: number; |
16 | 17 |
private _userType: UserType; |
18 |
private readonly _userId: number; |
|
19 |
@Output() postUserSettings = new EventEmitter<UserSettings>(); |
|
17 | 20 | |
18 | 21 |
constructor(public dialogRef: MatDialogRef<EditEmployeeDialogComponent>, |
19 |
@Inject(MAT_DIALOG_DATA) public data: User) { |
|
20 | ||
22 |
@Inject(MAT_DIALOG_DATA) public data: UserProfile, |
|
23 |
private snackBar: MatSnackBar) { |
|
24 |
this._sickDaysCount = data.sickdayCount; |
|
25 |
this._vacationDaysCount = data.vacationCount; |
|
26 |
this._userType = data.role; |
|
27 |
this._userId = data.id; |
|
21 | 28 |
} |
22 | 29 | |
23 | 30 |
ngOnInit() { |
24 | 31 |
} |
25 | 32 | |
26 |
@Input() |
|
27 |
set userType(userType: string) { |
|
28 |
this._userType = UserType.EMPLOYEE; |
|
29 |
console.log('intercepted ' + this._userType); |
|
30 |
} |
|
31 | ||
32 | 33 |
onConfirmClick(): void { |
33 |
this.dialogRef.close(); |
|
34 |
if (this._sickDaysCount == null || this._vacationDaysCount == null || this._userType == null) { |
|
35 |
this.snackBar.open('Vyplňte prosím všechny údaje', 'Zavřít'); |
|
36 |
} else { |
|
37 |
this.postUserSettings.emit({ |
|
38 |
id: this._userId, |
|
39 |
role: this._userType, |
|
40 |
sickdayCount: this._sickDaysCount, |
|
41 |
vacationCount: this._vacationDaysCount |
|
42 |
}); |
|
43 | ||
44 |
this.dialogRef.close(); |
|
45 |
} |
|
34 | 46 |
} |
35 | 47 | |
36 | ||
37 | 48 |
onCloseClick(): void { |
38 | 49 |
this.dialogRef.close(); |
39 | 50 |
} |
webapp/src/app/employees/employees-list.component.html | ||
---|---|---|
1 | 1 |
<div class="employee-component"> |
2 | 2 |
<h3>Zaměstnanci |
3 |
<span class="material-icons" style="font-size: medium; margin-right: 5px">add</span> |
|
4 | 3 |
<span class="material-icons" style="font-size: medium">edit</span> |
5 | 4 |
</h3> |
6 | 5 | |
... | ... | |
32 | 31 |
</div> |
33 | 32 |
</td> |
34 | 33 |
<td> |
35 |
<span class="material-icons" style="font-size: small" (click)="openDialog(user)">edit</span> |
|
34 |
<span class="material-icons" style="font-size: small" (click)="openEditUserDialog(user)">edit</span>
|
|
36 | 35 |
</td> |
37 | 36 |
</tr> |
38 | 37 |
</tbody> |
webapp/src/app/employees/employees-list.component.ts | ||
---|---|---|
1 | 1 |
import {Component, OnInit} from '@angular/core'; |
2 | 2 |
import {UsersService} from '../services/users.service'; |
3 | 3 |
import {VacationType} from '../enums/common.enum'; |
4 |
import {MatDialog} from '@angular/material'; |
|
4 |
import {MatDialog, MatSnackBar} from '@angular/material';
|
|
5 | 5 |
import {EditEmployeeDialogComponent} from './edit-employee-dialog/edit-employee-dialog.component'; |
6 | 6 |
import {DayInfo, User} from './user.model'; |
7 |
import {UserBasicInformation} from '../models/user.model'; |
|
7 |
import {UserBasicInformation, UserProfile} from '../models/user.model'; |
|
8 |
import {UserService} from '../services/user.service'; |
|
9 |
import {SettingsService} from '../services/settings.service'; |
|
8 | 10 | |
9 | 11 |
const daysOfWeek: string[] = [ |
10 | 12 |
'po', |
... | ... | |
28 | 30 |
private _employeesBasicInformation: UserBasicInformation[] = []; |
29 | 31 |
readonly _todayDate: Date = new Date(); |
30 | 32 | |
31 |
constructor(private usersService: UsersService, public dialog: MatDialog) { |
|
33 |
constructor(private usersService: UsersService, |
|
34 |
private userService: UserService, |
|
35 |
private settingsService: SettingsService, |
|
36 |
public dialog: MatDialog, |
|
37 |
private snackBar: MatSnackBar) { |
|
32 | 38 |
this.generateDays(); |
33 | 39 |
this.generateDates(); |
34 | 40 |
this.editDates(); |
35 | 41 |
} |
36 | 42 | |
37 |
openDialog(user: User): void { |
|
38 |
this.dialog.open(EditEmployeeDialogComponent, { |
|
39 |
data: user, |
|
40 |
}); |
|
43 |
openEditUserDialog(user: User): void { |
|
44 |
this.userService.getUserProfile(user.id) |
|
45 |
.subscribe((userProfile: UserProfile) => { |
|
46 |
const dialogRef = this.dialog.open(EditEmployeeDialogComponent, { |
|
47 |
data: userProfile, |
|
48 |
}); |
|
49 | ||
50 |
dialogRef.componentInstance.postUserSettings.subscribe((emittedData) => { |
|
51 |
this.userService.putUserSettings(emittedData) |
|
52 |
.subscribe(() => this.snackBar.open('Povedlo se', 'Zavrit')); |
|
53 |
}); |
|
54 |
}); |
|
41 | 55 |
} |
42 | 56 | |
43 | 57 |
private generateDays(): void { |
... | ... | |
119 | 133 |
// this.userService.postCalendar(calendar) |
120 | 134 |
// .subscribe((data: any) => console.log(data)); |
121 | 135 | |
122 |
// const settings: PostUserSettings = {
|
|
136 |
// const settings: UserSettings = { |
|
123 | 137 |
// id: 1, |
124 | 138 |
// role: UserType.EMPLOYEE, |
125 | 139 |
// sickdayCount: 1, |
webapp/src/app/employees/employees.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core';
|
|
2 |
import { CommonModule } from '@angular/common';
|
|
1 |
import {NgModule} from '@angular/core';
|
|
2 |
import {CommonModule} from '@angular/common';
|
|
3 | 3 |
import {EmployeesListComponent} from './employees-list.component'; |
4 |
import {MatDialogModule, MatFormFieldModule, MatInputModule, MatRadioModule, MatTableModule} from '@angular/material'; |
|
4 |
import {MatDatepickerModule, MatDialogModule, MatFormFieldModule, MatInputModule, MatRadioModule, MatTableModule} from '@angular/material';
|
|
5 | 5 |
import {EditEmployeeDialogComponent} from './edit-employee-dialog/edit-employee-dialog.component'; |
6 | 6 |
import {FormsModule} from '@angular/forms'; |
7 | 7 | |
8 | 8 |
@NgModule({ |
9 | 9 |
declarations: [ |
10 | 10 |
EmployeesListComponent, |
11 |
EditEmployeeDialogComponent |
|
11 |
EditEmployeeDialogComponent,
|
|
12 | 12 |
], |
13 | 13 |
imports: [ |
14 | 14 |
CommonModule, |
... | ... | |
17 | 17 |
FormsModule, |
18 | 18 |
MatInputModule, |
19 | 19 |
MatDialogModule, |
20 |
MatRadioModule |
|
20 |
MatRadioModule, |
|
21 |
MatDatepickerModule |
|
21 | 22 |
], |
22 | 23 |
entryComponents: [ |
23 | 24 |
EditEmployeeDialogComponent, |
webapp/src/app/models/settings.model.ts | ||
---|---|---|
5 | 5 |
notification: string; |
6 | 6 |
} |
7 | 7 | |
8 |
export interface PostUserSettings {
|
|
8 |
export interface UserSettings { |
|
9 | 9 |
id: number; |
10 | 10 |
vacationCount: number; |
11 | 11 |
sickdayCount: number; |
webapp/src/app/services/profile.service.ts | ||
---|---|---|
12 | 12 |
constructor( |
13 | 13 |
private userService: UserService |
14 | 14 |
) { |
15 |
// userService.getEmployeeProfile(1)
|
|
15 |
// userService.getUserProfile(1)
|
|
16 | 16 |
// .subscribe((data: UserProfile) => this.profile = data); |
17 | 17 |
} |
18 | 18 | |
... | ... | |
22 | 22 |
observer.next(this.profile); |
23 | 23 |
observer.complete(); |
24 | 24 |
} else { |
25 |
this.userService.getEmployeeProfile(1) // TODO zmenit id na prihlaseneho uzivatele
|
|
25 |
this.userService.getUserProfile(1) // TODO zmenit id na prihlaseneho uzivatele
|
|
26 | 26 |
.subscribe((data: UserProfile) => { |
27 | 27 |
this.profile = data; |
28 | 28 |
observer.next(this.profile); |
webapp/src/app/services/user.service.ts | ||
---|---|---|
5 | 5 |
import {BasicService} from './basic.service'; |
6 | 6 |
import {catchError} from 'rxjs/operators'; |
7 | 7 |
import {Languages, RequestStatus, RequestTypes} from '../enums/common.enum'; |
8 |
import {PostUserSettings} from '../models/settings.model';
|
|
8 |
import {UserSettings} from '../models/settings.model'; |
|
9 | 9 |
import {UserProfile} from '../models/user.model'; |
10 | 10 |
import {UserRequest} from '../models/requests.model'; |
11 | 11 | |
... | ... | |
20 | 20 |
} |
21 | 21 | |
22 | 22 |
/** |
23 |
* Returns employee profile if the user making this call
|
|
23 |
* Returns user profile if the user making this call
|
|
24 | 24 |
* is logged as admin |
25 | 25 |
* UserProfile.notification might be returned as string instead of date |
26 | 26 |
* @param id employee id |
27 | 27 |
*/ |
28 |
getEmployeeProfile(id: number) {
|
|
29 |
return this.makeGetProfileApiCall(id.toString(), '');
|
|
28 |
getUserProfile(id: number) {
|
|
29 |
return this.makeGetProfileApiCall(id.toString(), null);
|
|
30 | 30 |
} |
31 | 31 | |
32 | 32 |
/** |
33 |
* Overloaded version of getEmployeeProfile to filter profiles
|
|
33 |
* Overloaded version of getUserProfile to filter profiles
|
|
34 | 34 |
* by language |
35 | 35 |
* UserProfile.notification might be returned as string instead of date |
36 |
* @param id employee profile id
|
|
36 |
* @param id user profile id
|
|
37 | 37 |
* @param language language to filtery by |
38 | 38 |
*/ |
39 |
getEmployeeProfileWithLanguage(id: number, language: Languages) {
|
|
39 |
getUserProfileWithLanguage(id: number, language: Languages) {
|
|
40 | 40 |
return this.makeGetProfileApiCall(id.toString(), language); |
41 | 41 |
} |
42 | 42 | |
... | ... | |
99 | 99 |
* Put user settings with given id for the user |
100 | 100 |
* @param settings settings to be put |
101 | 101 |
*/ |
102 |
putUserSettings(settings: PostUserSettings) {
|
|
102 |
putUserSettings(settings: UserSettings) { |
|
103 | 103 |
return this.makePutUserSettingsApiCall(settings, null); |
104 | 104 |
} |
105 | 105 | |
... | ... | |
108 | 108 |
* @param settings settings to be put |
109 | 109 |
* @param language specified language |
110 | 110 |
*/ |
111 |
putUserSettingsWithLanguage(settings: PostUserSettings, language: Languages) {
|
|
111 |
putUserSettingsWithLanguage(settings: UserSettings, language: Languages) { |
|
112 | 112 |
return this.makePutUserSettingsApiCall(settings, language); |
113 | 113 |
} |
114 | 114 | |
... | ... | |
157 | 157 |
*/ |
158 | 158 |
private makeGetProfileApiCall(id: string, language: string) { |
159 | 159 |
const httpParams: HttpParams = this.createParams({lang: language}); |
160 | ||
161 | 160 |
const options = {params: httpParams}; |
162 | 161 | |
163 | 162 |
return this.http.get<UserProfile>(this._userUrl + id + '/profile', options) |
... | ... | |
215 | 214 |
* @param settings setting to be set for given user |
216 | 215 |
* @param language specified language |
217 | 216 |
*/ |
218 |
private makePutUserSettingsApiCall(settings: PostUserSettings, language: Languages) {
|
|
217 |
private makePutUserSettingsApiCall(settings: UserSettings, language: Languages) { |
|
219 | 218 |
const httpParams: HttpParams = this.createParams({lang: language}); |
220 | 219 |
const options = {params: httpParams}; |
221 | 220 | |
222 |
return this.http.put<PostUserSettings>(this._userUrl + 'settings', settings, options)
|
|
221 |
return this.http.put<UserSettings>(this._userUrl + 'settings', settings, options) |
|
223 | 222 |
.pipe( |
224 | 223 |
catchError(err => this.handleError(err)) |
225 | 224 |
); |
webapp/yarn.lock | ||
---|---|---|
3003 | 3003 |
nan "^2.12.1" |
3004 | 3004 |
node-pre-gyp "^0.12.0" |
3005 | 3005 | |
3006 |
fsevents@^2.0.7: |
|
3007 |
version "2.0.7" |
|
3008 |
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.0.7.tgz#382c9b443c6cbac4c57187cdda23aa3bf1ccfc2a" |
|
3009 |
integrity sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ== |
|
3010 | ||
3011 | 3006 |
fstream@^1.0.0, fstream@^1.0.12: |
3012 | 3007 |
version "1.0.12" |
3013 | 3008 |
resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045" |
Také k dispozici: Unified diff
Re#7494 Implemented edit user settings