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

mgr/dashboard: Improve table search #20807

Merged
merged 2 commits into from Apr 9, 2018
Merged

Conversation

Devp00l
Copy link

@Devp00l Devp00l commented Mar 8, 2018

You can now search for multiple words at a time if you separate them by
comma or space. The other improvement is that you can specify which
column should be searched by a search term. For example if you wand to
filter for a row with the ID 3 you type "id:3". The column name is case
insensitive and is separated from the search word by a colon.

Signed-off-by: Stephan Müller smueller@suse.com

@Devp00l Devp00l changed the title mgr/dashboard_v2: Improve table search [WIP] mgr/dashboard_v2: Improve table search Mar 8, 2018
@LenzGr LenzGr added the DNM label Mar 8, 2018
@Devp00l Devp00l changed the title [WIP] mgr/dashboard_v2: Improve table search mgr/dashboard_v2: Improve table search Mar 8, 2018
@Devp00l Devp00l removed the DNM label Mar 8, 2018
@rjfd
Copy link
Contributor

rjfd commented Mar 9, 2018

@Devp00l is there already any documentation file where we can add the information about how to use the web UI? (maybe @LenzGr can answer this)
We should update documentation with these usability features.

@rjfd
Copy link
Contributor

rjfd commented Mar 9, 2018

@Devp00l this is a general comment: if the frontend is now written in typescript why don't I see type declarations in the code?

I know that most types can be inferred, and probably typescript compiler will do that, but it might also be the case that the compiler cannot infer the type and fallbacks to the any type and processes that code as pure javascript without taking the advantage of the type checker.

@Devp00l
Copy link
Author

Devp00l commented Mar 9, 2018

search

@rjfd I will add missing declarations

@Devp00l
Copy link
Author

Devp00l commented Mar 9, 2018

@rjfd Added the missing declarations

@LenzGr
Copy link
Contributor

LenzGr commented Mar 9, 2018

Yes, the various pages and datatable features need to be documented. Right now, this is still TBD, but a "Dashboard users guide" would be nice to have.

@tspmelo
Copy link
Contributor

tspmelo commented Mar 13, 2018

Wouldn't it be better to separate the search strings only by ,?
ATM there is no way to search for strings with multiple words.

@Devp00l
Copy link
Author

Devp00l commented Mar 14, 2018

@tspmelo if you search any search function on a page with spaces in between you won't search multiple words at once, only if you hit ctrl+f you will search for the exact pattern, but this is another type of search. This search works as you would expect a page search to function.

Copy link
Contributor

@tspmelo tspmelo left a comment

Choose a reason for hiding this comment

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

ATM we can't filter for columns with multiple words.
If we search for "public address:192" no result will be found because it was searching for "public" and "address:192".

I would suggest we force the comma separator if there is a reference to any column. Otherwise we can still use the space as a separator.

@Devp00l
Copy link
Author

Devp00l commented Mar 15, 2018

@tspmelo You don't need to type the full column - it's enough to type address:192. But we can remove the comma separator as this is a uncommon thing to have. Are you ok with it if you have to search "public address":192 instead? This would be common also public+address:192 would be common too.

@Devp00l Devp00l force-pushed the improve-table-search branch 3 times, most recently from df52079 to 4af511f Compare March 16, 2018 11:35
@LenzGr LenzGr changed the title mgr/dashboard_v2: Improve table search mgr/dashboard: Improve table search Mar 16, 2018
@tspmelo
Copy link
Contributor

tspmelo commented Mar 16, 2018

Using "" is ok with me.

@Devp00l
Copy link
Author

Devp00l commented Mar 20, 2018

jenkins retest this please

@rjfd
Copy link
Contributor

rjfd commented Mar 21, 2018

@Devp00l "make check" failed because of linting problems in the frontend code, could you fix it?

if (searchWords.length === 2) {
tempColumns = [...columns];
columns = columns.filter((c) => c.name.toLowerCase().indexOf(searchWords[0]) !== -1);
const searchTerms: string[] = currentSearch.pop().split(':');
Copy link
Contributor

Choose a reason for hiding this comment

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

you could replace + with , after pop(). This way you don't need to define getSearchTerm.

Copy link
Author

Choose a reason for hiding this comment

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

good spotting :)

});
const searchTerm: string = getSearchTerm(_.last(searchTerms));
data = this.basicDataSearch(searchTerm, data, columns);
// Checks if user searches for column but he is still typing
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the search should focus only on the values of each field, it should only check the column if there is a : after the string.

You could delay the search until the user finished typing, that way you would never get a empty result caused by an incomplete search.

Copy link
Author

Choose a reason for hiding this comment

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

This way you also won't get an empty list, and it's a nicer user experience to provide instant search results.

return;
}
if (_.isArray(cellValue)) {
cellValue = cellValue.join('');
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use the same char that we normally use to display the tables.

I will list some tests I made on the OSD page where all rows have "up, in" as the Status.

  • up, in -> Didn't return anything. Maybe this should return all rows, but I'm ok with this.
  • up in -> Returned all rows. Correct.
  • "up, in" -> Didn't return anything. Should return all rows, because I typed exactly what I see in the rows.
  • "up in" -> Didn't return anything. Correct.
  • status:up status:in -> Returned all rows. Correct.
  • pi -> Return all rows. Should have returned empty.

Copy link
Author

Choose a reason for hiding this comment

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

Commas are ignored now.
I couldn't reproduce the pi example it will return nothing for me.
Now all other examples will show all up and in rows.
It's OK if you miss the comma in quotes as you are not searching any string, you are searching an array. Of course ignoring the comma will loose the way to find strings with a comma in name but those strings a pretty rare, comma is mostly used as separator for items.

}).length > 0
);
});
console.log(search);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@ricardoasmarques ricardoasmarques left a comment

Choose a reason for hiding this comment

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

Missing pipe support

}
return data.filter(d => {
return columns.filter(c => {
let cellValue: any = _.get(d, c.prop);
Copy link
Contributor

Choose a reason for hiding this comment

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

If the column is using a pipe, the first transformation that you should do is applying that pipe. Otherwise user will not be filtering by what he is seeing.

  if (!_.isUndefined(c.pipe)) {
    cellValue = c.pipe.transform(cellValue);
  }

Copy link
Author

Choose a reason for hiding this comment

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

Nice spotting :) Implemented it 👍

Stephan Müller added 2 commits April 6, 2018 16:46
You can now search for multiple words at a time if you separate them by
comma or space. The other improvement is that you can specify which
column should be searched by a search term. For example if you wand to
filter for a row with the ID 3 you type "id:3". The column name is case
insensitive and is separated from the search word by a colon.

Signed-off-by: Stephan Müller <smueller@suse.com>
Removed the usage of using comma to indicated a new search term and
introduced the possibility to use quoted strings in order to search for
spaces too.

Also improved the column search handling in order to not get no search
results found while typing a column name.

Signed-off-by: Stephan Müller <smueller@suse.com>
Copy link
Contributor

@ricardoasmarques ricardoasmarques left a comment

Choose a reason for hiding this comment

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

LGTM

@tspmelo
Copy link
Contributor

tspmelo commented Apr 9, 2018

jenkins retest this please

1 similar comment
@tspmelo
Copy link
Contributor

tspmelo commented Apr 9, 2018

jenkins retest this please

@LenzGr LenzGr merged commit 2bf2013 into ceph:master Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants