Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
1c8c7469
Commit
1c8c7469
authored
Aug 09, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code-editor: prometheus metrics autocomplete
parent
aa670244
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
public/app/core/components/code_editor/code_editor.ts
+20
-1
public/app/plugins/datasource/prometheus/partials/query.editor.html
+3
-1
public/app/plugins/datasource/prometheus/query_ctrl.ts
+5
-0
No files found.
public/app/core/components/code_editor/code_editor.ts
View file @
1c8c7469
...
...
@@ -125,6 +125,23 @@ function link(scope, elem, attrs) {
}
});
let
extCompleter
=
{
getCompletions
:
getExtCompletions
};
function
getExtCompletions
(
editor
,
session
,
pos
,
prefix
,
callback
)
{
scope
.
getMetrics
(
prefix
).
then
(
results
=>
{
let
wordList
=
results
;
callback
(
null
,
wordList
.
map
(
word
=>
{
return
{
caption
:
word
,
value
:
word
,
meta
:
"metric"
};
}));
});
}
function
setLangMode
(
lang
)
{
let
aceModeName
=
`ace/mode/
${
lang
}
`
;
fixModuleUrl
(
"mode"
,
lang
);
...
...
@@ -136,6 +153,7 @@ function link(scope, elem, attrs) {
enableLiveAutocompletion
:
true
,
enableSnippets
:
true
});
codeEditor
.
completers
.
push
(
extCompleter
);
});
}
...
...
@@ -157,7 +175,8 @@ export function codeEditorDirective() {
template
:
editorTemplate
,
scope
:
{
content
:
"="
,
onChange
:
"&"
onChange
:
"&"
,
getMetrics
:
"="
},
link
:
link
};
...
...
public/app/plugins/datasource/prometheus/partials/query.editor.html
View file @
1c8c7469
...
...
@@ -7,7 +7,9 @@
<div
class=
"gf-form-inline"
>
<div
class=
"gf-form gf-form--grow"
>
<code-editor
content=
"ctrl.target.expr"
on-change=
"ctrl.refreshMetricData()"
data-mode=
"prometheus"
></code-editor>
<code-editor
content=
"ctrl.target.expr"
on-change=
"ctrl.refreshMetricData()"
get-metrics=
"ctrl.getMetricsAutocomplete"
data-mode=
"prometheus"
>
</code-editor>
</div>
</div>
...
...
public/app/plugins/datasource/prometheus/query_ctrl.ts
View file @
1c8c7469
...
...
@@ -15,6 +15,7 @@ class PrometheusQueryCtrl extends QueryCtrl {
formats
:
any
;
oldTarget
:
any
;
suggestMetrics
:
any
;
getMetricsAutocomplete
:
any
;
linkToPrometheus
:
any
;
/** @ngInject */
...
...
@@ -51,6 +52,10 @@ class PrometheusQueryCtrl extends QueryCtrl {
this
.
datasource
.
performSuggestQuery
(
query
).
then
(
callback
);
};
this
.
getMetricsAutocomplete
=
(
query
)
=>
{
return
this
.
datasource
.
performSuggestQuery
(
query
);
};
this
.
updateLink
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment