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
1eb9efe2
Commit
1eb9efe2
authored
Jun 08, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing broken things
parent
d5882f2e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
73 deletions
+28
-73
src/app/controllers/dash.js
+4
-1
src/app/controllers/grafanaCtrl.js
+0
-3
src/app/routes/dashboard-from-es.js
+6
-63
src/app/services/dashboard.js
+5
-1
src/app/services/filterSrv.js
+13
-5
No files found.
src/app/controllers/dash.js
View file @
1eb9efe2
...
...
@@ -31,7 +31,7 @@ function (angular, $, config, _) {
var
module
=
angular
.
module
(
'kibana.controllers'
);
module
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
,
dashboardKeybindings
,
filterSrv
,
dashboard
,
panelMoveSrv
)
{
$scope
,
$rootScope
,
dashboardKeybindings
,
filterSrv
,
dashboard
,
panelMoveSrv
,
alertSrv
)
{
$scope
.
editor
=
{
index
:
0
};
...
...
@@ -39,6 +39,9 @@ function (angular, $, config, _) {
$scope
.
reset_row
();
dashboardKeybindings
.
shortcuts
();
// Clear existing alerts
alertSrv
.
clearAll
();
$scope
.
onAppEvent
(
'setup-dashboard'
,
$scope
.
setupDashboard
,
$scope
);
};
...
...
src/app/controllers/grafanaCtrl.js
View file @
1eb9efe2
...
...
@@ -15,9 +15,6 @@ function (angular, config, _) {
$scope
.
init
=
function
()
{
$scope
.
_
=
_
;
$scope
.
dashAlerts
=
alertSrv
;
// Clear existing alerts
alertSrv
.
clearAll
();
};
$scope
.
onAppEvent
=
function
(
name
,
callback
,
scope
)
{
...
...
src/app/routes/dashboard-from-es.js
View file @
1eb9efe2
...
...
@@ -14,10 +14,6 @@ function (angular, $, config, _) {
.
when
(
'/dashboard/elasticsearch/:id'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
controller
:
'DashFromElasticProvider'
,
})
.
when
(
'/dashboard/file/:jsonFile'
,
{
templateUrl
:
'app/partials/dashboard.html'
,
controller
:
'DashFromFileProvider'
,
});
});
...
...
@@ -30,8 +26,12 @@ function (angular, $, config, _) {
url
:
url
+
'?'
+
new
Date
().
getTime
(),
method
:
"GET"
,
transformResponse
:
function
(
response
)
{
var
dashJson
=
angular
.
fromJson
(
response
).
_source
.
dashboard
;
return
angular
.
fromJson
(
dashJson
);
var
esResponse
=
angular
.
fromJson
(
response
);
if
(
esResponse
.
_source
&&
esResponse
.
_source
.
dashboard
)
{
return
angular
.
fromJson
(
esResponse
.
_source
.
dashboard
);
}
else
{
return
false
;
}
}
};
...
...
@@ -60,61 +60,4 @@ function (angular, $, config, _) {
});
module
.
controller
(
'DashFromFileProvider'
,
function
(
$scope
,
$rootScope
,
$http
,
$routeParams
,
alertSrv
,
dashboard
,
filterSrv
,
panelMoveSrv
)
{
$scope
.
init
=
function
()
{
file_load
(
$routeParams
.
jsonFile
).
then
(
function
(
data
)
{
$scope
.
dashboard
=
dashboard
.
create
(
data
);
$scope
.
filter
=
filterSrv
;
$scope
.
filter
.
init
(
$scope
.
dashboard
);
var
panelMove
=
panelMoveSrv
.
create
(
$scope
.
dashboard
);
// For moving stuff around the dashboard.
$scope
.
panelMoveDrop
=
panelMove
.
onDrop
;
$scope
.
panelMoveStart
=
panelMove
.
onStart
;
$scope
.
panelMoveStop
=
panelMove
.
onStop
;
$scope
.
panelMoveOver
=
panelMove
.
onOver
;
$scope
.
panelMoveOut
=
panelMove
.
onOut
;
$rootScope
.
$emit
(
"dashboard-loaded"
,
$scope
.
dashboard
);
});
};
var
renderTemplate
=
function
(
json
,
params
)
{
var
_r
;
_
.
templateSettings
=
{
interpolate
:
/
\{\{(
.+
?)\}\}
/g
};
var
template
=
_
.
template
(
json
);
var
rendered
=
template
({
ARGS
:
params
});
try
{
_r
=
angular
.
fromJson
(
rendered
);
}
catch
(
e
)
{
_r
=
false
;
}
return
_r
;
};
var
file_load
=
function
(
file
)
{
return
$http
({
url
:
"app/dashboards/"
+
file
.
replace
(
/
\.(?!
json
)
/
,
"/"
)
+
'?'
+
new
Date
().
getTime
(),
method
:
"GET"
,
transformResponse
:
function
(
response
)
{
return
renderTemplate
(
response
,
$routeParams
);
}
}).
then
(
function
(
result
)
{
if
(
!
result
)
{
return
false
;
}
return
result
.
data
;
},
function
()
{
alertSrv
.
set
(
'Error'
,
"Could not load <i>dashboards/"
+
file
+
"</i>. Please make sure it exists"
,
'error'
);
return
false
;
});
};
$scope
.
init
();
});
});
src/app/services/dashboard.js
View file @
1eb9efe2
...
...
@@ -16,6 +16,10 @@ function (angular, $, kbn, _) {
module
.
service
(
'dashboard'
,
function
(
timer
,
$rootScope
,
$timeout
)
{
function
DashboardModel
(
data
)
{
if
(
!
data
)
{
data
=
{};
};
this
.
title
=
data
.
title
;
this
.
tags
=
data
.
tags
||
[];
this
.
style
=
data
.
style
||
"dark"
;
...
...
@@ -25,7 +29,7 @@ function (angular, $, kbn, _) {
this
.
pulldowns
=
data
.
pulldowns
||
[];
this
.
nav
=
data
.
nav
||
[];
this
.
services
=
data
.
services
||
{};
this
.
loader
=
data
.
loader
;
this
.
loader
=
data
.
loader
||
{}
;
_
.
defaults
(
this
.
loader
,
{
save_gist
:
false
,
...
...
src/app/services/filterSrv.js
View file @
1eb9efe2
...
...
@@ -94,14 +94,22 @@ define([
this
.
dashboard
=
dashboard
;
this
.
templateSettings
=
{
interpolate
:
/
\[\[([\s\S]
+
?)\]\]
/g
};
if
(
dashboard
.
services
&&
dashboard
.
services
.
filter
)
{
this
.
time
=
dashboard
.
services
.
filter
.
time
;
this
.
templateParameters
=
dashboard
.
services
.
filter
.
list
||
[];
this
.
updateTemplateData
(
true
);
/* if (!this.dashboard.services.filter) {
this.dashboard.services.filter = {
list: [],
time: {
from: '1h',
to: 'now'
}
};
}
*/
this
.
time
=
dashboard
.
services
.
filter
.
time
;
this
.
templateParameters
=
dashboard
.
services
.
filter
.
list
||
[];
this
.
updateTemplateData
(
true
);
}
};
return
result
;
});
...
...
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