use new history search api

This commit is contained in:
sawka 2023-03-06 11:49:14 -08:00
parent aae5b81de0
commit 3eadd676ce
5 changed files with 44 additions and 7 deletions

View File

@ -258,6 +258,12 @@ class HistoryView extends React.Component<{}, {}> {
})(); })();
} }
@boundMethod
resetAllFilters() : void {
let hvm = GlobalModel.historyViewModel;
hvm.resetAllFilters();
}
render() { render() {
let isHidden = (GlobalModel.activeMainView.get() != "history"); let isHidden = (GlobalModel.activeMainView.get() != "history");
if (isHidden) { if (isHidden) {
@ -354,6 +360,9 @@ class HistoryView extends React.Component<{}, {}> {
<input type="date" onChange={this.handleFromTsChange} value={this.searchFromTsInputValue()} className="input is-small"/> <input type="date" onChange={this.handleFromTsChange} value={this.searchFromTsInputValue()} className="input is-small"/>
</div> </div>
</div> </div>
<div onClick={this.resetAllFilters} className="reset-button">
Reset All Filters
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -2249,7 +2249,7 @@ class MainSideBar extends React.Component<{}, {}> {
})(); })();
return; return;
} }
GlobalCommandRunner.historyView({}); GlobalCommandRunner.historyView({offset: 0, rawOffset: 0, noMeta: true});
} }
@boundMethod @boundMethod

View File

@ -1803,6 +1803,7 @@ class HistoryViewModel {
searchRemoteId : OV<string> = mobx.observable.box(null, {name: "historyview-searchRemoteId"}); searchRemoteId : OV<string> = mobx.observable.box(null, {name: "historyview-searchRemoteId"});
searchShowMeta : OV<boolean> = mobx.observable.box(false, {name: "historyview-searchShowMeta"}); searchShowMeta : OV<boolean> = mobx.observable.box(false, {name: "historyview-searchShowMeta"});
searchFromDate : OV<string> = mobx.observable.box(null, {name: "historyview-searchfromts"}); searchFromDate : OV<string> = mobx.observable.box(null, {name: "historyview-searchfromts"});
nextRawOffset : number = 0;
historyItemLines : LineType[] = []; historyItemLines : LineType[] = [];
historyItemCmds : CmdDataType[] = []; historyItemCmds : CmdDataType[] = [];
@ -1916,6 +1917,7 @@ class HistoryViewModel {
let offset = (newOffset != null ? newOffset : this.offset.get()); let offset = (newOffset != null ? newOffset : this.offset.get());
let opts : HistorySearchParams = { let opts : HistorySearchParams = {
offset: offset, offset: offset,
rawOffset: offset,
searchText: this.activeSearchText, searchText: this.activeSearchText,
searchSessionId: this.searchSessionId.get(), searchSessionId: this.searchSessionId.get(),
searchRemoteId: this.searchRemoteId.get(), searchRemoteId: this.searchRemoteId.get(),
@ -1934,6 +1936,19 @@ class HistoryViewModel {
return opts; return opts;
} }
resetAllFilters() : void {
mobx.action(() => {
this.offset.set(0);
this.activeSearchText = "";
this.searchText.set("");
this.searchSessionId.set(null);
this.searchRemoteId.set(null);
this.searchFromDate.set(null);
this.searchShowMeta.set(false);
})();
GlobalCommandRunner.historyView(this._getSearchParams());
}
setFromDate(fromDate : string) : void { setFromDate(fromDate : string) : void {
if (this.searchFromDate.get() == fromDate) { if (this.searchFromDate.get() == fromDate) {
return; return;
@ -3304,9 +3319,8 @@ class CommandRunner {
historyView(params : HistorySearchParams) { historyView(params : HistorySearchParams) {
let kwargs = {"nohist": "1"}; let kwargs = {"nohist": "1"};
if (params.offset != null) {
kwargs["offset"] = String(params.offset); kwargs["offset"] = String(params.offset);
} kwargs["rawoffset"] = String(params.rawOffset);
if (params.searchText != null) { if (params.searchText != null) {
kwargs["text"] = params.searchText; kwargs["text"] = params.searchText;
} }

View File

@ -288,6 +288,18 @@ body::-webkit-scrollbar {
.fromts-text { .fromts-text {
} }
} }
.reset-button {
cursor: pointer;
margin-left: 15px;
font-size: 12px;
border: 1px solid #777;
padding: 5px 10px 5px 10px;
&:hover {
background-color: #666;
}
}
} }
} }

View File

@ -291,11 +291,12 @@ type ModelUpdateType = {
}; };
type HistoryViewDataType = { type HistoryViewDataType = {
offset : number,
items : HistoryItem[], items : HistoryItem[],
offset : number,
nextrawoffset : number,
hasmore : boolean,
lines : LineType[], lines : LineType[],
cmds : CmdDataType[], cmds : CmdDataType[],
hasmore : boolean,
}; };
type BookmarkType = { type BookmarkType = {
@ -428,7 +429,8 @@ type AlertMessageType = {
}; };
type HistorySearchParams = { type HistorySearchParams = {
offset? : number, offset : number,
rawOffset : number,
searchText? : string, searchText? : string,
searchSessionId? : string, searchSessionId? : string,
searchRemoteId? : string, searchRemoteId? : string,