Przeglądaj źródła

Small fixes to dasheditor and firefox fixes for search

Torkel Ödegaard 11 lat temu
rodzic
commit
7d6e04ac77

+ 8 - 3
src/app/controllers/search.js

@@ -28,7 +28,7 @@ function (angular, _, config, $) {
 
     $scope.keyDown = function (evt) {
       if (evt.keyCode === 27) {
-        $element.find('.dropdown-toggle').dropdown('toggle');
+        $scope.emitAppEvent('hide-dash-editor');
       }
       if (evt.keyCode === 40) {
         $scope.selectedIndex++;
@@ -134,13 +134,18 @@ function (angular, _, config, $) {
 
   module.directive('xngFocus', function() {
     return function(scope, element, attrs) {
-      $(element).click(function(e) {
+      element.click(function(e) {
         e.stopPropagation();
       });
 
       scope.$watch(attrs.xngFocus,function (newValue) {
+        if (!newValue) {
+          return;
+        }
         setTimeout(function() {
-          newValue && element.focus();
+          element.focus();
+          var pos = element.val().length * 2;
+          element[0].setSelectionRange(pos, pos);
         }, 200);
       },true);
     };

+ 14 - 0
src/app/directives/dashEditLink.js

@@ -31,6 +31,16 @@ function (angular, $) {
           var editorScope;
           var lastEditor;
 
+          function hideScrollbars(value) {
+            if (value) {
+              document.documentElement.style.overflow = 'hidden';  // firefox, chrome
+              document.body.scroll = "no"; // ie only
+            } else {
+              document.documentElement.style.overflow = 'auto';
+              document.body.scroll = "yes";
+            }
+          }
+
           scope.onAppEvent('hide-dash-editor', function() {
             if (editorScope) {
               editorScope.dismiss();
@@ -56,8 +66,12 @@ function (angular, $) {
               elem.empty();
               lastEditor = null;
               editorScope = null;
+              hideScrollbars(false);
             };
 
+            // hide page scrollbars while edit pane is visible
+            hideScrollbars(true);
+
             var src = "'" + payload.src + "'";
             var view = $('<div class="dashboard-edit-view" ng-include="' + src + '"></div>');
             elem.append(view);

+ 2 - 2
src/app/directives/grafanaVersionCheck.js

@@ -11,7 +11,7 @@ function (angular) {
         restrict: 'A',
         link: function(scope, elem) {
           if (grafanaVersion[0] === '@') {
-            return;
+          //  return;
           }
 
           $http({ method: 'GET', url: 'https://grafanarel.s3.amazonaws.com/latest.json' })
@@ -30,4 +30,4 @@ function (angular) {
         }
       };
     });
-});
+});

+ 7 - 7
src/app/partials/dasheditor.html

@@ -5,7 +5,7 @@
 	</div>
 
 	<div ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
-		<div ng-repeat="tab in ['General', 'Rows', 'Controls', 'Import']" data-title="{{tab}}">
+		<div ng-repeat="tab in ['General', 'Rows', 'Features', 'Import']" data-title="{{tab}}">
 		</div>
 		<div ng-repeat="tab in dashboard.nav" data-title="{{tab.type}}">
 		</div>
@@ -42,6 +42,7 @@
 						</bootstrap-tagsinput>
 						<tip>Press enter to a add tag</tip>
 					</div>
+
 				</div>
 			</div>
 		</div>
@@ -91,13 +92,12 @@
 </div>
 
 <div class="dashboard-editor-footer">
-	<div class="pull-left" ng-if="editor.index == 0">
-		<span class="editor-option small" style="line-height: 20px;">
-			Grafana version: {{grafanaVersion}}
+	<div class="grafana-version-info" ng-show="editor.index === 0">
+		<span class="editor-option small">
+			Grafana version: {{grafanaVersion}} &nbsp;&nbsp;
+		</span>
+		<span grafana-version-check>
 		</span>
-		<span> | <a ng-click="toggleConsole()" ng-show="!consoleEnabled">enable console</a> <a ng-click="toggleConsole()" ng-show="consoleEnabled">disable console</a></span>
-		<div class="small" grafana-version-check>
-		</div>
 	</div>
 
 	<button type="button" class="btn btn-success pull-right" ng-click="editor.index=0;dismiss();reset_panel();dashboard.emit_refresh()">Close</button>

+ 9 - 4
src/css/less/grafana.less

@@ -32,10 +32,6 @@
   }
 }
 
-body {
-  overflow-y: hidden;
-}
-
 // Search
 .grafana-search-panel {
   .search-field-wrapper {
@@ -518,6 +514,7 @@ select.grafana-target-segment-input {
 .dashboard-edit-view {
   padding: 20px;
   background-color: @grafanaPanelBackground;
+  position: relative;
 }
 
 .dashboard-editor-body {
@@ -554,3 +551,11 @@ select.grafana-target-segment-input {
   }
 }
 
+.grafana-version-info {
+  position: absolute;
+  bottom: 2px;
+  left: 3px;
+  font-size: 80%;
+  color: darken(@gray, 25%);
+  a { color: darken(@gray, 25%); }
+}