Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

psyray
Copy link
Contributor

@psyray psyray commented Jul 17, 2022

Fix #1404

Copy link
Member

@p-l- p-l- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time to test right now but I will do asap

Comment on lines +97 to +99
function escapeRegex(string) {
return '\\"'+string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&').trim()+'\\"';
}
Copy link
Member

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:

Suggested change
function escapeRegex(string) {
return '\\"'+string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&').trim()+'\\"';
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

Copy link
Contributor Author

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"

Copy link
Member

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)

@@ -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 +'");';
Copy link
Member

@p-l- p-l- Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have the display: directive.

Suggested change
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegex(x) + '/");setparam(FILTER, "display:'+ field +'");';
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegExp(x).trim() + '/");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display: is set to display the content we want to see while clicking.
When you click on the line, you have the list filtered, but without the details it's not really accurate.
Everytime I have to set the filter display:xxx to have details.
And it's more simple to click on the cross to deactivate filter than typing on the keyboard -> it's annoying ... :(

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

No problem, you're the boss, boss ;)

@psyray
Copy link
Contributor Author

psyray commented Jul 18, 2022

I don't have time to test right now but I will do asap

No problem ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore view filter when clicking on title does not work for script:xxxx
2 participants