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
31052154
Commit
31052154
authored
Aug 16, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(mixed datasource): changed how query ref ids (letters) are assigned, now they are persisted
parent
e916f937
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
21 deletions
+86
-21
public/app/features/panel/panelDirective.js
+0
-3
public/app/features/panel/panelSrv.js
+14
-1
public/app/plugins/datasource/graphite/datasource.js
+11
-15
public/app/plugins/datasource/graphite/partials/query.editor.html
+1
-1
public/app/plugins/datasource/opentsdb/partials/query.editor.html
+1
-1
public/test/specs/panelSrv-specs.js
+58
-0
public/test/test-main.js
+1
-0
No files found.
public/app/features/panel/panelDirective.js
View file @
31052154
...
...
@@ -40,8 +40,6 @@ function (angular, $, config) {
};
});
var
targetLetters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
module
.
directive
(
'queryEditorLoader'
,
function
(
$compile
,
$parse
,
datasourceSrv
)
{
return
{
restrict
:
'E'
,
...
...
@@ -59,7 +57,6 @@ function (angular, $, config) {
editorScope
=
scope
.
$new
();
editorScope
.
datasource
=
ds
;
editorScope
.
targetLetters
=
targetLetters
;
var
panelEl
=
angular
.
element
(
document
.
createElement
(
'metric-query-editor-'
+
ds
.
meta
.
type
));
elem
.
append
(
panelEl
);
...
...
public/app/features/panel/panelSrv.js
View file @
31052154
...
...
@@ -44,7 +44,20 @@ function (angular, _, config) {
};
$scope
.
addDataQuery
=
function
(
datasource
)
{
$scope
.
panel
.
targets
.
push
({
target
:
''
,
datasource
:
datasource
});
var
letters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
var
target
=
{};
if
(
datasource
)
{
target
.
datasource
=
datasource
;
}
target
.
refId
=
_
.
find
(
letters
,
function
(
refId
)
{
return
_
.
every
(
$scope
.
panel
.
targets
,
function
(
other
)
{
return
other
.
refId
!==
refId
;
});
});
$scope
.
panel
.
targets
.
push
(
target
);
};
$scope
.
removeDataQuery
=
function
(
query
)
{
...
...
public/app/plugins/datasource/graphite/datasource.js
View file @
31052154
...
...
@@ -228,21 +228,13 @@ function (angular, _, $, config, kbn, moment) {
return
backendSrv
.
datasourceRequest
(
options
);
};
GraphiteDatasource
.
prototype
.
_seriesRefLetters
=
[
'#A'
,
'#B'
,
'#C'
,
'#D'
,
'#E'
,
'#F'
,
'#G'
,
'#H'
,
'#I'
,
'#J'
,
'#K'
,
'#L'
,
'#M'
,
'#N'
,
'#O'
,
'#P'
,
'#Q'
,
'#R'
,
'#S'
,
'#T'
,
'#U'
,
'#V'
,
'#W'
,
'#X'
,
'#Y'
,
'#Z'
];
GraphiteDatasource
.
prototype
.
_seriesRefLetters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
GraphiteDatasource
.
prototype
.
buildGraphiteParams
=
function
(
options
,
scopedVars
)
{
var
graphite_options
=
[
'from'
,
'until'
,
'rawData'
,
'format'
,
'maxDataPoints'
,
'cacheTimeout'
];
var
clean_options
=
[],
targets
=
{};
var
target
,
targetValue
,
i
;
var
regex
=
/
(\#
[
A-Z
])
/g
;
var
regex
=
/
\#(
[
A-Z
])
/g
;
var
intervalFormatFixRegex
=
/'
(\d
+
)
m'/gi
;
if
(
options
.
format
!==
'png'
)
{
...
...
@@ -259,13 +251,17 @@ function (angular, _, $, config, kbn, moment) {
continue
;
}
if
(
!
target
.
refId
)
{
target
.
refId
=
this
.
_seriesRefLetters
[
i
];
}
targetValue
=
templateSrv
.
replace
(
target
.
target
,
scopedVars
);
targetValue
=
targetValue
.
replace
(
intervalFormatFixRegex
,
fixIntervalFormat
);
targets
[
t
his
.
_seriesRefLetters
[
i
]
]
=
targetValue
;
targets
[
t
arget
.
refId
]
=
targetValue
;
}
function
nestedSeriesRegexReplacer
(
match
)
{
return
targets
[
match
];
function
nestedSeriesRegexReplacer
(
match
,
g1
)
{
return
targets
[
g1
];
}
for
(
i
=
0
;
i
<
options
.
targets
.
length
;
i
++
)
{
...
...
@@ -274,9 +270,9 @@ function (angular, _, $, config, kbn, moment) {
continue
;
}
targetValue
=
targets
[
t
his
.
_seriesRefLetters
[
i
]
];
targetValue
=
targets
[
t
arget
.
refId
];
targetValue
=
targetValue
.
replace
(
regex
,
nestedSeriesRegexReplacer
);
targets
[
t
his
.
_seriesRefLetters
[
i
]
]
=
targetValue
;
targets
[
t
arget
.
refId
]
=
targetValue
;
if
(
!
target
.
hide
)
{
clean_options
.
push
(
"target="
+
encodeURIComponent
(
targetValue
));
...
...
public/app/plugins/datasource/graphite/partials/query.editor.html
View file @
31052154
...
...
@@ -48,7 +48,7 @@
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"min-width: 15px; text-align: center"
>
{{target
Letters[$index]
}}
{{target
.refId
}}
</li>
<li>
<a
class=
"tight-form-item"
...
...
public/app/plugins/datasource/opentsdb/partials/query.editor.html
View file @
31052154
...
...
@@ -26,7 +26,7 @@
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"min-width: 15px; text-align: center"
>
{{target
Letters[$index]
}}
{{target
.refId
}}
</li>
<li>
<a
class=
"tight-form-item"
...
...
public/test/specs/panelSrv-specs.js
0 → 100644
View file @
31052154
define
([
'helpers'
,
'features/panel/panelSrv'
,
],
function
()
{
'use strict'
;
describe
(
'PanelSrv'
,
function
()
{
var
_panelSrv
;
var
_panelScope
;
var
_datasourceSrvStub
;
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
module
(
function
(
$provide
)
{
_datasourceSrvStub
=
{
getMetricSources
:
sinon
.
spy
(),
};
$provide
.
value
(
'datasourceSrv'
,
_datasourceSrvStub
);
}));
beforeEach
(
inject
(
function
(
panelSrv
,
$rootScope
)
{
_panelSrv
=
panelSrv
;
_panelScope
=
$rootScope
.
$new
();
_panelScope
.
panel
=
{
targets
:
[],
};
_panelScope
.
dashboardViewState
=
{
registerPanel
:
sinon
.
spy
(),
};
}));
describe
(
'init'
,
function
()
{
beforeEach
(
function
()
{
_panelSrv
.
init
(
_panelScope
);
});
describe
(
'addDataQuery'
,
function
()
{
it
(
'should add target'
,
function
()
{
_panelScope
.
addDataQuery
();
expect
(
_panelScope
.
panel
.
targets
.
length
).
to
.
be
(
1
);
});
it
(
'should set refId'
,
function
()
{
_panelScope
.
addDataQuery
();
expect
(
_panelScope
.
panel
.
targets
[
0
].
refId
).
to
.
be
(
'A'
);
});
it
(
'should set refId to first available letter'
,
function
()
{
_panelScope
.
panel
.
targets
=
[{
refId
:
'A'
}];
_panelScope
.
addDataQuery
();
expect
(
_panelScope
.
panel
.
targets
[
1
].
refId
).
to
.
be
(
'B'
);
});
});
});
});
});
public/test/test-main.js
View file @
31052154
...
...
@@ -139,6 +139,7 @@ require([
'specs/seriesOverridesCtrl-specs'
,
'specs/shareModalCtrl-specs'
,
'specs/timeSrv-specs'
,
'specs/panelSrv-specs'
,
'specs/templateSrv-specs'
,
'specs/templateValuesSrv-specs'
,
'specs/kbn-format-specs'
,
...
...
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