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
149e694c
Commit
149e694c
authored
Aug 10, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ace: prometheus completion improvements
parent
0b2cc404
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
public/app/core/components/code_editor/code_editor.ts
+2
-16
public/app/plugins/datasource/prometheus/completer.ts
+19
-1
No files found.
public/app/core/components/code_editor/code_editor.ts
View file @
149e694c
...
...
@@ -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
)
{
...
...
public/app/plugins/datasource/prometheus/completer.ts
View file @
149e694c
...
...
@@ -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
:
nam
e
,
value
:
valu
e
,
meta
:
'metric'
,
};
}));
...
...
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