Bläddra i källkod

More work on refactoring and changing graph axis edit view, #1331

Torkel Ödegaard 11 år sedan
förälder
incheckning
c39f9ed2f3

+ 1 - 1
src/app/directives/dropdown.typeahead.js

@@ -37,7 +37,7 @@ function (angular, app, _, $) {
 
 
           if (attrs.ngModel) {
           if (attrs.ngModel) {
             $scope.$watch('model', function(newValue) {
             $scope.$watch('model', function(newValue) {
-              _.each($scope.menuItems, function(item){
+              _.each($scope.menuItems, function(item) {
                 _.each(item.submenu, function(subItem) {
                 _.each(item.submenu, function(subItem) {
                   if (subItem.value === newValue) {
                   if (subItem.value === newValue) {
                     $button.html(subItem.text);
                     $button.html(subItem.text);

+ 12 - 0
src/app/directives/ngModelOnBlur.js

@@ -22,5 +22,17 @@ function (angular) {
           });
           });
         }
         }
       };
       };
+    })
+    .directive('emptyToNull', function () {
+      return {
+        restrict: 'A',
+        require: 'ngModel',
+        link: function (scope, elm, attrs, ctrl) {
+          ctrl.$parsers.push(function (viewValue) {
+            if(viewValue === "") { return null; }
+            return viewValue;
+          });
+        }
+      };
     });
     });
 });
 });

+ 16 - 6
src/app/panels/graph/axisEditor.html

@@ -19,19 +19,24 @@
 						   Grid Max
 						   Grid Max
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					   	empty-to-null ng-model="panel.grid.leftMax"
+							ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Min
 						Min
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					  	empty-to-null ng-model="panel.grid.leftMin"
+							ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Label
 						Label
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" value="">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					  	ng-model="panel.leftYAxisLabel" ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Show
 						Show
@@ -56,19 +61,24 @@
 						&nbsp;&nbsp; Grid Max
 						&nbsp;&nbsp; Grid Max
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					   	empty-to-null ng-model="panel.grid.rightMax"
+							ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Min
 						Min
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					  	empty-to-null ng-model="panel.grid.rightMin"
+							ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Label
 						Label
 					</li>
 					</li>
 					<li>
 					<li>
-						<input type="text" class="input-small grafana-target-segment-input" value="">
+						<input type="text" class="input-small grafana-target-segment-input" placeholder="auto"
+					  	ng-model="panel.rightYAxisLabel" ng-change="render()" ng-model-onblur>
 					</li>
 					</li>
 					<li class="grafana-target-segment">
 					<li class="grafana-target-segment">
 						Show
 						Show

+ 0 - 5
src/app/panels/graph/module.js

@@ -268,11 +268,6 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
       $scope.render();
       $scope.render();
     };
     };
 
 
-    $scope.toggleGridMinMax = function(key) {
-      $scope.panel.grid[key] = _.toggle($scope.panel.grid[key], null, 0);
-      $scope.render();
-    };
-
     $scope.addSeriesOverride = function(override) {
     $scope.addSeriesOverride = function(override) {
       $scope.panel.seriesOverrides.push(override || {});
       $scope.panel.seriesOverrides.push(override || {});
     };
     };

+ 1 - 7
src/test/specs/seriesOverridesCtrl-specs.js

@@ -16,15 +16,9 @@ define([
       ctx.scope.render = function() {};
       ctx.scope.render = function() {};
     });
     });
 
 
-    describe('Controller should init overrideMenu', function() {
-      it('click should include option and value index', function() {
-        expect(ctx.scope.overrideMenu[1].submenu[1].click).to.be('menuItemSelected(1,1)');
-      });
-    });
-
     describe('When setting an override', function() {
     describe('When setting an override', function() {
       beforeEach(function() {
       beforeEach(function() {
-        ctx.scope.setOverride(1, 0);
+        ctx.scope.setOverride({propertyName: 'lines'}, {value: true});
       });
       });
 
 
       it('should set override property', function() {
       it('should set override property', function() {