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

Annotations filters UI #2743

Closed
wants to merge 11 commits into from
Closed

Conversation

vnishukov
Copy link
Contributor

@vnishukov vnishukov commented Jan 29, 2021

Motivation and context

1418: CVAT new UI: find the way to simplify the syntax for filters

How has this been tested?

  • Go to annotation page
  • Click to filters input
  • Play around with form
  • Shift+Left click: add open bracket for item
  • Shift+Right click: add close bracket for item
  • Alt+Left click: remove open bracket for item
  • Alt+Right click: remove close bracket for item
  • Right click on filter input open confirm dialog to clean up filters

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

@vnishukov
Copy link
Contributor Author

FiltersInput component has to be removed after review

This was referenced Jan 29, 2021
cvat-ui/package-lock.json Outdated Show resolved Hide resolved
@bsekachev bsekachev added the enhancement New feature or request label Feb 1, 2021
@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

@vnishukov , by a reason first image is zoomed when I open a job. Can it be connected with your changes?

@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

In help message:

  • Can we replace [Right] and [Left] on icons for left and right buttons?
  • Do we need ServerID and ClientID? The user can see ID. I will prefer to keep only ID = ClientID.
  • CVAT uses json queries to perform search.. Why do we need mention that? Is it important?

@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

@nmanovic

Can we have an icon to clear filter somewhere instead of context menu?

image

We actually can, but I'm pretty sure that current approach is more comfortable for users, and allow to keep filters pane with no extra elements. It actually not a big deal to change, so could we give users a chance to test it?

@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

Why did you decide to use hotkeys to add ( and )?

@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

@vnishukov
Copy link
Contributor Author

vnishukov commented Feb 3, 2021

@nmanovic

In help message:

  • Can we replace [Right] and [Left] on icons for left and right buttons?
    This is a dynamic values fetched from global shortcuts map, don't think we shall hardcode it
  • Do we need ServerID and ClientID? The user can see ID. I will prefer to keep only ID = ClientID.
    This developed as it was requested in concept. Maybe we can ask @bsekachev?
  • CVAT uses json queries to perform search.. Why do we need mention that? Is it important?
    This was mentioned before. JSON queries is still used to apply the filters, that's why it is still present. Should I remove it?

@vnishukov
Copy link
Contributor Author

vnishukov commented Feb 3, 2021

@nmanovic

Why did you decide to use hotkeys to add ( and )?

I'm absolutely sure this is more comfortable than it was described in concept (additional combine button in change filter panel). We should improve UX and make it possible for users to achieve theirs goals using minimum of clicks, navigations, etc. In current approach user can group filters by single clicks for each of them. In the approach described in concept it will be couple of clicks, and extra button. But the main benefit here is the multigrouping (two or more braces) in the current approach we still handle it by two clicks, in other approach it requires a "by hand" input in filters pane which is acts slowly and takes more efforts from user. Let's give a chance to test it by users as well?

@vnishukov
Copy link
Contributor Author

@nmanovic

@vnishukov , did you look at https://github.com/ukrbublik/react-awesome-query-builder? Can it help?

Current logic of json queries was not changed, as it works fine. What benefits will we have to change it with something else instead?

@nmanovic
Copy link
Contributor

nmanovic commented Feb 3, 2021

@nmanovic

@vnishukov , did you look at https://github.com/ukrbublik/react-awesome-query-builder? Can it help?

Current logic of json queries was not changed, as it works fine. What benefits will we have to change it with something else instead?

@vnishukov , I see your point. @bsekachev , @ActiveChooN , what do you think?

@bsekachev
Copy link
Member

bsekachev commented Feb 4, 2021

@ActiveChooN Can I ask you to review the PR when it is ready?

@vnishukov vnishukov changed the title Annotations filters UI [WIP] Annotations filters UI Feb 4, 2021
@vnishukov
Copy link
Contributor Author

@vnishukov , by a reason first image is zoomed when I open a job. Can it be connected with your changes?

This is the one of the reason of failed tests. I didn't make any specific with images, changes affect only right side panel, but seems somehow it affects annotation area as well

@bsekachev
Copy link
Member

