|
@@ -14,18 +14,38 @@ function (angular, _, config, $) {
|
|
|
$scope.init = function() {
|
|
$scope.init = function() {
|
|
|
$scope.elasticsearch = $scope.elasticsearch || {};
|
|
$scope.elasticsearch = $scope.elasticsearch || {};
|
|
|
$scope.giveSearchFocus = 0;
|
|
$scope.giveSearchFocus = 0;
|
|
|
- $scope.search_results = {
|
|
|
|
|
- dashboards: [],
|
|
|
|
|
- metrics: [],
|
|
|
|
|
- graphs: []
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ $scope.selectedIndex = null;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ $scope.keyDown = function (evt) {
|
|
|
|
|
+ if (evt.keyCode === 40) {
|
|
|
|
|
+ $scope.selectedIndex = ($scope.selectedIndex || 0) + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ $scope.elasticsearch_dashboards = function(queryStr) {
|
|
|
|
|
+ dashboard.elasticsearch_list(queryStr + '*', 50).then(function(results) {
|
|
|
|
|
+ if(_.isUndefined(results.hits)) {
|
|
|
|
|
+ $scope.search_results = { dashboards: [] };
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $scope.search_results = { dashboards: results.hits.hits };
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
$scope.elasticsearch_dblist = function(queryStr) {
|
|
$scope.elasticsearch_dblist = function(queryStr) {
|
|
|
- var words = queryStr.split(" ");
|
|
|
|
|
|
|
+ queryStr = queryStr.toLowerCase();
|
|
|
|
|
+
|
|
|
|
|
+ if (queryStr.indexOf('d:') === 0) {
|
|
|
|
|
+ $scope.elasticsearch_dashboards(queryStr.substring(2, queryStr.length));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var words = queryStr.split(' ');
|
|
|
var query = $scope.ejs.BoolQuery();
|
|
var query = $scope.ejs.BoolQuery();
|
|
|
var terms = _.map(words, function(word) {
|
|
var terms = _.map(words, function(word) {
|
|
|
- return $scope.ejs.MatchQuery("metricPath_ng", word).boost(1.2);
|
|
|
|
|
|
|
+ return $scope.ejs.MatchQuery('metricPath_ng', word).boost(1.2);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
var ngramQuery = $scope.ejs.BoolQuery();
|
|
var ngramQuery = $scope.ejs.BoolQuery();
|
|
@@ -39,11 +59,10 @@ function (angular, _, config, $) {
|
|
|
|
|
|
|
|
results.then(function(results) {
|
|
results.then(function(results) {
|
|
|
if (results && results.hits && results.hits.hits.length > 0) {
|
|
if (results && results.hits && results.hits.hits.length > 0) {
|
|
|
- $scope.search_results.metrics = results.hits.hits;
|
|
|
|
|
- console.log("hits", $scope.search_results.metrics);
|
|
|
|
|
|
|
+ $scope.search_results = { metrics: results.hits.hits };
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- $scope.search_results.metrics = [];
|
|
|
|
|
|
|
+ $scope.search_results = { metric: [] };
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
@@ -52,8 +71,26 @@ function (angular, _, config, $) {
|
|
|
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ $scope.addMetricToCurrentDashboard = function (metricId) {
|
|
|
|
|
+ dashboard.current.rows.push({
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ height: '250px',
|
|
|
|
|
+ editable: true,
|
|
|
|
|
+ panels: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'graphite',
|
|
|
|
|
+ title: 'test',
|
|
|
|
|
+ span: 12,
|
|
|
|
|
+ targets: [ { target: metricId } ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
module.directive('xngFocus', function() {
|
|
module.directive('xngFocus', function() {
|
|
|
return function(scope, element, attrs) {
|
|
return function(scope, element, attrs) {
|
|
|
$(element).click(function(e) {
|
|
$(element).click(function(e) {
|