mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix(ui): add previous option to download logs functionality (#26427)
Signed-off-by: linghaoSu <linghao.su@daocloud.io>
This commit is contained in:
@@ -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');
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user