-
-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add filter in Explore view for script:xxx #1405
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -94,6 +94,10 @@ var GraphTopValues = (function(_super) { | |||||
this.filename = "TopValues"; | ||||||
} | ||||||
|
||||||
function escapeRegex(string) { | ||||||
return '\\"'+string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&').trim()+'\\"'; | ||||||
} | ||||||
|
||||||
$.extend(GraphTopValues.prototype, _super.prototype, { | ||||||
get_url: function() { | ||||||
return 'cgi/view/top/' + encodeURIComponent(this.field) + ':' + | ||||||
|
@@ -268,6 +272,11 @@ var GraphTopValues = (function(_super) { | |||||
return 'setparam(FILTER, "script", "' + x + '");'; | ||||||
}; | ||||||
} | ||||||
else if(field.substr(0, 7) === 'script:') { | ||||||
preparefilter = function(x) { | ||||||
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegex(x) + '/");setparam(FILTER, "display:'+ field +'");'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should have the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand but that's not what exists in IVRE so far. For now, clicking in top values creates a filter for that value, it does not limit the display. For now, I'd rather keep it that way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No problem, you're the boss, boss ;) |
||||||
}; | ||||||
} | ||||||
else if(field === 'port') { | ||||||
prepareoutput = function(x) { | ||||||
return x.join(' / '); | ||||||
|
@@ -1305,3 +1314,4 @@ var GraphDiffCategories = (function(_super) { | |||||
|
||||||
return GraphDiffCategories; | ||||||
})(GraphIpPort); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather remove the double quotes added here as they are not part of the regexp escape process:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double quote is here to take the string in it's whole, and simplify the condition and make more readable, and also to prevent repeat the double quote everytime.
Maybe we should name it formatRegEx instead of escapeRegEx, and set a parameter to include the double quote or not ?
But you remove trim, and it's necessary to remove the line feed, if not the Javascript will fail and drop an error "unescaped line feed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point for the
.trim()
. I think it is better to add it after the call, so I did it (see below)