From 9398f0a1130cdd183c1760d000c3b7bad8bcb134 Mon Sep 17 00:00:00 2001 From: Andreas Dinauer Date: Thu, 25 Dec 2025 13:38:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20Console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 - assets/style.css | 16 ++++ classes/LogRepo.ts | 5 +- classes/Pod.ts | 15 ++- components/LogPopup.vue | 88 ----------------- components/ScrollComponent.vue | 1 + components/deployment/DeploymentComponent.vue | 4 + components/inspect/logs/Console.vue | 95 +++++++++++++++++++ components/inspect/logs/ConsoleConfig.ts | 13 +++ .../inspect/logs/DeploymentLogPopup.vue | 73 ++++++++++++++ components/inspect/logs/PodLogPopup.vue | 64 +++++++++++++ components/pod/PodComponent.vue | 3 +- components/ui/PodPicker.vue | 21 ++++ requests/logs.ts | 1 + 14 files changed, 305 insertions(+), 98 deletions(-) delete mode 100644 components/LogPopup.vue create mode 100644 components/inspect/logs/Console.vue create mode 100644 components/inspect/logs/ConsoleConfig.ts create mode 100644 components/inspect/logs/DeploymentLogPopup.vue create mode 100644 components/inspect/logs/PodLogPopup.vue create mode 100644 components/ui/PodPicker.vue diff --git a/.gitignore b/.gitignore index 4a7f73a..385fd02 100644 --- a/.gitignore +++ b/.gitignore @@ -9,10 +9,6 @@ dist # Node dependencies node_modules -# Logs -logs -*.log - # Misc .DS_Store .fleet diff --git a/assets/style.css b/assets/style.css index 9e986c1..1d93951 100644 --- a/assets/style.css +++ b/assets/style.css @@ -22,6 +22,22 @@ html * { color: black; } +html a.external { + color: #24a4ff; +} + +html .marked.green { + color: #24ff24; +} + +html .marked.yellow { + color: #ffa32b; +} + +html .marked.red { + color: #ff362f; +} + html, body, #__nuxt { width: 100vw; height: 100vh; diff --git a/classes/LogRepo.ts b/classes/LogRepo.ts index 4f23b99..bc9e4dc 100644 --- a/classes/LogRepo.ts +++ b/classes/LogRepo.ts @@ -4,14 +4,13 @@ export class LogRepo { websocket?: WebSocket = undefined; - listen(namespace: string, name: string, onReceive: (logs: Log[]) => void) + listen(resourceType: string, namespace: string, name: string, onReceive: (logs: Log[]) => void) { - const websocket = new WebSocket(StringUtils.format("%s/logs/%s/%s", ApiConfig.getWsBase(), namespace, name)); + const websocket = new WebSocket(StringUtils.format("%s/logs/%s/%s/%s", ApiConfig.getWsBase(), resourceType, namespace, name)); websocket.addEventListener('open', () => { console.info("Opened Websocket."); }) websocket.addEventListener("message", (event) => { - console.log(event.data); onReceive(JSON.parse(event.data) as Log[]); }); const interval = setInterval(() => { diff --git a/classes/Pod.ts b/classes/Pod.ts index c13e1ff..b1c28cf 100644 --- a/classes/Pod.ts +++ b/classes/Pod.ts @@ -2,16 +2,27 @@ import dayjs from "dayjs"; import advancedFormat from "dayjs/plugin/advancedFormat"; import type { Metadata } from "./Metadata"; import type { HasMetadata } from "./repo/ResourceRepo"; +import axios from "axios"; export class Pod implements HasMetadata { - - constructor ( public metadata: Metadata, public spec: Spec, public status: Status ) { } + + static getByDeployment(namespace: string, name: string, onSuccess: (pods: Pod[]) => void) + { + axios.get(StringUtils.format('%s/resources/deployments/%s/%s/pods', ApiConfig.getHttpBase(), namespace, name), { + headers: { + Authorization: "Bearer " + requireToken() + } + }) + .then((response) => { + onSuccess(response.data) + }); + } } class Spec { diff --git a/components/LogPopup.vue b/components/LogPopup.vue deleted file mode 100644 index d5245e2..0000000 --- a/components/LogPopup.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - - - \ No newline at end of file diff --git a/components/ScrollComponent.vue b/components/ScrollComponent.vue index b2e0999..773dbbb 100644 --- a/components/ScrollComponent.vue +++ b/components/ScrollComponent.vue @@ -15,6 +15,7 @@ function scrollToBottom() const element = document.getElementById(id); if(element) { + console.log("Scroll to bottom"); element.scrollTo({top: element.scrollHeight, behavior: 'instant'}); } }) diff --git a/components/deployment/DeploymentComponent.vue b/components/deployment/DeploymentComponent.vue index 4479f01..c841dc3 100644 --- a/components/deployment/DeploymentComponent.vue +++ b/components/deployment/DeploymentComponent.vue @@ -5,11 +5,13 @@