Hi, I tried the patch and here are some thoughts:

  1. Why do we need "@babel/plugin-proposal-nullish-coalescing-operator"? Let's just use "||" to get default value.

  2. Bug: Image scaled after opening a job (already mentioned)

  3. Delete by right mouse click: not obvious (why not left icon as it was?)

  4. Disappeared feature: the latest 10 filters list to quick select on of them

  5. Personally, it took me 10 minutes to understand how to add brackets in current implementation

  6. Bug: the object with ID 6 is inaccessible (literally it is out of scroll area, scroll is set to maximum on the screenshot)
    Screenshot from 2021-02-09 18-30-48

  7. Pressing right button (to remove a bracket) looks quite risky because in case when I pressed it before Alt (or missed the key in some reasons) it opens popover with suggestion to remove filter and button "Yes" close to the cursor

  8. Bug: In attribute annotation mode we still have old component for filters

  9. Bug: Not critical but looks strange when a label does not have any attributes
    Screenshot from 2021-02-09 18-38-27

  10. Bug: I set empty_frame=="false" and CVAT still navigates by empty frames. How is it expected to work? We already have another feature to empty frames navigation actually

  11. Probably bug: boolean attributes have only one option (I understand that it could be replaced with ==, !==, but for me personally it looks strange (maybe @ActiveChooN think in other way)
    Screenshot from 2021-02-09 18-41-59

  12. Disappeared feature: filters like width > height; height > width; height == width, etc

  13. Type filter does not contain "Tag" option

  14. Bug: Filter: occluded=="true" hides occluded object (occluded=="false" also hides occluded object as it expected)

I also looked at https://github.com/ukrbublik/react-awesome-query-builder and I would say it looks promising. IMO UX is simplier and the builder is quite flexible. I have some concerns related with output format (out of the box it is different, but GitHub says "Export to MongoDb, SQL, JsonLogic or your custom format", so maybe we will be able to setup it properly or adjust format that cvat-core expects (it is also possible because cvat-core expects custom format, not jsonpath and we have our code for convertation which could be adjusted). And additionally we need to be sure that this library is able to provide necessary flexibility (in possible queries). After quick review it looks like it is able more or less, but need more investigations.

@bsekachev
Copy link
Member

@vnishukov @ActiveChooN

Let's have a meeting tomorrow about the patch, guys. I'll send an invite.

@bsekachev
Copy link
Member

@nmanovic

Do we need ServerID and ClientID? The user can see ID. I will prefer to keep only ID = ClientID.

Previously when dump file included server IDs some people used serverID to find objects from dump file in UI.
Now a dump file does not include id anymore, so I think it can be removed.

@@ -1,4 +1,4 @@
// Copyright (C) 2019-2020 Intel Corporation
// Copyright (C) 2021 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

It should be 2019-2021

//
// SPDX-License-Identifier: MIT

import { Tag } from 'antd';
Copy link
Member

Choose a reason for hiding this comment

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

Let's use the same import policy, now project uses modular import: import Tag from /antd/lib/Tag
For information: https://nsisodiya.medium.com/reduce-size-in-ant-design-bundle-size-c35dad9ce3a8

};
function AnnotationFilterItem({
item, onEdit, onDelete, onGrouping,
}: Props): ReactElement {
Copy link
Member

Choose a reason for hiding this comment

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

ReactElement > JSX.Element

case ActionType.addRight:
return { ...state, right: [...state.right, ')'] };
case ActionType.removeLeft:
state.left.pop();
Copy link
Member

Choose a reason for hiding this comment

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

state.right property before reducing is equal to state.right property after.
It is better to use something destructive like that:
return { ...state, left: state.left.slice(0, -1) };

Comment on lines +48 to +49
state.right.pop();
return { ...state };
Copy link
Member

Choose a reason for hiding this comment

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

The same

@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2021 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

Please, abort changes in this file

@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2021 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

Please, abort changes in this file

@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2021 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

Should be 2020-2021

@@ -1,22 +1,21 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2021 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

Should be 2020-2021

import StatesOrderingSelector from 'components/annotation-page/standard-workspace/objects-side-bar/states-ordering-selector';
import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

Please, do 3rdparty import before internal import
What is a reason to change import order in this file?

Comment on lines +18 to +29
concatenator,
filterBy,
operator,
value,
attribute,
attributeOperator,
attributeValue,
anotherAttributeLabel,
anotherAttributeValue,
fillState,
partialReset,
reset,
Copy link
Member

Choose a reason for hiding this comment

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

I expect all actions to be a verb (or contain a verb)
For example I cannot understand what such actions like concatenator, value, operator, attribute, etc. do.
Also to follow the current codestyle let actions to be written in upper case: FILTER_BY, FILL_STATE, PARTIAL_RESET.

@bsekachev
Copy link
Member

Some common comments after code review:

  1. Using any and some abstract types is too often, we lose the main benefit of TypeScript in this case
  2. I see code style and header changes in some files which are not expected to be affected by the patch

@vnishukov
Copy link
Contributor Author

vnishukov commented Feb 10, 2021

@bsekachev

  1. Why do we need "@babel/plugin-proposal-nullish-coalescing-operator"? Let's just use "||" to get default value.

Using || we apply right branch value when the left branch value is false but not only includes undefined and null but also 0 and ''.
I believe ?? is much more specific as to apply only for undefined and null and not for 0 and '' (which more like a js assertions side effect)

@bsekachev
Copy link
Member

Using || we apply right branch value when the left

I read about the difference, but in the code I do not see where it is important in our case. Could you please direct me?

Copy link
Contributor

@ActiveChooN ActiveChooN left a comment

Choose a reason for hiding this comment

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

Most problems was described by @bsekachev and i have to add only few things:

  1. It's better to save state of the filter input for reducing clicks for similar filters (in case we want to select some obejcts with differnt clientID).
  2. There is no way to insert filter in the middle of the query, only remove secand half of the query.
  3. I guess it can be really nice feature to insert query as a string like it works for label editor. It can be helpful for common filters.

Probably bug: boolean attributes have only one option (I understand that it could be replaced with ==, !==, but for me personally it looks strange (maybe @ActiveChooN think in other way)

I did not notice anithing strange.

const { changeAnnotationsFilters } = props;

const [editItem, setEditItem] = useState();
const [filters, setFilters] = useState([] as any);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use filter type from annotation-filter-item.tsx and reduce using any type as possible?

}, [state]);

useEffect(() => {
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's better to use recap for timeout in useEffect hook

@vnishukov vnishukov changed the title [WIP] Annotations filters UI Annotations filters UI Feb 26, 2021
@vnishukov
Copy link
Contributor Author

Reimplemented with new UI in #2871 using https://github.com/ukrbublik/react-awesome-query-builder

@vnishukov vnishukov closed this Feb 27, 2021
@bsekachev bsekachev deleted the feature/1418-annotations-filters-ui branch April 1, 2021 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants