diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 6096bff97..ef2794dc0 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -61,7 +61,7 @@ import { XMLHttpRequestConfig, XMLHttpResponse, } from './api.types'; -import { isHttpError, isActiveRecording, includesTarget, isHttpOk, isXMLHttpError } from './api.utils'; +import { isHttpError, includesTarget, isHttpOk, isXMLHttpError } from './api.utils'; import { LoginService } from './Login.service'; import { NotificationService } from './Notifications.service'; import { SessionState } from './service.types'; @@ -775,48 +775,12 @@ export class ApiService { ); } - downloadReport(recording: Recording): void { - const body = new window.FormData(); - if (isActiveRecording(recording)) { - body.append('resource', recording.reportUrl.replace('/api/v1', '/api/v2.1')); - } else { - body.append('resource', recording.reportUrl.concat('/jwt')); - } - this.sendRequest('v2.1', 'auth/token', { - method: 'POST', - body, - }) - .pipe( - concatMap((resp) => resp.json()), - map((response: AssetJwtResponse) => response.data.result.resourceUrl), - ) - .subscribe((resourceUrl) => { - this.downloadFile(resourceUrl, `${recording.name}.report.json`, false); - }); - } - downloadRecording(recording: Recording): void { - const body = new window.FormData(); - if (isActiveRecording(recording)) { - body.append('resource', recording.downloadUrl.replace('/api/v1', '/api/v2.1')); - } else { - body.append('resource', recording.downloadUrl.concat('/jwt')); - } - this.sendRequest('v2.1', 'auth/token', { - method: 'POST', - body, - }) - .pipe( - concatMap((resp) => resp.json()), - map((response: AssetJwtResponse) => response.data.result.resourceUrl), - ) - .subscribe((resourceUrl) => { - this.downloadFile(resourceUrl, recording.name + (recording.name.endsWith('.jfr') ? '' : '.jfr')); - this.downloadFile( - createBlobURL(JSON.stringify(recording.metadata), 'application/json'), // Blob for metadata - recording.name.replace(/\.jfr$/, '') + '.metadata.json', - ); - }); + this.downloadFile(recording.downloadUrl, recording.name + (recording.name.endsWith('.jfr') ? '' : '.jfr')); + this.downloadFile( + createBlobURL(JSON.stringify(recording.metadata), 'application/json'), + recording.name.replace(/\.jfr$/, '') + '.metadata.json', + ); } downloadTemplate(template: EventTemplate): void { diff --git a/src/test/Recordings/ActiveRecordingsTable.test.tsx b/src/test/Recordings/ActiveRecordingsTable.test.tsx index b262e933c..38e98fb0c 100644 --- a/src/test/Recordings/ActiveRecordingsTable.test.tsx +++ b/src/test/Recordings/ActiveRecordingsTable.test.tsx @@ -82,7 +82,6 @@ jest.spyOn(defaultServices.api, 'archiveRecording').mockReturnValue(of(true)); jest.spyOn(defaultServices.api, 'deleteRecording').mockReturnValue(of(true)); jest.spyOn(defaultServices.api, 'doGet').mockReturnValue(of([mockRecording])); jest.spyOn(defaultServices.api, 'downloadRecording').mockReturnValue(void 0); -jest.spyOn(defaultServices.api, 'downloadReport').mockReturnValue(void 0); jest.spyOn(defaultServices.api, 'grafanaDashboardUrl').mockReturnValue(of('/grafanaUrl')); jest.spyOn(defaultServices.api, 'grafanaDatasourceUrl').mockReturnValue(of('/datasource')); jest.spyOn(defaultServices.api, 'stopRecording').mockReturnValue(of(true)); diff --git a/src/test/Recordings/ArchivedRecordingsTable.test.tsx b/src/test/Recordings/ArchivedRecordingsTable.test.tsx index 214aab514..4a492c6ab 100644 --- a/src/test/Recordings/ArchivedRecordingsTable.test.tsx +++ b/src/test/Recordings/ArchivedRecordingsTable.test.tsx @@ -101,7 +101,6 @@ jest.mock('@app/Recordings/RecordingFilters', () => { jest.spyOn(defaultServices.api, 'deleteArchivedRecording').mockReturnValue(of(true)); jest.spyOn(defaultServices.api, 'downloadRecording').mockReturnValue(); -jest.spyOn(defaultServices.api, 'downloadReport').mockReturnValue(); jest.spyOn(defaultServices.api, 'grafanaDatasourceUrl').mockReturnValue(of('/datasource')); jest.spyOn(defaultServices.api, 'grafanaDashboardUrl').mockReturnValue(of('/grafanaUrl')); jest.spyOn(defaultServices.api, 'graphql').mockReturnValue(of(mockArchivedRecordingsResponse));