Commit a5fac17f by Torkel Ödegaard

Added public snapshot test, hosted on snapshots.raintank.io

parent 49a0ea53
...@@ -82,6 +82,11 @@ ...@@ -82,6 +82,11 @@
<i ng-if="loading" class="fa fa-spinner fa-spin"></i> <i ng-if="loading" class="fa fa-spinner fa-spin"></i>
</button> </button>
<button class="btn btn-primary btn" ng-click="createSnapshot(true)" ng-if="!snapshotUrl" ng-disabled="loading">
Create Public snapshot (snapshots.raintank.io)
<i ng-if="loading" class="fa fa-spinner fa-spin"></i>
</button>
</div> </div>
</div> </div>
......
...@@ -12,17 +12,29 @@ function (angular) { ...@@ -12,17 +12,29 @@ function (angular) {
name: $scope.dashboard.title name: $scope.dashboard.title
}; };
$scope.createSnapshot = function() { $scope.createSnapshot = function(makePublic) {
$scope.dashboard.snapshot = true; $scope.dashboard.snapshot = true;
$scope.loading = true; $scope.loading = true;
$rootScope.$broadcast('refresh'); $rootScope.$broadcast('refresh');
$timeout(function() { $timeout(function() {
var dash = angular.copy($scope.dashboard); var dash = angular.copy($scope.dashboard);
backendSrv.post('/api/snapshots/', {dashboard: dash}).then(function(results) { dash.title = $scope.snapshot.name;
var apiUrl = '/api/snapshots';
if (makePublic) {
apiUrl = 'http://snapshots.raintank.io/api/snapshots';
}
backendSrv.post(apiUrl, {dashboard: dash}).then(function(results) {
$scope.loading = false; $scope.loading = false;
var baseUrl = $location.absUrl().replace($location.url(), ""); var baseUrl = $location.absUrl().replace($location.url(), "");
if (makePublic) {
baseUrl = 'http://snapshots.raintank.io';
}
$scope.snapshotUrl = baseUrl + '/dashboard/snapshots/' + results.key; $scope.snapshotUrl = baseUrl + '/dashboard/snapshots/' + results.key;
}, function() { }, function() {
......
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