Added Pega API
This commit is contained in:
11
angular.json
11
angular.json
@@ -82,6 +82,14 @@
|
||||
"maximumError": "10kb"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pega": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/dafa-web/src/environments/environment.ts",
|
||||
"with": "apps/dafa-web/src/environments/environment.pega.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -94,6 +102,9 @@
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "dafa-web:build:production"
|
||||
},
|
||||
"pega": {
|
||||
"browserTarget": "dafa-web:build:pega"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Agency } from '@dafa-models/agency.model';
|
||||
import { Participant } from './participant.model';
|
||||
import { EmployeeReponse } from './pega/employee-reponse.model';
|
||||
|
||||
export interface Employee {
|
||||
id: string;
|
||||
@@ -25,3 +26,18 @@ export interface EmployeeDetail extends Employee {
|
||||
agencies: Agency[];
|
||||
participants: Participant[];
|
||||
}
|
||||
|
||||
export function mapEmployeeReponseToEmployee(data: EmployeeReponse): Employee {
|
||||
const names = data.pyUserName.split(' ');
|
||||
|
||||
return {
|
||||
id: data.pyUserIdentifier,
|
||||
employeeId: data.pyUserIdentifier,
|
||||
lastName: names.pop() || 'Doe',
|
||||
firstName: names.join(' ') || 'John',
|
||||
utforandeverksamhet: '',
|
||||
active: true,
|
||||
service: '',
|
||||
fullName: data.pyUserName,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface EmployeeReponse {
|
||||
pxObjClass: string;
|
||||
pyAccessGroup: string;
|
||||
pyLabel: string;
|
||||
pyPosition: string;
|
||||
pyReportTo: string;
|
||||
pyUserIdentifier: string;
|
||||
pyUserName: string;
|
||||
pyWorkGroup: string;
|
||||
}
|
||||
@@ -52,7 +52,7 @@
|
||||
[afCurrentResultEnd]="currentResultEnd"
|
||||
[afTotalResults]="employees.length"
|
||||
(afOnPageChange)="handlePagination($event.detail)"
|
||||
af-result-name="deltagare"
|
||||
af-result-name="medarbetare"
|
||||
>
|
||||
</digi-navigation-pagination>
|
||||
</div>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
<form class="employees__search-wrapper" (ngSubmit)="handleSearchSubmit()">
|
||||
<digi-form-input-search
|
||||
af-label="Sök kunder"
|
||||
af-label-description="Sök på namn eller ärendenummer"
|
||||
af-label="Sök personal"
|
||||
af-label-description="Sök på namn"
|
||||
(afOnInput)="handleSearchInput($event)"
|
||||
></digi-form-input-search>
|
||||
</form>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<form class="participants__search-wrapper" (ngSubmit)="handleSearchSubmit()">
|
||||
<digi-form-input-search
|
||||
af-label="Sök kunder"
|
||||
af-label="Sök deltagare"
|
||||
af-label-description="Sök på namn eller ärendenummer"
|
||||
(afOnInput)="handleSearchInput($event)"
|
||||
></digi-form-input-search>
|
||||
|
||||
69
apps/dafa-web/src/app/services/api/employee.service copy.ts
Normal file
69
apps/dafa-web/src/app/services/api/employee.service copy.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '@dafa-environment';
|
||||
import { Employee, EmployeeDetail } from '@dafa-models/employee.model';
|
||||
import { SortBy } from '@dafa-models/sort-by.model';
|
||||
import { sort } from '@dafa-utils/sort.util';
|
||||
import { BehaviorSubject, combineLatest, Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
function filterEmployees(employees: Employee[], searchFilter: string): Employee[] {
|
||||
return employees.filter(person => {
|
||||
const searchValueExistsInName = person.fullName.toLowerCase().includes(searchFilter.toLowerCase());
|
||||
|
||||
return searchValueExistsInName;
|
||||
});
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EmployeeService {
|
||||
private _employeesApiUrl = `${environment.apiBase}/employees`;
|
||||
private _allEmployees$: Observable<Employee[]> = this.httpClient.get<Employee[]>(this._employeesApiUrl, {
|
||||
params: { _embed: 'participants' },
|
||||
});
|
||||
|
||||
private _employeesSortBy$ = new BehaviorSubject<SortBy | null>({ key: 'fullName', reverse: false });
|
||||
public employeesSortBy$: Observable<SortBy> = this._employeesSortBy$.asObservable();
|
||||
private _searchFilter$ = new BehaviorSubject<string>('');
|
||||
public searchFilter$: Observable<string> = this._searchFilter$.asObservable();
|
||||
|
||||
private _filteredEmployees$: Observable<Employee[]> = combineLatest([this._allEmployees$, this._searchFilter$]).pipe(
|
||||
map(([employees, searchFilter]) => filterEmployees(employees, searchFilter))
|
||||
);
|
||||
|
||||
public filteredEmployees$: Observable<Employee[]> = combineLatest([
|
||||
this._filteredEmployees$,
|
||||
this._employeesSortBy$,
|
||||
]).pipe(
|
||||
map(([employees, sortBy]) => {
|
||||
return sortBy ? sort(employees, sortBy) : employees;
|
||||
})
|
||||
);
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
public getDetailedEmployeeData(id: string): Observable<Employee> {
|
||||
return this.httpClient.get<Employee>(`${this._employeesApiUrl}/${id}`, { params: { _embed: 'participants' } });
|
||||
}
|
||||
|
||||
public setSearchFilter(value: string) {
|
||||
this._searchFilter$.next(value);
|
||||
}
|
||||
|
||||
public setEmployeesSortKey(key: keyof Employee) {
|
||||
const currentSortBy = this._employeesSortBy$.getValue();
|
||||
const reverse = currentSortBy?.key === key ? !currentSortBy.reverse : false;
|
||||
this._employeesSortBy$.next({ key, reverse });
|
||||
}
|
||||
|
||||
public createAccount(employeesData: EmployeeDetail): Observable<string> {
|
||||
return this.httpClient.post<EmployeeDetail>(this._employeesApiUrl, employeesData).pipe(
|
||||
map(data => data.id),
|
||||
catchError(error => {
|
||||
return throwError(error);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,26 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '@dafa-environment';
|
||||
import { Employee, EmployeeDetail } from '@dafa-models/employee.model';
|
||||
import { Employee, EmployeeDetail, mapEmployeeReponseToEmployee } from '@dafa-models/employee.model';
|
||||
import { SortBy } from '@dafa-models/sort-by.model';
|
||||
import { sort } from '@dafa-utils/sort.util';
|
||||
import { BehaviorSubject, combineLatest, Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
function filterEmployees(employees: Employee[], searchFilter: string): Employee[] {
|
||||
return employees.filter(person => {
|
||||
const searchValueExistsInName = person.fullName.toLowerCase().includes(searchFilter.toLowerCase());
|
||||
|
||||
return searchValueExistsInName;
|
||||
});
|
||||
return employees.filter(person => person.fullName.toLowerCase().includes(searchFilter.toLowerCase()));
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EmployeeService {
|
||||
private _employeesApiUrl = `${environment.apiBase}/employees`;
|
||||
private _allEmployees$: Observable<Employee[]> = this.httpClient.get<Employee[]>(this._employeesApiUrl, {
|
||||
params: { _embed: 'participants' },
|
||||
});
|
||||
private _employeesApiUrl = `${environment.apiBase}/D_pxOperatorsList`;
|
||||
private _allEmployees$: Observable<Employee[]> = this.httpClient
|
||||
.get<any>(this._employeesApiUrl, {
|
||||
headers: environment.apiHeaders,
|
||||
})
|
||||
.pipe(map(({ pxResults }) => pxResults.map(result => mapEmployeeReponseToEmployee(result))));
|
||||
|
||||
private _employeesSortBy$ = new BehaviorSubject<SortBy | null>({ key: 'fullName', reverse: false });
|
||||
public employeesSortBy$: Observable<SortBy> = this._employeesSortBy$.asObservable();
|
||||
|
||||
7
apps/dafa-web/src/environments/environment.pega.ts
Normal file
7
apps/dafa-web/src/environments/environment.pega.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiBase: 'https://dafa-utv.tocp.arbetsformedlingen.se/prweb/api/v1/data',
|
||||
apiHeaders: {
|
||||
Authorization: 'Basic dGVzdHVzZXIxOmRhZmFAMTIz', // user: testuser1, password: dafa@123
|
||||
},
|
||||
};
|
||||
@@ -1,17 +1,5 @@
|
||||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiBase: '/api',
|
||||
apiHeaders: {},
|
||||
};
|
||||
|
||||
/*
|
||||
* For easier debugging in development mode, you can import the following file
|
||||
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||
*
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
|
||||
2
openshift/dev/Jenkinsfile
vendored
2
openshift/dev/Jenkinsfile
vendored
@@ -97,7 +97,7 @@ pipeline {
|
||||
echo '### Building application... ###'
|
||||
|
||||
sh '''
|
||||
npm run build:dafa
|
||||
npm run build:pega
|
||||
|
||||
cp nginx/nginx.conf ${NGINX_PATH}
|
||||
#cp -r nginx/* ${NGINX_PATH}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
"nx": "nx",
|
||||
"start": "ng serve",
|
||||
"start:dafa": "ng serve dafa-web",
|
||||
"start:pega": "ng serve dafa-web --configuration pega",
|
||||
"build": "ng build",
|
||||
"build:dafa": "ng build dafa-web",
|
||||
"build:pega": "ng build dafa-web --configuration pega",
|
||||
"test": "ng test",
|
||||
"test:dafa": "ng test dafa-web",
|
||||
"lint": "nx workspace-lint && ng lint",
|
||||
|
||||
Reference in New Issue
Block a user