From 5d002e72084821ffb6accd5960831cceeca4422b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 2 Jan 2014 10:38:04 +0100 Subject: [PATCH] refactoring target controller --- src/app/controllers/graphiteTarget.js | 21 ++++++++------------- src/vendor/bootstrap/less/grafana.less | 5 +---- src/vendor/bootstrap/less/overrides.less | 1 - 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js index 5c68c5d510d..db6823392ea 100644 --- a/src/app/controllers/graphiteTarget.js +++ b/src/app/controllers/graphiteTarget.js @@ -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 { diff --git a/src/vendor/bootstrap/less/grafana.less b/src/vendor/bootstrap/less/grafana.less index 4727b60519b..d05b4ef8027 100644 --- a/src/vendor/bootstrap/less/grafana.less +++ b/src/vendor/bootstrap/less/grafana.less @@ -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 { diff --git a/src/vendor/bootstrap/less/overrides.less b/src/vendor/bootstrap/less/overrides.less index 7877ab6e96f..22db8e50ee1 100644 --- a/src/vendor/bootstrap/less/overrides.less +++ b/src/vendor/bootstrap/less/overrides.less @@ -33,7 +33,6 @@ .bgWarning { background: @btnWarningBackground; color: rgba(255,255,255,.90); - } .bgDanger {