diff --git a/src/history.tsx b/src/history.tsx index 9190cd87..516ecfe0 100644 --- a/src/history.tsx +++ b/src/history.tsx @@ -9,8 +9,10 @@ import {GlobalModel, GlobalCommandRunner, Cmd} from "./model"; import {HistoryItem, RemotePtrType, LineType, CmdDataType} from "./types"; import dayjs from "dayjs"; import localizedFormat from 'dayjs/plugin/localizedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; import {Line} from "./linecomps"; +dayjs.extend(customParseFormat) dayjs.extend(localizedFormat) type OV = mobx.IObservableValue; @@ -188,6 +190,28 @@ class HistoryView extends React.Component<{}, {}> { this.checkWidth(); } + searchFromTsInputValue() : string { + let hvm = GlobalModel.historyViewModel; + let fromDate = hvm.searchFromDate.get(); + if (fromDate == null) { + return dayjs().format("YYYY-MM-DD"); + } + return fromDate; + } + + @boundMethod + handleFromTsChange(e : any) : void { + let hvm = GlobalModel.historyViewModel; + let newDate = e.target.value; + let today = dayjs().format("YYYY-MM-DD"); + if (newDate == "" || newDate == today) { + hvm.setFromDate(null); + return; + } + hvm.setFromDate(e.target.value); + return; + } + @boundMethod toggleSessionDropdown() : void { mobx.action(() => { @@ -324,6 +348,12 @@ class HistoryView extends React.Component<{}, {}> {
Show MetaCmds
+
+
From: 
+
+ +
+
diff --git a/src/model.ts b/src/model.ts index 17f8f035..b1846950 100644 --- a/src/model.ts +++ b/src/model.ts @@ -9,6 +9,12 @@ import type {SessionDataType, WindowDataType, LineType, RemoteType, HistoryItem, import {WSControl} from "./ws"; import {ImageRendererModel} from "./imagerenderer"; import {measureText, getMonoFontSize} from "./textmeasure"; +import dayjs from "dayjs"; +import localizedFormat from 'dayjs/plugin/localizedFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; + +dayjs.extend(customParseFormat) +dayjs.extend(localizedFormat) var GlobalUser = "sawka"; const RemotePtyRows = 8; // also in main.tsx @@ -1796,6 +1802,7 @@ class HistoryViewModel { searchSessionId : OV = mobx.observable.box(null, {name: "historyview-searchSessionId"}); searchRemoteId : OV = mobx.observable.box(null, {name: "historyview-searchRemoteId"}); searchShowMeta : OV = mobx.observable.box(false, {name: "historyview-searchShowMeta"}); + searchFromDate : OV = mobx.observable.box(null, {name: "historyview-searchfromts"}); historyItemLines : LineType[] = []; historyItemCmds : CmdDataType[] = []; @@ -1916,9 +1923,27 @@ class HistoryViewModel { if (!this.searchShowMeta.get()) { opts.noMeta = true; } + if (this.searchFromDate.get() != null) { + let fromDate = this.searchFromDate.get(); + let fromTs = dayjs(fromDate, "YYYY-MM-DD").valueOf(); + let d = new Date(fromTs); + d.setDate(d.getDate() + 1); + let ts = d.getTime()-1; + opts.fromTs = ts; + } return opts; } + setFromDate(fromDate : string) : void { + if (this.searchFromDate.get() == fromDate) { + return; + } + mobx.action(() => { + this.searchFromDate.set(fromDate); + })(); + GlobalCommandRunner.historyView(this._getSearchParams(0)); + } + setSearchShowMeta(show : boolean) : void { mobx.action(() => { this.searchShowMeta.set(show); diff --git a/src/sh2.less b/src/sh2.less index 93eb9dc5..aa0dad60 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -277,6 +277,17 @@ body::-webkit-scrollbar { cursor: pointer; } } + + .fromts { + font-size: 12px; + display: flex; + flex-direction: row; + align-items: center; + margin-left: 15px; + + .fromts-text { + } + } } }