feat(export): Added export deltagare. (TV-872)
Squashed commit of the following: commit 9c06b7f1d44a4b48d7f31a22b6bfbd233e09d2f7 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 15:07:15 2021 +0100 Updated api endpoint commit f9bfbecda6d03b70d87febbada920d0eca798b1f Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 15:01:13 2021 +0100 Updated libs commit 9edb413d537288fa0708b8a04eb54f801ebc23a0 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 14:58:13 2021 +0100 Added @types/file-saver commit 624affac55ce771fd58e2770a0d4a98233a8e9ba Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 14:42:29 2021 +0100 Updated libs commit 65dae1d906bbcec474581692b2aced9e47d2484c Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 14:36:42 2021 +0100 Added utils lib config commit 223bd59724663523bdbaf87b5502396156ddb9eb Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 14:06:13 2021 +0100 Added validation commit 166dfcf0448155ac21c0eaa904b4ce1271f73193 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 13:25:35 2021 +0100 Changed styling and removed some fake data commit 3906f2793dd52b626b95c13e115495451332c894 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 13:18:52 2021 +0100 Added digi-ng datepicker commit de0d51434d15cac5476303d4b417c591da16fd8f Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Nov 2 12:31:48 2021 +0100 Added checkbox
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { DropdownTriggerForDirective } from '@msfa-shared/components/dropdown/dropdown-trigger-for.directive';
|
||||
import { MultiselectFilterOption } from '@msfa-shared/components/multiselect/multiselect-filter-option';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
import { uuid } from '@utils/uuid.util';
|
||||
|
||||
interface PropagateChangeFn {
|
||||
(_: unknown): void;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
import { uuid } from '@utils/uuid.util';
|
||||
import { TreeNode, TreeNodeModel, TreeNodesSelectorService } from '../../services/tree-nodes-selector.service';
|
||||
import { TreeNodesSelectorPanelComponent } from '../tree-nodes-selector-panel/tree-nodes-selector-panel.component';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
import { uuid } from '@utils/uuid.util';
|
||||
|
||||
export interface TreeNode {
|
||||
label: string;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface DeltagareExportRequest {
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
includeExportedDeltagare: boolean;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ErrorType } from '@msfa-enums/error-type.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { DeltagareExportRequest } from '@msfa-models/api/deltagare-export.request.model';
|
||||
import { Params } from '@msfa-models/api/params.model';
|
||||
import { CustomError } from '@msfa-models/error/custom-error';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ExportApiService {
|
||||
private _apiBaseUrl = `${environment.api.url}/export`;
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
public fetchDeltagareExportFile$(requestData: DeltagareExportRequest): Observable<Blob> {
|
||||
const params: Params = {
|
||||
...requestData,
|
||||
includeExportedDeltagare: requestData.includeExportedDeltagare.toString(),
|
||||
};
|
||||
|
||||
return this.httpClient
|
||||
.get<Blob>(`${this._apiBaseUrl}/deltagare`, { params, responseType: 'blob' as 'json' })
|
||||
.pipe(
|
||||
catchError((error: Error) => {
|
||||
throw new CustomError({
|
||||
error,
|
||||
message: `Kunde inte hämta exportfilen för deltagare.\n\n${error.message}`,
|
||||
type: ErrorType.API,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ export function mapPathsToBreadcrumbs(
|
||||
} else if (isDeltagareReportingRoute(paths)) {
|
||||
breadcrumbs = breadcrumbs.slice(0, -1);
|
||||
breadcrumbs[breadcrumbs.length - 2].text = 'Deltagarinformation';
|
||||
} else if (isExportRoute(paths)) {
|
||||
breadcrumbs[breadcrumbs.length - 1].text = `Exportera ${paths[paths.length - 1]}`;
|
||||
}
|
||||
|
||||
return breadcrumbs;
|
||||
@@ -54,3 +56,7 @@ function isDeltagareReportingFormRoute(paths: string[]): boolean {
|
||||
function isDeltagareReportingRoute(paths: string[]): boolean {
|
||||
return paths.length === 4 && paths[0] === 'deltagare' && paths[2] in DELTAGARE_REPORTING_ROUTES;
|
||||
}
|
||||
|
||||
function isExportRoute(paths: string[]): boolean {
|
||||
return paths[0] === 'exporter';
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// From https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
|
||||
export function uuid(): string {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
const r = (Math.random() * 16) | 0,
|
||||
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user