From 3eadd676ce280093ed618961e65bb3e36b470b06 Mon Sep 17 00:00:00 2001 From: sawka Date: Mon, 6 Mar 2023 11:49:14 -0800 Subject: [PATCH] use new history search api --- src/history.tsx | 9 +++++++++ src/main.tsx | 2 +- src/model.ts | 20 +++++++++++++++++--- src/sh2.less | 12 ++++++++++++ src/types.ts | 8 +++++--- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/history.tsx b/src/history.tsx index 516ecfe0..7830a6f4 100644 --- a/src/history.tsx +++ b/src/history.tsx @@ -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<{}, {}> { +
+ Reset All Filters +
diff --git a/src/main.tsx b/src/main.tsx index 208fb00a..830fa12e 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2249,7 +2249,7 @@ class MainSideBar extends React.Component<{}, {}> { })(); return; } - GlobalCommandRunner.historyView({}); + GlobalCommandRunner.historyView({offset: 0, rawOffset: 0, noMeta: true}); } @boundMethod diff --git a/src/model.ts b/src/model.ts index b1846950..54a92dab 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1803,6 +1803,7 @@ class HistoryViewModel { 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"}); + 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; } diff --git a/src/sh2.less b/src/sh2.less index aa0dad60..23270ab2 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -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; + } + } } } diff --git a/src/types.ts b/src/types.ts index 62e824f2..4c3b837e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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,