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
bcc3efff
Commit
bcc3efff
authored
Jan 06, 2014
by
Torkel Odegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: import dashboards from graphite (WIP)
parent
1dba1942
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
5 deletions
+136
-5
src/app/controllers/all.js
+3
-1
src/app/controllers/graphiteImport.js
+91
-0
src/app/partials/dashboard.html
+1
-1
src/app/partials/dasheditor.html
+7
-3
src/app/partials/import.html
+22
-0
src/app/services/graphite/graphiteSrv.js
+12
-0
No files found.
src/app/controllers/all.js
View file @
bcc3efff
...
@@ -5,5 +5,6 @@ define([
...
@@ -5,5 +5,6 @@ define([
'./pulldown'
,
'./pulldown'
,
'./search'
,
'./search'
,
'./metricKeys'
,
'./metricKeys'
,
'./graphiteTarget'
'./graphiteTarget'
,
'./graphiteImport'
,
],
function
()
{});
],
function
()
{});
\ No newline at end of file
src/app/controllers/graphiteImport.js
0 → 100644
View file @
bcc3efff
define
([
'angular'
,
'app'
,
'underscore'
],
function
(
angular
,
app
,
_
)
{
'use strict'
;
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'GraphiteImportCtrl'
,
function
(
$scope
,
$rootScope
,
$timeout
,
graphiteSrv
,
dashboard
)
{
$scope
.
init
=
function
()
{
console
.
log
(
'hej!'
);
};
$scope
.
listAll
=
function
(
query
)
{
delete
$scope
.
error
;
graphiteSrv
.
listDashboards
(
query
)
.
then
(
function
(
results
)
{
$scope
.
dashboards
=
results
;
})
.
then
(
null
,
function
(
err
)
{
$scope
.
error
=
err
.
message
||
'Error while fetching list of dashboards'
;
});
};
$scope
.
import
=
function
(
dashName
)
{
delete
$scope
.
error
;
graphiteSrv
.
loadDashboard
(
dashName
)
.
then
(
function
(
results
)
{
if
(
!
results
.
data
||
!
results
.
data
.
state
)
{
throw
{
message
:
'no dashboard state received from graphite'
};
}
graphiteToGrafanaTranslator
(
results
.
data
.
state
);
})
.
then
(
null
,
function
(
err
)
{
$scope
.
error
=
err
.
message
||
'Failed to import dashboard'
;
});
};
function
graphiteToGrafanaTranslator
(
state
)
{
var
graphsPerRow
=
2
;
var
rowHeight
=
300
;
var
rowTemplate
;
var
currentRow
;
var
panel
;
rowTemplate
=
{
title
:
''
,
panels
:
[],
height
:
rowHeight
};
currentRow
=
angular
.
copy
(
rowTemplate
);
var
newDashboard
=
angular
.
copy
(
dashboard
.
current
);
newDashboard
.
rows
=
[];
newDashboard
.
title
=
state
.
name
;
newDashboard
.
rows
.
push
(
currentRow
);
_
.
each
(
state
.
graphs
,
function
(
graph
)
{
if
(
currentRow
.
panels
.
length
===
graphsPerRow
)
{
currentRow
=
angular
.
copy
(
rowTemplate
);
}
panel
=
{
type
:
'graphite'
,
span
:
12
/
graphsPerRow
,
targets
:
[]
};
_
.
each
(
graph
[
1
].
target
,
function
(
target
)
{
panel
.
targets
.
push
({
target
:
target
});
});
currentRow
.
panels
.
push
(
panel
);
});
dashboard
.
dash_load
(
newDashboard
);
}
});
});
\ No newline at end of file
src/app/partials/dashboard.html
View file @
bcc3efff
...
@@ -77,7 +77,7 @@
...
@@ -77,7 +77,7 @@
<div
class=
"row-fluid"
ng-show=
'dashboard.current.editable && dashboard.current.panel_hints'
>
<div
class=
"row-fluid"
ng-show=
'dashboard.current.editable && dashboard.current.panel_hints'
>
<div
class=
"span12"
style=
"text-align:right;"
>
<div
class=
"span12"
style=
"text-align:right;"
>
<span
style=
"margin-left: 0px;"
class=
"pointer btn btn-mini"
bs-modal=
"'app/partials/dasheditor.html'"
>
<span
style=
"margin-left: 0px;"
class=
"pointer btn btn-mini"
bs-modal=
"'app/partials/dasheditor.html'"
>
<span
ng-click=
"editor.index =
2
"
><i
class=
"icon-plus-sign"
></i>
ADD A ROW
</span>
<span
ng-click=
"editor.index =
1
"
><i
class=
"icon-plus-sign"
></i>
ADD A ROW
</span>
</span>
</span>
</div>
</div>
</div>
</div>
...
...
src/app/partials/dasheditor.html
View file @
bcc3efff
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"pull-right editor-title"
>
Dashboard settings
</div>
<div
class=
"pull-right editor-title"
>
Dashboard settings
</div>
<div
ng-model=
"editor.index"
bs-tabs
style=
"text-transform:capitalize;"
>
<div
ng-model=
"editor.index"
bs-tabs
style=
"text-transform:capitalize;"
>
<div
ng-repeat=
"tab in ['General', 'Rows','Controls', 'Metrics']"
data-title=
"{{tab}}"
>
<div
ng-repeat=
"tab in ['General', 'Rows','Controls', 'Metrics'
, 'Import'
]"
data-title=
"{{tab}}"
>
</div>
</div>
<div
ng-repeat=
"tab in dashboard.current.nav"
data-title=
"{{tab.type}}"
>
<div
ng-repeat=
"tab in dashboard.current.nav"
data-title=
"{{tab.type}}"
>
</div>
</div>
...
@@ -124,11 +124,15 @@
...
@@ -124,11 +124,15 @@
</div>
</div>
</div>
</div>
<div
ng-
show
=
"editor.index == 3"
>
<div
ng-
if
=
"editor.index == 3"
>
<ng-include
src=
"'app/partials/loadmetrics.html'"
></ng-include>
<ng-include
src=
"'app/partials/loadmetrics.html'"
></ng-include>
</div>
</div>
<div
ng-repeat=
"pulldown in dashboard.current.nav"
ng-controller=
"PulldownCtrl"
ng-show=
"editor.index == 4+$index"
>
<div
ng-if=
"editor.index == 4"
>
<ng-include
src=
"'app/partials/import.html'"
></ng-include>
</div>
<div
ng-repeat=
"pulldown in dashboard.current.nav"
ng-controller=
"PulldownCtrl"
ng-show=
"editor.index == 5+$index"
>
<ng-include
ng-show=
"pulldown.enable"
src=
"edit_path(pulldown.type)"
></ng-include>
<ng-include
ng-show=
"pulldown.enable"
src=
"edit_path(pulldown.type)"
></ng-include>
<button
ng-hide=
"pulldown.enable"
class=
"btn"
ng-click=
"pulldown.enable = true"
>
Enable the {{pulldown.type}}
</button>
<button
ng-hide=
"pulldown.enable"
class=
"btn"
ng-click=
"pulldown.enable = true"
>
Enable the {{pulldown.type}}
</button>
</div>
</div>
...
...
src/app/partials/import.html
0 → 100644
View file @
bcc3efff
<div
ng-controller=
"GraphiteImportCtrl"
ng-init=
"init()"
>
<h5>
Import dashboards from graphite webb
</h5>
<div
class=
"editor-row"
>
<div
class=
"section"
>
<button
ng-click=
"listAll()"
class=
"btn btn-primary"
>
List all dashboards
</button>
</div>
</div>
<div
class=
"editor-row"
style=
"margin-top: 10px;"
>
<table
class=
"table table-condensed table-striped"
>
<tr
ng-repeat=
"dash in dashboards"
>
<td
style=
"padding-right: 20px;"
><button
class=
"btn btn-success"
ng-click=
"import(dash.name)"
>
Import
</button>
<td
style=
"width: 100%; vertical-align: middle;"
>
{{dash.name}}
</td>
</tr>
</table>
</div>
<div
ng-show=
"error"
style=
"margin-top: 20px"
class=
"alert alert-error"
>
{{error}}
</div>
</div>
src/app/services/graphite/graphiteSrv.js
View file @
bcc3efff
...
@@ -71,6 +71,18 @@ function (angular, _, $, config) {
...
@@ -71,6 +71,18 @@ function (angular, _, $, config) {
});
});
};
};
this
.
listDashboards
=
function
(
query
)
{
var
url
=
config
.
graphiteUrl
+
'/dashboard/find/'
;
return
$http
.
get
(
url
,
{
params
:
{
query
:
query
||
''
}})
.
then
(
function
(
results
)
{
return
results
.
data
.
dashboards
;
});
};
this
.
loadDashboard
=
function
(
dashName
)
{
var
url
=
config
.
graphiteUrl
+
'/dashboard/load/'
+
encodeURIComponent
(
dashName
);
return
$http
.
get
(
url
);
};
function
buildGraphitePostParams
(
options
)
{
function
buildGraphitePostParams
(
options
)
{
var
clean_options
=
[];
var
clean_options
=
[];
...
...
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