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