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

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

View File

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

View File

@ -1803,6 +1803,7 @@ class HistoryViewModel {
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"});
nextRawOffset : number = 0;
historyItemLines : LineType[] = [];
historyItemCmds : CmdDataType[] = [];
@ -1916,6 +1917,7 @@ class HistoryViewModel {
let offset = (newOffset != null ? newOffset : this.offset.get());
let opts : HistorySearchParams = {
offset: offset,
rawOffset: offset,
searchText: this.activeSearchText,
searchSessionId: this.searchSessionId.get(),
searchRemoteId: this.searchRemoteId.get(),
@ -1934,6 +1936,19 @@ class HistoryViewModel {
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 {
if (this.searchFromDate.get() == fromDate) {
return;
@ -3304,9 +3319,8 @@ class CommandRunner {
historyView(params : HistorySearchParams) {
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) {
kwargs["text"] = params.searchText;
}

View File

@ -288,6 +288,18 @@ body::-webkit-scrollbar {
.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 = {
offset : number,
items : HistoryItem[],
offset : number,
nextrawoffset : number,
hasmore : boolean,
lines : LineType[],
cmds : CmdDataType[],
hasmore : boolean,
};
type BookmarkType = {
@ -428,7 +429,8 @@ type AlertMessageType = {
};
type HistorySearchParams = {
offset? : number,
offset : number,
rawOffset : number,
searchText? : string,
searchSessionId? : string,
searchRemoteId? : string,