Skip to content

Commit 00bd2c8

Browse files
committed
Adding reverse functionnality to trendings panel
1 parent 42ad326 commit 00bd2c8

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/app/panels/trends/editor.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ <h4>Settings</h4>
44
<div class="span3" ng-hide='panel.auto_int'>
55
<label class="small">Use Elasticsearch date math format here (eg 1m, 5m, 1d, 2w, 1y)</label>
66
</div>
7-
<div class="span3">
7+
<div class="span2">
88
<label class="small">Time Ago</label>
99
<input type="text" class="input-small" ng-model="panel.ago" ng-change="set_refresh(true)">
1010
</div>
1111
<div class="span2">
1212
<label class="small">Font Size</label>
13-
<select class="input-small" ng-model="panel.style['font-size']" ng-options="f for f in ['7pt','8pt','9pt','10pt','12pt','14pt','16pt','18pt','20pt','24pt','28pt','32pt','36pt','42pt','48pt','52pt','60pt','72pt']"></select></span>
13+
<select class="input-small" ng-model="panel.style['font-size']" ng-options="f for f in ['7pt','8pt','9pt','10pt','12pt','14pt','16pt','18pt','20pt','24pt','28pt','32pt','36pt','42pt','48pt','52pt','60pt','72pt']"></select>
14+
</div>
15+
<div class="span2">
16+
<label class="small">List Format</label>
17+
<select class="input-small" ng-model="panel.arrangement" ng-options="f for f in ['horizontal','vertical']"></select>
1418
</div>
15-
<div class="span3">
16-
<label class="small" >List Format</label>
17-
<select class="input-small" ng-model="panel.arrangement" ng-options="f for f in ['horizontal','vertical']"></select></span>
19+
<div class="span2">
20+
<label class="small">Reverse</label>
21+
<input type="checkbox" ng-model="panel.reverse" ng-checked="panel.reverse">
1822
</div>
1923
</div>
2024
</div>

src/app/panels/trends/module.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@
99

1010
<div ng-class="{'trends-horizontal':panel.arrangement == 'horizontal'}" ng-style="panel.style" style="line-height:{{panel.style['font-size']}};" ng-repeat="query in trends">
1111
<i class="icon-circle" style="color:{{query.info.color}}"></i>
12-
<span bs-tooltip="'Then: '+query.hits.old+', Now: '+query.hits.new" ng-class="{'text-success': query.hits.new >= query.hits.old, 'text-error': query.hits.old > query.hits.new}" class='pointer strong'>
13-
<i class='large' ng-class="{'icon-caret-up': query.hits.new >= query.hits.old, 'icon-caret-down': query.hits.old > query.hits.new}"></i> {{query.percent}}%
12+
<span
13+
bs-tooltip="'Then: '+query.hits.old+', Now: '+query.hits.new"
14+
ng-class="
15+
{
16+
'text-success': (query.hits.new >= query.hits.old && panel.reverse === false) || (query.hits.new < query.hits.old && panel.reverse === true),
17+
'text-error': (query.hits.old > query.hits.new && panel.reverse === false) || (query.hits.old <= query.hits.new && panel.reverse === true)
18+
}
19+
"
20+
class='pointer strong'
21+
>
22+
<i class='large' ng-class="{'icon-caret-up': query.hits.new >= query.hits.old, 'icon-caret-down': query.hits.old > query.hits.new}"></i>{{query.percent}}%
1423
</span>
1524
<span class="tiny light" ng-show="query.info.alias != ''">({{query.info.alias}})</span>
1625
</div>

src/app/panels/trends/module.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function (angular, app, _, kbn) {
6060
* arrangement:: `horizontal' or `vertical'
6161
*/
6262
arrangement : 'vertical',
63+
/** @scratch /panels/trends/5
64+
* reverse:: true or false.
65+
* Set to true if you want to display trending informations in red if the variation is positive.
66+
* Set to false if you want to display trending informations in green if the variation is positive.
67+
*/
68+
reverse : false,
6369
/** @scratch /panels/trends/5
6470
* spyable:: Set to false to disable the inspect icon
6571
*/

0 commit comments

Comments
 (0)