Commit 149e694c by Torkel Ödegaard

ace: prometheus completion improvements

parent 0b2cc404
......@@ -128,22 +128,6 @@ function link(scope, elem, attrs) {
}
});
let extCompleter = {
identifierRegexps: [/[\[\]a-zA-Z_0-9=]/],
getCompletions: function (editor, session, pos, prefix, callback) {
console.log(pos);
scope.getCompletions({$query: prefix}).then(results => {
callback(null, results.map(hit => {
return {
caption: hit.word,
value: hit.word,
meta: hit.type
};
}));
});
},
};
function setLangMode(lang) {
let aceModeName = `ace/mode/${lang}`;
setModuleUrl("mode", lang);
......@@ -161,6 +145,8 @@ function link(scope, elem, attrs) {
codeEditor.completers.push(scope.getCompleter());
}
});
codeEditor.setBehavioursEnabled(true);
}
function setThemeMode(theme) {
......
......@@ -9,12 +9,30 @@ export class PromCompleter {
}
getCompletions(editor, session, pos, prefix, callback) {
if (prefix === '[') {
var vectors = [];
for (let unit of ['s', 'm', 'h']) {
for (let value of [1,5,10,30]) {
vectors.push({caption: value+unit, value: '['+value+unit, meta: 'range vector'});
}
}
callback(null, vectors);
return;
}
var query = prefix;
var line = editor.session.getLine(pos.row);
return this.datasource.performSuggestQuery(query).then(metricNames => {
callback(null, metricNames.map(name => {
let value = name;
if (prefix === '(') {
value = '(' + name;
}
return {
caption: name,
value: name,
value: value,
meta: 'metric',
};
}));
......
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