Commit 4d1102db by Torkel Ödegaard

Panel edit state is working pretty good now, #672

parent 4987a215
...@@ -24,10 +24,6 @@ function (angular, _, moment, config) { ...@@ -24,10 +24,6 @@ function (angular, _, moment, config) {
}); });
}; };
$scope.exitFullscreen = function() {
$scope.emitAppEvent('panel-fullscreen-exit');
};
$scope.set_default = function() { $scope.set_default = function() {
window.localStorage.grafanaDashboardDefault = $location.path(); window.localStorage.grafanaDashboardDefault = $location.path();
alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000); alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000);
......
...@@ -21,7 +21,6 @@ function (angular, $, kbn, moment, _) { ...@@ -21,7 +21,6 @@ function (angular, $, kbn, moment, _) {
var legendSideLastValue = null; var legendSideLastValue = null;
scope.$on('refresh',function() { scope.$on('refresh',function() {
if (scope.otherPanelInFullscreenMode()) { return; }
scope.get_data(); scope.get_data();
}); });
...@@ -39,6 +38,10 @@ function (angular, $, kbn, moment, _) { ...@@ -39,6 +38,10 @@ function (angular, $, kbn, moment, _) {
// Receive render events // Receive render events
scope.$on('render',function(event, renderData) { scope.$on('render',function(event, renderData) {
data = renderData || data; data = renderData || data;
if (!data) {
scope.get_data();
return;
}
annotations = data.annotations || annotations; annotations = data.annotations || annotations;
render_panel(); render_panel();
}); });
......
...@@ -12,16 +12,6 @@ function(angular, $) { ...@@ -12,16 +12,6 @@ function(angular, $) {
this.shortcuts = function(scope) { this.shortcuts = function(scope) {
scope.onAppEvent('panel-fullscreen-exit', function() {
scope.dashboardViewState.update({ fullscreen: false });
});
scope.onAppEvent('dashboard-saved', function() {
if (scope.dashboardViewState.fullscreen) {
scope.emitAppEvent('panel-fullscreen-exit');
}
});
scope.$on('$destroy', function() { scope.$on('$destroy', function() {
keyboardManager.unbind('ctrl+f'); keyboardManager.unbind('ctrl+f');
keyboardManager.unbind('ctrl+h'); keyboardManager.unbind('ctrl+h');
...@@ -63,7 +53,7 @@ function(angular, $) { ...@@ -63,7 +53,7 @@ function(angular, $) {
modalData.$scope.dismiss(); modalData.$scope.dismiss();
} }
scope.emitAppEvent('panel-fullscreen-exit'); scope.exitFullscreen();
}, { inputDisabled: true }); }, { inputDisabled: true });
}; };
}); });
......
...@@ -10,7 +10,7 @@ function (angular, $, kbn, _) { ...@@ -10,7 +10,7 @@ function (angular, $, kbn, _) {
var module = angular.module('grafana.services'); var module = angular.module('grafana.services');
module.factory('dashboardSrv', function(timer, $rootScope, $timeout, $location) { module.factory('dashboardSrv', function(timer, $rootScope, $timeout) {
function DashboardModel (data) { function DashboardModel (data) {
......
...@@ -15,6 +15,14 @@ function (angular, _, $) { ...@@ -15,6 +15,14 @@ function (angular, _, $) {
function DashboardViewState($scope) { function DashboardViewState($scope) {
var self = this; var self = this;
$scope.exitFullscreen = function() {
self.update({ fullscreen: false });
};
$scope.onAppEvent('dashboard-saved', function() {
self.update({ fullscreen: false });
});
$scope.onAppEvent('$routeUpdate', function() { $scope.onAppEvent('$routeUpdate', function() {
var urlState = self.getQueryStringState(); var urlState = self.getQueryStringState();
if (self.needsSync(urlState)) { if (self.needsSync(urlState)) {
...@@ -45,9 +53,8 @@ function (angular, _, $) { ...@@ -45,9 +53,8 @@ function (angular, _, $) {
}; };
DashboardViewState.prototype.update = function(state, skipUrlSync) { DashboardViewState.prototype.update = function(state, skipUrlSync) {
console.log('viewstate update: ', state);
_.extend(this, state); _.extend(this, state);
if (!this.fullscreen) { if (!this.fullscreen) {
this.panelId = null; this.panelId = null;
this.edit = false; this.edit = false;
......
define([ define([
'angular', 'angular',
'lodash', 'lodash',
'jquery',
], ],
function (angular, _, $) { function (angular, _) {
'use strict'; 'use strict';
var module = angular.module('grafana.services'); var module = angular.module('grafana.services');
...@@ -71,46 +70,6 @@ function (angular, _, $) { ...@@ -71,46 +70,6 @@ function (angular, _, $) {
}); });
}; };
$scope.enterFullscreenMode = function(options) {
var docHeight = $(window).height();
var editHeight = Math.floor(docHeight * 0.3);
var fullscreenHeight = Math.floor(docHeight * 0.7);
var oldTimeRange = $scope.range;
$scope.height = options.edit ? editHeight : fullscreenHeight;
$scope.editMode = options.edit;
if (!$scope.fullscreen) {
var closeEditMode = $rootScope.$on('panel-fullscreen-exit', function() {
$scope.editMode = false;
$scope.fullscreen = false;
delete $scope.height;
closeEditMode();
$timeout(function() {
if (oldTimeRange !== $scope.range) {
$scope.dashboard.emit_refresh();
}
else {
$scope.$emit('render');
}
});
});
}
$(window).scrollTop(0);
$scope.dashboardViewState.update({ fullscreen: true, edit: $scope.editMode, panelId: $scope.panel.id });
$scope.fullscreen = true;
$timeout(function() {
$scope.$emit('render');
});
};
$scope.addDataQuery = function() { $scope.addDataQuery = function() {
$scope.panel.targets.push({target: ''}); $scope.panel.targets.push({target: ''});
}; };
...@@ -165,6 +124,7 @@ function (angular, _, $) { ...@@ -165,6 +124,7 @@ function (angular, _, $) {
panel_get_data(); panel_get_data();
}; };
if (!$scope.skipDataOnInit) { if (!$scope.skipDataOnInit) {
$scope.get_data(); $scope.get_data();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment