mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Respect timestamps and previous props
in callForAllLogsInjectable Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
175a1dc815
commit
f6d30f289c
@ -3,6 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import type { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||||
import callForLogsInjectable from "./call-for-logs.injectable";
|
import callForLogsInjectable from "./call-for-logs.injectable";
|
||||||
|
|
||||||
const callForAllLogsInjectable = getInjectable({
|
const callForAllLogsInjectable = getInjectable({
|
||||||
@ -11,11 +12,10 @@ const callForAllLogsInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const callForLogs = di.inject(callForLogsInjectable);
|
const callForLogs = di.inject(callForLogsInjectable);
|
||||||
|
|
||||||
return async (name: string, namespace: string) => {
|
return async (pod: Pod, query?: PodLogsQuery) => {
|
||||||
const logs = await callForLogs({
|
const namespace = pod.getNs();
|
||||||
name,
|
const name = pod.getName();
|
||||||
namespace,
|
const logs = await callForLogs({ name, namespace }, query);
|
||||||
});
|
|
||||||
|
|
||||||
return logs;
|
return logs;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { withInjectables } from "@ogre-tools/injectable-react";
|
|||||||
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
||||||
import callForAllLogsInjectable from "./call-for-all-logs.injectable";
|
import callForAllLogsInjectable from "./call-for-all-logs.injectable";
|
||||||
import { DownloadLogsDropdown } from "./download-logs-dropdown";
|
import { DownloadLogsDropdown } from "./download-logs-dropdown";
|
||||||
|
import type { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||||
|
|
||||||
export interface LogControlsProps {
|
export interface LogControlsProps {
|
||||||
model: LogTabViewModel;
|
model: LogTabViewModel;
|
||||||
@ -22,7 +23,7 @@ export interface LogControlsProps {
|
|||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
openSaveFileDialog: (filename: string, contents: BlobPart | BlobPart[], type: string) => void;
|
openSaveFileDialog: (filename: string, contents: BlobPart | BlobPart[], type: string) => void;
|
||||||
callForAllLogs: (name: string, namespace: string) => Promise<string>;
|
callForAllLogs: (pod: Pod, query?: PodLogsQuery) => Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAllLogs }: Dependencies & LogControlsProps) => {
|
const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAllLogs }: Dependencies & LogControlsProps) => {
|
||||||
@ -50,7 +51,7 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAll
|
|||||||
const pod = model.pod.get();
|
const pod = model.pod.get();
|
||||||
|
|
||||||
if (pod) {
|
if (pod) {
|
||||||
const logs = await callForAllLogs(pod.getName(), pod.getNs());
|
const logs = await callForAllLogs(pod, { timestamps: showTimestamps, previous });
|
||||||
|
|
||||||
openSaveFileDialog(`${pod.getName()}.log`, logs, "text/plain");
|
openSaveFileDialog(`${pod.getName()}.log`, logs, "text/plain");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user