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
a053552f
Commit
a053552f
authored
Feb 01, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes to data source query editors
parent
6886faa9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
28 deletions
+29
-28
public/app/features/panel/query_editor.ts
+1
-1
public/app/plugins/datasource/graphite/query_ctrl.js
+3
-2
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
+10
-11
public/app/plugins/datasource/influxdb/partials/query.editor.html
+4
-4
public/app/plugins/datasource/influxdb/query_ctrl.js
+9
-8
public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts
+2
-2
No files found.
public/app/features/panel/query_editor.ts
View file @
a053552f
...
...
@@ -9,7 +9,7 @@ function metricsQueryEditor(dynamicDirectiveSrv, datasourceSrv) {
directive
:
scope
=>
{
let
datasource
=
scope
.
target
.
datasource
||
scope
.
ctrl
.
panel
.
datasource
;
return
datasourceSrv
.
get
(
datasource
).
then
(
ds
=>
{
scope
.
ctrl
.
datasource
=
ds
;
scope
.
datasource
=
ds
;
if
(
!
scope
.
target
.
refId
)
{
scope
.
target
.
refId
=
'A'
;
...
...
public/app/plugins/datasource/graphite/query_ctrl.js
View file @
a053552f
...
...
@@ -12,6 +12,7 @@ function (angular, _, config, gfunc, Parser) {
module
.
controller
(
'GraphiteQueryCtrl'
,
function
(
$scope
,
uiSegmentSrv
,
templateSrv
)
{
var
panelCtrl
=
$scope
.
panelCtrl
=
$scope
.
ctrl
;
var
datasource
=
$scope
.
datasource
;
$scope
.
init
=
function
()
{
if
(
$scope
.
target
)
{
...
...
@@ -126,7 +127,7 @@ function (angular, _, config, gfunc, Parser) {
}
var
path
=
getSegmentPathUpTo
(
fromIndex
+
1
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
path
)
return
datasource
.
metricFindQuery
(
path
)
.
then
(
function
(
segments
)
{
if
(
segments
.
length
===
0
)
{
if
(
path
!==
''
)
{
...
...
@@ -160,7 +161,7 @@ function (angular, _, config, gfunc, Parser) {
$scope
.
getAltSegments
=
function
(
index
)
{
var
query
=
index
===
0
?
'*'
:
getSegmentPathUpTo
(
index
)
+
'.*'
;
return
panelCtrl
.
datasource
.
metricFindQuery
(
query
).
then
(
function
(
segments
)
{
return
datasource
.
metricFindQuery
(
query
).
then
(
function
(
segments
)
{
var
altSegments
=
_
.
map
(
segments
,
function
(
segment
)
{
return
uiSegmentSrv
.
newSegment
({
value
:
segment
.
text
,
expandable
:
segment
.
expandable
});
});
...
...
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
View file @
a053552f
...
...
@@ -19,14 +19,13 @@ describe('GraphiteQueryCtrl', function() {
ctx
.
scope
=
$rootScope
.
$new
();
ctx
.
scope
.
ctrl
=
{
panel
:
ctx
.
panel
};
ctx
.
panelCtrl
=
ctx
.
scope
.
ctrl
;
ctx
.
scope
.
datasource
=
ctx
.
datasource
;
ctx
.
scope
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
ctx
.
controller
=
$controller
(
'GraphiteQueryCtrl'
,
{
$scope
:
ctx
.
scope
});
}));
beforeEach
(
function
()
{
ctx
.
scope
.
target
=
{
target
:
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
};
ctx
.
panelCtrl
.
datasource
=
ctx
.
datasource
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
});
describe
(
'init'
,
function
()
{
...
...
@@ -36,7 +35,7 @@ describe('GraphiteQueryCtrl', function() {
});
it
(
'should validate metric key exists'
,
function
()
{
expect
(
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
getCall
(
0
).
args
[
0
]).
to
.
be
(
'test.prod.*'
);
expect
(
ctx
.
scope
.
datasource
.
metricFindQuery
.
getCall
(
0
).
args
[
0
]).
to
.
be
(
'test.prod.*'
);
});
it
(
'should delete last segment if no metrics are found'
,
function
()
{
...
...
@@ -51,7 +50,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when adding function'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'test.prod.*.count'
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
...
...
@@ -75,7 +74,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when adding function before any metric segment'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
''
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
true
}]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
true
}]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
ctx
.
scope
.
addFunction
(
gfunc
.
getFuncDef
(
'asPercent'
));
...
...
@@ -89,7 +88,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when initalizing target without metric expression and only function'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'asPercent(#A, #B)'
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
});
...
...
@@ -107,7 +106,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when initializing a target with single param func using variable'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'movingAverage(prod.count, $var)'
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
});
...
...
@@ -125,7 +124,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when initalizing target without metric expression and function with series-ref'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'asPercent(metric.node.count, #A)'
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
ctx
.
scope
.
$parent
=
{
get_data
:
sinon
.
spy
()
};
...
...
@@ -143,7 +142,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'when getting altSegments and metricFindQuery retuns empty array'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'test.count'
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
init
();
ctx
.
scope
.
getAltSegments
(
1
).
then
(
function
(
results
)
{
ctx
.
altSegments
=
results
;
...
...
@@ -159,7 +158,7 @@ describe('GraphiteQueryCtrl', function() {
describe
(
'targetChanged'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
...
...
public/app/plugins/datasource/influxdb/partials/query.editor.html
View file @
a053552f
...
...
@@ -16,15 +16,15 @@
</a>
<ul
class=
"dropdown-menu pull-right"
role=
"menu"
>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"toggleQueryMode()"
>
Switch editor mode
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"duplicateDataQuery(target)"
>
Duplicate
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"moveDataQuery($index, $index-1)"
>
Move up
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"moveDataQuery($index, $index+1)"
>
Move down
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"
panelCtrl.
duplicateDataQuery(target)"
>
Duplicate
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"
panelCtrl.
moveDataQuery($index, $index-1)"
>
Move up
</a></li>
<li
role=
"menuitem"
><a
tabindex=
"1"
ng-click=
"
panelCtrl.
moveDataQuery($index, $index+1)"
>
Move down
</a></li>
</ul>
</div>
</li>
<li
class=
"tight-form-item last"
>
<a
class=
"pointer"
tabindex=
"1"
ng-click=
"removeDataQuery(target)"
>
<a
class=
"pointer"
tabindex=
"1"
ng-click=
"
panelCtrl.
removeDataQuery(target)"
>
<i
class=
"fa fa-remove"
></i>
</a>
</li>
...
...
public/app/plugins/datasource/influxdb/query_ctrl.js
View file @
a053552f
...
...
@@ -16,6 +16,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
module
.
controller
(
'InfluxQueryCtrl'
,
function
(
$scope
,
templateSrv
,
$q
,
uiSegmentSrv
)
{
var
panelCtrl
=
$scope
.
ctrl
;
var
datasource
=
$scope
.
datasource
;
$scope
.
panelCtrl
=
panelCtrl
;
$scope
.
init
=
function
()
{
...
...
@@ -23,7 +24,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
$scope
.
target
=
$scope
.
target
;
$scope
.
queryModel
=
new
InfluxQuery
(
$scope
.
target
);
$scope
.
queryBuilder
=
new
InfluxQueryBuilder
(
$scope
.
target
,
panelCtrl
.
datasource
.
database
);
$scope
.
queryBuilder
=
new
InfluxQueryBuilder
(
$scope
.
target
,
datasource
.
database
);
$scope
.
groupBySegment
=
uiSegmentSrv
.
newPlusButton
();
$scope
.
resultFormats
=
[
{
text
:
'Time series'
,
value
:
'time_series'
},
...
...
@@ -77,7 +78,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
$scope
.
getGroupByOptions
=
function
()
{
var
query
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'TAG_KEYS'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
query
)
return
datasource
.
metricFindQuery
(
query
)
.
then
(
function
(
tags
)
{
var
options
=
[];
if
(
!
$scope
.
queryModel
.
hasFill
())
{
...
...
@@ -137,7 +138,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
$scope
.
getPolicySegments
=
function
()
{
var
policiesQuery
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'RETENTION POLICIES'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
policiesQuery
)
return
datasource
.
metricFindQuery
(
policiesQuery
)
.
then
(
$scope
.
transformToSegments
(
false
))
.
then
(
null
,
$scope
.
handleQueryError
);
};
...
...
@@ -153,19 +154,19 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
$scope
.
getMeasurements
=
function
()
{
var
query
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'MEASUREMENTS'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
query
)
return
datasource
.
metricFindQuery
(
query
)
.
then
(
$scope
.
transformToSegments
(
true
),
$scope
.
handleQueryError
);
};
$scope
.
getPartOptions
=
function
(
part
)
{
if
(
part
.
def
.
type
===
'field'
)
{
var
fieldsQuery
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'FIELDS'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
fieldsQuery
)
return
datasource
.
metricFindQuery
(
fieldsQuery
)
.
then
(
$scope
.
transformToSegments
(
true
),
$scope
.
handleQueryError
);
}
if
(
part
.
def
.
type
===
'tag'
)
{
var
tagsQuery
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'TAG_KEYS'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
tagsQuery
)
return
datasource
.
metricFindQuery
(
tagsQuery
)
.
then
(
$scope
.
transformToSegments
(
true
),
$scope
.
handleQueryError
);
}
};
...
...
@@ -213,7 +214,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
addTemplateVars
=
true
;
}
return
panelCtrl
.
datasource
.
metricFindQuery
(
query
)
return
datasource
.
metricFindQuery
(
query
)
.
then
(
$scope
.
transformToSegments
(
addTemplateVars
))
.
then
(
function
(
results
)
{
if
(
segment
.
type
===
'key'
)
{
...
...
@@ -226,7 +227,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
$scope
.
getFieldSegments
=
function
()
{
var
fieldsQuery
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'FIELDS'
);
return
panelCtrl
.
datasource
.
metricFindQuery
(
fieldsQuery
)
return
datasource
.
metricFindQuery
(
fieldsQuery
)
.
then
(
$scope
.
transformToSegments
(
false
))
.
then
(
null
,
$scope
.
handleQueryError
);
};
...
...
public/app/plugins/datasource/influxdb/specs/query_ctrl_specs.ts
View file @
a053552f
...
...
@@ -15,6 +15,8 @@ describe('InfluxDBQueryCtrl', function() {
ctx
.
$q
=
$q
;
ctx
.
scope
=
$rootScope
.
$new
();
ctx
.
scope
.
ctrl
=
{
panel
:
ctx
.
panel
};
ctx
.
scope
.
datasource
=
ctx
.
datasource
;
ctx
.
scope
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
ctx
.
panelCtrl
=
ctx
.
scope
.
ctrl
;
ctx
.
controller
=
$controller
(
'InfluxQueryCtrl'
,
{
$scope
:
ctx
.
scope
});
}));
...
...
@@ -22,8 +24,6 @@ describe('InfluxDBQueryCtrl', function() {
beforeEach
(
function
()
{
ctx
.
scope
.
target
=
{};
ctx
.
panelCtrl
.
refresh
=
sinon
.
spy
();
ctx
.
panelCtrl
.
datasource
=
ctx
.
datasource
;
ctx
.
panelCtrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
});
describe
(
'init'
,
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