You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by ahgittin <gi...@git.apache.org> on 2018/11/01 12:30:59 UTC
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
GitHub user ahgittin opened a pull request:
https://github.com/apache/brooklyn-ui/pull/96
Relevance and other composer tweaks
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!):
<img width="1411" alt="screen shot 2018-11-01 at 12 25 13" src="https://user-images.githubusercontent.com/496540/47851889-e41fe900-ddd1-11e8-9864-917c668ebe43.png">
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ahgittin/brooklyn-ui relevance-and-other-composer-tweaks
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/brooklyn-ui/pull/96.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #96
----
commit 6ae7338f72a25cc7862ad0db37860a108dabce3d
Author: Alex Heneveld <al...@...>
Date: 2018-10-31T12:56:20Z
sort search results by relevance
and display sort fields dropdown in order used
commit 4d42539e695fdd8354b076b2ae724f730f4aef0f
Author: Alex Heneveld <al...@...>
Date: 2018-10-31T13:24:47Z
make default view 3x wide rather than 4x wide
commit bad6676562e58ad9adf9a3b9fb893b5fc4763852
Author: Alex Heneveld <al...@...>
Date: 2018-10-31T16:37:10Z
quick info pane is toggle-able, and has buttons to add
commit feac3fc1b1034160fda7c1a285061a2cd8ef4d1f
Author: Alex Heneveld <al...@...>
Date: 2018-10-31T16:56:58Z
allow spec editor sections to be customized
commit e20a8d12bffb05b7010fe824a8c57deec27a8e0f
Author: Alex Heneveld <al...@...>
Date: 2018-11-01T11:22:53Z
allow selection text and behaviour to be customized in palette
when adding, clicking the icon adds it directly; but on palette clicking opens popup;
and popup button gets correct configurable message
----
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230391995
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -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>
--- End diff --
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.
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230391061
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html ---
@@ -145,19 +153,29 @@ <h3>{{freeFormTile | entityName}}</h3>
<!-- QUICK INFO TEMPLATE :: START-->
<script type="text/ng-template" id="QuickInfoTemplate.html">
<div class="palette-item-quick-info">
- <div class="deprecated-marker" ng-if="item.deprecated">DEPRECATED</div>
+ <div class="quick-info-title">{{ popover | entityName }}
+ <br-svg type="close" class="pull-right closer" ng-click="closePopover()"></br-svg>
+ </div>
+ <div class="deprecated-marker" ng-if="popover.deprecated">DEPRECATED</div>
<div class="quick-info-metadata">
- <p><i class="mini-icon fa fa-fw fa-bookmark"></i> <samp class="type-symbolic-name">{{item.symbolicName}}</samp></p>
- <p ng-if="item.version"><i class="mini-icon fa fa-fw fa-code-fork"></i> {{item.version}}</p>
+ <p><i class="mini-icon fa fa-fw fa-bookmark"></i> <samp class="type-symbolic-name">{{popover.symbolicName}}</samp></p>
+ <p ng-if="popover.version"><i class="mini-icon fa fa-fw fa-code-fork"></i> {{popover.version}}</p>
</div>
- <p class="quick-info-description" ng-if="item.description">{{item.description}}</p>
+ <p class="quick-info-description" ng-if="popover.description">{{popover.description}}</p>
<div class="quick-info-metadata bundle">
- <p ng-if="lastUsedText(item)"><i class="mini-icon fa fa-clock-o"></i> {{ lastUsedText(item) }}</p>
- <p ng-if="item.displayTags && item.displayTags.length"><i class="mini-icon fa fa-fw fa-tags"></i>
- <span ng-repeat-start="tag in item.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
+ <p ng-if="lastUsedText(popover)"><i class="mini-icon fa fa-clock-o"></i> {{ lastUsedText(popover) }}
+ <br-svg type="close" class="closer" ng-click="popover.lastUsed = 0"></br-svg>
+ </p>
+ <p ng-if="popover.displayTags && popover.displayTags.length"><i class="mini-icon fa fa-fw fa-tags"></i>
+ <span ng-repeat-start="tag in popover.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
<span ng-repeat-end> </span> </p>
- <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>
--- End diff --
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?
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230340893
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
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;
+ // 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);
--- End diff --
A bit complicated to understand at first but I like it! 👍
---
[GitHub] brooklyn-ui issue #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:
https://github.com/apache/brooklyn-ui/pull/96
everything addressed @tbouron . fixed the two popover issues also, good spot there. also added a message for use with freeform tiles and tidied that.
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230382222
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html ---
@@ -157,6 +157,7 @@ <h3>{{freeFormTile | entityName}}</h3>
<span ng-repeat-start="tag in item.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
<span ng-repeat-end> </span> </p>
<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>
--- End diff --
nice
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230380075
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
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;
+ // 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);
+ /* to debug the scoring function:
+ if (item.symbolicName.indexOf("EIP") >= 0 || item.symbolicName.indexOf("OpsWorks") >= 0) {
+ console.log(item.symbolicName, ": match", part, "in", field,
+ "#", fieldNum, wordNum,
+ "pos", index, "/", text.length,
+ ":", item.relevance, "+=", score);
+ }
+ */
--- End diff --
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.
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230342561
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -247,11 +266,23 @@ function controller($scope, $element, $timeout, $q, $uibModal, $log, $templateCa
paletteDragAndDropService.dragEnd();
tryMarkUsed(item);
};
+
$scope.sortBy = function (order) {
- let newOrder = [].concat($scope.state.currentOrder);
- newOrder = newOrder.filter( (o) => o !== order.field );
- $scope.state.currentOrder = [order.field].concat(newOrder);
+ let newFirst = {};
+ if (order) {
+ newFirst[order.id] = order;
+ }
+ $scope.state.currentOrder = Object.assign(newFirst, $scope.state.currentOrder, newFirst);
+ $scope.state.currentOrderFields = [];
+ $scope.state.currentOrderValues = [];
+ Object.values($scope.state.currentOrder).forEach( it => {
+ $scope.state.currentOrderValues.push(it);
+ $scope.state.currentOrderFields.push(it.field);
+ });
--- End diff --
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
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230349124
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -365,10 +367,13 @@ <h4>No location attached</h4>
<button class="btn btn-danger btn-link" ng-click="model.clearIssues({group: 'location'}).removeLocation()">Remove</button>
</div>
</div>
-</br-collapsible>
+ </br-collapsible>
+</script>
<!-- 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>
--- End diff --
Same as above
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230340735
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
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;
+ // 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);
+ /* to debug the scoring function:
+ if (item.symbolicName.indexOf("EIP") >= 0 || item.symbolicName.indexOf("OpsWorks") >= 0) {
+ console.log(item.symbolicName, ": match", part, "in", field,
+ "#", fieldNum, wordNum,
+ "pos", index, "/", text.length,
+ ":", item.relevance, "+=", score);
+ }
+ */
--- End diff --
Seems like this can be removed
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230340611
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
--- End diff --
I know I'm a pain in the b** but could you use curly brackets for consistency please? :)
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230342731
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html ---
@@ -157,6 +157,7 @@ <h3>{{freeFormTile | entityName}}</h3>
<span ng-repeat-start="tag in item.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
<span ng-repeat-end> </span> </p>
<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>
--- End diff --
Use the `number` filter instead: https://docs.angularjs.org/api/ng/filter/number
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230348970
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -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>
--- End diff --
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`
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230340646
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
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;
--- End diff --
Same a above
---
[GitHub] brooklyn-ui issue #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on the issue:
https://github.com/apache/brooklyn-ui/pull/96
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
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230389759
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
return function (items, search) {
if (search) {
return items.filter(function (item) {
- return search.toLowerCase().split(' ').reduce( (found, part) =>
- found &&
- FIELDS_TO_SEARCH
- .filter(field => item.hasOwnProperty(field) && item[field])
- .reduce((match, field) => {
+ item.relevance = 0;
+ let wordNum = 0;
+ return search.toLowerCase().split(' ').reduce( (found, part) => {
+ wordNum++;
+ let fieldNum = 0;
+ return found &&
+ FIELDS_TO_SEARCH.reduce((match, field) => {
if (match) return true;
+ fieldNum++;
+ if (!item.hasOwnProperty(field) || !item[field]) return false;
--- End diff --
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!
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230344363
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -33,9 +33,10 @@ const PALETTE_VIEW_ORDERS = {
};
const PALETTE_VIEW_MODES = {
- compact: { name: "Compact", classes: "col-xs-2 item-compact", itemsPerRow: 6, rowHeightPx: 75, hideName: true },
- normal: { name: "Normal", classes: "col-xs-3", itemsPerRow: 4 },
- large: { name: "Large", classes: "col-xs-4", itemsPerRow: 3 },
+ tiny: { name: "Tiny", classes: "col-xs-2 item-compact", itemsPerRow: 6, rowHeightPx: 75, hideName: true },
--- End diff --
Not sure about `tiny`, it doesn't feel right. I would rather see `small` instead.
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230381696
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
@@ -247,11 +266,23 @@ function controller($scope, $element, $timeout, $q, $uibModal, $log, $templateCa
paletteDragAndDropService.dragEnd();
tryMarkUsed(item);
};
+
$scope.sortBy = function (order) {
- let newOrder = [].concat($scope.state.currentOrder);
- newOrder = newOrder.filter( (o) => o !== order.field );
- $scope.state.currentOrder = [order.field].concat(newOrder);
+ let newFirst = {};
+ if (order) {
+ newFirst[order.id] = order;
+ }
+ $scope.state.currentOrder = Object.assign(newFirst, $scope.state.currentOrder, newFirst);
+ $scope.state.currentOrderFields = [];
+ $scope.state.currentOrderValues = [];
+ Object.values($scope.state.currentOrder).forEach( it => {
+ $scope.state.currentOrderValues.push(it);
+ $scope.state.currentOrderFields.push(it.field);
+ });
--- End diff --
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.
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230349155
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -431,7 +439,13 @@ <h4 ng-if="model.hasEnrichers() && filteredEnrichers.length === 0">No enrichers
<ng-include src="'AdjunctTemplate.html'"></ng-include>
</div>
</div>
-</br-collapsible>
+ </br-collapsible>
+</script>
+
+<ng-include src="'SpecEditorOtherSections.html'"></ng-include>
--- End diff --
Same as above
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230349133
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -398,10 +403,13 @@ <h4 ng-if="model.hasPolicies() && filteredPolicies.length === 0">No policies mat
<ng-include src="'AdjunctTemplate.html'"></ng-include>
</div>
</div>
-</br-collapsible>
+ </br-collapsible>
+</script>
<!-- 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>
--- End diff --
Same as above
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230392115
--- Diff: ui-modules/blueprint-composer/app/components/spec-editor/spec-editor.template.html ---
@@ -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>
--- End diff --
suggest we do this as a separate PR however!
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/brooklyn-ui/pull/96
---
[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks
Posted by tbouron <gi...@git.apache.org>.
Github user tbouron commented on a diff in the pull request:
https://github.com/apache/brooklyn-ui/pull/96#discussion_r230347692
--- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.template.html ---
@@ -145,19 +153,29 @@ <h3>{{freeFormTile | entityName}}</h3>
<!-- QUICK INFO TEMPLATE :: START-->
<script type="text/ng-template" id="QuickInfoTemplate.html">
<div class="palette-item-quick-info">
- <div class="deprecated-marker" ng-if="item.deprecated">DEPRECATED</div>
+ <div class="quick-info-title">{{ popover | entityName }}
+ <br-svg type="close" class="pull-right closer" ng-click="closePopover()"></br-svg>
+ </div>
+ <div class="deprecated-marker" ng-if="popover.deprecated">DEPRECATED</div>
<div class="quick-info-metadata">
- <p><i class="mini-icon fa fa-fw fa-bookmark"></i> <samp class="type-symbolic-name">{{item.symbolicName}}</samp></p>
- <p ng-if="item.version"><i class="mini-icon fa fa-fw fa-code-fork"></i> {{item.version}}</p>
+ <p><i class="mini-icon fa fa-fw fa-bookmark"></i> <samp class="type-symbolic-name">{{popover.symbolicName}}</samp></p>
+ <p ng-if="popover.version"><i class="mini-icon fa fa-fw fa-code-fork"></i> {{popover.version}}</p>
</div>
- <p class="quick-info-description" ng-if="item.description">{{item.description}}</p>
+ <p class="quick-info-description" ng-if="popover.description">{{popover.description}}</p>
<div class="quick-info-metadata bundle">
- <p ng-if="lastUsedText(item)"><i class="mini-icon fa fa-clock-o"></i> {{ lastUsedText(item) }}</p>
- <p ng-if="item.displayTags && item.displayTags.length"><i class="mini-icon fa fa-fw fa-tags"></i>
- <span ng-repeat-start="tag in item.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
+ <p ng-if="lastUsedText(popover)"><i class="mini-icon fa fa-clock-o"></i> {{ lastUsedText(popover) }}
+ <br-svg type="close" class="closer" ng-click="popover.lastUsed = 0"></br-svg>
+ </p>
+ <p ng-if="popover.displayTags && popover.displayTags.length"><i class="mini-icon fa fa-fw fa-tags"></i>
+ <span ng-repeat-start="tag in popover.displayTags" class="label label-primary palette-item-tag">{{ tag }}</span>
<span ng-repeat-end> </span> </p>
- <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>
--- End diff --
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
---