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
72d9fcdc
Commit
72d9fcdc
authored
Nov 27, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(influxdb): progress with new influxdb editor
parent
aa13a80d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
11 deletions
+58
-11
public/app/plugins/datasource/influxdb/influx_query.ts
+12
-4
public/app/plugins/datasource/influxdb/query_ctrl.js
+1
-1
public/app/plugins/datasource/influxdb/query_part.ts
+17
-2
public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts
+28
-4
No files found.
public/app/plugins/datasource/influxdb/influx_query.ts
View file @
72d9fcdc
...
@@ -16,7 +16,10 @@ class InfluxQuery {
...
@@ -16,7 +16,10 @@ class InfluxQuery {
this
.
target
=
target
;
this
.
target
=
target
;
target
.
tags
=
target
.
tags
||
[];
target
.
tags
=
target
.
tags
||
[];
target
.
groupBy
=
target
.
groupBy
||
[{
type
:
'time'
,
params
:
[
'$interval'
]}];
target
.
groupBy
=
target
.
groupBy
||
[
{
type
:
'time'
,
params
:
[
'$interval'
]},
{
type
:
'fill'
,
params
:
[
'null'
]},
];
target
.
select
=
target
.
select
||
[[
target
.
select
=
target
.
select
||
[[
{
type
:
'field'
,
params
:
[
'value'
]},
{
type
:
'field'
,
params
:
[
'value'
]},
{
type
:
'mean'
,
params
:
[]},
{
type
:
'mean'
,
params
:
[]},
...
@@ -160,13 +163,18 @@ class InfluxQuery {
...
@@ -160,13 +163,18 @@ class InfluxQuery {
query
+=
conditions
.
join
(
' '
);
query
+=
conditions
.
join
(
' '
);
query
+=
(
conditions
.
length
>
0
?
' AND '
:
''
)
+
'$timeFilter'
;
query
+=
(
conditions
.
length
>
0
?
' AND '
:
''
)
+
'$timeFilter'
;
query
+=
' GROUP BY '
;
var
groupBySection
=
""
;
for
(
i
=
0
;
i
<
this
.
groupByParts
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
this
.
groupByParts
.
length
;
i
++
)
{
var
part
=
this
.
groupByParts
[
i
];
var
part
=
this
.
groupByParts
[
i
];
if
(
i
>
0
)
{
if
(
i
>
0
)
{
query
+=
', '
;
// for some reason fill has no seperator
groupBySection
+=
part
.
def
.
type
===
'fill'
?
' '
:
', '
;
}
groupBySection
+=
part
.
render
(
''
);
}
}
query
+=
part
.
render
(
''
);
if
(
groupBySection
.
length
)
{
query
+=
' GROUP BY '
+
groupBySection
;
}
}
if
(
target
.
fill
)
{
if
(
target
.
fill
)
{
...
...
public/app/plugins/datasource/influxdb/query_ctrl.js
View file @
72d9fcdc
...
@@ -70,7 +70,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
...
@@ -70,7 +70,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
.
then
(
function
(
tags
)
{
.
then
(
function
(
tags
)
{
var
options
=
[];
var
options
=
[];
if
(
!
$scope
.
queryModel
.
hasFill
())
{
if
(
!
$scope
.
queryModel
.
hasFill
())
{
options
.
push
(
uiSegmentSrv
.
newSegment
({
value
:
'fill(
option
)'
}));
options
.
push
(
uiSegmentSrv
.
newSegment
({
value
:
'fill(
null
)'
}));
}
}
if
(
!
$scope
.
queryModel
.
hasGroupByTime
())
{
if
(
!
$scope
.
queryModel
.
hasGroupByTime
())
{
options
.
push
(
uiSegmentSrv
.
newSegment
({
value
:
'time($interval)'
}));
options
.
push
(
uiSegmentSrv
.
newSegment
({
value
:
'time($interval)'
}));
...
...
public/app/plugins/datasource/influxdb/query_part.ts
View file @
72d9fcdc
...
@@ -71,6 +71,13 @@ function quotedIdentityRenderer(part, innerExpr) {
...
@@ -71,6 +71,13 @@ function quotedIdentityRenderer(part, innerExpr) {
return
'"'
+
part
.
params
[
0
]
+
'"'
;
return
'"'
+
part
.
params
[
0
]
+
'"'
;
}
}
function
fieldRenderer
(
part
,
innerExpr
)
{
if
(
part
.
params
[
0
]
===
'*'
)
{
return
'*'
;
}
return
'"'
+
part
.
params
[
0
]
+
'"'
;
}
function
replaceAggregationAddStrategy
(
selectParts
,
partModel
)
{
function
replaceAggregationAddStrategy
(
selectParts
,
partModel
)
{
// look for existing aggregation
// look for existing aggregation
for
(
var
i
=
0
;
i
<
selectParts
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
selectParts
.
length
;
i
++
)
{
...
@@ -146,7 +153,7 @@ QueryPartDef.register({
...
@@ -146,7 +153,7 @@ QueryPartDef.register({
category
:
categories
.
Fields
,
category
:
categories
.
Fields
,
params
:
[{
type
:
'field'
}],
params
:
[{
type
:
'field'
}],
defaultParams
:
[
'value'
],
defaultParams
:
[
'value'
],
renderer
:
quotedIdentity
Renderer
,
renderer
:
field
Renderer
,
});
});
QueryPartDef
.
register
({
QueryPartDef
.
register
({
...
@@ -185,11 +192,19 @@ QueryPartDef.register({
...
@@ -185,11 +192,19 @@ QueryPartDef.register({
});
});
QueryPartDef
.
register
({
QueryPartDef
.
register
({
type
:
'fill'
,
category
:
groupByTimeFunctions
,
params
:
[{
name
:
"fill"
,
type
:
"string"
,
options
:
[
'none'
,
'null'
,
'0'
,
'previous'
]
}],
defaultParams
:
[
'null'
],
renderer
:
functionRenderer
,
});
QueryPartDef
.
register
({
type
:
'tag'
,
type
:
'tag'
,
category
:
groupByTimeFunctions
,
category
:
groupByTimeFunctions
,
params
:
[{
name
:
'tag'
,
type
:
'string'
}],
params
:
[{
name
:
'tag'
,
type
:
'string'
}],
defaultParams
:
[
'tag'
],
defaultParams
:
[
'tag'
],
renderer
:
quotedIdentity
Renderer
,
renderer
:
field
Renderer
,
});
});
QueryPartDef
.
register
({
QueryPartDef
.
register
({
...
...
public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts
View file @
72d9fcdc
...
@@ -4,18 +4,18 @@ import InfluxQuery = require('../influx_query');
...
@@ -4,18 +4,18 @@ import InfluxQuery = require('../influx_query');
describe
.
only
(
'InfluxQuery'
,
function
()
{
describe
.
only
(
'InfluxQuery'
,
function
()
{
describe
(
'series with mesurement only'
,
function
()
{
describe
(
'
render
series with mesurement only'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
var
query
=
new
InfluxQuery
({
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
measurement
:
'cpu'
,
});
});
var
queryText
=
query
.
render
();
var
queryText
=
query
.
render
();
expect
(
queryText
).
to
.
be
(
'SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($interval)'
);
expect
(
queryText
).
to
.
be
(
'SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($interval)
fill(null)
'
);
});
});
});
});
describe
(
'series with math and alias'
,
function
()
{
describe
(
'
render
series with math and alias'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
var
query
=
new
InfluxQuery
({
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
measurement
:
'cpu'
,
...
@@ -30,7 +30,31 @@ describe.only('InfluxQuery', function() {
...
@@ -30,7 +30,31 @@ describe.only('InfluxQuery', function() {
});
});
var
queryText
=
query
.
render
();
var
queryText
=
query
.
render
();
expect
(
queryText
).
to
.
be
(
'SELECT mean("value") /100 AS "text" FROM "cpu" WHERE $timeFilter GROUP BY time($interval)'
);
expect
(
queryText
).
to
.
be
(
'SELECT mean("value") /100 AS "text" FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(null)'
);
});
});
describe
(
'render series without group by'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
select
:
[[{
type
:
'field'
,
params
:
[
'value'
]}]],
groupBy
:
[],
});
var
queryText
=
query
.
render
();
expect
(
queryText
).
to
.
be
(
'SELECT "value" FROM "cpu" WHERE $timeFilter'
);
});
});
describe
(
'render series without group by and fill'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
select
:
[[{
type
:
'field'
,
params
:
[
'value'
]}]],
groupBy
:
[{
type
:
'time'
},
{
type
:
'fill'
,
params
:
[
'0'
]}],
});
var
queryText
=
query
.
render
();
expect
(
queryText
).
to
.
be
(
'SELECT "value" FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(0)'
);
});
});
});
});
...
...
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