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

First impl. for issue 322 #325

Closed
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ var config = new Settings(
modules: ['histogram','map','pie','table','filtering',
'timepicker','text','fields','hits','dashcontrol',
'column','derivequeries','trends','bettermap','query',
'terms'],
'terms','condition']
}
);
7 changes: 7 additions & 0 deletions panels/condition/editor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div>
<div class="row-fluid">
<div class="span12">
No options here
</div>
</div>
</div>
36 changes: 36 additions & 0 deletions panels/condition/module.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<kibana-panel ng-controller='condition' ng-init="init()" class="query-panel">
<style>
.begin-query {
position:absolute;
left:13px;
top:5px;
}
.end-query {
position:absolute;
right:15px;
top:5px;
}
.panel-query {
padding-left: 35px !important;
height: 31px !important;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.form-search:hover .remove-query {
opacity: 1;
}
</style>
<label class="small">{{panel.label}}</label>
<form class="form-search" style="position:relative;margin-bottom:5px;" ng-submit="refresh()">
<input class="panel-query input-block-level"
ng-class=""
data-min-length=0
data-items=100
type="text"
ng-model="conditionString"/>
<span class="end-query">
<i class="icon-search pointer" ng-click="refresh()" ></i>
</span>
</form>
</kibana-panel>
67 changes: 67 additions & 0 deletions panels/condition/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*jshint globalstrict:true */
/*global angular:true */
/*

## Conditions

a simple text field to input a filter expression.

Author: Andre Kullmann

### Parameters
* label :: The label to stick over the field
*/

'use strict';

angular.module('kibana.condition', [])
.controller('condition', function($scope, dashboard, filterSrv) {

$scope.panelMeta = {
status : "Experimental",
description : ""
};

// Set and populate defaults
var _d = {
label : "Condition",
history : [],
remember: 10 // max: 100, angular strap can't take a variable for items param
};
_.defaults($scope.panel,_d);

$scope.filterSrv = filterSrv;

$scope.init = function() {
$scope.conditionId = null;
};

var isBlank = function(str) {
return (!str || /^\s*$/.test(str));
}

$scope.refresh = function() {
var id = $scope.conditionId;
var blank = isBlank( $scope.conditionString );
//alert("id:" + id + " blank:" + blank );

if( id != null && blank ) {
filterSrv.remove( id );
id = null;
} else if( id == null ) {
id = filterSrv.set({
type: 'querystring',
query: $scope.conditionString
} );
} else {
id = filterSrv.set({
type: 'querystring',
query: $scope.conditionString
}, id );
}
$scope.conditionId = id;

dashboard.refresh();
};

});