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

Relevance and other composer tweaks #96

Merged
merged 8 commits into from
Nov 6, 2018

Conversation

ahgittin
Copy link
Contributor

@ahgittin ahgittin commented Nov 1, 2018

Several things to make composer easier to use:

  • When searching in palette, it now sorts by "Relevance" as primary order; relevance formula is a bit complicated, poor-man's AI :), but works pretty damn well (!)
  • Sort is always multi-sort, and dropdown shows the sort order (this could do with more UI goodness to make that obvious, but it does the right thing if you interact with it; "relevance" above obviously has no effect when not searching so "name" as second-order search order is what you normally get)
  • Default palette now shows 3 wide; with more height and longer names this seems better (4 wide aka "Compact" is an option)
  • the Quick Info pane from the palette is now toggleable, and showing this is the default action if you click on a tile (not adding to the root of the application which was a bit surprising!); it has buttons for the previous "selection" action, and also a button to open in catalog
  • selecting from palette adds to a focus entity if there is a focus entity
  • extensible in several places, including the spec editor sections can be customized or removed

Below is a sample screen shot, for a downstream project that uses the UI (and has a lot of types), but the mods all apply to the stock brooklyn UI (though only really useful with a big catalog!):

screen shot 2018-11-01 at 12 25 13

Copy link
Member

@tbouron tbouron left a comment

Choose a reason for hiding this comment

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

The relevance filter works great 👍
Granted we should also put more work into the UX for the filters but that can be addressed later on.

However, I do have issue with the popup and the way it's implemented. There are CSS issues (see the white line on top of the title in the screenshot + things not aligned) and it does weird rendering when you stop hovering the information icon (see gif)

screen shot 2018-11-02 at 12 10 52

popover issue

In order to not drag down the main feature, I suggest to remove commits related to the popover from this PR and open a separate one.

if (match) return true;
fieldNum++;
if (!item.hasOwnProperty(field) || !item[field]) return false;
Copy link
Member

Choose a reason for hiding this comment

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

I know I'm a pain in the b** but could you use curly brackets for consistency please? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it adds 6 lines making the code in my view a lot harder to follow. there is a reason languages allow one-line if consequents to be inlined :) . i've done it as you request but hope you see the light and conclude the verbosity is worse than the inconsistency!

let text = item[field];
if (!text.toLowerCase) {
text = JSON.stringify(text).toLowerCase();
} else {
text = text.toLowerCase();
}
return match || text.indexOf(part) > -1;
let index = text.indexOf(part);
if (index == -1) return false;
Copy link
Member

Choose a reason for hiding this comment

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

Same a above

"pos", index, "/", text.length,
":", item.relevance, "+=", score);
}
*/
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this can be removed

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 think it's useful in case we need to revisit how/why the scoring function works. it has a comment explaining why it is there so i'd prefer to keep it.

if (index == -1) return false;
// found, set relevance -- uses an ad hoc heuristic preferring first fields and short text length,
// earlier occurrences and earlier words weighted more highly (smaller number is better)
let score = fieldNum * (2 / (1 + wordNum)) * Math.log(1 + text.length * index);
Copy link
Member

Choose a reason for hiding this comment

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

A bit complicated to understand at first but I like it! 👍

Object.values($scope.state.currentOrder).forEach( it => {
$scope.state.currentOrderValues.push(it);
$scope.state.currentOrderFields.push(it.field);
});
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating multiple objects and arrays, you can have only one array containing sort object that you update with Array.splice() and Array.unshift(). This array can then be use to generate the multi sort filter + the display on the template.

That would be more efficient that what we currently have

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's O(n) so i don't think there's any major efficiency savings to be had. anyway n=5 so it's moot. the ugliness is around the multiple different lists but when i tried to use a single more sophisticated object angular didn't detect it was changing so seemed simplest to generate the exact different data structures we want. i could try to revise them each but that feels more brittle. so not worth changing in my view.

<p><i class="mini-icon fa fa-fw fa-file-zip-o"></i> {{item.containingBundle}}</p>
<p ng-if="item.relevance"><i class="mini-icon fa fa-sort-numeric-asc"></i> Relevance score: {{ roundTwoDecimals(item.relevance) }}</p>
<p><i class="mini-icon fa fa-fw fa-file-zip-o"></i> {{popover.containingBundle}}</p>
<p ng-if="popover.relevance"><i class="mini-icon fa fa-sort-numeric-asc"></i> Relevance score: {{ roundTwoDecimals(popover.relevance) }}</p>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think seeing the relevance number has any value for the user. In fact, we don't explain nor display what is the scale and order of this. I think we should not display this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is value in seeing a big jump for someone who uses this a lot, and i think it's more likely someone will appreciate this than resent it (but both are unlikely). leave it until/unless someone says they don't want it?

@@ -341,7 +341,9 @@ <h4>No matching configuration</h4>
</br-collapsible>

<!-- ENTITY LOCATION -->
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.location.open">
<ng-include src="'SpecEditorLocationSection.html'"></ng-include>
Copy link
Member

Choose a reason for hiding this comment

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

As we introduce more and more templates through $templateCache (which is great) we should then adopt a naming convention now instead of changing the name after and breaking downstream project.

Therefore I would propose <angular_component_type>/<component_name>/<template_id>.html. For example:

  • directive/spec-editor/section-location.html for this particular template
  • view/main/graphical/footer.html for a footer template in the view main.graphical

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree w making these unique. i think it should definitely have the project name in it to make this happen.

don't think there's much value in component type. project_id/component_id/template_id would get my vote.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

suggest we do this as a separate PR however!


<!-- ENTITY POLICIES -->
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.policy.open">
<ng-include src="'SpecEditorPoliciesSection.html'"></ng-include>
Copy link
Member

Choose a reason for hiding this comment

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

Same as above


<!-- ENTITY ENRICHERS -->
<br-collapsible ng-if="[FAMILIES.ENTITY, FAMILIES.SPEC].indexOf(model.family) > -1" state="state.enricher.open">
<ng-include src="'SpecEditorEnrichersSection.html'"></ng-include>
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

</br-collapsible>
</script>

<ng-include src="'SpecEditorOtherSections.html'"></ng-include>
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

@ahgittin
Copy link
Contributor Author

ahgittin commented Nov 2, 2018

everything addressed @tbouron . fixed the two popover issues also, good spot there. also added a message for use with freeform tiles and tidied that.

@tbouron
Copy link
Member

tbouron commented Nov 6, 2018

LGTM. There are couple of thing I want to change but I'll do this in a separate PR shortly. Merging this in the meantime

@asfgit asfgit merged commit 1da5338 into apache:master Nov 6, 2018
asfgit pushed a commit that referenced this pull request Nov 6, 2018
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.

3 participants