Commit 2953d644 by Torkel Ödegaard

prometheus: minor update to focus editor PR, #9201

parent 4b851de6
...@@ -110,7 +110,8 @@ function link(scope, elem, attrs) { ...@@ -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) { ...@@ -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() { ...@@ -209,7 +210,7 @@ export function codeEditorDirective() {
template: editorTemplate, template: editorTemplate,
scope: { scope: {
content: "=", content: "=",
focus: "=", codeEditorFocus: "<",
onChange: "&", onChange: "&",
getCompleter: "&" getCompleter: "&"
}, },
......
...@@ -10,9 +10,11 @@ export class QueryCtrl { ...@@ -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() {
......
...@@ -2,7 +2,7 @@ ...@@ -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>
......
...@@ -77,3 +77,7 @@ $doc-font-size: $font-size-sm; ...@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment