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
b3d494d4
Commit
b3d494d4
authored
Nov 30, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(influxdb): minor fixes to new editor
parent
72d9fcdc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
5 deletions
+47
-5
public/app/plugins/datasource/influxdb/influx_query.ts
+18
-4
public/app/plugins/datasource/influxdb/query_part.ts
+1
-1
public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts
+28
-0
No files found.
public/app/plugins/datasource/influxdb/influx_query.ts
View file @
b3d494d4
...
@@ -44,20 +44,34 @@ class InfluxQuery {
...
@@ -44,20 +44,34 @@ class InfluxQuery {
}
}
hasGroupByTime
()
{
hasGroupByTime
()
{
return
false
;
return
_
.
find
(
this
.
target
.
groupBy
,
(
g
:
any
)
=>
g
.
type
===
'time'
)
;
}
}
hasFill
()
{
hasFill
()
{
return
false
;
return
_
.
find
(
this
.
target
.
groupBy
,
(
g
:
any
)
=>
g
.
type
===
'fill'
)
;
}
}
addGroupBy
(
value
)
{
addGroupBy
(
value
)
{
var
stringParts
=
value
.
match
(
/^
(\w
+
)\((
.*
)\)
$/
);
var
stringParts
=
value
.
match
(
/^
(\w
+
)\((
.*
)\)
$/
);
var
typePart
=
stringParts
[
1
];
var
typePart
=
stringParts
[
1
];
var
arg
=
stringParts
[
2
];
var
arg
=
stringParts
[
2
];
console
.
log
(
value
,
stringParts
);
var
partModel
=
queryPart
.
create
({
type
:
typePart
,
params
:
[
arg
]});
var
partModel
=
queryPart
.
create
({
type
:
typePart
,
params
:
[
arg
]});
this
.
target
.
groupBy
.
push
(
partModel
.
part
);
var
partCount
=
this
.
target
.
groupBy
.
length
;
if
(
partCount
===
0
)
{
this
.
target
.
groupBy
.
push
(
partModel
.
part
);
}
else
if
(
typePart
===
'time'
)
{
this
.
target
.
groupBy
.
splice
(
0
,
0
,
partModel
.
part
);
}
else
if
(
typePart
===
'tag'
)
{
if
(
this
.
target
.
groupBy
[
partCount
-
1
].
type
===
'fill'
)
{
this
.
target
.
groupBy
.
splice
(
partCount
-
1
,
0
,
partModel
.
part
);
}
else
{
this
.
target
.
groupBy
.
push
(
partModel
.
part
);
}
}
else
{
this
.
target
.
groupBy
.
push
(
partModel
.
part
);
}
this
.
updateProjection
();
this
.
updateProjection
();
}
}
...
...
public/app/plugins/datasource/influxdb/query_part.ts
View file @
b3d494d4
...
@@ -186,7 +186,7 @@ QueryPartDef.register({
...
@@ -186,7 +186,7 @@ QueryPartDef.register({
QueryPartDef
.
register
({
QueryPartDef
.
register
({
type
:
'time'
,
type
:
'time'
,
category
:
groupByTimeFunctions
,
category
:
groupByTimeFunctions
,
params
:
[{
name
:
"rate"
,
type
:
"interval"
,
options
:
[
'$interval'
,
'1s'
,
'10s'
,
'1m'
,
'5m
in
'
,
'10m'
,
'15m'
,
'1h'
]
}],
params
:
[{
name
:
"rate"
,
type
:
"interval"
,
options
:
[
'$interval'
,
'1s'
,
'10s'
,
'1m'
,
'5m'
,
'10m'
,
'15m'
,
'1h'
]
}],
defaultParams
:
[
'$interval'
],
defaultParams
:
[
'$interval'
],
renderer
:
functionRenderer
,
renderer
:
functionRenderer
,
});
});
...
...
public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts
View file @
b3d494d4
...
@@ -58,6 +58,34 @@ describe.only('InfluxQuery', function() {
...
@@ -58,6 +58,34 @@ describe.only('InfluxQuery', function() {
});
});
});
});
describe
(
'when adding group by part'
,
function
()
{
it
(
'should add tag before fill'
,
function
()
{
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
groupBy
:
[{
type
:
'time'
},
{
type
:
'fill'
}]
});
query
.
addGroupBy
(
'tag(host)'
);
expect
(
query
.
target
.
groupBy
.
length
).
to
.
be
(
3
);
expect
(
query
.
target
.
groupBy
[
1
].
type
).
to
.
be
(
'tag'
);
expect
(
query
.
target
.
groupBy
[
1
].
params
[
0
]).
to
.
be
(
'host'
);
expect
(
query
.
target
.
groupBy
[
2
].
type
).
to
.
be
(
'fill'
);
});
it
(
'should add tag last if no fill'
,
function
()
{
var
query
=
new
InfluxQuery
({
measurement
:
'cpu'
,
groupBy
:
[]
});
query
.
addGroupBy
(
'tag(host)'
);
expect
(
query
.
target
.
groupBy
.
length
).
to
.
be
(
1
);
expect
(
query
.
target
.
groupBy
[
0
].
type
).
to
.
be
(
'tag'
);
});
});
describe
(
'when adding select part'
,
function
()
{
describe
(
'when adding select part'
,
function
()
{
it
(
'should add mean after after field'
,
function
()
{
it
(
'should add mean after after field'
,
function
()
{
...
...
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