mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Added type-to-filter to dashboard loading pulldown
This commit is contained in:
parent
30398ad52d
commit
6acd29f7d4
3 changed files with 57 additions and 26 deletions
|
@ -42,7 +42,7 @@ define(function (require) {
|
|||
gridster = elem.gridster({
|
||||
autogenerate_stylesheet: false,
|
||||
widget_margins: [5, 5],
|
||||
widget_base_dimensions: [((width - 80) / 12), 100],
|
||||
widget_base_dimensions: [((width - 100) / 12), 100],
|
||||
min_cols: 12,
|
||||
max_cols: 12,
|
||||
resize: {
|
||||
|
|
|
@ -17,12 +17,58 @@ define(function (require) {
|
|||
|
||||
app.controller('dashboard', function ($scope, courier) {
|
||||
|
||||
$scope.$broadcast('application.load');
|
||||
$scope.dashboard = {
|
||||
title: 'New Dashboard',
|
||||
panels: []
|
||||
};
|
||||
|
||||
// Passed in the grid attr to the directive so we can access the directive's function from
|
||||
// the controller and view
|
||||
$scope.gridControl = {};
|
||||
|
||||
$scope.input = {
|
||||
search: ''
|
||||
};
|
||||
|
||||
$scope.$watch('configurable.input.search', function (newVal) {
|
||||
dashboardSearch(newVal);
|
||||
});
|
||||
|
||||
var init = function () {
|
||||
$scope.configurable = {
|
||||
dashboard: $scope.dashboard,
|
||||
load: $scope.load,
|
||||
input: {
|
||||
search: $scope.input.search
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var dashboardSearch = function (query) {
|
||||
var search;
|
||||
|
||||
if (_.isString(query) && query.length > 0) {
|
||||
|
||||
query = {match: {title: {query: query, type: 'phrase_prefix'}}};
|
||||
} else {
|
||||
query = {match_all: {}};
|
||||
}
|
||||
|
||||
search = courier.createSource('search')
|
||||
.index(configFile.kibanaIndex)
|
||||
.type('dashboard')
|
||||
.size(20)
|
||||
.query(query)
|
||||
.$scope($scope)
|
||||
.inherits(courier.rootSearchSource)
|
||||
.on('results', function (res) {
|
||||
$scope.configurable.searchResults = res.hits.hits;
|
||||
});
|
||||
|
||||
search.fetch();
|
||||
|
||||
};
|
||||
|
||||
var setConfigTemplate = function (template) {
|
||||
// Close if already open
|
||||
if ($scope.configTemplate === template) {
|
||||
|
@ -44,19 +90,7 @@ define(function (require) {
|
|||
$scope.openLoad = function () {
|
||||
setConfigTemplate(require('text!./partials/load_dashboard.html'));
|
||||
|
||||
var search = courier.createSource('search')
|
||||
.index(configFile.kibanaIndex)
|
||||
.type('dashboard')
|
||||
.size(20)
|
||||
.$scope($scope)
|
||||
.inherits(courier.rootSearchSource)
|
||||
.on('results', function (res) {
|
||||
console.log(res.hits);
|
||||
$scope.configurable.searchResults = res.hits.hits;
|
||||
});
|
||||
|
||||
// TODO: Find out why results is fired twice
|
||||
search.fetch();
|
||||
if ($scope.configTemplate) dashboardSearch($scope.configurable.input.search);
|
||||
};
|
||||
|
||||
$scope.save = function (title) {
|
||||
|
@ -78,15 +112,8 @@ define(function (require) {
|
|||
$scope.gridControl.unserializeGrid($scope.dashboard.panels);
|
||||
};
|
||||
|
||||
$scope.dashboard = {
|
||||
title: 'New Dashboard',
|
||||
panels: []
|
||||
};
|
||||
|
||||
$scope.configurable = {
|
||||
dashboard: $scope.dashboard,
|
||||
load: $scope.load
|
||||
};
|
||||
init();
|
||||
$scope.$broadcast('application.load');
|
||||
|
||||
});
|
||||
});
|
|
@ -1,5 +1,9 @@
|
|||
<div class="container-fluid">
|
||||
<label>Filter Dashboards</label>
|
||||
<input type="text" ng-model="configurable.input.search" class="form-control"/>
|
||||
</div>
|
||||
<ul class="nav nav-pills">
|
||||
<li ng-repeat="res in configObject.searchResults | orderBy:'_source.title'" ng-class="{active: configObject.dashboard.title == res._source.title}">
|
||||
<a ng-click="configObject.load(res._source)">{{res._source.title}}</a>
|
||||
<li ng-repeat="res in configurable.searchResults | orderBy:'_source.title'" ng-class="{active: configurable.dashboard.title == res._source.title}">
|
||||
<a ng-click="configurable.load(res._source)">{{res._source.title}}</a>
|
||||
</li>
|
||||
</ul>
|
Loading…
Add table
Add a link
Reference in a new issue