-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: add new attribute to employee * feat: alter table employee adding isAway column * feat: update update profile dto * feat: add new translation (en.json) * feat: import spinner module * fix: translation * feat: update view
- Loading branch information
Showing
9 changed files
with
293 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,4 +120,8 @@ | |
} | ||
} | ||
} | ||
.disabled-table { | ||
pointer-events: none; | ||
opacity: 0.5; | ||
} | ||
} |
112 changes: 95 additions & 17 deletions
112
apps/gauzy/src/app/@theme/components/user-menu/user-menu.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,129 @@ | ||
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; | ||
import { NbDialogService } from '@nebular/theme'; | ||
import { IUser } from '@gauzy/contracts'; | ||
import { IEmployee, IUser, IEmployeeUpdateInput } from '@gauzy/contracts'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { BehaviorSubject, tap, Observable, filter, firstValueFrom } from 'rxjs'; | ||
import { EmployeesService, ErrorHandlingService } from '../../../@core'; | ||
|
||
@UntilDestroy({ checkProperties: true }) | ||
@Component({ | ||
selector: 'gauzy-user-menu', | ||
templateUrl: './user-menu.component.html', | ||
styleUrls: ['./user-menu.component.scss'] | ||
styleUrls: ['./user-menu.component.scss'], | ||
}) | ||
export class UserMenuComponent implements OnInit { | ||
@Input() user: IUser; | ||
@Output() close: EventEmitter<any> = new EventEmitter<any>(null); | ||
private _user$: BehaviorSubject<IUser>; | ||
private _employee$: BehaviorSubject<IEmployee>; | ||
private _isSubmit$: BehaviorSubject<boolean>; | ||
|
||
clicks: boolean[] = []; | ||
@Output() | ||
public close: EventEmitter<any> = new EventEmitter<any>(null); | ||
|
||
downloadApps = [ | ||
public clicks: boolean[] = []; | ||
|
||
public downloadApps = [ | ||
{ | ||
link: 'https://web.gauzy.co/downloads#desktop/apple', | ||
icon: 'fab fa-apple' | ||
icon: 'fab fa-apple', | ||
}, | ||
{ | ||
link: 'https://web.gauzy.co/downloads#desktop/windows', | ||
icon: 'fa-brands fa-windows' | ||
icon: 'fa-brands fa-windows', | ||
}, | ||
{ | ||
link: 'https://web.gauzy.co/downloads#desktop/linux', | ||
icon: 'fa-brands fa-linux' | ||
icon: 'fa-brands fa-linux', | ||
}, | ||
{ | ||
link: 'https://web.gauzy.co/downloads#mobile', | ||
icon: 'fas fa-mobile' | ||
icon: 'fas fa-mobile', | ||
}, | ||
{ | ||
link: 'https://web.gauzy.co/downloads#extensions', | ||
icon: 'fa-brands fa-chrome' | ||
} | ||
icon: 'fa-brands fa-chrome', | ||
}, | ||
]; | ||
|
||
constructor(private dialogService: NbDialogService) {} | ||
constructor( | ||
private readonly _employeeService: EmployeesService, | ||
private readonly _errorHandler: ErrorHandlingService | ||
) { | ||
this._user$ = new BehaviorSubject(null); | ||
this._employee$ = new BehaviorSubject(null); | ||
this._isSubmit$ = new BehaviorSubject(false); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.user$ | ||
.pipe( | ||
filter(({ employee }) => !!employee), | ||
tap(async (user: IUser) => { | ||
this._isSubmit$.next(true); | ||
const employee = await firstValueFrom( | ||
this._employeeService.getEmployeeById(user.employeeId) | ||
); | ||
this._employee$.next(employee); | ||
this._isSubmit$.next(false); | ||
|
||
}), | ||
|
||
ngOnInit(): void {} | ||
untilDestroyed(this) | ||
) | ||
.subscribe(); | ||
} | ||
|
||
onClick() { | ||
public onClick() { | ||
this.close.emit(); | ||
} | ||
|
||
onClickOutside(event: boolean) { | ||
public onClickOutside(event: boolean) { | ||
this.clicks.push(event); | ||
if (!event && this.clicks.length > 1) this.onClick(); | ||
} | ||
|
||
public async onChangeStatus(): Promise<void> { | ||
try { | ||
if (!this.employee) { | ||
return; | ||
} | ||
this._isSubmit$.next(true); | ||
const { id, isAway, tenantId, organizationId } = this.employee; | ||
const payload: IEmployeeUpdateInput = { | ||
isAway: !isAway, | ||
tenantId, | ||
organizationId, | ||
}; | ||
await this._employeeService.updateProfile(id, payload); | ||
this._employee$.next({ ...this.employee, ...payload }); | ||
} catch (error) { | ||
this._errorHandler.handleError(error); | ||
} | ||
this._isSubmit$.next(false); | ||
} | ||
|
||
public get employee(): IEmployee { | ||
return this._employee$.getValue(); | ||
} | ||
|
||
public get employee$(): Observable<IEmployee> { | ||
return this._employee$.asObservable(); | ||
} | ||
|
||
@Input() | ||
public set user(value: IUser) { | ||
if (value) { | ||
this._user$.next(value); | ||
} | ||
} | ||
|
||
public get user(): IUser { | ||
return this._user$.getValue(); | ||
} | ||
|
||
public get user$(): Observable<IUser> { | ||
return this._user$.asObservable(); | ||
} | ||
|
||
public get isSubmit$(): Observable<boolean> { | ||
return this._isSubmit$.asObservable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.