mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move downloadAllLogs to model
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
8f264fdd48
commit
16aac15f1a
@ -19,6 +19,7 @@ import searchStoreInjectable from "../../../search-store/search-store.injectable
|
|||||||
import getPodsByOwnerIdInjectable from "../../+workloads-pods/get-pods-by-owner-id.injectable";
|
import getPodsByOwnerIdInjectable from "../../+workloads-pods/get-pods-by-owner-id.injectable";
|
||||||
import getPodByIdInjectable from "../../+workloads-pods/get-pod-by-id.injectable";
|
import getPodByIdInjectable from "../../+workloads-pods/get-pod-by-id.injectable";
|
||||||
import downloadLogsInjectable from "./download-logs.injectable";
|
import downloadLogsInjectable from "./download-logs.injectable";
|
||||||
|
import downloadAllLogsInjectable from "./download-all-logs.injectable";
|
||||||
|
|
||||||
export interface InstantiateArgs {
|
export interface InstantiateArgs {
|
||||||
tabId: TabId;
|
tabId: TabId;
|
||||||
@ -41,6 +42,7 @@ const logsViewModelInjectable = getInjectable({
|
|||||||
getPodById: di.inject(getPodByIdInjectable),
|
getPodById: di.inject(getPodByIdInjectable),
|
||||||
getPodsByOwnerId: di.inject(getPodsByOwnerIdInjectable),
|
getPodsByOwnerId: di.inject(getPodsByOwnerIdInjectable),
|
||||||
downloadLogs: di.inject(downloadLogsInjectable),
|
downloadLogs: di.inject(downloadLogsInjectable),
|
||||||
|
downloadAllLogs: di.inject(downloadAllLogsInjectable),
|
||||||
searchStore: di.inject(searchStoreInjectable),
|
searchStore: di.inject(searchStoreInjectable),
|
||||||
}),
|
}),
|
||||||
lifecycle: lifecycleEnum.transient,
|
lifecycle: lifecycleEnum.transient,
|
||||||
|
|||||||
@ -7,12 +7,13 @@ import type { IComputedValue } from "mobx";
|
|||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import type { TabId } from "../dock/store";
|
import type { TabId } from "../dock/store";
|
||||||
import type { SearchStore } from "../../../search-store/search-store";
|
import type { SearchStore } from "../../../search-store/search-store";
|
||||||
import type { Pod } from "../../../../common/k8s-api/endpoints";
|
import type { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||||
import { isDefined } from "../../../utils";
|
import { isDefined } from "../../../utils";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import type { GetPodById } from "../../+workloads-pods/get-pod-by-id.injectable";
|
import type { GetPodById } from "../../+workloads-pods/get-pod-by-id.injectable";
|
||||||
import type { GetPodsByOwnerId } from "../../+workloads-pods/get-pods-by-owner-id.injectable";
|
import type { GetPodsByOwnerId } from "../../+workloads-pods/get-pods-by-owner-id.injectable";
|
||||||
import type { LoadLogs } from "./load-logs.injectable";
|
import type { LoadLogs } from "./load-logs.injectable";
|
||||||
|
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
||||||
|
|
||||||
export interface LogTabViewModelDependencies {
|
export interface LogTabViewModelDependencies {
|
||||||
getLogs: (tabId: TabId) => string[];
|
getLogs: (tabId: TabId) => string[];
|
||||||
@ -28,6 +29,7 @@ export interface LogTabViewModelDependencies {
|
|||||||
getPodsByOwnerId: GetPodsByOwnerId;
|
getPodsByOwnerId: GetPodsByOwnerId;
|
||||||
areLogsPresent: (tabId: TabId) => boolean;
|
areLogsPresent: (tabId: TabId) => boolean;
|
||||||
downloadLogs: (filename: string, logs: string[]) => void;
|
downloadLogs: (filename: string, logs: string[]) => void;
|
||||||
|
downloadAllLogs: (params: ResourceDescriptor, query: PodLogsQuery) => Promise<void>;
|
||||||
searchStore: SearchStore;
|
searchStore: SearchStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,4 +94,16 @@ export class LogTabViewModel {
|
|||||||
this.dependencies.downloadLogs(`${fileName}.log`, logsToDownload);
|
this.dependencies.downloadLogs(`${fileName}.log`, logsToDownload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
downloadAllLogs = async () => {
|
||||||
|
const pod = this.pod.get();
|
||||||
|
const tabData = this.logTabData.get();
|
||||||
|
|
||||||
|
if (pod && tabData) {
|
||||||
|
const params = { name: pod.getName(), namespace: pod.getNs() };
|
||||||
|
const query = { timestamps: tabData.showTimestamps, previous: tabData.showPrevious }
|
||||||
|
|
||||||
|
this.dependencies.downloadAllLogs(params, query);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user