소스 검색

prometheus: minor update to focus editor PR, #9201

Torkel Ödegaard 8 년 전
부모
커밋
2953d64429

+ 4 - 3
public/app/core/components/code_editor/code_editor.ts

@@ -110,7 +110,8 @@ function link(scope, elem, attrs) {
   elem.addClass("gf-code-editor");
   elem.addClass("gf-code-editor");
   let textarea = elem.find("textarea");
   let textarea = elem.find("textarea");
   textarea.addClass('gf-form-input');
   textarea.addClass('gf-form-input');
-  if (scope.focus) {
+
+  if (scope.codeEditorFocus) {
     setTimeout(function () {
     setTimeout(function () {
       textarea.focus();
       textarea.focus();
       var domEl = textarea[0];
       var domEl = textarea[0];
@@ -118,7 +119,7 @@ function link(scope, elem, attrs) {
         var pos = textarea.val().length * 2;
         var pos = textarea.val().length * 2;
         domEl.setSelectionRange(pos, pos);
         domEl.setSelectionRange(pos, pos);
       }
       }
-    }, 200);
+    }, 100);
   }
   }
 
 
   // Event handlers
   // Event handlers
@@ -209,7 +210,7 @@ export function codeEditorDirective() {
     template: editorTemplate,
     template: editorTemplate,
     scope: {
     scope: {
       content: "=",
       content: "=",
-      focus: "=",
+      codeEditorFocus: "<",
       onChange: "&",
       onChange: "&",
       getCompleter: "&"
       getCompleter: "&"
     },
     },

+ 2 - 0
public/app/features/panel/query_ctrl.ts

@@ -10,9 +10,11 @@ export class QueryCtrl {
   panel: any;
   panel: any;
   hasRawMode: boolean;
   hasRawMode: boolean;
   error: string;
   error: string;
+  isLastQuery: boolean;
 
 
   constructor(public $scope, private $injector) {
   constructor(public $scope, private $injector) {
     this.panel = this.panelCtrl.panel;
     this.panel = this.panelCtrl.panel;
+    this.isLastQuery = _.indexOf(this.panel.targets, this.target) === (this.panel.targets.length - 1);
   }
   }
 
 
   refresh() {
   refresh() {

+ 1 - 1
public/app/plugins/datasource/prometheus/partials/query.editor.html

@@ -2,7 +2,7 @@
 	<div class="gf-form-inline">
 	<div class="gf-form-inline">
 		<div class="gf-form gf-form--grow">
 		<div class="gf-form gf-form--grow">
 			<code-editor content="ctrl.target.expr" on-change="ctrl.refreshMetricData()"
 			<code-editor content="ctrl.target.expr" on-change="ctrl.refreshMetricData()"
-				get-completer="ctrl.getCompleter()" data-mode="prometheus" focus="ctrl.target.refId == 'A'">
+				get-completer="ctrl.getCompleter()" data-mode="prometheus" code-editor-focus="ctrl.isLastQuery">
 			</code-editor>
 			</code-editor>
 		</div>
 		</div>
 	</div>
 	</div>

+ 4 - 0
public/sass/components/_code_editor.scss

@@ -77,3 +77,7 @@ $doc-font-size: $font-size-sm;
 .ace_tooltip {
 .ace_tooltip {
   border-radius: 3px;
   border-radius: 3px;
 }
 }
+
+.ace_hidden-cursors .ace_cursor {
+  opacity: 0 !important;
+}