11<script setup lang="ts">
22import socket from " ~/web-sockets/Socket" ;
33import { Card , CardHeader , CardContent } from " ~/components/ui/card" ;
4- import { Button } from " ~/components/ui/button" ;
54import { Switch } from " ~/components/ui/switch" ;
65import { Tabs , TabsList , TabsTrigger , TabsContent } from " ~/components/ui/tabs" ;
76import {
@@ -18,7 +17,6 @@ import {
1817} from " ~/components/ui/dropdown-menu" ;
1918
2019import { DownloadIcon , FullscreenIcon , ExpandIcon } from " lucide-vue-next" ;
21- import Convert from " ansi-to-html" ;
2220
2321const config = useRuntimeConfig ();
2422
@@ -67,19 +65,7 @@ async function downloadFullLogs(service: string) {
6765 <Card >
6866 <CardHeader class =" flex flex-col gap-2" >
6967 <div class =" flex items-center justify-between gap-4" >
70- <div
71- v-if =" oldestTimestamp"
72- class =" text-xs font-mono text-muted-foreground"
73- >
74- Displaying logs from
75- {{ new Date(oldestTimestamp).toLocaleString() }}
76- </div >
77-
7868 <div class =" flex items-center gap-4" >
79- <Button variant =" outline" @click =" jumpToLive" >
80- {{ $t("ui.logs.jump_to_live") }}
81- </Button >
82-
8369 <TooltipProvider >
8470 <Tooltip >
8571 <TooltipTrigger >
@@ -157,49 +143,33 @@ async function downloadFullLogs(service: string) {
157143 </CardHeader >
158144
159145 <CardContent class =" p-4" >
160- <!-- Multi-pod -->
161146 <Tabs v-if =" podCount > 1" v-model =" activePod" >
162147 <TabsContent v-for =" pod in podList" :key =" pod" :value =" pod" >
163- <div class =" overflow-auto whitespace-nowrap max-h-[50vh]" >
164- <div
165- v-for =" (entry, index) in logsByPod[pod]"
166- :key =" index"
167- class =" text-xs font-mono py-1 flex gap-4"
168- >
169- <span
170- v-if =" (timestamps === undefined && _timestamps) || timestamps"
171- class =" text-muted-foreground"
172- >
173- {{ entry.timestamp }}
174- </span >
175- <span v-html =" colorize(entry.log)" />
176- </div >
177- </div >
148+ <PodLogs
149+ :logs =" logsByPod[pod] || []"
150+ :show-timestamps ="
151+ (timestamps === undefined && _timestamps) || timestamps
152+ "
153+ :follow =" (followLogs === undefined && _followLogs) || followLogs"
154+ />
178155 </TabsContent >
179156 </Tabs >
180157
181158 <!-- Single pod -->
182- <div v-else class =" overflow-auto whitespace-nowrap max-h-[50vh]" >
183- <div
184- v-for =" (entry, index) in logsByPod[activePod] || []"
185- :key =" index"
186- class =" text-xs font-mono py-1 flex gap-4"
187- >
188- <span
189- v-if =" (timestamps === undefined && _timestamps) || timestamps"
190- class =" text-muted-foreground"
191- >
192- {{ entry.timestamp }}
193- </span >
194- <span v-html =" colorize(entry.log)" />
195- </div >
196- </div >
159+ <PodLogs
160+ v-else
161+ :logs =" logsByPod[activePod] || []"
162+ :show-timestamps ="
163+ (timestamps === undefined && _timestamps) || timestamps
164+ "
165+ :follow =" (followLogs === undefined && _followLogs) || followLogs"
166+ />
197167 </CardContent >
198168 </Card >
199169</template >
200170
201171<script lang="ts">
202- const convert = new Convert () ;
172+ import PodLogs from " ~/components/PodLogs.vue " ;
203173
204174type LogEntry = {
205175 log: string ;
@@ -221,7 +191,6 @@ export default {
221191 return {
222192 logsByPod: {} as Record <string , LogEntry []>,
223193 activePod: " " ,
224- oldestTimestamp: undefined as string | undefined ,
225194 _timestamps: true ,
226195 _followLogs: true ,
227196 expanded: false ,
@@ -240,15 +209,6 @@ export default {
240209 },
241210
242211 methods: {
243- colorize(log : string ) {
244- return convert .toHtml (log );
245- },
246-
247- jumpToLive() {
248- this ._followLogs = true ;
249- this .$emit (" follow-logs-changed" , true );
250- },
251-
252212 toggleFullscreen() {
253213 document .documentElement .requestFullscreen ?.();
254214 },
@@ -281,11 +241,6 @@ export default {
281241 this .logListener = socket .listen (` logs:${this .service } ` , (raw ) => {
282242 const log = JSON .parse (raw );
283243
284- if (log .oldest_timestamp ) {
285- this .oldestTimestamp = log .oldest_timestamp ;
286- return ;
287- }
288-
289244 if (! log .log ) return ;
290245
291246 const pod = log .pod ?? " default" ;
0 commit comments