Commit 5d002e72 by Torkel Ödegaard

refactoring target controller

parent 1e7ced2a
......@@ -10,7 +10,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
var module = angular.module('kibana.controllers');
module.controller('GraphiteTargetCtrl', function($scope, $http) {
module.controller('GraphiteTargetCtrl', function($scope, $http, filterSrv, graphiteSrv) {
$scope.init = function() {
$scope.funcCategories = graphiteFuncs.getCategories();
......@@ -98,7 +98,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
}
}
function getSegmentPathUpTo(index) {
function getSegmentPathUpTo(index, interpolateTemplate) {
var arr = $scope.segments.slice(0, index);
return _.reduce(arr, function(result, segment) {
......@@ -106,26 +106,21 @@ function (angular, _, config, graphiteFuncs, Parser) {
}, "");
}
function graphiteMetricQuery(query) {
var url = config.graphiteUrl + '/metrics/find/?query=' + query;
return $http.get(url);
}
function checkOtherSegments(fromIndex) {
if (fromIndex === 0) {
$scope.segments.push({html: 'select metric'});
return;
}
var path = getSegmentPathUpTo(fromIndex + 1);
return graphiteMetricQuery(path)
.then(function(result) {
if (result.data.length === 0) {
var path = getSegmentPathUpTo(fromIndex + 1, true);
return graphiteSrv.metricFindQuery(path)
.then(function(segments) {
if (segments.length === 0) {
$scope.segments = $scope.segments.splice(0, fromIndex);
$scope.segments.push({html: 'select metric'});
return;
}
if (result.data[0].expandable) {
if (segments[0].expandable) {
if ($scope.segments.length === fromIndex) {
$scope.segments.push({html: 'select metric'});
}
......@@ -161,7 +156,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
var query = index === 0 ?
'*' : getSegmentPathUpTo(index) + '.*';
return graphiteMetricQuery(query)
return graphiteSrv.metricFindQuery(query)
.then(function(result) {
var altSegments = _.map(result.data, function(altSegment) {
return {
......
......@@ -45,12 +45,9 @@
.top-row-close {
border-right: 1px solid #202020;
}
.top-row-open {
float: left;
padding: 0px;
}
.top-row-open {
background: none;
}
......@@ -162,7 +159,7 @@
}
.tab-content {
overflow: visible;
padding: 10px;
padding: 15px;
}
.nav-tabs > li > a {
......
......@@ -33,7 +33,6 @@
.bgWarning {
background: @btnWarningBackground;
color: rgba(255,255,255,.90);
}
.bgDanger {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment