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
8526230b
Commit
8526230b
authored
Oct 22, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(influxdb_08): fixed influxdb 08 query editor issue, fixes #3009
parent
9d04a4c4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
134 additions
and
137 deletions
+134
-137
public/app/plugins/datasource/influxdb_08/datasource.js
+4
-4
public/app/plugins/datasource/influxdb_08/func_editor.js
+0
-0
public/app/plugins/datasource/influxdb_08/influx_series.js
+0
-0
public/app/plugins/datasource/influxdb_08/query_builder.js
+0
-0
public/app/plugins/datasource/influxdb_08/query_ctrl.js
+2
-1
public/app/plugins/datasource/influxdb_08/specs/datasource-specs.ts
+75
-79
public/app/plugins/datasource/influxdb_08/specs/influx_series_specs.ts
+0
-0
public/app/plugins/datasource/influxdb_08/specs/query_builder_specs.ts
+53
-53
No files found.
public/app/plugins/datasource/influxdb_08/datasource.js
View file @
8526230b
...
@@ -2,11 +2,11 @@ define([
...
@@ -2,11 +2,11 @@ define([
'angular'
,
'angular'
,
'lodash'
,
'lodash'
,
'app/core/utils/datemath'
,
'app/core/utils/datemath'
,
'./influx
S
eries'
,
'./influx
_s
eries'
,
'./query
B
uilder'
,
'./query
_b
uilder'
,
'./directives'
,
'./directives'
,
'./query
C
trl'
,
'./query
_c
trl'
,
'./func
E
ditor'
,
'./func
_e
ditor'
,
],
],
function
(
angular
,
_
,
dateMath
,
InfluxSeries
,
InfluxQueryBuilder
)
{
function
(
angular
,
_
,
dateMath
,
InfluxSeries
,
InfluxQueryBuilder
)
{
'use strict'
;
'use strict'
;
...
...
public/app/plugins/datasource/influxdb_08/func
E
ditor.js
→
public/app/plugins/datasource/influxdb_08/func
_e
ditor.js
View file @
8526230b
File moved
public/app/plugins/datasource/influxdb_08/influx
S
eries.js
→
public/app/plugins/datasource/influxdb_08/influx
_s
eries.js
View file @
8526230b
File moved
public/app/plugins/datasource/influxdb_08/query
B
uilder.js
→
public/app/plugins/datasource/influxdb_08/query
_b
uilder.js
View file @
8526230b
File moved
public/app/plugins/datasource/influxdb_08/query
C
trl.js
→
public/app/plugins/datasource/influxdb_08/query
_c
trl.js
View file @
8526230b
...
@@ -89,6 +89,7 @@ function (angular) {
...
@@ -89,6 +89,7 @@ function (angular) {
}
}
};
};
}
);
$scope
.
init
(
);
});
});
});
public/
test/specs/influxdb-datasource-specs.j
s
→
public/
app/plugins/datasource/influxdb_08/specs/datasource-specs.t
s
View file @
8526230b
define
([
///<amd-dependency path="app/plugins/datasource/influxdb_08/datasource"/>
'./helpers'
,
///<amd-dependency path="app/services/backendSrv"/>
'app/plugins/datasource/influxdb_08/datasource'
,
///<amd-dependency path="app/services/alertSrv"/>
'app/services/backendSrv'
,
///<amd-dependency path="test/specs/helpers" name="helpers" />
'app/services/alertSrv'
],
function
(
helpers
)
{
'use strict'
;
describe
(
'InfluxDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'templateSrv'
]));
beforeEach
(
ctx
.
createService
(
'InfluxDatasource_08'
));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
''
,
user
:
'test'
,
password
:
'mupp'
});
});
describe
(
'When querying influxdb with one target using query editor target spec'
,
function
()
{
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
var
results
;
var
urlExpected
=
"/series?p=mupp&q=select+mean(value)+from+%22test%22"
+
"+where+time+%3E+now()-1h+group+by+time(1s)+order+asc"
;
var
query
=
{
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
series
:
'test'
,
column
:
'value'
,
function
:
'mean'
}],
interval
:
'1s'
};
var
response
=
[{
declare
var
helpers
:
any
;
columns
:
[
"time"
,
"sequence_nr"
,
"value"
],
name
:
'test'
,
points
:
[[
10
,
1
,
1
]],
}];
beforeEach
(
function
()
{
describe
(
'InfluxDatasource'
,
function
()
{
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
var
ctx
=
new
helpers
.
ServiceTestContext
();
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
});
beforeEach
(
ctx
.
providePhase
([
'templateSrv'
]));
beforeEach
(
ctx
.
createService
(
'InfluxDatasource_08'
));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
''
,
user
:
'test'
,
password
:
'mupp'
});
});
it
(
'should generate the correct query'
,
function
()
{
describe
(
'When querying influxdb with one target using query editor target spec'
,
function
()
{
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
var
results
;
});
var
urlExpected
=
"/series?p=mupp&q=select+mean(value)+from+%22test%22+where+time+%3E+now()-1h+group+by+time(1s)+order+asc"
;
var
query
=
{
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
series
:
'test'
,
column
:
'value'
,
function
:
'mean'
}],
interval
:
'1s'
};
var
response
=
[{
columns
:
[
"time"
,
"sequence_nr"
,
"value"
],
name
:
'test'
,
points
:
[[
10
,
1
,
1
]],
}];
it
(
'should return series list'
,
function
()
{
beforeEach
(
function
()
{
expect
(
results
.
data
.
length
).
to
.
be
(
1
);
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
expect
(
results
.
data
[
0
].
target
).
to
.
be
(
'test.value'
);
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
});
ctx
.
$httpBackend
.
flush
();
});
it
(
'should generate the correct query'
,
function
()
{
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
});
});
describe
(
'When querying influxdb with one raw query'
,
function
()
{
it
(
'should return series list'
,
function
()
{
var
results
;
expect
(
results
.
data
.
length
).
to
.
be
(
1
);
var
urlExpected
=
"/series?p=mupp&q=select+value+from+series"
+
expect
(
results
.
data
[
0
].
target
).
to
.
be
(
'test.value'
);
"+where+time+%3E+now()-1h"
;
});
var
query
=
{
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
query
:
"select value from series where $timeFilter"
,
rawQuery
:
true
}]
};
var
response
=
[]
;
})
;
beforeEach
(
function
()
{
describe
(
'When querying influxdb with one raw query'
,
function
()
{
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
var
results
;
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
var
urlExpected
=
"/series?p=mupp&q=select+value+from+series+where+time+%3E+now()-1h"
;
ctx
.
$httpBackend
.
flush
();
var
query
=
{
});
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
query
:
"select value from series where $timeFilter"
,
rawQuery
:
true
}]
};
it
(
'should generate the correct query'
,
function
()
{
var
response
=
[];
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
});
beforeEach
(
function
()
{
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
});
});
describe
(
'When issuing annotation query'
,
function
()
{
it
(
'should generate the correct query'
,
function
()
{
var
results
;
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
var
urlExpected
=
"/series?p=mupp&q=select+title+from+events.backend_01"
+
});
"+where+time+%3E+now()-1h"
;
var
range
=
{
from
:
'now-1h'
,
to
:
'now'
};
});
var
annotation
=
{
query
:
'select title from events.$server where $timeFilter'
};
var
response
=
[];
beforeEach
(
function
()
{
describe
(
'When issuing annotation query'
,
function
()
{
ctx
.
templateSrv
.
replace
=
function
(
str
)
{
var
results
;
return
str
.
replace
(
'$server'
,
'backend_01'
);
var
urlExpected
=
"/series?p=mupp&q=select+title+from+events.backend_01+where+time+%3E+now()-1h"
;
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
ctx
.
ds
.
annotationQuery
(
annotation
,
range
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
});
it
(
'should generate the correct query'
,
function
()
{
var
range
=
{
from
:
'now-1h'
,
to
:
'now'
};
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
()
;
var
annotation
=
{
query
:
'select title from events.$server where $timeFilter'
}
;
})
;
var
response
=
[]
;
beforeEach
(
function
()
{
ctx
.
templateSrv
.
replace
=
function
(
str
)
{
return
str
.
replace
(
'$server'
,
'backend_01'
);
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
ctx
.
ds
.
annotationQuery
(
annotation
,
range
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
});
it
(
'should generate the correct query'
,
function
()
{
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
});
});
});
});
});
});
public/
test/specs/influxSeries08-specs.j
s
→
public/
app/plugins/datasource/influxdb_08/specs/influx_series_specs.t
s
View file @
8526230b
This diff is collapsed.
Click to expand it.
public/
test/specs/influxQueryBuilder-specs.j
s
→
public/
app/plugins/datasource/influxdb_08/specs/query_builder_specs.t
s
View file @
8526230b
define
([
///<amd-dependency path="app/plugins/datasource/influxdb_08/query_builder" name="InfluxQueryBuilder"/>
'app/plugins/datasource/influxdb_08/queryBuilder'
],
function
(
InfluxQueryBuilder
)
{
'use strict'
;
describe
(
'InfluxQueryBuilder'
,
function
()
{
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
}
from
'test/lib/common'
;
describe
(
'series with conditon and group by'
,
function
()
{
declare
var
InfluxQueryBuilder
:
any
;
var
builder
=
new
InfluxQueryBuilder
({
series
:
'google.test'
,
column
:
'value'
,
function
:
'mean'
,
condition
:
"code=1"
,
groupby_field
:
'code'
});
var
query
=
builder
.
build
();
describe
(
'InfluxQueryBuilder'
,
function
()
{
it
(
'should generate correct query'
,
function
()
{
describe
(
'series with conditon and group by'
,
function
()
{
expect
(
query
).
to
.
be
(
'select code, mean(value) from "google.test" where $timeFilter and code=1 '
+
var
builder
=
new
InfluxQueryBuilder
({
'group by time($interval), code order asc'
);
series
:
'google.test'
,
});
column
:
'value'
,
function
:
'mean'
,
condition
:
"code=1"
,
groupby_field
:
'code'
});
it
(
'should expose groupByFiled'
,
function
()
{
var
query
=
builder
.
build
();
expect
(
builder
.
groupByField
).
to
.
be
(
'code'
);
});
it
(
'should generate correct query'
,
function
()
{
expect
(
query
).
to
.
be
(
'select code, mean(value) from "google.test" where $timeFilter and code=1 '
+
'group by time($interval), code order asc'
);
});
});
describe
(
'series with fill and minimum group by time'
,
function
()
{
it
(
'should expose groupByFiled'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
expect
(
builder
.
groupByField
).
to
.
be
(
'code'
);
series
:
'google.test'
,
});
column
:
'value'
,
function
:
'mean'
,
fill
:
'0'
,
});
var
query
=
builder
.
build
();
it
(
'should generate correct query'
,
function
()
{
});
expect
(
query
).
to
.
be
(
'select mean(value) from "google.test" where $timeFilter '
+
'group by time($interval) fill(0) order asc'
);
});
describe
(
'series with fill and minimum group by time'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
series
:
'google.test'
,
column
:
'value'
,
function
:
'mean'
,
fill
:
'0'
,
});
});
describe
(
'merge function detection'
,
function
()
{
var
query
=
builder
.
build
();
it
(
'should not quote wrap regex merged series'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
it
(
'should generate correct query'
,
function
()
{
series
:
'merge(/^google.test/)'
,
expect
(
query
).
to
.
be
(
'select mean(value) from "google.test" where $timeFilter '
+
column
:
'value'
,
'group by time($interval) fill(0) order asc'
);
function
:
'mean'
});
});
var
query
=
builder
.
build
(
);
}
);
expect
(
query
).
to
.
be
(
'select mean(value) from merge(/^google.test/) where $timeFilter '
+
describe
(
'merge function detection'
,
function
()
{
'group by time($interval) order asc'
);
it
(
'should not quote wrap regex merged series'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
series
:
'merge(/^google.test/)'
,
column
:
'value'
,
function
:
'mean'
});
});
it
(
'should quote wrap series names that start with "merge"'
,
function
()
{
var
query
=
builder
.
build
();
var
builder
=
new
InfluxQueryBuilder
({
series
:
'merge.google.test'
,
column
:
'value'
,
function
:
'mean'
});
var
query
=
builder
.
build
();
expect
(
query
).
to
.
be
(
'select mean(value) from merge(/^google.test/) where $timeFilter '
+
'group by time($interval) order asc'
);
});
expect
(
query
).
to
.
be
(
'select mean(value) from "merge.google.test" where $timeFilter '
+
it
(
'should quote wrap series names that start with "merge"'
,
function
()
{
'group by time($interval) order asc'
);
var
builder
=
new
InfluxQueryBuilder
({
series
:
'merge.google.test'
,
column
:
'value'
,
function
:
'mean'
});
});
var
query
=
builder
.
build
();
expect
(
query
).
to
.
be
(
'select mean(value) from "merge.google.test" where $timeFilter '
+
'group by time($interval) order asc'
);
});
});
});
});
});
});
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