mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Small cleanup of dashboard partial, removed unused stuff
This commit is contained in:
parent
83e9bc4816
commit
9390b1eef5
@ -15,20 +15,6 @@ function (angular, _, moment) {
|
|||||||
|
|
||||||
var events = [];
|
var events = [];
|
||||||
|
|
||||||
var oldLog = console.log;
|
|
||||||
console.log = function (message) {
|
|
||||||
try {
|
|
||||||
if (_.isObject(message)) {
|
|
||||||
message = angular.toJson(message);
|
|
||||||
if (message.length > 50) {
|
|
||||||
message = message.substring(0, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
events.push(new ConsoleEvent('log', message, {}));
|
|
||||||
oldLog.apply(console, arguments);
|
|
||||||
} catch (e) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
function ConsoleEvent(type, title, data) {
|
function ConsoleEvent(type, title, data) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
@ -112,6 +98,7 @@ function (angular, _, moment) {
|
|||||||
$httpProvider.interceptors.push('mupp');
|
$httpProvider.interceptors.push('mupp');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
module.controller('ConsoleCtrl', function($scope) {
|
module.controller('ConsoleCtrl', function($scope) {
|
||||||
|
|
||||||
$scope.events = events;
|
$scope.events = events;
|
||||||
|
@ -26,6 +26,10 @@ function (angular, $, config, _) {
|
|||||||
$scope.setupDashboard = function(event, dashboardData) {
|
$scope.setupDashboard = function(event, dashboardData) {
|
||||||
timer.cancel_all();
|
timer.cancel_all();
|
||||||
|
|
||||||
|
$scope.performance.dashboardLoadStart = new Date().getTime();
|
||||||
|
$scope.performance.panelsInitialized = 0;
|
||||||
|
$scope.performance.panelsRendered= 0;
|
||||||
|
|
||||||
$scope.dashboard = dashboardSrv.create(dashboardData);
|
$scope.dashboard = dashboardSrv.create(dashboardData);
|
||||||
$scope.dashboardViewState = dashboardViewStateSrv.create($scope);
|
$scope.dashboardViewState = dashboardViewStateSrv.create($scope);
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'config',
|
'config',
|
||||||
'lodash',
|
'lodash',
|
||||||
|
'jquery',
|
||||||
],
|
],
|
||||||
function (angular, config, _) {
|
function (angular, config, _, $) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
@ -11,6 +12,20 @@ function (angular, config, _) {
|
|||||||
module.controller('GrafanaCtrl', function($scope, alertSrv, grafanaVersion, $rootScope) {
|
module.controller('GrafanaCtrl', function($scope, alertSrv, grafanaVersion, $rootScope) {
|
||||||
|
|
||||||
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
|
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
|
||||||
|
$scope.performance = { loadStart: new Date().getTime() };
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
$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.init = function() {
|
$scope.init = function() {
|
||||||
$scope._ = _;
|
$scope._ = _;
|
||||||
@ -46,6 +61,29 @@ function (angular, config, _) {
|
|||||||
"#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7
|
"#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$scope.getTotalWatcherCount = function() {
|
||||||
|
var count = 0;
|
||||||
|
var scopes = 0;
|
||||||
|
var root = $(document.getElementsByTagName('body'));
|
||||||
|
|
||||||
|
var f = function (element) {
|
||||||
|
if (element.data().hasOwnProperty('$scope')) {
|
||||||
|
scopes++;
|
||||||
|
angular.forEach(element.data().$scope.$$watchers, function () {
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
angular.forEach(element.children(), function (childElement) {
|
||||||
|
f($(childElement));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
f(root);
|
||||||
|
$scope.performance.scopeCount = scopes;
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.init();
|
$scope.init();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Panels -->
|
<!-- Panels -->
|
||||||
<div ng-repeat="(name, panel) in row.panels|filter:isPanel" ng-hide="panel.hide" class="panel nospace" ng-style="{'width':(panel.span/1.2)*10+'%'}" data-drop="true" ng-model="row.panels" data-jqyoui-options jqyoui-droppable="{index:$index,mutate:false,onDrop:'panelMoveDrop',onOver:'panelMoveOver(true)',onOut:'panelMoveOut'}" ng-class="{'dragInProgress':dashboard.$$panelDragging}">
|
<div ng-repeat="(name, panel) in row.panels" class="panel nospace" ng-style="{'width':(panel.span/1.2)*10+'%'}" data-drop="true" ng-model="row.panels" data-jqyoui-options jqyoui-droppable="{index:$index,mutate:false,onDrop:'panelMoveDrop',onOver:'panelMoveOver(true)',onOut:'panelMoveOut'}" ng-class="{'dragInProgress':dashboard.$$panelDragging}">
|
||||||
<!-- Content Panel -->
|
<!-- Content Panel -->
|
||||||
<div style="position:relative">
|
<div style="position:relative">
|
||||||
<grafana-panel type="panel.type" ng-cloak></grafana-panel>
|
<grafana-panel type="panel.type" ng-cloak></grafana-panel>
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<div style="margin-top:50px" ng-controller="dashcontrol">
|
|
||||||
<strong>type: </strong>{{type}} <br>
|
|
||||||
<strong>id: </strong>{{id}} <br>
|
|
||||||
</div>
|
|
@ -31,7 +31,6 @@
|
|||||||
<th>Delete</th>
|
<th>Delete</th>
|
||||||
<th>Move</th>
|
<th>Move</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Hide</th>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="panel in row.panels">
|
<tr ng-repeat="panel in row.panels">
|
||||||
<td>{{panel.title}}</td>
|
<td>{{panel.title}}</td>
|
||||||
@ -40,7 +39,6 @@
|
|||||||
<td><i ng-click="row.panels = _.without(row.panels,panel)" class="pointer icon-remove"></i></td>
|
<td><i ng-click="row.panels = _.without(row.panels,panel)" class="pointer icon-remove"></i></td>
|
||||||
<td><i ng-click="_.move(row.panels,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
|
<td><i ng-click="_.move(row.panels,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
|
||||||
<td><i ng-click="_.move(row.panels,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
|
<td><i ng-click="_.move(row.panels,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
|
||||||
<td><input type="checkbox" ng-model="panel.hide" ng-checked="panel.hide"></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,6 +129,12 @@ function (angular, _) {
|
|||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.performance.panelsInitialized++;
|
||||||
|
if ($scope.performance.panelsInitialized === $scope.dashboard.rows.length) {
|
||||||
|
var timeTaken = new Date().getTime() - $scope.performance.dashboardLoadStart;
|
||||||
|
console.log("Dashboard::Performance - All panels initialized in " + timeTaken + " ms");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user