diff --git a/modules/ui/src/app/app.store.spec.ts b/modules/ui/src/app/app.store.spec.ts index 40b2d26dc..57901768c 100644 --- a/modules/ui/src/app/app.store.spec.ts +++ b/modules/ui/src/app/app.store.spec.ts @@ -513,6 +513,7 @@ describe('AppStore', () => { started: '2023-06-22T09:20:00.123Z', finished: '2023-06-22T09:26:00.123Z', report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', tags: [], tests: { total: 3, diff --git a/modules/ui/src/app/components/download-report-zip/download-report-zip.component.spec.ts b/modules/ui/src/app/components/download-report-zip/download-report-zip.component.spec.ts index c0a2bd18b..ae35a64bc 100644 --- a/modules/ui/src/app/components/download-report-zip/download-report-zip.component.spec.ts +++ b/modules/ui/src/app/components/download-report-zip/download-report-zip.component.spec.ts @@ -43,7 +43,8 @@ describe('DownloadReportZipComponent', () => { fixture = TestBed.createComponent(DownloadReportZipComponent); compiled = fixture.nativeElement as HTMLElement; component = fixture.componentInstance; - component.url = 'localhost:8080'; + component.report = 'localhost:8080'; + component.export = 'localhost:8080'; component.data = MOCK_PROGRESS_DATA_COMPLIANT; }); @@ -64,7 +65,8 @@ describe('DownloadReportZipComponent', () => { ariaLabel: 'Download zip', data: { profiles: [], - url: 'localhost:8080', + report: 'localhost:8080', + export: 'localhost:8080', isPilot: false, }, autoFocus: true, diff --git a/modules/ui/src/app/components/download-report-zip/download-report-zip.component.ts b/modules/ui/src/app/components/download-report-zip/download-report-zip.component.ts index 742210937..a9b2443d0 100644 --- a/modules/ui/src/app/components/download-report-zip/download-report-zip.component.ts +++ b/modules/ui/src/app/components/download-report-zip/download-report-zip.component.ts @@ -43,7 +43,8 @@ export class DownloadReportZipComponent implements OnInit { @Input() profiles: Profile[] = []; - @Input() url: string | null | undefined = null; + @Input() report: string | null | undefined = null; + @Input() export: string | null | undefined = null; @HostListener('click', ['$event']) @HostListener('keydown.enter', ['$event']) @@ -56,7 +57,8 @@ export class DownloadReportZipComponent ariaLabel: 'Download zip', data: { profiles: this.profiles, - url: this.url, + report: this.report, + export: this.export, isPilot: this.data?.device.test_pack === TestingType.Pilot, }, autoFocus: true, diff --git a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts index 74d0990e1..3f201b256 100644 --- a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts +++ b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts @@ -64,7 +64,8 @@ describe('DownloadZipModalComponent', () => { provide: MAT_DIALOG_DATA, useValue: { profiles: [PROFILE_MOCK_2, PROFILE_MOCK], - url: 'localhost:8080', + report: 'localhost:8080', + export: 'localhost:8080', }, }, { provide: TestRunService, useValue: testRunServiceMock }, @@ -78,7 +79,8 @@ describe('DownloadZipModalComponent', () => { TestBed.overrideProvider(MAT_DIALOG_DATA, { useValue: { profiles: [PROFILE_MOCK_2, PROFILE_MOCK, PROFILE_MOCK_3], - url: 'localhost:8080', + report: 'localhost:8080', + export: 'localhost:8080', isPilot: true, }, }); @@ -220,7 +222,8 @@ describe('DownloadZipModalComponent', () => { TestBed.overrideProvider(MAT_DIALOG_DATA, { useValue: { profiles: [], - url: 'localhost:8080', + report: 'localhost:8080', + export: 'localhost:8080', }, }); diff --git a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts index bb4c54b62..2884d9ec2 100644 --- a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts +++ b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts @@ -38,7 +38,8 @@ interface DialogData { profiles: Profile[]; testrunStatus?: TestrunStatus; isTestingComplete?: boolean; - url: string | null; + report: string | null; + export: string | null; isPilot?: boolean; } @@ -123,9 +124,12 @@ export class DownloadZipModalComponent ); return; } - if (this.data.url != null && typeof result.profile === 'string') { + if ( + (this.data.report != null || this.data.export != null) && + typeof result.profile === 'string' + ) { this.testRunService.downloadZip( - this.getZipLink(this.data.url), + this.getZipLink(this.data), result.profile ); if (this.data.isPilot) { @@ -177,7 +181,7 @@ export class DownloadZipModalComponent return data.status; } - private getZipLink(reportURL: string): string { - return reportURL.replace('report', 'export'); + private getZipLink(data: DialogData): string { + return data.export || data.report!.replace('report', 'export'); } } diff --git a/modules/ui/src/app/mocks/reports.mock.ts b/modules/ui/src/app/mocks/reports.mock.ts index 0c127b18c..5cfff1e06 100644 --- a/modules/ui/src/app/mocks/reports.mock.ts +++ b/modules/ui/src/app/mocks/reports.mock.ts @@ -17,6 +17,7 @@ export const HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', }, @@ -34,6 +35,7 @@ export const HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-07-23T10:11:00.123Z', finished: '2023-07-23T10:17:10.123Z', }, @@ -51,6 +53,7 @@ export const HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', }, @@ -71,6 +74,7 @@ export const HISTORY_AFTER_REMOVE = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', }, @@ -88,6 +92,7 @@ export const HISTORY_AFTER_REMOVE = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', }, @@ -108,6 +113,7 @@ export const FORMATTED_HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', deviceFirmware: '1.2.2', @@ -130,6 +136,7 @@ export const FORMATTED_HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-07-23T10:11:00.123Z', finished: '2023-07-23T10:17:10.123Z', deviceFirmware: '1.2.3', @@ -152,6 +159,7 @@ export const FORMATTED_HISTORY = [ }, tags: [], report: 'https://api.testrun.io/report.pdf', + export: 'https://api.testrun.io/export.pdf', started: '2023-06-23T10:11:00.123Z', finished: '2023-06-23T10:17:10.123Z', deviceFirmware: '1.2.2', diff --git a/modules/ui/src/app/mocks/testrun.mock.ts b/modules/ui/src/app/mocks/testrun.mock.ts index 48321f2d5..4739ddcdb 100644 --- a/modules/ui/src/app/mocks/testrun.mock.ts +++ b/modules/ui/src/app/mocks/testrun.mock.ts @@ -116,6 +116,7 @@ const PROGRESS_DATA_RESPONSE = ( finished, tests, report, + export: '', tags: ['VSA', 'Other tag', 'And one more'], } as TestrunStatus; if (result) { diff --git a/modules/ui/src/app/model/testrun-status.ts b/modules/ui/src/app/model/testrun-status.ts index 04596d5e4..a990a2a45 100644 --- a/modules/ui/src/app/model/testrun-status.ts +++ b/modules/ui/src/app/model/testrun-status.ts @@ -25,6 +25,7 @@ export interface TestrunStatus { finished: string | null; tests?: TestsResponse; report: string; + export: string; tags: string[] | null; } @@ -114,6 +115,7 @@ export const IDLE_STATUS = { started: null, finished: null, report: '', + export: '', mac_addr: '', tests: { total: 0, diff --git a/modules/ui/src/app/pages/reports/reports.component.html b/modules/ui/src/app/pages/reports/reports.component.html index c187a6c27..48df4157d 100644 --- a/modules/ui/src/app/pages/reports/reports.component.html +++ b/modules/ui/src/app/pages/reports/reports.component.html @@ -167,7 +167,8 @@

Reports

(Topic.Status).pipe( map(result => { result.report = this.testrunService.changeReportURL(result.report); + result.export = this.testrunService.changeReportURL(result.export); return result; }) ); diff --git a/modules/ui/src/app/services/test-run.service.ts b/modules/ui/src/app/services/test-run.service.ts index ee5b99f7c..ed252361d 100644 --- a/modules/ui/src/app/services/test-run.service.ts +++ b/modules/ui/src/app/services/test-run.service.ts @@ -58,7 +58,7 @@ export class TestRunService { return ''; } // replace url part before '/report' from static to dynamic API URL - return url.replace(/^.*(?=\/report)/, `${API_URL}`); + return url.replace(/^.*(?=\/report|\/export)/, `${API_URL}`); } fetchDevices(): Observable { @@ -83,6 +83,7 @@ export class TestRunService { return this.http.get(`${API_URL}/system/status`).pipe( map(result => { result.report = this.changeReportURL(result.report); + result.export = this.changeReportURL(result.export); return result; }), catchError(() => { @@ -152,9 +153,10 @@ export class TestRunService { getHistory(): Observable { return this.http.get(`${API_URL}/reports`).pipe( map(result => { - result.forEach( - item => (item.report = this.changeReportURL(item.report)) - ); + result.forEach(item => { + item.report = this.changeReportURL(item.report); + item.export = this.changeReportURL(item.export); + }); return result; }) );