mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add sketch of Download all logs button
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
90f8342387
commit
a191a46e4b
@ -14,6 +14,7 @@ import { Icon } from "../../icon";
|
|||||||
import type { LogTabViewModel } from "./logs-view-model";
|
import type { LogTabViewModel } from "./logs-view-model";
|
||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
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";
|
||||||
|
|
||||||
export interface LogControlsProps {
|
export interface LogControlsProps {
|
||||||
model: LogTabViewModel;
|
model: LogTabViewModel;
|
||||||
@ -21,9 +22,10 @@ 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>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NonInjectedLogControls = observer(({ openSaveFileDialog, model }: Dependencies & LogControlsProps) => {
|
const NonInjectedLogControls = observer(({ openSaveFileDialog, model, callForAllLogs }: Dependencies & LogControlsProps) => {
|
||||||
const tabData = model.logTabData.get();
|
const tabData = model.logTabData.get();
|
||||||
const pod = model.pod.get();
|
const pod = model.pod.get();
|
||||||
|
|
||||||
@ -44,6 +46,18 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model }: Dependen
|
|||||||
model.reloadLogs();
|
model.reloadLogs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const downloadAllLogs = async () => {
|
||||||
|
const pod = model.pod.get();
|
||||||
|
|
||||||
|
if (pod) {
|
||||||
|
const logs = await callForAllLogs(pod.getName(), pod.getNs());
|
||||||
|
|
||||||
|
console.log(logs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// openSaveFileDialog("logs.txt", logs, "text/plain");
|
||||||
|
}
|
||||||
|
|
||||||
const downloadLogs = () => {
|
const downloadLogs = () => {
|
||||||
const fileName = pod.getName();
|
const fileName = pod.getName();
|
||||||
const logsToDownload: string[] = showTimestamps
|
const logsToDownload: string[] = showTimestamps
|
||||||
@ -83,6 +97,13 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model }: Dependen
|
|||||||
tooltip="Download"
|
tooltip="Download"
|
||||||
className="download-icon"
|
className="download-icon"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Icon
|
||||||
|
material="refresh"
|
||||||
|
onClick={downloadAllLogs}
|
||||||
|
tooltip="Download"
|
||||||
|
className="download-icon"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -91,6 +112,7 @@ const NonInjectedLogControls = observer(({ openSaveFileDialog, model }: Dependen
|
|||||||
export const LogControls = withInjectables<Dependencies, LogControlsProps>(NonInjectedLogControls, {
|
export const LogControls = withInjectables<Dependencies, LogControlsProps>(NonInjectedLogControls, {
|
||||||
getProps: (di, props) => ({
|
getProps: (di, props) => ({
|
||||||
openSaveFileDialog: di.inject(openSaveFileDialogInjectable),
|
openSaveFileDialog: di.inject(openSaveFileDialogInjectable),
|
||||||
|
callForAllLogs: di.inject(callForAllLogsInjectable),
|
||||||
...props,
|
...props,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user