From 215c316be9acc3644e5fe58440270c3f1d909dc2 Mon Sep 17 00:00:00 2001 From: Claudia Bressi Date: Wed, 9 Aug 2023 09:53:50 +0200 Subject: [PATCH] Enable execution logs for tasks executing on platform != default (#1926) * Fetch link on task execution resource * Up model * Up clean fields * Enable test on logs for task executions * schemaTarget on task exeuction model * Up check * Up * Up test * Up parameters * Cleanup field * Cleanup * Polish test --- ui/src/app/shared/api/task.service.spec.ts | 7 +++++-- ui/src/app/shared/api/task.service.ts | 15 +++++++-------- ui/src/app/shared/model/task-execution.model.ts | 13 ++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ui/src/app/shared/api/task.service.spec.ts b/ui/src/app/shared/api/task.service.spec.ts index db0a565c9..3ec1c632a 100644 --- a/ui/src/app/shared/api/task.service.spec.ts +++ b/ui/src/app/shared/api/task.service.spec.ts @@ -147,12 +147,15 @@ describe('shared/api/task.service.ts', () => { taskService.getExecutionLogs( TaskExecution.parse({ externalExecutionId: 'foo', - arguments: ['--spring.cloud.data.flow.platformname=bar'] + schemaTarget: 'boot3', + arguments: [ + '--spring.cloud.data.flow.platformname=bar' + ] }) ); const httpUri = mockHttp.get.calls.mostRecent().args[0]; const headerArgs = mockHttp.get.calls.mostRecent().args[1].headers; - expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar'); + expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar&schemaTarget=boot3'); expect(headerArgs.get('Content-Type')).toEqual('application/json'); expect(headerArgs.get('Accept')).toEqual('application/json'); }); diff --git a/ui/src/app/shared/api/task.service.ts b/ui/src/app/shared/api/task.service.ts index 3b363037e..355f8bc45 100644 --- a/ui/src/app/shared/api/task.service.ts +++ b/ui/src/app/shared/api/task.service.ts @@ -256,16 +256,15 @@ export class TaskService { } }); } + const url = taskExecution?._links && taskExecution?._links['tasks/logs'] !== undefined + ? taskExecution?._links['tasks/logs'].href : + UrlUtilities.calculateBaseApiUrl() + `tasks/logs/${taskExecution.externalExecutionId}?platformName=${platformName}&schemaTarget=${taskExecution.schemaTarget}`; const params = new HttpParams({encoder: new DataflowEncoder()}); return this.httpClient - .get( - UrlUtilities.calculateBaseApiUrl() + - `tasks/logs/${taskExecution.externalExecutionId}?platformName=${platformName}`, - { - headers, - params - } - ) + .get(url, { + headers, + params + }) .pipe(catchError(ErrorUtils.catchError)); } diff --git a/ui/src/app/shared/model/task-execution.model.ts b/ui/src/app/shared/model/task-execution.model.ts index fceb7b9a8..df1310791 100644 --- a/ui/src/app/shared/model/task-execution.model.ts +++ b/ui/src/app/shared/model/task-execution.model.ts @@ -1,6 +1,14 @@ import {DateTime} from 'luxon'; import {Page} from './page.model'; +interface hrefObj { + href: string; +} + +interface TaskExecutionLinks { + 'tasks/logs': hrefObj; +} + export class LaunchResponse { executionId: number; schemaTarget: string; @@ -23,13 +31,14 @@ export class TaskExecution { arguments: string[]; jobExecutionIds: number[]; errorMessage: string; + schemaTarget: string; externalExecutionId: string; taskExecutionStatus: string; parentExecutionId: number; resourceUrl: string; appProperties: any; - schemaTarget: string; deploymentProperties: {[key: string]: string}; + _links: TaskExecutionLinks; static parse(input: any): TaskExecution { const execution = new TaskExecution(); @@ -41,6 +50,7 @@ export class TaskExecution { execution.endTime = input?.endTime ? DateTime.fromISO(input.endTime) : null; execution.exitMessage = input?.exitMessage; execution.arguments = input?.arguments || []; + execution.schemaTarget = input?.schemaTarget || 'boot2'; execution.jobExecutionIds = input?.jobExecutionIds || []; execution.errorMessage = input?.errorMessage; execution.taskExecutionStatus = input?.taskExecutionStatus; @@ -49,6 +59,7 @@ export class TaskExecution { execution.resourceUrl = input?.resourceUrl; execution.appProperties = input?.appProperties; execution.deploymentProperties = input?.deploymentProperties; + execution._links = input?._links; execution.schemaTarget = input?.schemaTarget; return execution; }