updates for search by day

This commit is contained in:
sawka 2023-03-05 13:54:17 -08:00
parent 778d801b88
commit aae5b81de0
3 changed files with 66 additions and 0 deletions

View File

@ -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<V> = mobx.IObservableValue<V>;
@ -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<{}, {}> {
<div className="checkbox-container"><input onChange={this.toggleShowMeta} type="checkbox" checked={hvm.searchShowMeta.get()}/></div>
<div onClick={this.toggleShowMeta} className="meta-text">Show MetaCmds</div>
</div>
<div className="fromts">
<div onClick={this.toggleShowMeta} className="fromts-text">From:&nbsp;</div>
<div>
<input type="date" onChange={this.handleFromTsChange} value={this.searchFromTsInputValue()} className="input is-small"/>
</div>
</div>
</div>
</div>
</div>

View File

@ -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<string> = mobx.observable.box(null, {name: "historyview-searchSessionId"});
searchRemoteId : OV<string> = mobx.observable.box(null, {name: "historyview-searchRemoteId"});
searchShowMeta : OV<boolean> = mobx.observable.box(false, {name: "historyview-searchShowMeta"});
searchFromDate : OV<string> = 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);

View File

@ -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 {
}
}
}
}