From b755ff13180d42303b00a0f75ea776d43b2f6433 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Wed, 4 Sep 2024 21:50:13 +0200 Subject: [PATCH 1/2] remove log timestamps --- cyclops-ctrl/internal/controller/modules.go | 18 ++++++++++++++++-- .../k8s-resources/common/PodTable/PodLogs.tsx | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cyclops-ctrl/internal/controller/modules.go b/cyclops-ctrl/internal/controller/modules.go index db3d2310..479ab4b2 100644 --- a/cyclops-ctrl/internal/controller/modules.go +++ b/cyclops-ctrl/internal/controller/modules.go @@ -10,13 +10,13 @@ import ( "github.com/gin-gonic/gin" "github.com/cyclops-ui/cyclops/cyclops-ctrl/api/v1alpha1" - "github.com/cyclops-ui/cyclops/cyclops-ctrl/pkg/cluster/k8sclient" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/mapper" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/models/dto" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/prometheus" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/telemetry" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/template" "github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/template/render" + "github.com/cyclops-ui/cyclops/cyclops-ctrl/pkg/cluster/k8sclient" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -505,7 +505,7 @@ func (m *Modules) GetLogs(ctx *gin.Context) { ctx.Header("Access-Control-Allow-Origin", "*") logCount := int64(100) - logs, err := m.kubernetesClient.GetPodLogs( + rawLogs, err := m.kubernetesClient.GetPodLogs( ctx.Param("namespace"), ctx.Param("container"), ctx.Param("name"), @@ -517,6 +517,11 @@ func (m *Modules) GetLogs(ctx *gin.Context) { return } + logs := make([]string, 0, len(rawLogs)) + for _, log := range rawLogs { + logs = append(logs, trimLogLine(log)) + } + ctx.JSON(http.StatusOK, logs) } @@ -686,3 +691,12 @@ func getTargetGeneration(generation string, module *v1alpha1.Module) (*v1alpha1. Status: module.Status, }, true } + +func trimLogLine(logLine string) string { + // Split the line by the first space after the timestamp + parts := strings.SplitN(logLine, " ", 2) + if len(parts) > 1 { + return parts[1] + } + return logLine +} diff --git a/cyclops-ui/src/components/k8s-resources/common/PodTable/PodLogs.tsx b/cyclops-ui/src/components/k8s-resources/common/PodTable/PodLogs.tsx index 6843b9eb..cfd34609 100644 --- a/cyclops-ui/src/components/k8s-resources/common/PodTable/PodLogs.tsx +++ b/cyclops-ui/src/components/k8s-resources/common/PodTable/PodLogs.tsx @@ -189,7 +189,8 @@ const PodLogs = ({ pod }: PodLogsProps) => { onOk={handleCancelLogs} onCancel={handleCancelLogs} cancelButtonProps={{ style: { display: "none" } }} - width={"60%"} + style={{ zIndex: 100 }} + width={"80%"} > {error.message.length !== 0 && ( Date: Wed, 4 Sep 2024 22:13:46 +0200 Subject: [PATCH 2/2] support complex map values --- cyclops-ui/src/components/form/fields/map/MapField.tsx | 3 ++- .../src/components/pages/EditModule/EditModule.tsx | 9 +++++++++ cyclops-ui/src/components/pages/NewModule/NewModule.tsx | 8 ++++++++ cyclops-ui/src/utils/form.tsx | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cyclops-ui/src/components/form/fields/map/MapField.tsx b/cyclops-ui/src/components/form/fields/map/MapField.tsx index e2a0cd44..ac76b77b 100644 --- a/cyclops-ui/src/components/form/fields/map/MapField.tsx +++ b/cyclops-ui/src/components/form/fields/map/MapField.tsx @@ -1,6 +1,7 @@ import React from "react"; import { Button, Col, Divider, Form, Input, Row } from "antd"; import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons"; +import TextArea from "antd/es/input/TextArea"; interface Props { field: any; @@ -72,7 +73,7 @@ export const MapField = ({ rules={[{ required: true, message: "Missing value" }]} style={{ margin: 0, flex: 1, marginRight: "12px" }} > - +