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
042e2a20
Commit
042e2a20
authored
Dec 24, 2013
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrated parser into graphite target editor
parent
e19d3a53
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
13 deletions
+47
-13
src/app/controllers/graphiteTarget.js
+44
-10
src/app/panels/graphite/funcEditor.html
+1
-1
src/app/services/graphite/functions.js
+1
-1
src/app/services/graphite/parser.js
+1
-1
No files found.
src/app/controllers/graphiteTarget.js
View file @
042e2a20
...
...
@@ -2,9 +2,10 @@ define([
'angular'
,
'underscore'
,
'config'
,
'/app/services/graphite/functions.js'
'../services/graphite/functions'
,
'../services/graphite/parser'
],
function
(
angular
,
_
,
config
,
graphiteFunctions
)
{
function
(
angular
,
_
,
config
,
graphiteFunctions
,
Parser
)
{
'use strict'
;
var
module
=
angular
.
module
(
'kibana.controllers'
);
...
...
@@ -12,17 +13,50 @@ function (angular, _, config, graphiteFunctions) {
module
.
controller
(
'GraphiteTargetCtrl'
,
function
(
$scope
,
$http
)
{
$scope
.
init
=
function
()
{
$scope
.
segments
=
_
.
map
(
$scope
.
target
.
target
.
split
(
'.'
),
function
(
segmentStr
)
{
return
{
val
:
segmentStr
,
html
:
segmentStr
===
'*'
?
'<i class="icon-asterisk"><i>'
:
segmentStr
};
});
$scope
.
funcDefs
=
graphiteFunctions
;
$scope
.
functions
=
[];
$scope
.
segments
=
[];
$scope
.
funcDefs
=
graphiteFunctions
;
var
parser
=
new
Parser
(
$scope
.
target
.
target
);
var
astNode
=
parser
.
getAst
();
console
.
log
(
'GraphiteTargetCtrl:init -> target'
,
$scope
.
target
.
target
);
console
.
log
(
'GraphiteTargetCtrl:init -> ast'
,
astNode
);
parseTargetExpression
(
astNode
);
};
function
parseTargetExpression
(
astNode
,
func
,
index
)
{
if
(
astNode
===
null
)
{
return
null
;
}
if
(
astNode
.
type
===
'function'
)
{
var
innerFunc
=
{};
innerFunc
.
def
=
_
.
findWhere
(
$scope
.
funcDefs
,
{
name
:
astNode
.
name
})
innerFunc
.
params
=
innerFunc
.
def
.
defaultParams
;
_
.
each
(
astNode
.
params
,
function
(
param
,
index
)
{
parseTargetExpression
(
param
,
innerFunc
,
index
);
});
innerFunc
.
text
=
getFuncText
(
innerFunc
.
def
,
innerFunc
.
params
);
$scope
.
functions
.
push
(
innerFunc
);
}
if
(
astNode
.
type
===
'number'
||
astNode
.
type
===
'string'
)
{
func
.
params
[
index
-
1
]
=
astNode
.
value
;
}
if
(
astNode
.
type
===
'metric'
)
{
$scope
.
segments
=
_
.
map
(
astNode
.
segments
,
function
(
segment
)
{
return
{
val
:
segment
.
value
,
html
:
segment
.
value
===
'*'
?
'<i class="icon-asterisk"><i>'
:
segment
.
value
};
});
}
}
function
getSegmentPathUpTo
(
index
)
{
var
arr
=
$scope
.
segments
.
slice
(
0
,
index
);
...
...
src/app/panels/graphite/funcEditor.html
View file @
042e2a20
...
...
@@ -49,7 +49,7 @@
style=
"width: 110px"
ng-change=
"functionParamsChanged(func)"
ng-model=
"func.params[$index]"
ng-options=
"f for f in ['sum
Series', 'avgSeries
']"
>
ng-options=
"f for f in ['sum
', 'avg
']"
>
</select>
</div>
</div>
...
...
src/app/services/graphite/functions.js
View file @
042e2a20
...
...
@@ -26,7 +26,7 @@ function () {
type
:
"function"
,
}
],
defaultParams
:
[
3
,
"sum
Series
"
]
defaultParams
:
[
3
,
"sum"
]
},
{
name
:
"alias"
,
...
...
src/app/services/graphite/parser.js
View file @
042e2a20
...
...
@@ -117,7 +117,7 @@ define([
return
{
type
:
'number'
,
value
:
this
.
tokens
[
this
.
index
-
1
].
value
value
:
parseInt
(
this
.
tokens
[
this
.
index
-
1
].
value
)
};
},
...
...
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