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
8cba5940
Commit
8cba5940
authored
Apr 03, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:nikicat/grafana into nikicat-master
parents
f2c9cc17
a1632e48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
src/app/controllers/graphiteImport.js
+19
-5
src/app/partials/import.html
+10
-1
No files found.
src/app/controllers/graphiteImport.js
View file @
8cba5940
...
...
@@ -12,12 +12,25 @@ function (angular, app, _) {
$scope
.
init
=
function
()
{
console
.
log
(
'hej!'
);
$scope
.
datasources
=
datasourceSrv
.
listOptions
();
$scope
.
setDatasource
(
null
);
};
$scope
.
setDatasource
=
function
(
datasource
)
{
$scope
.
datasource
=
datasourceSrv
.
get
(
datasource
);
if
(
!
$scope
.
datasource
)
{
$scope
.
error
=
"Cannot find datasource "
+
datasource
;
return
;
}
};
$scope
.
listAll
=
function
(
query
)
{
delete
$scope
.
error
;
datasourceSrv
.
default
.
listDashboards
(
query
)
$scope
.
datasource
.
listDashboards
(
query
)
.
then
(
function
(
results
)
{
$scope
.
dashboards
=
results
;
})
...
...
@@ -29,20 +42,20 @@ function (angular, app, _) {
$scope
.
import
=
function
(
dashName
)
{
delete
$scope
.
error
;
datasourceSrv
.
default
.
loadDashboard
(
dashName
)
$scope
.
datasource
.
loadDashboard
(
dashName
)
.
then
(
function
(
results
)
{
if
(
!
results
.
data
||
!
results
.
data
.
state
)
{
throw
{
message
:
'no dashboard state received from graphite'
};
}
graphiteToGrafanaTranslator
(
results
.
data
.
state
);
graphiteToGrafanaTranslator
(
results
.
data
.
state
,
$scope
.
datasource
.
name
);
})
.
then
(
null
,
function
(
err
)
{
$scope
.
error
=
err
.
message
||
'Failed to import dashboard'
;
});
};
function
graphiteToGrafanaTranslator
(
state
)
{
function
graphiteToGrafanaTranslator
(
state
,
datasource
)
{
var
graphsPerRow
=
2
;
var
rowHeight
=
300
;
var
rowTemplate
;
...
...
@@ -72,7 +85,8 @@ function (angular, app, _) {
type
:
'graphite'
,
span
:
12
/
graphsPerRow
,
title
:
graph
[
1
].
title
,
targets
:
[]
targets
:
[],
datasource
:
datasource
};
_
.
each
(
graph
[
1
].
target
,
function
(
target
)
{
...
...
src/app/partials/import.html
View file @
8cba5940
<div
ng-controller=
"GraphiteImportCtrl"
ng-init=
"init()"
>
<div
ng-controller=
"GraphiteImportCtrl"
ng-init=
"init()"
style=
"height: 400px"
>
<h5>
Import dashboards from graphite web
</h5>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<div
class=
"btn-group"
>
<button
class=
"btn btn-info dropdown-toggle"
data-toggle=
"dropdown"
bs-tooltip=
"'Datasource'"
>
{{datasource.name}}
<span
class=
"caret"
></span></button>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li
ng-repeat=
"datasource in datasources"
role=
"menuitem"
>
<a
ng-click=
"setDatasource(datasource.value);"
>
{{datasource.name}}
</a>
</li>
</ul>
</div>
<button
ng-click=
"listAll()"
class=
"btn btn-primary"
>
List all dashboards
</button>
</div>
</div>
...
...
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