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
21ef0cdc
Commit
21ef0cdc
authored
Dec 22, 2013
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring graphite target editor
parent
76fa88cf
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
35 deletions
+81
-35
src/app/controllers/graphiteTarget.js
+24
-29
src/app/panels/graphite/funcEditor.html
+1
-1
src/app/panels/graphite/module.js
+3
-5
src/app/services/graphite/functions.js
+45
-0
src/app/services/graphite/graphiteSrv.js
+8
-0
No files found.
src/app/controllers/graphiteTarget.js
View file @
21ef0cdc
define
([
'angular'
,
'underscore'
,
'config'
'config'
,
'/app/services/graphite/functions.js'
],
function
(
angular
,
_
,
config
)
{
function
(
angular
,
_
,
config
,
graphiteFunctions
)
{
'use strict'
;
var
module
=
angular
.
module
(
'kibana.controllers'
);
var
funcDefs
=
[
{
name
:
"scaleToSeconds"
,
params
:
[
{
name
:
"seconds"
,
type
:
"int"
}
],
defaultParams
:
[
1
]
},
{
name
:
"sumSeries"
,
params
:
[],
},
{
name
:
"groupByNode"
,
params
:
[
{
name
:
"node"
,
type
:
"node"
,
},
{
name
:
"function"
,
type
:
"function"
,
}
],
defaultParams
:
[
3
,
"sumSeries"
]
}
];
module
.
controller
(
'GraphiteTargetCtrl'
,
function
(
$scope
,
$http
)
{
...
...
@@ -43,7 +19,7 @@ function (angular, _, config) {
};
});
$scope
.
funcDefs
=
funcDef
s
;
$scope
.
funcDefs
=
graphiteFunction
s
;
$scope
.
functions
=
[];
};
...
...
@@ -100,6 +76,19 @@ function (angular, _, config) {
return
text
;
}
function
wrapFunction
(
target
,
func
)
{
var
targetWrapped
=
func
.
def
.
name
+
'('
+
target
;
_
.
each
(
func
.
params
,
function
(
param
)
{
if
(
_
.
isString
(
param
))
{
targetWrapped
+=
",'"
+
param
+
"'"
;
}
else
{
targetWrapped
+=
","
+
param
;
}
});
return
targetWrapped
+
')'
;
}
$scope
.
getAltSegments
=
function
(
index
)
{
$scope
.
altSegments
=
[];
...
...
@@ -135,16 +124,21 @@ function (angular, _, config) {
};
$scope
.
targetChanged
=
function
()
{
$scope
.
target
.
target
=
getSegmentPathUpTo
(
$scope
.
segments
.
length
);
var
target
=
getSegmentPathUpTo
(
$scope
.
segments
.
length
);
target
=
_
.
reduce
(
$scope
.
functions
,
wrapFunction
,
target
);
console
.
log
(
'target: '
,
target
);
$scope
.
target
.
target
=
target
;
$scope
.
$parent
.
get_data
();
};
$scope
.
removeFunction
=
function
(
func
)
{
$scope
.
functions
=
_
.
without
(
$scope
.
functions
,
func
);
$scope
.
targetChanged
();
};
$scope
.
functionParamsChanged
=
function
(
func
)
{
func
.
text
=
getFuncText
(
func
.
def
,
func
.
params
);
$scope
.
targetChanged
();
};
$scope
.
addFunction
=
function
(
funcDef
)
{
...
...
@@ -153,6 +147,7 @@ function (angular, _, config) {
params
:
funcDef
.
defaultParams
,
text
:
getFuncText
(
funcDef
,
funcDef
.
defaultParams
)
});
$scope
.
targetChanged
();
};
});
...
...
src/app/panels/graphite/funcEditor.html
View file @
21ef0cdc
...
...
@@ -23,7 +23,7 @@
<div
class=
"editor-option"
ng-repeat=
"param in func.def.params"
>
<label
class=
"small"
>
{{param.name}}
</label>
<input
ng-if=
"param.type === 'int'"
type=
"
text
"
type=
"
number
"
placeholder=
"seconds"
focus-me=
"true"
class=
"input-mini"
...
...
src/app/panels/graphite/module.js
View file @
21ef0cdc
...
...
@@ -459,6 +459,9 @@ function (angular, app, $, _, kbn, moment, timeSeries, graphiteSrv, RQ) {
// Function for rendering panel
function
render_panel
(
data
)
{
if
(
!
data
)
{
return
;
}
// IE doesn't work without this
elem
.
css
({
height
:
scope
.
panel
.
height
||
scope
.
row
.
height
});
...
...
@@ -476,7 +479,6 @@ function (angular, app, $, _, kbn, moment, timeSeries, graphiteSrv, RQ) {
var
stack
=
scope
.
panel
.
stack
?
true
:
null
;
// Populate element
try
{
var
options
=
{
legend
:
{
show
:
false
},
series
:
{
...
...
@@ -595,10 +597,6 @@ function (angular, app, $, _, kbn, moment, timeSeries, graphiteSrv, RQ) {
elem
.
css
(
'margin-left'
,
''
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
// Nothing to do here
}
}
function
time_format
(
interval
)
{
...
...
src/app/services/graphite/functions.js
0 → 100644
View file @
21ef0cdc
define
([
],
function
()
{
'use strict'
;
return
[
{
name
:
"scaleToSeconds"
,
params
:
[
{
name
:
"seconds"
,
type
:
"int"
}
],
defaultParams
:
[
1
]
},
{
name
:
"sumSeries"
,
params
:
[],
},
{
name
:
"groupByNode"
,
params
:
[
{
name
:
"node"
,
type
:
"node"
,
},
{
name
:
"function"
,
type
:
"function"
,
}
],
defaultParams
:
[
3
,
"sumSeries"
]
},
{
name
:
"alias"
,
params
:
[
{
name
:
"alias"
,
type
:
'string'
}
],
defaultParams
:
[
'alias'
]
},
{
name
:
'aliasByNode'
,
params
:
[
{
name
:
"node"
,
type
:
"node"
,
}
],
defaultParams
:
[
3
]
}
];
});
\ No newline at end of file
src/app/services/graphite/graphiteSrv.js
0 → 100644
View file @
21ef0cdc
define
([
],
function
()
{
});
\ No newline at end of file
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