Skip to content

Commit

Permalink
inspector url search support or operate (#765)
Browse files Browse the repository at this point in the history
* inspector url search support or operate

* deal with search empty in or operator

* fix PR feedback

---------

Co-authored-by: wujiasheng03 <noO0oOo0ob>
  • Loading branch information
noO0oOo0ob authored Jul 21, 2023
1 parent a21214c commit 31a8839
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/src/views/inspector/ButtonBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
height=26
v-model="searchStr"
class="inspector-search-text"
label="Separate multiple keywords by spaces"
label="Separate multiple keywords by spaces or |"
clearable
@click:clear="clearInspectorSearch"
/>
Expand Down
32 changes: 22 additions & 10 deletions frontend/src/views/inspector/FlowList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,32 @@ export default {
filterMethod (value, option) {
return option.toUpperCase().indexOf(value.toUpperCase()) !== -1
},
isMatchByAnd (url, searchList) {
for (const searchItem of searchList)
if (!searchItem || !this.filterMethod(searchItem, url))
return false
return true
},
isMatch (url, searchList) {
for (const searchItem of searchList)
if(this.isMatchByAnd(url, searchItem))
return true
return false
},
refreshFlowList () {
let displayFlowList = []
let searchStr = typeof(this.searchStr) === 'string' ? this.searchStr.trim() : ''
// Split searchStr by one or more spaces
let searchStrList = searchStr.split(/\s+/)
if(!searchStr){
displayFlowList = this.originFlowList
}
// Split searchStr by one or more (spaces, |)
let searchStrList = searchStr.split(/\|+/)
for(const idx in searchStrList){
searchStrList[idx] = searchStrList[idx].trim()
searchStrList[idx] = searchStrList[idx].split(/\s+/)
}
for (const flow of this.originFlowList) {
let isMatch = true
for (const searchItem of searchStrList) {
if (!this.filterMethod(searchItem, flow.request.url)) {
isMatch = false
break
}
}
isMatch ? displayFlowList.push(flow) : null
this.isMatch(flow.request.url, searchStrList) ? displayFlowList.push(flow) : null
}
this.displayFlowCount = displayFlowList.length
this.pageCount = Math.max(Math.ceil(this.displayFlowCount / this.pageSize), 1)
Expand Down

0 comments on commit 31a8839

Please sign in to comment.