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;
|
||||
pyOrganization: string;
|
||||
pyOrgDivision: string;
|
||||
pyOrgUnit: string;
|
||||
pyTelephone: string;
|
||||
pyUserIdentifier: string;
|
||||
pyUserName: string;
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
import { mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum';
|
||||
import { Agency } from '@dafa-models/agency.model';
|
||||
import { EmployeeResponse } from './api/employee-response.model';
|
||||
import { Participant } from './participant.model';
|
||||
import { User } from './user.model';
|
||||
|
||||
export interface Employee {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
organization: string;
|
||||
organizationDivision: string;
|
||||
organizationUnit: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
accessGroup: string;
|
||||
utforandeverksamhet: string;
|
||||
service: string;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface Employee extends User {}
|
||||
|
||||
export interface EmployeeDetail extends Employee {
|
||||
languages: string[];
|
||||
@@ -42,7 +32,7 @@ export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee {
|
||||
organizationUnit: data.pyOrgUnit,
|
||||
phone: data.pyTelephone,
|
||||
email: '',
|
||||
accessGroup: data.pyAccessGroup,
|
||||
accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup),
|
||||
utforandeverksamhet: '',
|
||||
service: '',
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AccessGroup, mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum';
|
||||
import { UserResponse } from './api/user-response.model';
|
||||
|
||||
export interface User {
|
||||
@@ -5,9 +6,14 @@ export interface User {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
userName: string;
|
||||
organization: string;
|
||||
organizationDivision: string;
|
||||
organizationUnit: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
accessGroups: AccessGroup[];
|
||||
utforandeverksamhet: string;
|
||||
service: string;
|
||||
}
|
||||
|
||||
export function mapUserReponseToUser(data: UserResponse): User {
|
||||
@@ -16,8 +22,13 @@ export function mapUserReponseToUser(data: UserResponse): User {
|
||||
lastName: data.pyLastName,
|
||||
firstName: data.pyFirstName,
|
||||
fullName: `${data.pyFirstName} ${data.pyLastName}`,
|
||||
userName: data.pyUserName,
|
||||
organization: data.pyOrganization,
|
||||
organizationDivision: data.pyOrgDivision,
|
||||
organizationUnit: data.pyOrgUnit,
|
||||
phone: data.pyTelephone,
|
||||
email: data.pyAddresses.Email.pyEmailAddress,
|
||||
accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup),
|
||||
utforandeverksamhet: '',
|
||||
service: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@
|
||||
|
||||
<dl>
|
||||
<dt>Personnummer</dt>
|
||||
<dd>{{ detailedEmployeeData.ssn || '' }}</dd>
|
||||
<dt>Personal-ID</dt>
|
||||
<dd>{{ detailedEmployeeData.employeeId || '' }}</dd>
|
||||
<dt>Telefon arbete</dt>
|
||||
<dd *ngIf="detailedEmployeeData.ssn; else emptyDD">{{ detailedEmployeeData.ssn }}</dd>
|
||||
<dt>Telefonnummer</dt>
|
||||
<dd *ngIf="detailedEmployeeData.phone; else emptyDD">
|
||||
<a [attr.href]="'tel:' + detailedEmployeeData.phone">{{ detailedEmployeeData.phone }}</a>
|
||||
</dd>
|
||||
<dt>Mailadress arbete</dt>
|
||||
<dt>Epost adress</dt>
|
||||
<dd *ngIf="detailedEmployeeData.email; else emptyDD">
|
||||
<a [attr.href]="'mailto:' + detailedEmployeeData.email">{{ detailedEmployeeData.email }}</a>
|
||||
</dd>
|
||||
@@ -31,14 +29,22 @@
|
||||
<h2>Uppgifter om arbete</h2>
|
||||
|
||||
<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>
|
||||
<ng-container *ngIf="detailedEmployeeData.authorisations?.length; else emptyDD">
|
||||
<dd *ngFor="let item of detailedEmployeeData.authorisations">
|
||||
{{ item }}
|
||||
</dd>
|
||||
</ng-container>
|
||||
<dt>Aktivt i arbete</dt>
|
||||
<dd>{{ detailedEmployeeData.active ? 'Ja' : 'Nej' }}</dd>
|
||||
<dt>Frånvaroperiod</dt>
|
||||
<ng-container *ngIf="detailedEmployeeData.outOfOffice?.length; else emptyDD">
|
||||
<dd *ngFor="let date of detailedEmployeeData.outOfOffice">
|
||||
@@ -46,7 +52,7 @@
|
||||
</dd>
|
||||
</ng-container>
|
||||
<dt>Tjänst</dt>
|
||||
<dd>{{ detailedEmployeeData.service || '' }}</dd>
|
||||
<dd *ngIf="detailedEmployeeData.service; else emptyDD">{{ detailedEmployeeData.service }}</dd>
|
||||
<dt>Språk</dt>
|
||||
<dd>{{ detailedEmployeeData.languages?.join(', ') }}</dd>
|
||||
</dl>
|
||||
|
||||
@@ -21,10 +21,8 @@ export class EmployeeCardComponent extends UnsubscribeDirective {
|
||||
|
||||
super.unsubscribeOnDestroy(
|
||||
this.activatedRoute.params.subscribe(({ id }) => {
|
||||
console.log(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()));
|
||||
}
|
||||
|
||||
const API_HEADERS = { headers: environment.api.headers };
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EmployeeService {
|
||||
private _employeesApiUrl = `${environment.api.meet}/employees`;
|
||||
private _employeeApiUrl = `${environment.api.meet}/employee`;
|
||||
private _employeesRawData: Observable<EmployeesApiResponse> = this.httpClient.get<EmployeesApiResponse>(
|
||||
this._employeesApiUrl,
|
||||
{ headers: environment.api.headers }
|
||||
API_HEADERS
|
||||
);
|
||||
private _allEmployees$: Observable<Employee[]> = this._employeesRawData.pipe(
|
||||
map(({ pxResults }) => pxResults.map(result => mapEmployeeReponseToEmployee(result)))
|
||||
@@ -47,7 +49,9 @@ export class EmployeeService {
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user