mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-22 21:42:49 +01:00
updates for search by day
This commit is contained in:
parent
778d801b88
commit
aae5b81de0
@ -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: </div>
|
||||
<div>
|
||||
<input type="date" onChange={this.handleFromTsChange} value={this.searchFromTsInputValue()} className="input is-small"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
25
src/model.ts
25
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<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);
|
||||
|
11
src/sh2.less
11
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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user