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
aee3ddd0
Commit
aee3ddd0
authored
Aug 14, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified panel bootstrapping, limiting digest cycles during dashboard boot
parent
0ca6b671
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
34 deletions
+28
-34
src/app/controllers/grafanaCtrl.js
+15
-5
src/app/directives/grafanaPanel.js
+12
-27
src/app/services/panelSrv.js
+1
-2
No files found.
src/app/controllers/grafanaCtrl.js
View file @
aee3ddd0
...
...
@@ -78,17 +78,27 @@ function (angular, config, _, $) {
$scope
.
initProfiling
=
function
()
{
var
count
=
0
;
console
.
log
(
"registering digest counter"
);
$scope
.
$watch
(
function
()
{
console
.
log
(
1
);
count
++
;
},
function
()
{
});
setTimeout
(
function
()
{
console
.
log
(
"Dashboard::Performance Total Digests: "
+
count
);
console
.
log
(
"Dashboard::Performance Total Watchers: "
+
$scope
.
getTotalWatcherCount
());
console
.
log
(
"Dashboard::Performance Total ScopeCount: "
+
$scope
.
performance
.
scopeCount
);
},
3000
);
$scope
.
onAppEvent
(
'setup-dashboard'
,
function
()
{
count
=
0
;
setTimeout
(
function
()
{
console
.
log
(
"Dashboard::Performance Total Digests: "
+
count
);
console
.
log
(
"Dashboard::Performance Total Watchers: "
+
$scope
.
getTotalWatcherCount
());
console
.
log
(
"Dashboard::Performance Total ScopeCount: "
+
$rootScope
.
performance
.
scopeCount
);
var
timeTaken
=
$rootScope
.
performance
.
allPanelsInitialized
-
$rootScope
.
performance
.
dashboardLoadStart
;
console
.
log
(
"Dashboard::Performance - All panels initialized in "
+
timeTaken
+
" ms"
);
},
3000
);
});
};
...
...
src/app/directives/grafanaPanel.js
View file @
aee3ddd0
...
...
@@ -8,7 +8,7 @@ function (angular, $) {
angular
.
module
(
'grafana.directives'
)
.
directive
(
'grafanaPanel'
,
function
(
$compile
)
{
.
directive
(
'grafanaPanel'
,
function
(
$compile
,
$parse
)
{
var
container
=
'<div class="panel-container"></div>'
;
var
content
=
'<div class="panel-content"></div>'
;
...
...
@@ -51,8 +51,7 @@ function (angular, $) {
return
{
restrict
:
'E'
,
link
:
function
(
$scope
,
elem
,
attr
)
{
// once we have the template, scan it for controllers and
// load the module.js if we have any
var
getter
=
$parse
(
attr
.
type
),
panelType
=
getter
(
$scope
);
var
newScope
=
$scope
.
$new
();
$scope
.
kbnJqUiDraggableOptions
=
{
...
...
@@ -77,31 +76,17 @@ function (angular, $) {
elem
.
remove
();
});
$scope
.
$watch
(
attr
.
type
,
function
(
name
)
{
elem
.
addClass
(
"ng-cloak"
);
// load the panels module file, then render it in the dom.
var
nameAsPath
=
name
.
replace
(
"."
,
"/"
);
$scope
.
require
([
'jquery'
,
'text!panels/'
+
nameAsPath
+
'/module.html'
],
function
(
$
,
moduleTemplate
)
{
var
$module
=
$
(
moduleTemplate
);
// top level controllers
var
$controllers
=
$module
.
filter
(
'ngcontroller, [ng-controller], .ng-controller'
);
// add child controllers
$controllers
=
$controllers
.
add
(
$module
.
find
(
'ngcontroller, [ng-controller], .ng-controller'
));
elem
.
addClass
(
'ng-cloak'
);
if
(
$controllers
.
length
)
{
$controllers
.
first
().
prepend
(
panelHeader
);
$controllers
.
first
().
find
(
'.panel-header'
).
nextAll
().
wrapAll
(
content
);
$scope
.
require
([
'panels/'
+
nameAsPath
+
'/module'
],
function
()
{
loadModule
(
$module
);
});
}
else
{
loadModule
(
$module
);
}
});
$scope
.
require
([
'jquery'
,
'text!panels/'
+
panelType
+
'/module.html'
,
'panels/'
+
panelType
+
"/module"
,
],
function
(
$
,
moduleTemplate
)
{
var
$module
=
$
(
moduleTemplate
);
$module
.
prepend
(
panelHeader
);
$module
.
first
().
find
(
'.panel-header'
).
nextAll
().
wrapAll
(
content
);
loadModule
(
$module
);
});
}
...
...
src/app/services/panelSrv.js
View file @
aee3ddd0
...
...
@@ -133,8 +133,7 @@ function (angular, _) {
if
(
$rootScope
.
profilingEnabled
)
{
$rootScope
.
performance
.
panelsInitialized
++
;
if
(
$rootScope
.
performance
.
panelsInitialized
===
$scope
.
dashboard
.
rows
.
length
)
{
var
timeTaken
=
new
Date
().
getTime
()
-
$scope
.
performance
.
dashboardLoadStart
;
console
.
log
(
"Dashboard::Performance - All panels initialized in "
+
timeTaken
+
" ms"
);
$rootScope
.
performance
.
allPanelsInitialized
=
new
Date
().
getTime
();
}
}
};
...
...
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