mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
Panel edit state is working pretty good now, #672
This commit is contained in:
parent
4987a2158e
commit
4d1102db0b
@ -24,10 +24,6 @@ function (angular, _, moment, config) {
|
||||
});
|
||||
};
|
||||
|
||||
$scope.exitFullscreen = function() {
|
||||
$scope.emitAppEvent('panel-fullscreen-exit');
|
||||
};
|
||||
|
||||
$scope.set_default = function() {
|
||||
window.localStorage.grafanaDashboardDefault = $location.path();
|
||||
alertSrv.set('Home Set','This page has been set as your default dashboard','success',5000);
|
||||
|
@ -21,7 +21,6 @@ function (angular, $, kbn, moment, _) {
|
||||
var legendSideLastValue = null;
|
||||
|
||||
scope.$on('refresh',function() {
|
||||
if (scope.otherPanelInFullscreenMode()) { return; }
|
||||
scope.get_data();
|
||||
});
|
||||
|
||||
@ -39,6 +38,10 @@ function (angular, $, kbn, moment, _) {
|
||||
// Receive render events
|
||||
scope.$on('render',function(event, renderData) {
|
||||
data = renderData || data;
|
||||
if (!data) {
|
||||
scope.get_data();
|
||||
return;
|
||||
}
|
||||
annotations = data.annotations || annotations;
|
||||
render_panel();
|
||||
});
|
||||
|
@ -12,16 +12,6 @@ function(angular, $) {
|
||||
|
||||
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() {
|
||||
keyboardManager.unbind('ctrl+f');
|
||||
keyboardManager.unbind('ctrl+h');
|
||||
@ -63,7 +53,7 @@ function(angular, $) {
|
||||
modalData.$scope.dismiss();
|
||||
}
|
||||
|
||||
scope.emitAppEvent('panel-fullscreen-exit');
|
||||
scope.exitFullscreen();
|
||||
}, { inputDisabled: true });
|
||||
};
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ function (angular, $, kbn, _) {
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.factory('dashboardSrv', function(timer, $rootScope, $timeout, $location) {
|
||||
module.factory('dashboardSrv', function(timer, $rootScope, $timeout) {
|
||||
|
||||
function DashboardModel (data) {
|
||||
|
||||
|
@ -15,6 +15,14 @@ function (angular, _, $) {
|
||||
function DashboardViewState($scope) {
|
||||
var self = this;
|
||||
|
||||
$scope.exitFullscreen = function() {
|
||||
self.update({ fullscreen: false });
|
||||
};
|
||||
|
||||
$scope.onAppEvent('dashboard-saved', function() {
|
||||
self.update({ fullscreen: false });
|
||||
});
|
||||
|
||||
$scope.onAppEvent('$routeUpdate', function() {
|
||||
var urlState = self.getQueryStringState();
|
||||
if (self.needsSync(urlState)) {
|
||||
@ -45,9 +53,8 @@ function (angular, _, $) {
|
||||
};
|
||||
|
||||
DashboardViewState.prototype.update = function(state, skipUrlSync) {
|
||||
console.log('viewstate update: ', state);
|
||||
|
||||
_.extend(this, state);
|
||||
|
||||
if (!this.fullscreen) {
|
||||
this.panelId = null;
|
||||
this.edit = false;
|
||||
|
@ -1,9 +1,8 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash',
|
||||
'jquery',
|
||||
],
|
||||
function (angular, _, $) {
|
||||
function (angular, _) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
@ -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.panel.targets.push({target: ''});
|
||||
};
|
||||
@ -165,6 +124,7 @@ function (angular, _, $) {
|
||||
|
||||
panel_get_data();
|
||||
};
|
||||
|
||||
if (!$scope.skipDataOnInit) {
|
||||
$scope.get_data();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user