From fd404d5343c4226b5abaee0c64785aa91dc86265 Mon Sep 17 00:00:00 2001 From: pgiertych Date: Tue, 16 Jan 2024 13:55:52 +0100 Subject: [PATCH] finished log view --- .../app-log-access.component.css | 15 ++++++ .../app-log-access.component.html | 30 +++++++----- .../app-log-access.component.ts | 48 +++++++++++-------- .../appinstance/appinstance.routes.ts | 2 + .../appinstance/appinstance.component.html | 7 ++- 5 files changed, 68 insertions(+), 34 deletions(-) diff --git a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.css b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.css index e69de29..eede507 100644 --- a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.css +++ b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.css @@ -0,0 +1,15 @@ +.terminal { + height: 60vh; + overflow-y: scroll; + padding: 10px; + background: black; + color: white; +} + +.log { + white-space: pre-wrap; +} + +.button-height { + height: 70%; +} diff --git a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.html b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.html index 46ddf9b..13d1edd 100644 --- a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.html +++ b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.html @@ -1,13 +1,11 @@ -

Application instance logs

-
-

Logs

-
-
+

{{ 'APP_INSTANCE.LOG_ACCESS.HEADER' | translate}}

+
+
-

Pod selector

+

{{ 'APP_INSTANCE.LOG_ACCESS.POD' | translate}}

+ placeholder="{{ 'APP_INSTANCE.LOG_ACCESS.DROPDOWN_PLACEHOLDER' | translate}}" class="col-2 bottom"> {{ option.displayName }} @@ -15,12 +13,18 @@

Pod selector

{{ selected.displayName }}
-
-
-

{{ line }}

-
- Download log in a text file -
+
+ + +
+
+
{{ log }}
diff --git a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.ts b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.ts index 56a3d1d..d8976b5 100644 --- a/src/app/appmarket/appinstance/app-log-access/app-log-access.component.ts +++ b/src/app/appmarket/appinstance/app-log-access/app-log-access.component.ts @@ -2,6 +2,7 @@ import {Component, Input, OnInit} from '@angular/core'; import {PodLogs} from '../../../model/pod-logs'; import {AppLogsService} from '../../../service/app-logs.service'; import {PodInfo} from '../../../model/podinfo'; +import {ActivatedRoute} from '@angular/router'; @Component({ selector: 'app-log-access', @@ -18,26 +19,39 @@ export class AppLogAccessComponent implements OnInit { public blobUrl; - constructor(private logService: AppLogsService) { - } + constructor(private logService: AppLogsService, + private route: ActivatedRoute) {} ngOnInit(): void { - this.logService.getPodNames(this.appInstanceId).subscribe( - podNames => { - this.pods = new Map(); - this.podInfos = podNames; - podNames.forEach(pod => { - this.logService.getLogsFromPod(this.appInstanceId, pod.name).subscribe( - podLogs => { - this.pods.set(pod, podLogs); - } - ) - }) - } + this.retrieveLogs(); + } + + private retrieveLogs(): void { + this.route.params.subscribe(params => { + this.appInstanceId = params['id']; + this.logService.getPodNames(this.appInstanceId).subscribe( + podNames => { + this.pods = new Map(); + this.podInfos = podNames; + podNames.forEach(pod => { + this.logService.getLogsFromPod(this.appInstanceId, pod.name).subscribe( + podLogs => { + this.pods.set(pod, podLogs); + } + ) + }) + } + ) + }) + } + + refreshLogs(pod: PodInfo): void { + this.logService.getLogsFromPod(this.appInstanceId, pod.name).subscribe( + podLogs => this.selectedPodLogs = podLogs ) } - getLogs(podName: string, lines: string[]): void { + downloadLogs(podName: string, lines: string[]): void { const content = lines.join('\n'); const blob = new Blob([content], {type: 'text/plain'}) this.blobUrl = window.URL.createObjectURL(blob); @@ -51,10 +65,6 @@ export class AppLogAccessComponent implements OnInit { a.remove(); } - hasMultiplePods(): boolean { - return this.pods.size > 1; - } - selectPod(event: any): void { this.selectedPodLogs = this.pods.get(event.value); } diff --git a/src/app/appmarket/appinstance/appinstance.routes.ts b/src/app/appmarket/appinstance/appinstance.routes.ts index e5cb4ef..c92d262 100644 --- a/src/app/appmarket/appinstance/appinstance.routes.ts +++ b/src/app/appmarket/appinstance/appinstance.routes.ts @@ -1,9 +1,11 @@ import {Route} from '@angular/router'; import {AppInstanceComponent, AppInstanceListComponent} from './index'; import {AppInstanceShellViewComponent} from './appinstance-shell-view/appinstance-shell-view.component'; +import {AppLogAccessComponent} from './app-log-access/app-log-access.component'; export const AppInstanceRoutes: Route[] = [ {path: 'instances', component: AppInstanceListComponent}, {path: 'instances/:id', component: AppInstanceComponent}, {path: 'instances/:id/shell/:podname', component: AppInstanceShellViewComponent}, + {path: 'instances/:id/logs', component: AppLogAccessComponent}, ]; diff --git a/src/app/appmarket/appinstance/appinstance/appinstance.component.html b/src/app/appmarket/appinstance/appinstance/appinstance.component.html index e582b6d..29e8556 100644 --- a/src/app/appmarket/appinstance/appinstance/appinstance.component.html +++ b/src/app/appmarket/appinstance/appinstance/appinstance.component.html @@ -149,6 +149,11 @@

{{ translateState(appInstanceStatus?.state) }} +
  • + + {{'APP_INSTANCE.VIEW_LOGS' | translate}} + +
  • {{'APP_INSTANCE.UNDEPLOY_BUTTON' | translate}} @@ -318,8 +323,6 @@

    {{'APP_INSTANCE.DEPLOYMENT_HISTORY.HEADER' | translate}}

    screenReaderPaginationLabel="{{ 'PAGINATION.SCREEN_READER.PAGINATION' | translate }}" screenReaderPageLabel="{{ 'PAGINATION.SCREEN_READER.PAGE' | translate }}" screenReaderCurrentLabel="{{ 'PAGINATION.SCREEN_READER.CURRENT' | translate }}"> - -