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
afc8380f
Commit
afc8380f
authored
Sep 05, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on getting template variables to work well with functions that take integers, #262
parent
03190518
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
24 deletions
+18
-24
src/app/controllers/graphiteTarget.js
+11
-14
src/app/services/graphite/gfunc.js
+0
-3
src/app/services/templateSrv.js
+1
-1
src/app/services/templateValuesSrv.js
+1
-1
src/test/specs/gfunc-specs.js
+5
-5
No files found.
src/app/controllers/graphiteTarget.js
View file @
afc8380f
...
...
@@ -54,6 +54,13 @@ function (angular, _, config, gfunc, Parser) {
checkOtherSegments
(
$scope
.
segments
.
length
-
1
);
}
function
addFunctionParameter
(
func
,
value
,
index
,
shiftBack
)
{
if
(
shiftBack
)
{
index
=
Math
.
max
(
index
-
1
,
0
);
}
func
.
params
[
index
]
=
value
;
}
function
parseTargeRecursive
(
astNode
,
func
,
index
)
{
if
(
astNode
===
null
)
{
return
null
;
...
...
@@ -72,29 +79,19 @@ function (angular, _, config, gfunc, Parser) {
break
;
case
'series-ref'
:
if
(
$scope
.
segments
.
length
===
0
)
{
func
.
params
[
index
]
=
astNode
.
value
;
}
else
{
func
.
params
[
index
-
1
]
=
astNode
.
value
;
}
addFunctionParameter
(
func
,
astNode
.
value
,
index
,
$scope
.
segments
.
length
>
0
);
break
;
case
'string'
:
case
'number'
:
if
((
index
-
1
)
>=
func
.
def
.
params
.
length
)
{
throw
{
message
:
'invalid number of parameters to method '
+
func
.
def
.
name
};
}
if
(
index
===
0
)
{
func
.
params
[
index
]
=
astNode
.
value
;
}
else
{
func
.
params
[
index
-
1
]
=
astNode
.
value
;
}
addFunctionParameter
(
func
,
astNode
.
value
,
index
,
true
);
break
;
case
'metric'
:
if
(
$scope
.
segments
.
length
>
0
)
{
throw
{
message
:
'Multiple metric params not supported, use text editor.'
};
addFunctionParameter
(
func
,
astNode
.
segments
[
0
].
value
,
index
,
true
);
break
;
}
$scope
.
segments
=
_
.
map
(
astNode
.
segments
,
function
(
segment
)
{
...
...
src/app/services/graphite/gfunc.js
View file @
afc8380f
...
...
@@ -555,9 +555,6 @@ function (_) {
if
(
strValue
===
''
&&
this
.
def
.
params
[
index
].
optional
)
{
this
.
params
.
splice
(
index
,
1
);
}
else
if
(
this
.
def
.
params
[
index
].
type
===
'int'
)
{
this
.
params
[
index
]
=
parseFloat
(
strValue
,
10
);
}
else
{
this
.
params
[
index
]
=
strValue
;
}
...
...
src/app/services/templateSrv.js
View file @
afc8380f
...
...
@@ -47,7 +47,7 @@ function (angular, _) {
};
this
.
highlightVariablesAsHtml
=
function
(
str
)
{
if
(
!
str
)
{
return
str
;
}
if
(
!
str
||
!
_
.
isString
(
str
)
)
{
return
str
;
}
this
.
regex
.
lastIndex
=
0
;
return
str
.
replace
(
this
.
regex
,
function
(
match
,
g1
,
g2
)
{
...
...
src/app/services/templateValuesSrv.js
View file @
afc8380f
...
...
@@ -56,7 +56,7 @@ function (angular, _, kbn) {
return
{
text
:
text
,
value
:
text
};
});
self
.
setVariableValue
(
variable
,
variable
.
options
[
0
]);
return
;
return
$q
.
when
([])
;
}
var
datasource
=
datasourceSrv
.
get
(
variable
.
datasource
);
...
...
src/test/specs/gfunc-specs.js
View file @
afc8380f
...
...
@@ -85,7 +85,7 @@ define([
it
(
'should parse numbers as float'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'scale'
);
func
.
updateParam
(
'0.001'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
0.001
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'0.001'
);
});
});
...
...
@@ -93,14 +93,14 @@ define([
it
(
'should update value and text'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'1'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
1
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'1'
);
});
it
(
'should slit text and put value in second param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
4
);
expect
(
func
.
params
[
1
]).
to
.
be
(
-
5
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
'-5'
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4, -5)'
);
});
...
...
@@ -108,7 +108,7 @@ define([
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
func
.
updateParam
(
''
,
1
);
expect
(
func
.
params
[
0
]).
to
.
be
(
4
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
undefined
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4)'
);
});
...
...
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