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
f91f74be
Commit
f91f74be
authored
Sep 15, 2016
by
cmartin0077
Committed by
Torkel Ödegaard
Sep 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(influxdb) autocomplete measurement while typing, fixes #4278 (#5931)
parent
3c92f78e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
7 deletions
+27
-7
public/app/core/directives/metric_segment.js
+1
-3
public/app/plugins/datasource/influxdb/partials/query.editor.html
+1
-1
public/app/plugins/datasource/influxdb/query_builder.js
+5
-1
public/app/plugins/datasource/influxdb/query_ctrl.ts
+2
-2
public/app/plugins/datasource/influxdb/specs/query_builder_specs.ts
+18
-0
No files found.
public/app/core/directives/metric_segment.js
View file @
f91f74be
...
...
@@ -76,10 +76,8 @@ function (_, $, coreModule) {
};
$scope
.
source
=
function
(
query
,
callback
)
{
if
(
options
)
{
return
options
;
}
$scope
.
$apply
(
function
()
{
$scope
.
getOptions
().
then
(
function
(
altSegments
)
{
$scope
.
getOptions
(
{
measurementFilter
:
query
}
).
then
(
function
(
altSegments
)
{
$scope
.
altSegments
=
altSegments
;
options
=
_
.
map
(
$scope
.
altSegments
,
function
(
alt
)
{
return
alt
.
value
;
});
...
...
public/app/plugins/datasource/influxdb/partials/query.editor.html
View file @
f91f74be
...
...
@@ -11,7 +11,7 @@
<label
class=
"gf-form-label query-keyword width-7"
>
FROM
</label>
<metric-segment
segment=
"ctrl.policySegment"
get-options=
"ctrl.getPolicySegments()"
on-change=
"ctrl.policyChanged()"
></metric-segment>
<metric-segment
segment=
"ctrl.measurementSegment"
get-options=
"ctrl.getMeasurements()"
on-change=
"ctrl.measurementChanged()"
></metric-segment>
<metric-segment
segment=
"ctrl.measurementSegment"
get-options=
"ctrl.getMeasurements(
measurementFilter
)"
on-change=
"ctrl.measurementChanged()"
></metric-segment>
</div>
<div
class=
"gf-form"
>
...
...
public/app/plugins/datasource/influxdb/query_builder.js
View file @
f91f74be
...
...
@@ -39,7 +39,7 @@ function (_) {
return
this
.
target
.
rawQuery
?
this
.
_modifyRawQuery
()
:
this
.
_buildQuery
();
};
p
.
buildExploreQuery
=
function
(
type
,
withKey
)
{
p
.
buildExploreQuery
=
function
(
type
,
withKey
,
withMeasurementFilter
)
{
var
query
;
var
measurement
;
...
...
@@ -51,6 +51,10 @@ function (_) {
measurement
=
this
.
target
.
measurement
;
}
else
if
(
type
===
'MEASUREMENTS'
)
{
query
=
'SHOW MEASUREMENTS'
;
if
(
withMeasurementFilter
)
{
query
+=
' WITH MEASUREMENT =~ /'
+
withMeasurementFilter
+
'/'
;
}
}
else
if
(
type
===
'FIELDS'
)
{
query
=
'SHOW FIELD KEYS FROM "'
+
this
.
target
.
measurement
+
'"'
;
return
query
;
...
...
public/app/plugins/datasource/influxdb/query_ctrl.ts
View file @
f91f74be
...
...
@@ -191,8 +191,8 @@ export class InfluxQueryCtrl extends QueryCtrl {
this
.
target
.
rawQuery
=
!
this
.
target
.
rawQuery
;
}
getMeasurements
()
{
var
query
=
this
.
queryBuilder
.
buildExploreQuery
(
'MEASUREMENTS'
);
getMeasurements
(
measurementFilter
)
{
var
query
=
this
.
queryBuilder
.
buildExploreQuery
(
'MEASUREMENTS'
,
undefined
,
measurementFilter
);
return
this
.
datasource
.
metricFindQuery
(
query
)
.
then
(
this
.
transformToSegments
(
true
))
.
catch
(
this
.
handleQueryError
.
bind
(
this
));
...
...
public/app/plugins/datasource/influxdb/specs/query_builder_specs.ts
View file @
f91f74be
...
...
@@ -37,6 +37,24 @@ describe('InfluxQueryBuilder', function() {
expect
(
query
).
to
.
be
(
'SHOW MEASUREMENTS'
);
});
it
(
'should have no conditions in measurement query for query with no tags and empty query'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[]
});
var
query
=
builder
.
buildExploreQuery
(
'MEASUREMENTS'
,
undefined
,
''
);
expect
(
query
).
to
.
be
(
'SHOW MEASUREMENTS'
);
});
it
(
'should have WITH MEASUREMENT in measurement query for non-empty query with no tags'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[]
});
var
query
=
builder
.
buildExploreQuery
(
'MEASUREMENTS'
,
undefined
,
'something'
);
expect
(
query
).
to
.
be
(
'SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/'
);
});
it
(
'should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[{
key
:
'app'
,
value
:
'email'
}]
});
var
query
=
builder
.
buildExploreQuery
(
'MEASUREMENTS'
,
undefined
,
'something'
);
expect
(
query
).
to
.
be
(
"SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE
\"
app
\"
= 'email'"
);
});
it
(
'should have where condition in measurement query for query with tags'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[{
key
:
'app'
,
value
:
'email'
}]});
var
query
=
builder
.
buildExploreQuery
(
'MEASUREMENTS'
);
...
...
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