mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
small refactoring progress
This commit is contained in:
parent
61cd5cf4e6
commit
2328c60d12
@ -31,21 +31,24 @@ function (angular, $, config, _) {
|
|||||||
var module = angular.module('kibana.controllers');
|
var module = angular.module('kibana.controllers');
|
||||||
|
|
||||||
module.controller('DashCtrl', function(
|
module.controller('DashCtrl', function(
|
||||||
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv) {
|
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv, timer) {
|
||||||
|
|
||||||
$scope.editor = { index: 0 };
|
$scope.editor = { index: 0 };
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.reset_row();
|
$scope.availablePanels = config.panels;
|
||||||
dashboardKeybindings.shortcuts();
|
|
||||||
|
|
||||||
// Clear existing alerts
|
dashboardKeybindings.shortcuts();
|
||||||
alertSrv.clearAll();
|
|
||||||
|
|
||||||
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard, $scope);
|
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard, $scope);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setupDashboard = function(event, dashboardData) {
|
$scope.setupDashboard = function(event, dashboardData) {
|
||||||
|
timer.cancel_all();
|
||||||
|
alertSrv.clearAll();
|
||||||
|
|
||||||
|
$rootScope.fullscreen = false;
|
||||||
|
|
||||||
$scope.dashboard = dashboard.create(dashboardData);
|
$scope.dashboard = dashboard.create(dashboardData);
|
||||||
$scope.filter = filterSrv;
|
$scope.filter = filterSrv;
|
||||||
$scope.filter.init($scope.dashboard);
|
$scope.filter.init($scope.dashboard);
|
||||||
@ -58,6 +61,8 @@ function (angular, $, config, _) {
|
|||||||
$scope.panelMoveOver = panelMove.onOver;
|
$scope.panelMoveOver = panelMove.onOver;
|
||||||
$scope.panelMoveOut = panelMove.onOut;
|
$scope.panelMoveOut = panelMove.onOut;
|
||||||
|
|
||||||
|
window.document.title = 'Grafana - ' + $scope.dashboard.title;
|
||||||
|
|
||||||
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
|
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
<div class="row-fluid" ng-if="editor.index == 2">
|
<div class="row-fluid" ng-if="editor.index == 2">
|
||||||
<h4>Select Panel Type</h4>
|
<h4>Select Panel Type</h4>
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
<select class="input-medium" ng-model="panel.type" ng-options="panelType for panelType in dashboard.availablePanels|stringSort"></select>
|
<select class="input-medium" ng-model="panel.type" ng-options="panelType for panelType in availablePanels|stringSort"></select>
|
||||||
<small ng-show="rowSpan(row) > 11">
|
<small ng-show="rowSpan(row) > 11">
|
||||||
Note: This row is full, new panels will wrap to a new line. You should add another row.
|
Note: This row is full, new panels will wrap to a new line. You should add another row.
|
||||||
</small>
|
</small>
|
||||||
|
@ -16,6 +16,7 @@ function (angular, $, kbn, _) {
|
|||||||
module.service('dashboard', function(timer, $rootScope, $timeout) {
|
module.service('dashboard', function(timer, $rootScope, $timeout) {
|
||||||
|
|
||||||
function DashboardModel (data) {
|
function DashboardModel (data) {
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = {};
|
data = {};
|
||||||
}
|
}
|
||||||
@ -77,18 +78,22 @@ function (angular, $, kbn, _) {
|
|||||||
if (interval) {
|
if (interval) {
|
||||||
var _i = kbn.interval_to_ms(interval);
|
var _i = kbn.interval_to_ms(interval);
|
||||||
timer.cancel(this.refresh_timer);
|
timer.cancel(this.refresh_timer);
|
||||||
var dashboard_reference = this;
|
var self = this;
|
||||||
|
|
||||||
this.refresh_timer = timer.register($timeout(function() {
|
this.refresh_timer = timer.register($timeout(function() {
|
||||||
dashboard_reference.set_interval(interval);
|
self.set_interval(interval);
|
||||||
dashboard_reference.full_refresh();
|
self.emit_refresh();
|
||||||
},_i));
|
},_i));
|
||||||
this.full_refresh();
|
this.emit_refresh();
|
||||||
} else {
|
} else {
|
||||||
timer.cancel(this.refresh_timer);
|
timer.cancel(this.refresh_timer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// An elasticJS client to use
|
||||||
|
/*var ejs = ejsResource(config.elasticsearch, config.elasticsearchBasicAuth);
|
||||||
|
var gist_pattern = /(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;
|
||||||
|
*/
|
||||||
return {
|
return {
|
||||||
create: function(dashboard) {
|
create: function(dashboard) {
|
||||||
return new DashboardModel(dashboard);
|
return new DashboardModel(dashboard);
|
||||||
|
Loading…
Reference in New Issue
Block a user