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
76fa88cf
Commit
76fa88cf
authored
Dec 22, 2013
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function works
parent
2032ff66
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
67 deletions
+70
-67
src/app/controllers/graphiteTarget.js
+38
-33
src/app/panels/graphite/editor.html
+23
-5
src/app/panels/graphite/funcEditor.html
+9
-29
No files found.
src/app/controllers/graphiteTarget.js
View file @
76fa88cf
...
@@ -7,18 +7,29 @@ function (angular, _, config) {
...
@@ -7,18 +7,29 @@ function (angular, _, config) {
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'kibana.controllers'
);
var
module
=
angular
.
module
(
'kibana.controllers'
);
var
graphiteFunction
s
=
[
var
funcDef
s
=
[
{
{
name
:
"scaleToSeconds"
,
name
:
"scaleToSeconds"
,
params
:
[
{
name
:
"seconds"
,
type
:
"int"
}
]
params
:
[
{
name
:
"seconds"
,
type
:
"int"
}
],
defaultParams
:
[
1
]
},
},
{
{
name
:
"sumSeries"
,
name
:
"sumSeries"
,
params
:
[]
params
:
[]
,
},
},
{
{
name
:
"groupByNode"
,
name
:
"groupByNode"
,
params
:
[
{
name
:
"node"
,
type
:
"node"
},
{
name
:
"function"
,
type
:
"function"
}]
params
:
[
{
name
:
"node"
,
type
:
"node"
,
},
{
name
:
"function"
,
type
:
"function"
,
}
],
defaultParams
:
[
3
,
"sumSeries"
]
}
}
];
];
...
@@ -32,22 +43,8 @@ function (angular, _, config) {
...
@@ -32,22 +43,8 @@ function (angular, _, config) {
};
};
});
});
$scope
.
functions
=
[
$scope
.
funcDefs
=
funcDefs
;
{
$scope
.
functions
=
[];
text
:
"scaleToSeconds(1)"
,
def
:
graphiteFunctions
[
0
],
params
:
{
seconds
:
1
}
},
{
text
:
"groupByNode"
,
def
:
graphiteFunctions
[
2
],
params
:
{
}
}
];
};
};
function
getSegmentPathUpTo
(
index
)
{
function
getSegmentPathUpTo
(
index
)
{
...
@@ -89,6 +86,20 @@ function (angular, _, config) {
...
@@ -89,6 +86,20 @@ function (angular, _, config) {
});
});
}
}
function
getFuncText
(
funcDef
,
params
)
{
if
(
params
.
length
===
0
)
{
return
funcDef
.
name
+
'()'
;
}
var
text
=
funcDef
.
name
+
'('
;
_
.
each
(
funcDef
.
params
,
function
(
param
,
index
)
{
text
+=
params
[
index
]
+
', '
;
});
text
=
text
.
substring
(
0
,
text
.
length
-
2
);
text
+=
')'
;
return
text
;
}
$scope
.
getAltSegments
=
function
(
index
)
{
$scope
.
getAltSegments
=
function
(
index
)
{
$scope
.
altSegments
=
[];
$scope
.
altSegments
=
[];
...
@@ -133,20 +144,15 @@ function (angular, _, config) {
...
@@ -133,20 +144,15 @@ function (angular, _, config) {
};
};
$scope
.
functionParamsChanged
=
function
(
func
)
{
$scope
.
functionParamsChanged
=
function
(
func
)
{
func
.
text
=
func
.
def
.
name
+
'('
;
func
.
text
=
getFuncText
(
func
.
def
,
func
.
params
);
_
.
each
(
func
.
def
.
params
,
function
(
param
)
{
func
.
text
+=
func
.
params
[
param
.
name
]
+
', '
;
});
func
.
text
=
func
.
text
.
substring
(
0
,
func
.
text
.
length
-
2
);
func
.
text
+=
')'
;
};
};
$scope
.
addFunction
=
function
()
{
$scope
.
addFunction
=
function
(
funcDef
)
{
console
.
log
(
$scope
.
functions
);
$scope
.
functions
.
push
({
};
def
:
funcDef
,
params
:
funcDef
.
defaultParams
,
$scope
.
editFunction
=
function
()
{
text
:
getFuncText
(
funcDef
,
funcDef
.
defaultParams
)
//func.edit = true
;
})
;
};
};
});
});
...
@@ -157,7 +163,6 @@ function (angular, _, config) {
...
@@ -157,7 +163,6 @@ function (angular, _, config) {
link
:
function
(
scope
,
element
,
attrs
)
{
link
:
function
(
scope
,
element
,
attrs
)
{
var
model
=
$parse
(
attrs
.
focusMe
);
var
model
=
$parse
(
attrs
.
focusMe
);
scope
.
$watch
(
model
,
function
(
value
)
{
scope
.
$watch
(
model
,
function
(
value
)
{
console
.
log
(
'value='
,
value
);
if
(
value
===
true
)
{
if
(
value
===
true
)
{
$timeout
(
function
()
{
$timeout
(
function
()
{
element
[
0
].
focus
();
element
[
0
].
focus
();
...
...
src/app/panels/graphite/editor.html
View file @
76fa88cf
...
@@ -8,9 +8,13 @@
...
@@ -8,9 +8,13 @@
</span>
</span>
<ul
class=
"grafana-segment-list"
role=
"menu"
>
<ul
class=
"grafana-segment-list"
role=
"menu"
>
<li
class=
"dropdown"
ng-repeat=
"segment in segments"
role=
"menuitem"
>
<li
class=
"dropdown"
ng-repeat=
"segment in segments"
role=
"menuitem"
>
<a
tabindex=
"1"
class=
"grafana-target-segment dropdown-toggle"
<a
tabindex=
"1"
data-toggle=
"dropdown"
ng-click=
"getAltSegments($index)"
focus-me=
"segment.focus"
class=
"grafana-target-segment dropdown-toggle"
data-placement=
"bottom"
ng-bind-html-unsafe=
"segment.html"
></a>
data-toggle=
"dropdown"
ng-click=
"getAltSegments($index)"
focus-me=
"segment.focus"
ng-bind-html-unsafe=
"segment.html"
>
</a>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li
ng-repeat=
"altSegment in altSegments"
role=
"menuitem"
>
<li
ng-repeat=
"altSegment in altSegments"
role=
"menuitem"
>
<a
href=
"javascript:void(0)"
tabindex=
"1"
ng-click=
"setSegment($index, $parent.$index)"
ng-bind-html-unsafe=
"altSegment.html"
></a>
<a
href=
"javascript:void(0)"
tabindex=
"1"
ng-click=
"setSegment($index, $parent.$index)"
ng-bind-html-unsafe=
"altSegment.html"
></a>
...
@@ -34,8 +38,22 @@
...
@@ -34,8 +38,22 @@
<a
bs-popover=
"'app/panels/graphite/funcEditor.html'"
data-placement=
"top"
>
{{func.text}}
</a>
<a
bs-popover=
"'app/panels/graphite/funcEditor.html'"
data-placement=
"top"
>
{{func.text}}
</a>
<i
class=
"icon-long-arrow-right"
></i>
<i
class=
"icon-long-arrow-right"
></i>
</li>
</li>
<li>
<li
class=
"dropdown"
>
<a
ng-click=
"addFunction"
>
add function
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
tabindex=
"1"
ng-click=
"addFunction"
>
add function
</a>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li
ng-repeat=
"funcDef in funcDefs"
role=
"menuitem"
>
<a
href=
"javascript:void(0)"
tabindex=
"1"
ng-click=
"addFunction(funcDef)"
>
{{funcDef.name}}
</a>
</li>
</ul>
</li>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
...
src/app/panels/graphite/funcEditor.html
View file @
76fa88cf
<div
class=
"grafana-func-editor"
>
<div
class=
"grafana-func-editor"
>
<div
class=
"grafana-func-editor-header"
>
<div
class=
"grafana-func-editor-header"
>
<a
ng-click=
"removeFunction(func)"
>
<a
ng-click=
"removeFunction(func)"
>
Remove
Remove
</a>
</a>
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
<a
ng-click=
"dismiss()"
>
<a
ng-click=
"dismiss()"
>
Close
Close
</a>
</a>
</div>
</div>
<div
class=
"editor-row"
>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<div
class=
"section"
>
<div
class=
"editor-option"
ng-repeat=
"param in func.def.params"
>
<div
class=
"editor-option"
ng-repeat=
"param in func.def.params"
>
<label
class=
"small"
>
{{param.name}}
</label>
<label
class=
"small"
>
{{param.name}}
</label>
...
@@ -28,43 +28,23 @@
...
@@ -28,43 +28,23 @@
focus-me=
"true"
focus-me=
"true"
class=
"input-mini"
class=
"input-mini"
ng-change=
"functionParamsChanged(func)"
ng-model-onblur
ng-change=
"functionParamsChanged(func)"
ng-model-onblur
ng-model=
"func.params[param.name
]"
/>
ng-model=
"func.params[$index
]"
/>
<select
ng-if=
"param.type === 'node'"
<select
ng-if=
"param.type === 'node'"
class=
"input-mini"
class=
"input-mini"
ng-model=
"func.params[param.name
]"
ng-model=
"func.params[$index
]"
ng-change=
"functionParamsChanged(func)"
ng-change=
"functionParamsChanged(func)"
focus-me=
"true"
ng-options=
"f for f in [1,2,3,4,5,6,7,8,9,10]"
>
ng-options=
"f for f in [1,2,3,4,5,6,7,8,9,10]"
>
</select>
</select>
<select
ng-if=
"param.type === 'function'"
<select
ng-if=
"param.type === 'function'"
style=
"width: 110px"
style=
"width: 110px"
ng-change=
"functionParamsChanged(func)"
ng-change=
"functionParamsChanged(func)"
ng-model=
"func.params[param.name
]"
ng-model=
"func.params[$index
]"
ng-options=
"f for f in ['sumSeries', 'avgSeries']"
>
ng-options=
"f for f in ['sumSeries', 'avgSeries']"
>
</select>
</select>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="row-fluid">
<div class="pull-left">
<input ng-if="param.type === 'int'"
placeholder="seconds"
focus-me="true"
class="input-mini"
ng-model="func.params[param.name]" />
<select ng-if="param.type === 'node'"
class="input-mini"
ng-model="func.params[param.name]"
ng-options="f for f in [1,2,3,4,5,6,7,8,9,10]">
</select>
<select ng-if="param.type === 'function'"
class="input-small"
ng-model="func.params[param.name]"
ng-options="f for f in ['sumSeries', 'avgSeries']">
</select>
</div>
</div>
</div>
</div>
-->
</div>
\ No newline at end of file
\ 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