prometheus: minor update to focus editor PR, #9201

This commit is contained in:
Torkel Ödegaard 2017-09-08 11:43:29 +02:00
parent 4b851de648
commit 2953d64429
4 changed files with 11 additions and 4 deletions

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<div class="gf-form-inline">
<div class="gf-form gf-form--grow">
<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>
</div>
</div>

View File

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