Commit 2bd2605a by Torkel Ödegaard

Added poc of dashboard snapshot, sharable dashboard with data embedded

parent 36a94896
......@@ -11,7 +11,7 @@ function (angular, _, moment) {
var module = angular.module('grafana.controllers');
module.controller('DashboardNavCtrl', function($scope, $rootScope, alertSrv, $location, playlistSrv, backendSrv, timeSrv) {
module.controller('DashboardNavCtrl', function($scope, $rootScope, alertSrv, $location, playlistSrv, backendSrv, timeSrv, $timeout) {
$scope.init = function() {
$scope.onAppEvent('save-dashboard', $scope.saveDashboard);
......@@ -157,6 +157,18 @@ function (angular, _, moment) {
});
};
$scope.snapshot = function() {
$scope.dashboard.snapshot = true;
$rootScope.$broadcast('refresh');
$timeout(function() {
$scope.exportDashboard();
$scope.dashboard.snapshot = false;
$scope.appEvent('dashboard-snapshot-cleanup');
}, 1000);
};
$scope.editJson = function() {
$scope.appEvent('show-json-editor', { object: $scope.dashboard });
};
......
......@@ -23,7 +23,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
};
});
module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper) {
module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper, $q) {
$scope.panelMeta = new PanelMeta({
panelName: 'Graph',
......@@ -130,6 +130,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
$scope.refreshData = function(datasource) {
panelHelper.updateTimeRange($scope);
if ($scope.panel.snapshotData) {
$scope.annotationsPromise = $q.when([]);
$scope.dataHandler($scope.panel.snapshotData);
return;
}
$scope.annotationsPromise = annotationsSrv.getAnnotations($scope.rangeUnparsed, $scope.dashboard);
return panelHelper.issueMetricQuery($scope, datasource)
......@@ -141,6 +147,9 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
};
$scope.dataHandler = function(results) {
if ($scope.dashboard.snapshot) {
$scope.panel.snapshotData = results;
}
// png renderer returns just a url
if (_.isString(results)) {
$scope.render(results);
......@@ -285,6 +294,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
};
panelSrv.init($scope);
});
});
......@@ -40,6 +40,7 @@
<li><a class="pointer" ng-click="editJson();">View JSON</a></li>
<li><a class="pointer" ng-click="saveDashboardAs();">Save As...</a></li>
<li><a class="pointer" ng-click="deleteDashboard();">Delete dashboard</a></li>
<li><a class="pointer" ng-click="snapshot();">Snapshot dashboard</a></li>
</ul>
</li>
</ul>
......
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