{{ calcAge(deployment.metadata.creationTimestamp) }}

{{ deployment.spec.replicas }}

+ text_snippet autorenew height
+ @@ -18,6 +20,7 @@ import { Deployment } from '~/classes/Deployment'; import { calcAge } from '~/classes/Pod'; import RescaleDeploymentPopup from '../RescaleDeploymentPopup.vue'; import DeploymentViewPopup from "~/components/deployment/view/DeploymentViewPopup.vue"; +import DeploymentLogPopup from "~/components/inspect/logs/DeploymentLogPopup.vue"; defineProps<{ deployment: Deployment @@ -25,4 +28,5 @@ defineProps<{ const rescaleDeploymentPopup = ref(); const showViewPopup = ref(false); +const showLogsPopup = ref(false); \ No newline at end of file diff --git a/components/inspect/logs/Console.vue b/components/inspect/logs/Console.vue new file mode 100644 index 0000000..ac1e536 --- /dev/null +++ b/components/inspect/logs/Console.vue @@ -0,0 +1,95 @@ + + + + + \ No newline at end of file diff --git a/components/inspect/logs/ConsoleConfig.ts b/components/inspect/logs/ConsoleConfig.ts new file mode 100644 index 0000000..28fe525 --- /dev/null +++ b/components/inspect/logs/ConsoleConfig.ts @@ -0,0 +1,13 @@ +export class ConsoleConfig +{ + constructor( + public timestamps: boolean, + public podNames: boolean, + public lineWrap: boolean + ) {} + + static default(timestamps: boolean, podNames: boolean, lineWrap: boolean) + { + return new ConsoleConfig(timestamps, podNames, lineWrap); + } +} \ No newline at end of file diff --git a/components/inspect/logs/DeploymentLogPopup.vue b/components/inspect/logs/DeploymentLogPopup.vue new file mode 100644 index 0000000..b7ab341 --- /dev/null +++ b/components/inspect/logs/DeploymentLogPopup.vue @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file diff --git a/components/inspect/logs/PodLogPopup.vue b/components/inspect/logs/PodLogPopup.vue new file mode 100644 index 0000000..a3495bb --- /dev/null +++ b/components/inspect/logs/PodLogPopup.vue @@ -0,0 +1,64 @@ + + + + + \ No newline at end of file diff --git a/components/pod/PodComponent.vue b/components/pod/PodComponent.vue index 9a0db05..ed084a3 100644 --- a/components/pod/PodComponent.vue +++ b/components/pod/PodComponent.vue @@ -14,7 +14,7 @@ delete - + @@ -23,6 +23,7 @@ import type { Pod } from '~/classes/Pod'; import { calcAge } from '~/classes/Pod'; import PodDeletePopup from './view/PodDeletePopup.vue'; +import PodLogPopup from "~/components/inspect/logs/PodLogPopup.vue"; defineProps<{ pod: Pod diff --git a/components/ui/PodPicker.vue b/components/ui/PodPicker.vue new file mode 100644 index 0000000..5e0725f --- /dev/null +++ b/components/ui/PodPicker.vue @@ -0,0 +1,21 @@ + + + + + \ No newline at end of file diff --git a/requests/logs.ts b/requests/logs.ts index 36593b6..1a732e6 100644 --- a/requests/logs.ts +++ b/requests/logs.ts @@ -3,6 +3,7 @@ import axios from "axios"; export class Log { constructor ( + public podName: string, public timestamp: string, public message: string ) {}