Added poc of dashboard snapshot, sharable dashboard with data embedded

pull/1629/head
Torkel Ödegaard 11 years ago
parent 36a948965b
commit 2bd2605ae9
  1. 14
      src/app/features/dashboard/dashboardNavCtrl.js
  2. 12
      src/app/panels/graph/module.js
  3. 1
      src/app/partials/dashboard_topnav.html

@ -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>

Loading…
Cancel
Save