refactoring target controller

pull/7/head
Torkel Ödegaard 12 years ago
parent 1e7ced2ac6
commit 5d002e7208
  1. 21
      src/app/controllers/graphiteTarget.js
  2. 5
      src/vendor/bootstrap/less/grafana.less
  3. 1
      src/vendor/bootstrap/less/overrides.less

@ -10,7 +10,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
var module = angular.module('kibana.controllers'); var module = angular.module('kibana.controllers');
module.controller('GraphiteTargetCtrl', function($scope, $http) { module.controller('GraphiteTargetCtrl', function($scope, $http, filterSrv, graphiteSrv) {
$scope.init = function() { $scope.init = function() {
$scope.funcCategories = graphiteFuncs.getCategories(); $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); var arr = $scope.segments.slice(0, index);
return _.reduce(arr, function(result, segment) { 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) { function checkOtherSegments(fromIndex) {
if (fromIndex === 0) { if (fromIndex === 0) {
$scope.segments.push({html: 'select metric'}); $scope.segments.push({html: 'select metric'});
return; return;
} }
var path = getSegmentPathUpTo(fromIndex + 1); var path = getSegmentPathUpTo(fromIndex + 1, true);
return graphiteMetricQuery(path) return graphiteSrv.metricFindQuery(path)
.then(function(result) { .then(function(segments) {
if (result.data.length === 0) { if (segments.length === 0) {
$scope.segments = $scope.segments.splice(0, fromIndex); $scope.segments = $scope.segments.splice(0, fromIndex);
$scope.segments.push({html: 'select metric'}); $scope.segments.push({html: 'select metric'});
return; return;
} }
if (result.data[0].expandable) { if (segments[0].expandable) {
if ($scope.segments.length === fromIndex) { if ($scope.segments.length === fromIndex) {
$scope.segments.push({html: 'select metric'}); $scope.segments.push({html: 'select metric'});
} }
@ -161,7 +156,7 @@ function (angular, _, config, graphiteFuncs, Parser) {
var query = index === 0 ? var query = index === 0 ?
'*' : getSegmentPathUpTo(index) + '.*'; '*' : getSegmentPathUpTo(index) + '.*';
return graphiteMetricQuery(query) return graphiteSrv.metricFindQuery(query)
.then(function(result) { .then(function(result) {
var altSegments = _.map(result.data, function(altSegment) { var altSegments = _.map(result.data, function(altSegment) {
return { return {

@ -45,12 +45,9 @@
.top-row-close { .top-row-close {
border-right: 1px solid #202020; border-right: 1px solid #202020;
} }
.top-row-open { .top-row-open {
float: left; float: left;
padding: 0px; padding: 0px;
}
.top-row-open {
background: none; background: none;
} }
@ -162,7 +159,7 @@
} }
.tab-content { .tab-content {
overflow: visible; overflow: visible;
padding: 10px; padding: 15px;
} }
.nav-tabs > li > a { .nav-tabs > li > a {

@ -33,7 +33,6 @@
.bgWarning { .bgWarning {
background: @btnWarningBackground; background: @btnWarningBackground;
color: rgba(255,255,255,.90); color: rgba(255,255,255,.90);
} }
.bgDanger { .bgDanger {

Loading…
Cancel
Save