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

Allow to de-activate a pinned query #564

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/app/panels/query/module.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<div ng-controller='query' ng-init="init()" class="query-panel">
<style>
.pinned.selected {
border: 3px solid;
}
.pinned.unselected {
border: 0px solid;
}
</style>
<div ng-repeat="id in (unPinnedQueries = (querySrv.ids|pinnedQuery:false))" ng-class="{'short-query': unPinnedQueries.length>1}">
<form class="form-search" style="position:relative;margin-bottom:5px;" ng-submit="refresh()">
<span class="begin-query">
Expand All @@ -14,8 +22,10 @@
</div>
<div style="display:inline-block" ng-repeat="id in querySrv.ids|pinnedQuery:true">
<span class="pointer" ng-show="$first" ng-click="panel.pinned = !panel.pinned"><small class="pins">Pinned</small> <i ng-class="{'icon-caret-right':panel.pinned,'icon-caret-left':!panel.pinned}"></i></span>
<span ng-show="panel.pinned" class="pinned badge">
<i class="icon-circle pointer" ng-style="{color: querySrv.list[id].color}" data-unique="1" bs-popover="'app/panels/query/meta.html'"></i><span bs-tooltip="querySrv.list[id].query"> {{querySrv.list[id].alias || querySrv.list[id].query}}</span>
<span ng-show="panel.pinned" class="pinned pointer badge"
ng-style="{'border-color': querySrv.list[id].color}"
ng-class="{selected:querySrv.list[id].active,unselected:!querySrv.list[id].active}">
<i class="icon-circle pointer" ng-style="{color: querySrv.list[id].color}" data-unique="1" bs-popover="'app/panels/query/meta.html'"></i><span bs-tooltip="querySrv.list[id].query" ng-click="querySrv.list[id].active = !querySrv.list[id].active; refresh()"> {{querySrv.list[id].alias || querySrv.list[id].query}}</span>
</span>
</div>
<span style="display:inline-block" ng-show="unPinnedQueries.length == 0">
Expand Down
7 changes: 4 additions & 3 deletions src/app/services/querySrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function (angular, _, config) {
query: '*',
alias: '',
pin: false,
active: true,
type: 'lucene'
};

Expand Down Expand Up @@ -117,11 +118,11 @@ function (angular, _, config) {
switch(config.mode)
{
case 'all':
return self.ids;
return _.pluck(_.where(self.list,{active:true}),'id');
case 'pinned':
return _.pluck(_.where(self.list,{pin:true}),'id');
return _.pluck(_.where(self.list,{pin:true, active:true}),'id');
case 'unpinned':
return _.difference(self.ids,_.pluck(_.where(self.list,{pin:true}),'id'));
return _.difference(self.ids,_.pluck(_.where(self.list,{pin:true, active:true}),'id'));
case 'selected':
return _.intersection(self.ids,config.ids);
default:
Expand Down