mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Catching empty logs in various places
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
01e485d0e4
commit
6bb874d8ab
@ -22,9 +22,9 @@ interface Props extends PodLogSearchProps {
|
|||||||
|
|
||||||
export const PodLogControls = observer((props: Props) => {
|
export const PodLogControls = observer((props: Props) => {
|
||||||
if (!props.ready) return null;
|
if (!props.ready) return null;
|
||||||
const { tabData, tabId, save, reload, logs } = props;
|
const { tabData, save, reload, logs } = props;
|
||||||
const { selectedContainer, showTimestamps, previous } = tabData;
|
const { selectedContainer, showTimestamps, previous } = tabData;
|
||||||
const since = podLogsStore.getTimestamps(podLogsStore.logs.get(tabId)[0]);
|
const since = logs.length ? podLogsStore.getTimestamps(logs[0]) : null;
|
||||||
const pod = new Pod(tabData.pod);
|
const pod = new Pod(tabData.pod);
|
||||||
|
|
||||||
const toggleTimestamps = () => {
|
const toggleTimestamps = () => {
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { DockTabStore } from "./dock-tab.store";
|
|||||||
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
import { dockStore, IDockTab, TabKind } from "./dock.store";
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { _i18n } from "../../i18n";
|
import { _i18n } from "../../i18n";
|
||||||
import { isDevelopment } from "../../../common/vars";
|
|
||||||
import { searchStore } from "./search.store";
|
import { searchStore } from "./search.store";
|
||||||
|
|
||||||
export interface IPodLogsData {
|
export interface IPodLogsData {
|
||||||
@ -21,7 +20,7 @@ type TabId = string;
|
|||||||
type PodLogLine = string;
|
type PodLogLine = string;
|
||||||
|
|
||||||
// Number for log lines to load
|
// Number for log lines to load
|
||||||
export const logRange = 1000;
|
export const logRange = 500;
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class PodLogsStore extends DockTabStore<IPodLogsData> {
|
export class PodLogsStore extends DockTabStore<IPodLogsData> {
|
||||||
@ -90,6 +89,7 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
|
|||||||
* @param tabId
|
* @param tabId
|
||||||
*/
|
*/
|
||||||
loadMore = async (tabId: TabId) => {
|
loadMore = async (tabId: TabId) => {
|
||||||
|
if (!this.logs.get(tabId).length) return;
|
||||||
const oldLogs = this.logs.get(tabId);
|
const oldLogs = this.logs.get(tabId);
|
||||||
const logs = await this.loadLogs(tabId, {
|
const logs = await this.loadLogs(tabId, {
|
||||||
sinceTime: this.getLastSinceTime(tabId)
|
sinceTime: this.getLastSinceTime(tabId)
|
||||||
@ -128,7 +128,7 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
|
|||||||
* @param tabId
|
* @param tabId
|
||||||
*/
|
*/
|
||||||
setNewLogSince(tabId: TabId) {
|
setNewLogSince(tabId: TabId) {
|
||||||
if (!this.logs.has(tabId) || this.newLogSince.has(tabId)) return;
|
if (!this.logs.has(tabId) || !this.logs.get(tabId).length || this.newLogSince.has(tabId)) return;
|
||||||
const timestamp = this.getLastSinceTime(tabId);
|
const timestamp = this.getLastSinceTime(tabId);
|
||||||
this.newLogSince.set(tabId, timestamp.split(".")[0]); // Removing milliseconds from string
|
this.newLogSince.set(tabId, timestamp.split(".")[0]); // Removing milliseconds from string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,6 +212,7 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
top: this.logsElement.current.scrollHeight,
|
top: this.logsElement.current.scrollHeight,
|
||||||
behavior: "auto"
|
behavior: "auto"
|
||||||
});
|
});
|
||||||
|
this.showJumpToBottom = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Trans>Jump to bottom</Trans>
|
<Trans>Jump to bottom</Trans>
|
||||||
@ -229,7 +230,7 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
if (!this.logs.length) {
|
if (!this.logs.length) {
|
||||||
return (
|
return (
|
||||||
<div className="flex align-center justify-center">
|
<div className="flex box grow align-center justify-center">
|
||||||
<Trans>There are no logs available for container.</Trans>
|
<Trans>There are no logs available for container.</Trans>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -248,6 +249,7 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
onScroll={this.onScroll}
|
onScroll={this.onScroll}
|
||||||
outerRef={this.logsElement}
|
outerRef={this.logsElement}
|
||||||
ref={this.virtualListRef}
|
ref={this.virtualListRef}
|
||||||
|
className="box grow"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@ -276,7 +278,7 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
showSubmitClose={false}
|
showSubmitClose={false}
|
||||||
showButtons={false}
|
showButtons={false}
|
||||||
/>
|
/>
|
||||||
<div className="logs">
|
<div className="logs flex">
|
||||||
{this.renderJumpToBottom()}
|
{this.renderJumpToBottom()}
|
||||||
{this.renderLogs()}
|
{this.renderLogs()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export class SearchStore {
|
|||||||
* @returns {Array} Array of line indexes [0, 0, 14, 17, 17, 17, 20...]
|
* @returns {Array} Array of line indexes [0, 0, 14, 17, 17, 17, 20...]
|
||||||
*/
|
*/
|
||||||
findOccurencies(text: string[], query: string) {
|
findOccurencies(text: string[], query: string) {
|
||||||
if (!text) return;
|
if (!text) return [];
|
||||||
const occurences: number[] = [];
|
const occurences: number[] = [];
|
||||||
text.forEach((line, index) => {
|
text.forEach((line, index) => {
|
||||||
const regex = new RegExp(this.escapeRegex(query), "gi");
|
const regex = new RegExp(this.escapeRegex(query), "gi");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user