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');
|
||||
|
||||
module.controller('DashCtrl', function(
|
||||
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv) {
|
||||
$scope, $rootScope, dashboardKeybindings, filterSrv, dashboard, panelMoveSrv, alertSrv, timer) {
|
||||
|
||||
$scope.editor = { index: 0 };
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.reset_row();
|
||||
dashboardKeybindings.shortcuts();
|
||||
$scope.availablePanels = config.panels;
|
||||
|
||||
// Clear existing alerts
|
||||
alertSrv.clearAll();
|
||||
dashboardKeybindings.shortcuts();
|
||||
|
||||
$scope.onAppEvent('setup-dashboard', $scope.setupDashboard, $scope);
|
||||
};
|
||||
|
||||
$scope.setupDashboard = function(event, dashboardData) {
|
||||
timer.cancel_all();
|
||||
alertSrv.clearAll();
|
||||
|
||||
$rootScope.fullscreen = false;
|
||||
|
||||
$scope.dashboard = dashboard.create(dashboardData);
|
||||
$scope.filter = filterSrv;
|
||||
$scope.filter.init($scope.dashboard);
|
||||
@ -58,6 +61,8 @@ function (angular, $, config, _) {
|
||||
$scope.panelMoveOver = panelMove.onOver;
|
||||
$scope.panelMoveOut = panelMove.onOut;
|
||||
|
||||
window.document.title = 'Grafana - ' + $scope.dashboard.title;
|
||||
|
||||
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
|
||||
};
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
<div class="row-fluid" ng-if="editor.index == 2">
|
||||
<h4>Select Panel Type</h4>
|
||||
<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">
|
||||
Note: This row is full, new panels will wrap to a new line. You should add another row.
|
||||
</small>
|
||||
|
@ -16,6 +16,7 @@ function (angular, $, kbn, _) {
|
||||
module.service('dashboard', function(timer, $rootScope, $timeout) {
|
||||
|
||||
function DashboardModel (data) {
|
||||
|
||||
if (!data) {
|
||||
data = {};
|
||||
}
|
||||
@ -77,18 +78,22 @@ function (angular, $, kbn, _) {
|
||||
if (interval) {
|
||||
var _i = kbn.interval_to_ms(interval);
|
||||
timer.cancel(this.refresh_timer);
|
||||
var dashboard_reference = this;
|
||||
var self = this;
|
||||
|
||||
this.refresh_timer = timer.register($timeout(function() {
|
||||
dashboard_reference.set_interval(interval);
|
||||
dashboard_reference.full_refresh();
|
||||
self.set_interval(interval);
|
||||
self.emit_refresh();
|
||||
},_i));
|
||||
this.full_refresh();
|
||||
this.emit_refresh();
|
||||
} else {
|
||||
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 {
|
||||
create: function(dashboard) {
|
||||
return new DashboardModel(dashboard);
|
||||
|
Loading…
Reference in New Issue
Block a user