mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Small improvement to dashboard loading error handling
This commit is contained in:
parent
aa724fc11e
commit
b83367063e
@ -42,6 +42,7 @@ func authDenied(c *Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+c.Req.RequestURI), 0, setting.AppSubUrl+"/")
|
||||||
c.Redirect(setting.AppSubUrl + "/login")
|
c.Redirect(setting.AppSubUrl + "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,13 +64,11 @@ func RoleAuth(roles ...m.RoleType) macaron.Handler {
|
|||||||
func Auth(options *AuthOptions) macaron.Handler {
|
func Auth(options *AuthOptions) macaron.Handler {
|
||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
if !c.IsGrafanaAdmin && options.ReqGrafanaAdmin {
|
if !c.IsGrafanaAdmin && options.ReqGrafanaAdmin {
|
||||||
c.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+c.Req.RequestURI), 0, setting.AppSubUrl+"/")
|
|
||||||
authDenied(c)
|
authDenied(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsSignedIn && options.ReqSignedIn && !c.AllowAnonymous {
|
if !c.IsSignedIn && options.ReqSignedIn && !c.AllowAnonymous {
|
||||||
c.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+c.Req.RequestURI), 0, setting.AppSubUrl+"/")
|
|
||||||
authDenied(c)
|
authDenied(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,15 @@ function (angular, _, kbn, moment, $) {
|
|||||||
|
|
||||||
module.controller('DashFromDBCtrl', function($scope, $routeParams, backendSrv) {
|
module.controller('DashFromDBCtrl', function($scope, $routeParams, backendSrv) {
|
||||||
|
|
||||||
|
function dashboardLoadFailed(title) {
|
||||||
|
$scope.initDashboard({meta: {}, model: {title: title}}, $scope);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$routeParams.slug) {
|
if (!$routeParams.slug) {
|
||||||
backendSrv.get('/api/dashboards/home').then(function(result) {
|
backendSrv.get('/api/dashboards/home').then(function(result) {
|
||||||
$scope.initDashboard(result, $scope);
|
$scope.initDashboard(result, $scope);
|
||||||
},function() {
|
},function() {
|
||||||
$scope.initDashboard({}, $scope);
|
dashboardLoadFailed('Not found');
|
||||||
$scope.appEvent('alert-error', ['Load dashboard failed', '']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -26,11 +29,9 @@ function (angular, _, kbn, moment, $) {
|
|||||||
return backendSrv.getDashboard($routeParams.slug).then(function(result) {
|
return backendSrv.getDashboard($routeParams.slug).then(function(result) {
|
||||||
$scope.initDashboard(result, $scope);
|
$scope.initDashboard(result, $scope);
|
||||||
}, function() {
|
}, function() {
|
||||||
$scope.initDashboard({
|
dashboardLoadFailed('Not found');
|
||||||
meta: {},
|
|
||||||
model: { title: 'Not found' }
|
|
||||||
}, $scope);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.controller('DashFromSnapshotCtrl', function($scope, $routeParams, backendSrv) {
|
module.controller('DashFromSnapshotCtrl', function($scope, $routeParams, backendSrv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user