Commit 984ece64 by Torkel Ödegaard

Get access denied when trying to save from collaboration role viewer

parent 9637efd5
......@@ -9,7 +9,6 @@ function (angular) {
module.controller('AccountCtrl', function($scope, $http, backendSrv) {
$scope.collaborator = {};
$scope.showTokens = false;
$scope.init = function() {
$scope.getAccount();
......
......@@ -52,6 +52,10 @@ function (angular, _, kbn) {
return backendSrv.post('/api/dashboard/', { dashboard: dashboard })
.then(function(data) {
return { title: dashboard.title, url: '/dashboard/db/' + data.slug };
}, function(err) {
err.isHandled = true;
err.data = err.data || {};
throw err.data.message || "Unknown error";
});
};
......
......@@ -8,7 +8,8 @@ function (angular, _, config) {
var module = angular.module('grafana.services');
module.service('backendSrv', function($http, alertSrv) {
module.service('backendSrv', function($http, alertSrv, $timeout) {
var self = this;
this.get = function(url, params) {
return this.request({ method: 'GET', url: url, params: params });
......@@ -26,22 +27,7 @@ function (angular, _, config) {
return this.request({ method: 'PUT', url: url, data: data });
};
this.request = function(options) {
var httpOptions = {
url: config.appSubUrl + options.url,
method: options.method,
data: options.data,
params: options.params,
};
return $http(httpOptions).then(function(results) {
if (options.method !== 'GET') {
if (results && results.data.message) {
alertSrv.set(results.data.message, '', 'success', 3000);
}
}
return results.data;
}, function(err) {
this._handleError = function(err) {
if (err.status === 422) {
alertSrv.set("Validation failed", "", "warning", 4000);
throw err.data;
......@@ -64,6 +50,30 @@ function (angular, _, config) {
}
throw data;
};
this.request = function(options) {
var httpOptions = {
url: config.appSubUrl + options.url,
method: options.method,
data: options.data,
params: options.params,
};
return $http(httpOptions).then(function(results) {
if (options.method !== 'GET') {
if (results && results.data.message) {
alertSrv.set(results.data.message, '', 'success', 3000);
}
}
return results.data;
}, function(err) {
$timeout(function() {
if (err.isHandled) { return; }
self._handleError(err);
}, 50);
throw err;
});
};
......
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