There are no logs available for container
@@ -198,7 +212,7 @@ export class PodLogList extends React.Component
{
return (
void
toPrevOverlay: () => void
toNextOverlay: () => void
+}
+
+interface Props extends PodLogSearchProps {
logs: string[]
}
-export const PodLogSearch = observer((props: PodLogSearchProps) => {
+export const PodLogSearch = observer((props: Props) => {
const { logs, onSearch, toPrevOverlay, toNextOverlay } = props;
const { setNextOverlayActive, setPrevOverlayActive, searchQuery, occurrences, activeFind, totalFinds } = searchStore;
const jumpDisabled = !searchQuery || !occurrences.length;
diff --git a/src/renderer/components/dock/pod-logs.store.ts b/src/renderer/components/dock/pod-logs.store.ts
index 057b8eea15..2f3574d115 100644
--- a/src/renderer/components/dock/pod-logs.store.ts
+++ b/src/renderer/components/dock/pod-logs.store.ts
@@ -27,11 +27,11 @@ export class PodLogsStore extends DockTabStore {
private refresher = interval(10, () => {
const id = dockStore.selectedTabId;
- if (!this.logs.get(id)) return;
+ if (!this.podLogs.get(id)) return;
this.loadMore(id);
});
- @observable logs = observable.map();
+ @observable podLogs = observable.map();
@observable newLogSince = observable.map(); // Timestamp after which all logs are considered to be new
constructor() {
@@ -48,7 +48,7 @@ export class PodLogsStore extends DockTabStore {
}
}, { delay: 500 });
- reaction(() => this.logs.get(dockStore.selectedTabId), () => {
+ reaction(() => this.podLogs.get(dockStore.selectedTabId), () => {
this.setNewLogSince(dockStore.selectedTabId);
});
@@ -72,7 +72,7 @@ export class PodLogsStore extends DockTabStore {
});
this.refresher.start();
- this.logs.set(tabId, logs);
+ this.podLogs.set(tabId, logs);
} catch ({error}) {
const message = [
_i18n._(t`Failed to load logs: ${error.message}`),
@@ -80,7 +80,7 @@ export class PodLogsStore extends DockTabStore {
];
this.refresher.stop();
- this.logs.set(tabId, message);
+ this.podLogs.set(tabId, message);
}
};
@@ -91,14 +91,14 @@ export class PodLogsStore extends DockTabStore {
* @param tabId
*/
loadMore = async (tabId: TabId) => {
- if (!this.logs.get(tabId).length) return;
- const oldLogs = this.logs.get(tabId);
+ if (!this.podLogs.get(tabId).length) return;
+ const oldLogs = this.podLogs.get(tabId);
const logs = await this.loadLogs(tabId, {
sinceTime: this.getLastSinceTime(tabId)
});
// Add newly received logs to bottom
- this.logs.set(tabId, [...oldLogs, ...logs]);
+ this.podLogs.set(tabId, [...oldLogs, ...logs]);
};
/**
@@ -134,7 +134,7 @@ export class PodLogsStore extends DockTabStore {
* @param tabId
*/
setNewLogSince(tabId: TabId) {
- if (!this.logs.has(tabId) || !this.logs.get(tabId).length || this.newLogSince.has(tabId)) return;
+ if (!this.podLogs.has(tabId) || !this.podLogs.get(tabId).length || this.newLogSince.has(tabId)) return;
const timestamp = this.getLastSinceTime(tabId);
this.newLogSince.set(tabId, timestamp.split(".")[0]); // Removing milliseconds from string
@@ -147,18 +147,38 @@ export class PodLogsStore extends DockTabStore {
@computed
get lines() {
const id = dockStore.selectedTabId;
- const logs = this.logs.get(id);
+ const logs = this.podLogs.get(id);
return logs ? logs.length : 0;
}
+
+ /**
+ * Returns logs with timestamps for selected tab
+ */
+ get logs() {
+ const id = dockStore.selectedTabId;
+
+ if (!this.podLogs.has(id)) return [];
+
+ return this.podLogs.get(id);
+ }
+
+ /**
+ * Removes timestamps from each log line and returns changed logs
+ * @returns Logs without timestamps
+ */
+ get logsWithoutTimestamps() {
+ return this.logs.map(item => this.removeTimestamps(item));
+ }
+
/**
* It gets timestamps from all logs then returns last one + 1 second
* (this allows to avoid getting the last stamp in the selection)
* @param tabId
*/
getLastSinceTime(tabId: TabId) {
- const logs = this.logs.get(tabId);
+ const logs = this.podLogs.get(tabId);
const timestamps = this.getTimestamps(logs[logs.length - 1]);
const stamp = new Date(timestamps ? timestamps[0] : null);
@@ -176,7 +196,7 @@ export class PodLogsStore extends DockTabStore {
}
clearLogs(tabId: TabId) {
- this.logs.delete(tabId);
+ this.podLogs.delete(tabId);
}
clearData(tabId: TabId) {
diff --git a/src/renderer/components/dock/pod-logs.tsx b/src/renderer/components/dock/pod-logs.tsx
index 5b9c2860c4..fd4002141b 100644
--- a/src/renderer/components/dock/pod-logs.tsx
+++ b/src/renderer/components/dock/pod-logs.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { computed, observable, reaction } from "mobx";
+import { observable, reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import { searchStore } from "../../../common/search-store";
@@ -79,31 +79,15 @@ export class PodLogs extends React.Component {
}, 100);
}
- /**
- * Computed prop which returns logs with or without timestamps added to each line
- * @returns {Array} An array log items
- */
- @computed
- get logs(): string[] {
- if (!podLogsStore.logs.has(this.tabId)) return [];
- const logs = podLogsStore.logs.get(this.tabId);
- const { getData, removeTimestamps } = podLogsStore;
- const { showTimestamps } = getData(this.tabId);
-
- if (!showTimestamps) {
- return logs.map(item => removeTimestamps(item));
- }
-
- return logs;
- }
-
render() {
+ const logs = podLogsStore.logs;
+
const controls = (
{
showButtons={false}
/>