mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
added search filter cmds
This commit is contained in:
parent
3eadd676ce
commit
61fa23b854
@ -258,6 +258,14 @@ class HistoryView extends React.Component<{}, {}> {
|
||||
})();
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
toggleFilterCmds() : void {
|
||||
let hvm = GlobalModel.historyViewModel;
|
||||
mobx.action(() => {
|
||||
hvm.setSearchFilterCmds(!hvm.searchFilterCmds.get());
|
||||
})();
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
resetAllFilters() : void {
|
||||
let hvm = GlobalModel.historyViewModel;
|
||||
@ -305,9 +313,9 @@ class HistoryView extends React.Component<{}, {}> {
|
||||
HISTORY
|
||||
</div>
|
||||
<div className="history-search">
|
||||
<div className="field">
|
||||
<div className="main-search field">
|
||||
<p className="control has-icons-left">
|
||||
<input className="input" type="text" placeholder="Search" value={hvm.searchText.get()} onChange={this.changeSearchText} onKeyDown={this.searchKeyDown}/>
|
||||
<input className="input" type="text" placeholder="Exact String Search" value={hvm.searchText.get()} onChange={this.changeSearchText} onKeyDown={this.searchKeyDown}/>
|
||||
<span className="icon is-small is-left">
|
||||
<i className="fa-sharp fa-solid fa-search"/>
|
||||
</span>
|
||||
@ -350,9 +358,9 @@ class HistoryView extends React.Component<{}, {}> {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="allow-meta">
|
||||
<div className="allow-meta search-checkbox">
|
||||
<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 onClick={this.toggleShowMeta} className="checkbox-text">Show MetaCmds</div>
|
||||
</div>
|
||||
<div className="fromts">
|
||||
<div onClick={this.toggleShowMeta} className="fromts-text">From: </div>
|
||||
@ -360,8 +368,12 @@ class HistoryView extends React.Component<{}, {}> {
|
||||
<input type="date" onChange={this.handleFromTsChange} value={this.searchFromTsInputValue()} className="input is-small"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="filter-cmds search-checkbox" title="Filter common commands like 'ls' and 'cd' from the results">
|
||||
<div className="checkbox-container"><input onChange={this.toggleFilterCmds} type="checkbox" checked={hvm.searchFilterCmds.get()}/></div>
|
||||
<div onClick={this.toggleFilterCmds} className="checkbox-text">Filter Cmds</div>
|
||||
</div>
|
||||
<div onClick={this.resetAllFilters} className="reset-button">
|
||||
Reset All Filters
|
||||
Reset All
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2249,7 +2249,7 @@ class MainSideBar extends React.Component<{}, {}> {
|
||||
})();
|
||||
return;
|
||||
}
|
||||
GlobalCommandRunner.historyView({offset: 0, rawOffset: 0, noMeta: true});
|
||||
GlobalModel.historyViewModel.reSearch();
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
|
51
src/model.ts
51
src/model.ts
@ -1803,7 +1803,9 @@ 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"});
|
||||
searchFilterCmds : OV<boolean> = mobx.observable.box(true, {name: "historyview-filtercmds"});
|
||||
nextRawOffset : number = 0;
|
||||
curRawOffset : number = 0;
|
||||
|
||||
historyItemLines : LineType[] = [];
|
||||
historyItemCmds : CmdDataType[] = [];
|
||||
@ -1913,11 +1915,12 @@ class HistoryViewModel {
|
||||
})();
|
||||
}
|
||||
|
||||
_getSearchParams(newOffset? : number) : HistorySearchParams {
|
||||
_getSearchParams(newOffset? : number, newRawOffset? : number) : HistorySearchParams {
|
||||
let offset = (newOffset != null ? newOffset : this.offset.get());
|
||||
let rawOffset = (newRawOffset != null ? newRawOffset : this.curRawOffset);
|
||||
let opts : HistorySearchParams = {
|
||||
offset: offset,
|
||||
rawOffset: offset,
|
||||
rawOffset: rawOffset,
|
||||
searchText: this.activeSearchText,
|
||||
searchSessionId: this.searchSessionId.get(),
|
||||
searchRemoteId: this.searchRemoteId.get(),
|
||||
@ -1933,20 +1936,27 @@ class HistoryViewModel {
|
||||
let ts = d.getTime()-1;
|
||||
opts.fromTs = ts;
|
||||
}
|
||||
if (this.searchFilterCmds.get()) {
|
||||
opts.filterCmds = true;
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
reSearch() : void {
|
||||
GlobalCommandRunner.historyView(this._getSearchParams());
|
||||
}
|
||||
|
||||
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);
|
||||
this.searchFilterCmds.set(true);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams());
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
setFromDate(fromDate : string) : void {
|
||||
@ -1956,14 +1966,27 @@ class HistoryViewModel {
|
||||
mobx.action(() => {
|
||||
this.searchFromDate.set(fromDate);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0));
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
setSearchFilterCmds(filter : boolean) : void {
|
||||
if (this.searchFilterCmds.get() == filter) {
|
||||
return;
|
||||
}
|
||||
mobx.action(() => {
|
||||
this.searchFilterCmds.set(filter);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
setSearchShowMeta(show : boolean) : void {
|
||||
if (this.searchShowMeta.get() == show) {
|
||||
return;
|
||||
}
|
||||
mobx.action(() => {
|
||||
this.searchShowMeta.set(show);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0));
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
setSearchSessionId(sessionId : string) : void {
|
||||
@ -1973,7 +1996,7 @@ class HistoryViewModel {
|
||||
mobx.action(() => {
|
||||
this.searchSessionId.set(sessionId);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0));
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
setSearchRemoteId(remoteId : string) : void {
|
||||
@ -1983,7 +2006,7 @@ class HistoryViewModel {
|
||||
mobx.action(() => {
|
||||
this.searchRemoteId.set(remoteId);
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0));
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
goPrev() : void {
|
||||
@ -1992,14 +2015,14 @@ class HistoryViewModel {
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
let params = this._getSearchParams(offset);
|
||||
let params = this._getSearchParams(offset, 0);
|
||||
GlobalCommandRunner.historyView(params);
|
||||
}
|
||||
|
||||
goNext() : void {
|
||||
let offset = this.offset.get();
|
||||
offset += HistoryPageSize;
|
||||
let params = this._getSearchParams(offset);
|
||||
let params = this._getSearchParams(offset, (this.nextRawOffset ?? 0));
|
||||
GlobalCommandRunner.historyView(params);
|
||||
}
|
||||
|
||||
@ -2007,12 +2030,11 @@ class HistoryViewModel {
|
||||
mobx.action(() => {
|
||||
this.hasMore.set(false);
|
||||
this.items.replace([]);
|
||||
this.offset.set(0);
|
||||
this.activeSearchText = this.searchText.get();
|
||||
this.historyItemLines = [];
|
||||
this.historyItemCmds = [];
|
||||
})();
|
||||
GlobalCommandRunner.historyView(this._getSearchParams());
|
||||
GlobalCommandRunner.historyView(this._getSearchParams(0, 0));
|
||||
}
|
||||
|
||||
handleDocKeyDown(e : any) : void {
|
||||
@ -2029,6 +2051,8 @@ class HistoryViewModel {
|
||||
this.hasMore.set(data.hasmore);
|
||||
this.items.replace(data.items || []);
|
||||
this.offset.set(data.offset);
|
||||
this.nextRawOffset = data.nextrawoffset;
|
||||
this.curRawOffset = data.rawoffset;
|
||||
this.historyItemLines = (data.lines ?? []);
|
||||
this.historyItemCmds = (data.cmds ?? []);
|
||||
this.selectedItems.clear();
|
||||
@ -3336,6 +3360,9 @@ class CommandRunner {
|
||||
if (params.noMeta) {
|
||||
kwargs["meta"] = "0";
|
||||
}
|
||||
if (params.filterCmds) {
|
||||
kwargs["filter"] = "1";
|
||||
}
|
||||
GlobalModel.submitCommand("history", "viewall", null, kwargs, true);
|
||||
}
|
||||
|
||||
|
15
src/sh2.less
15
src/sh2.less
@ -226,8 +226,15 @@ body::-webkit-scrollbar {
|
||||
flex-grow: 1;
|
||||
margin-top: 5px;
|
||||
margin-left: 15px;
|
||||
.field {
|
||||
width: 80%;
|
||||
|
||||
.main-search {
|
||||
.field {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
input::placeholder {
|
||||
color: #777;
|
||||
}
|
||||
}
|
||||
|
||||
.advanced-search {
|
||||
@ -254,7 +261,7 @@ body::-webkit-scrollbar {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.allow-meta {
|
||||
.search-checkbox {
|
||||
margin-left: 15px;
|
||||
border: 1px solid #777;
|
||||
padding: 5px 10px 5px 10px;
|
||||
@ -272,7 +279,7 @@ body::-webkit-scrollbar {
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
.checkbox-text {
|
||||
padding-left: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -293,6 +293,7 @@ type ModelUpdateType = {
|
||||
type HistoryViewDataType = {
|
||||
items : HistoryItem[],
|
||||
offset : number,
|
||||
rawoffset : number,
|
||||
nextrawoffset : number,
|
||||
hasmore : boolean,
|
||||
lines : LineType[],
|
||||
@ -436,6 +437,7 @@ type HistorySearchParams = {
|
||||
searchRemoteId? : string,
|
||||
fromTs? : number,
|
||||
noMeta? : boolean,
|
||||
filterCmds? : boolean,
|
||||
};
|
||||
|
||||
type RenderModeType = "normal" | "collapsed";
|
||||
|
Loading…
Reference in New Issue
Block a user