fix(ui): add previous option to download logs functionality (#26427)

Signed-off-by: linghaoSu <linghao.su@daocloud.io>
This commit is contained in:
Linghao Su
2026-02-12 23:49:58 +08:00
committed by GitHub
parent a46baf4863
commit 8e636b78e5
3 changed files with 11 additions and 5 deletions

View File

@@ -3,13 +3,17 @@ import * as React from 'react';
import {PodLogsProps} from './pod-logs-viewer';
import {Button} from '../../../shared/components/button';
interface DownloadLogsButtonProps extends PodLogsProps {
previous?: boolean;
}
// DownloadLogsButton is a button that downloads the logs to a file
export const DownloadLogsButton = ({applicationName, applicationNamespace, containerName, group, kind, name, namespace, podName}: PodLogsProps) => (
export const DownloadLogsButton = ({applicationName, applicationNamespace, containerName, group, kind, name, namespace, podName, previous}: DownloadLogsButtonProps) => (
<Button
title='Download logs to file'
icon='download'
onClick={async () => {
const downloadURL = services.applications.getDownloadLogsURL(applicationName, applicationNamespace, namespace, podName, {group, kind, name}, containerName);
const downloadURL = services.applications.getDownloadLogsURL(applicationName, applicationNamespace, namespace, podName, {group, kind, name}, containerName, previous);
window.open(downloadURL, '_blank');
}}
/>

View File

@@ -43,6 +43,7 @@ export interface PodLogsProps {
containerGroups?: any[];
onClickContainer?: (group: any, i: number, tab: string) => void;
fullscreen?: boolean;
previous?: boolean;
}
export interface PodLogsQueryProps {
@@ -294,7 +295,7 @@ export const PodsLogsViewer = (props: PodLogsProps) => {
<Spacer />
<span>
<CopyLogsButton logs={logs} />
<DownloadLogsButton {...props} />
<DownloadLogsButton {...props} previous={previous} />
<FullscreenButton
{...props}
viewPodNames={viewPodNames}

View File

@@ -294,9 +294,10 @@ export class ApplicationsService {
namespace: string,
podName: string,
resource: {group: string; kind: string; name: string},
containerName: string
containerName: string,
previous: boolean
): string {
const search = this.getLogsQuery({namespace, appNamespace, podName, resource, containerName, follow: false});
const search = this.getLogsQuery({namespace, appNamespace, podName, resource, containerName, follow: false, previous});
search.set('download', 'true');
return `api/v1/applications/${applicationName}/logs?${search.toString()}`;
}