Added fetch for single employee and prepared data for access-groups
This commit is contained in:
28
apps/dafa-web/src/app/data/enums/access-group.enum.ts
Normal file
28
apps/dafa-web/src/app/data/enums/access-group.enum.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export enum AccessGroup {
|
||||||
|
UserManagement = 'UserManagement',
|
||||||
|
Economy = 'Economy',
|
||||||
|
Reports = 'Reports',
|
||||||
|
ParticipantManagement = 'ParticipantManagement',
|
||||||
|
User = 'User',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum PegaAccessGroup {
|
||||||
|
Users = 'MeetTest:Users',
|
||||||
|
Administrators = 'MeetTest:Administrators',
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mapPegaAccessGroupToAccessGroups(pegaAccessGroup: PegaAccessGroup): AccessGroup[] {
|
||||||
|
const accessGroups: AccessGroup[] = [];
|
||||||
|
switch (pegaAccessGroup) {
|
||||||
|
case PegaAccessGroup.Users:
|
||||||
|
accessGroups.push(AccessGroup.User);
|
||||||
|
break;
|
||||||
|
case PegaAccessGroup.Administrators:
|
||||||
|
accessGroups.push(AccessGroup.UserManagement);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return accessGroups;
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ export interface UserResponse {
|
|||||||
pyLastSignon: string;
|
pyLastSignon: string;
|
||||||
pyOrganization: string;
|
pyOrganization: string;
|
||||||
pyOrgDivision: string;
|
pyOrgDivision: string;
|
||||||
|
pyOrgUnit: string;
|
||||||
pyTelephone: string;
|
pyTelephone: string;
|
||||||
pyUserIdentifier: string;
|
pyUserIdentifier: string;
|
||||||
pyUserName: string;
|
pyUserName: string;
|
||||||
|
|||||||
@@ -1,21 +1,11 @@
|
|||||||
|
import { mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum';
|
||||||
import { Agency } from '@dafa-models/agency.model';
|
import { Agency } from '@dafa-models/agency.model';
|
||||||
import { EmployeeResponse } from './api/employee-response.model';
|
import { EmployeeResponse } from './api/employee-response.model';
|
||||||
import { Participant } from './participant.model';
|
import { Participant } from './participant.model';
|
||||||
|
import { User } from './user.model';
|
||||||
|
|
||||||
export interface Employee {
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
id: string;
|
export interface Employee extends User {}
|
||||||
firstName: string;
|
|
||||||
lastName: string;
|
|
||||||
fullName: string;
|
|
||||||
organization: string;
|
|
||||||
organizationDivision: string;
|
|
||||||
organizationUnit: string;
|
|
||||||
phone: string;
|
|
||||||
email: string;
|
|
||||||
accessGroup: string;
|
|
||||||
utforandeverksamhet: string;
|
|
||||||
service: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EmployeeDetail extends Employee {
|
export interface EmployeeDetail extends Employee {
|
||||||
languages: string[];
|
languages: string[];
|
||||||
@@ -42,7 +32,7 @@ export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee {
|
|||||||
organizationUnit: data.pyOrgUnit,
|
organizationUnit: data.pyOrgUnit,
|
||||||
phone: data.pyTelephone,
|
phone: data.pyTelephone,
|
||||||
email: '',
|
email: '',
|
||||||
accessGroup: data.pyAccessGroup,
|
accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup),
|
||||||
utforandeverksamhet: '',
|
utforandeverksamhet: '',
|
||||||
service: '',
|
service: '',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { AccessGroup, mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum';
|
||||||
import { UserResponse } from './api/user-response.model';
|
import { UserResponse } from './api/user-response.model';
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
@@ -5,9 +6,14 @@ export interface User {
|
|||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
fullName: string;
|
fullName: string;
|
||||||
userName: string;
|
organization: string;
|
||||||
|
organizationDivision: string;
|
||||||
|
organizationUnit: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
accessGroups: AccessGroup[];
|
||||||
|
utforandeverksamhet: string;
|
||||||
|
service: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapUserReponseToUser(data: UserResponse): User {
|
export function mapUserReponseToUser(data: UserResponse): User {
|
||||||
@@ -16,8 +22,13 @@ export function mapUserReponseToUser(data: UserResponse): User {
|
|||||||
lastName: data.pyLastName,
|
lastName: data.pyLastName,
|
||||||
firstName: data.pyFirstName,
|
firstName: data.pyFirstName,
|
||||||
fullName: `${data.pyFirstName} ${data.pyLastName}`,
|
fullName: `${data.pyFirstName} ${data.pyLastName}`,
|
||||||
userName: data.pyUserName,
|
organization: data.pyOrganization,
|
||||||
|
organizationDivision: data.pyOrgDivision,
|
||||||
|
organizationUnit: data.pyOrgUnit,
|
||||||
phone: data.pyTelephone,
|
phone: data.pyTelephone,
|
||||||
email: data.pyAddresses.Email.pyEmailAddress,
|
email: data.pyAddresses.Email.pyEmailAddress,
|
||||||
|
accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup),
|
||||||
|
utforandeverksamhet: '',
|
||||||
|
service: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,12 @@
|
|||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Personnummer</dt>
|
<dt>Personnummer</dt>
|
||||||
<dd>{{ detailedEmployeeData.ssn || '' }}</dd>
|
<dd *ngIf="detailedEmployeeData.ssn; else emptyDD">{{ detailedEmployeeData.ssn }}</dd>
|
||||||
<dt>Personal-ID</dt>
|
<dt>Telefonnummer</dt>
|
||||||
<dd>{{ detailedEmployeeData.employeeId || '' }}</dd>
|
|
||||||
<dt>Telefon arbete</dt>
|
|
||||||
<dd *ngIf="detailedEmployeeData.phone; else emptyDD">
|
<dd *ngIf="detailedEmployeeData.phone; else emptyDD">
|
||||||
<a [attr.href]="'tel:' + detailedEmployeeData.phone">{{ detailedEmployeeData.phone }}</a>
|
<a [attr.href]="'tel:' + detailedEmployeeData.phone">{{ detailedEmployeeData.phone }}</a>
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Mailadress arbete</dt>
|
<dt>Epost adress</dt>
|
||||||
<dd *ngIf="detailedEmployeeData.email; else emptyDD">
|
<dd *ngIf="detailedEmployeeData.email; else emptyDD">
|
||||||
<a [attr.href]="'mailto:' + detailedEmployeeData.email">{{ detailedEmployeeData.email }}</a>
|
<a [attr.href]="'mailto:' + detailedEmployeeData.email">{{ detailedEmployeeData.email }}</a>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -31,14 +29,22 @@
|
|||||||
<h2>Uppgifter om arbete</h2>
|
<h2>Uppgifter om arbete</h2>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
<dt>Organisation</dt>
|
||||||
|
<dd *ngIf="detailedEmployeeData.organization; else emptyDD">{{ detailedEmployeeData.organization }}</dd>
|
||||||
|
<dt>Avdelning</dt>
|
||||||
|
<dd *ngIf="detailedEmployeeData.organizationDivision; else emptyDD">
|
||||||
|
{{ detailedEmployeeData.organizationDivision }}
|
||||||
|
</dd>
|
||||||
|
<dt>Behörigheter</dt>
|
||||||
|
<dd *ngIf="detailedEmployeeData.accessGroups?.length; else emptyDD">
|
||||||
|
{{ detailedEmployeeData.accessGroups.join(', ') }}
|
||||||
|
</dd>
|
||||||
<dt>Behörighet</dt>
|
<dt>Behörighet</dt>
|
||||||
<ng-container *ngIf="detailedEmployeeData.authorisations?.length; else emptyDD">
|
<ng-container *ngIf="detailedEmployeeData.authorisations?.length; else emptyDD">
|
||||||
<dd *ngFor="let item of detailedEmployeeData.authorisations">
|
<dd *ngFor="let item of detailedEmployeeData.authorisations">
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</dd>
|
</dd>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<dt>Aktivt i arbete</dt>
|
|
||||||
<dd>{{ detailedEmployeeData.active ? 'Ja' : 'Nej' }}</dd>
|
|
||||||
<dt>Frånvaroperiod</dt>
|
<dt>Frånvaroperiod</dt>
|
||||||
<ng-container *ngIf="detailedEmployeeData.outOfOffice?.length; else emptyDD">
|
<ng-container *ngIf="detailedEmployeeData.outOfOffice?.length; else emptyDD">
|
||||||
<dd *ngFor="let date of detailedEmployeeData.outOfOffice">
|
<dd *ngFor="let date of detailedEmployeeData.outOfOffice">
|
||||||
@@ -46,7 +52,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<dt>Tjänst</dt>
|
<dt>Tjänst</dt>
|
||||||
<dd>{{ detailedEmployeeData.service || '' }}</dd>
|
<dd *ngIf="detailedEmployeeData.service; else emptyDD">{{ detailedEmployeeData.service }}</dd>
|
||||||
<dt>Språk</dt>
|
<dt>Språk</dt>
|
||||||
<dd>{{ detailedEmployeeData.languages?.join(', ') }}</dd>
|
<dd>{{ detailedEmployeeData.languages?.join(', ') }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ export class EmployeeCardComponent extends UnsubscribeDirective {
|
|||||||
|
|
||||||
super.unsubscribeOnDestroy(
|
super.unsubscribeOnDestroy(
|
||||||
this.activatedRoute.params.subscribe(({ id }) => {
|
this.activatedRoute.params.subscribe(({ id }) => {
|
||||||
console.log(id);
|
|
||||||
this.detailedEmployeeData$ = this.employeeService.getDetailedEmployeeData(id);
|
this.detailedEmployeeData$ = this.employeeService.getDetailedEmployeeData(id);
|
||||||
}),
|
})
|
||||||
this._pendingSelectedParticipants$.subscribe(ids => console.log(ids))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,16 @@ function filterEmployees(employees: Employee[], searchFilter: string): Employee[
|
|||||||
return employees.filter(person => person.fullName.toLowerCase().includes(searchFilter.toLowerCase()));
|
return employees.filter(person => person.fullName.toLowerCase().includes(searchFilter.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const API_HEADERS = { headers: environment.api.headers };
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EmployeeService {
|
export class EmployeeService {
|
||||||
private _employeesApiUrl = `${environment.api.meet}/employees`;
|
private _employeesApiUrl = `${environment.api.meet}/employees`;
|
||||||
|
private _employeeApiUrl = `${environment.api.meet}/employee`;
|
||||||
private _employeesRawData: Observable<EmployeesApiResponse> = this.httpClient.get<EmployeesApiResponse>(
|
private _employeesRawData: Observable<EmployeesApiResponse> = this.httpClient.get<EmployeesApiResponse>(
|
||||||
this._employeesApiUrl,
|
this._employeesApiUrl,
|
||||||
{ headers: environment.api.headers }
|
API_HEADERS
|
||||||
);
|
);
|
||||||
private _allEmployees$: Observable<Employee[]> = this._employeesRawData.pipe(
|
private _allEmployees$: Observable<Employee[]> = this._employeesRawData.pipe(
|
||||||
map(({ pxResults }) => pxResults.map(result => mapEmployeeReponseToEmployee(result)))
|
map(({ pxResults }) => pxResults.map(result => mapEmployeeReponseToEmployee(result)))
|
||||||
@@ -47,7 +49,9 @@ export class EmployeeService {
|
|||||||
constructor(private httpClient: HttpClient) {}
|
constructor(private httpClient: HttpClient) {}
|
||||||
|
|
||||||
public getDetailedEmployeeData(id: string): Observable<Employee> {
|
public getDetailedEmployeeData(id: string): Observable<Employee> {
|
||||||
return this.httpClient.get<Employee>(`${this._employeesApiUrl}/${id}`, { params: { _embed: 'participants' } });
|
return this.httpClient
|
||||||
|
.get<EmployeesApiResponse>(`${this._employeeApiUrl}/${id}`, API_HEADERS)
|
||||||
|
.pipe(map(({ pxResults }) => mapEmployeeReponseToEmployee(pxResults[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
public setSearchFilter(value: string) {
|
public setSearchFilter(value: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user