Added support for broadcasting an array of queries, added multi query support to stringquery panel
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<label class="small">Allow Mulitple</label><input type="checkbox" ng-model="panel.multi" ng-checked="panel.multi">
|
||||
</div>
|
||||
<div class="span4" ng-show="panel.multi">
|
||||
<label class="small">Multiquery Arrangement</label>
|
||||
<select class="input-medium" ng-model="panel.multi_arrange" ng-options="f for f in ['vertical','horizontal']"></select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,9 +1,26 @@
|
||||
<kibana-panel ng-controller='stringquery'>
|
||||
<form class="input-append" style="margin-bottom:0px; width:100%; white-space:nowrap;">
|
||||
<label><small>{{panel.label}}</small></label>
|
||||
<input type="text" ng-model="panel.query" style="width:85%">
|
||||
<button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i></button>
|
||||
<button type="submit" class="btn btn-danger" ng-click="panel.query='';send_query(panel.query)"><i class="icon-ban-circle"></i></button>
|
||||
|
||||
</form>
|
||||
<div ng-switch="_.isArray(panel.query)">
|
||||
<div ng-switch-when="false">
|
||||
<form class="input-append" style="margin-bottom:0px; width:100%; white-space:nowrap;">
|
||||
<label><small>{{panel.label}}</small></label>
|
||||
<input type="text" ng-model="panel.query" style="width:85%">
|
||||
<button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i></button>
|
||||
<button type="submit" class="btn btn-danger" ng-click="panel.query='';send_query(panel.query)"><i class="icon-ban-circle"></i></button>
|
||||
<button ng-show="panel.multi" type="submit" class="btn" ng-click="add_query()"><i class="icon-plus"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
<div ng-switch-when="true">
|
||||
<form ng-class="{form-inline: panel.multi_arrange == 'horizontal'}" style="width:100%;" >
|
||||
<span ng-repeat="q in panel.query">
|
||||
<span class="input-append" style="margin-bottom:0px;margin-right:5px">
|
||||
<button class="btn btn-danger" type="submit" style="width:50px;margin-left:-50px;visibility:hidden"></button>
|
||||
<input style="margin-bottom:5px;" type="text" ng-model="panel.query[$index]" ng-model-onblur style="width:90%">
|
||||
<button class="btn btn-danger" ng-show="panel.query.length > 1" ng-click="remove_query($index);send_query(panel.query)"><i class="icon-minus"></i></button><br>
|
||||
</span><br style:"height:0px" ng-show="panel.multi_arrange == 'vertical'">
|
||||
</span>
|
||||
</form>
|
||||
<button type="submit" class="btn btn-info" ng-click="send_query(panel.query)"><i class="icon-search"></i> Search</button>
|
||||
<button type="submit" class="btn" ng-click="send_query(panel.query);add_query();"><i class="icon-plus"></i> Add Query</button>
|
||||
</div>
|
||||
</div>
|
||||
</kibana-panel>
|
||||
@@ -1,15 +1,15 @@
|
||||
angular.module('kibana.stringquery', [])
|
||||
.controller('stringquery', function($scope, eventBus) {
|
||||
|
||||
var _id = _.uniqueId();
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
label : "Search",
|
||||
query : "*",
|
||||
size : 100,
|
||||
sort : [config.timefield,'desc'],
|
||||
group : "default"
|
||||
group : "default",
|
||||
multi : false,
|
||||
multi_arrange: 'horizontal',
|
||||
}
|
||||
_.defaults($scope.panel,_d);
|
||||
|
||||
@@ -19,11 +19,25 @@ angular.module('kibana.stringquery', [])
|
||||
$scope.init = function() {
|
||||
eventBus.register($scope,'query',function(event,query) {
|
||||
$scope.panel.query = query;
|
||||
});
|
||||
|
||||
$scope.send_query = function(query) {
|
||||
eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.send_query = function(query) {
|
||||
eventBus.broadcast($scope.$id,$scope.panel.group,'query',query)
|
||||
}
|
||||
|
||||
$scope.add_query = function() {
|
||||
if (_.isArray($scope.panel.query))
|
||||
$scope.panel.query.push("")
|
||||
else {
|
||||
$scope.panel.query = new Array($scope.panel.query)
|
||||
$scope.panel.query.push("")
|
||||
}
|
||||
}
|
||||
|
||||
$scope.remove_query = function(index) {
|
||||
$scope.panel.query.splice(index,1);
|
||||
}
|
||||
|
||||
$scope.init();
|
||||
});
|
||||
Reference in New Issue
Block a user