Fixed broken feature: new dashboard button
This commit is contained in:
@@ -154,7 +154,8 @@ function (angular, _, config, $) {
|
||||
};
|
||||
|
||||
$scope.newDashboard = function() {
|
||||
$location.url('/dashboard/file/empty.json');
|
||||
//$location.path('/dashboard/file/empty.json');
|
||||
$location.url('dashboard/new');
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@@ -20,16 +20,16 @@ define([
|
||||
controller : 'DashFromDBProvider',
|
||||
reloadOnSearch: false,
|
||||
})
|
||||
.when('/dashboard/temp/:id', {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'DashFromDBProvider',
|
||||
reloadOnSearch: false,
|
||||
})
|
||||
.when('/dashboard/import/:id', {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'DashFromImportCtrl',
|
||||
reloadOnSearch: false,
|
||||
})
|
||||
.when('/dashboard/new', {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'NewDashboardCtrl',
|
||||
reloadOnSearch: false,
|
||||
})
|
||||
.when('/account', {
|
||||
templateUrl: 'app/features/account/partials/account.html',
|
||||
controller : 'AccountCtrl',
|
||||
|
||||
@@ -48,18 +48,22 @@ function (angular, store) {
|
||||
}).then(null, function() {
|
||||
$scope.initDashboard({}, $scope);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
module.controller('DashFromImportCtrl', function($scope, $location, alertSrv) {
|
||||
|
||||
if (!window.grafanaImportDashboard) {
|
||||
alertSrv.set('Not found', 'Cannot reload page with unsaved imported dashboard', 'warning', 7000);
|
||||
$location.path('');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.initDashboard(window.grafanaImportDashboard, $scope);
|
||||
});
|
||||
|
||||
module.controller('NewDashboardCtrl', function($scope) {
|
||||
$scope.initDashboard({
|
||||
title: "New dashboard",
|
||||
rows: [{ height: '250px', panels:[] }]
|
||||
}, $scope);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -15,10 +15,16 @@ function (angular, $, config, _) {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'DashFromFileProvider',
|
||||
reloadOnSearch: false,
|
||||
})
|
||||
.when('/dashboard/new', {
|
||||
templateUrl: 'app/partials/dashboard.html',
|
||||
controller : 'DashFromFileProvider',
|
||||
reloadOnSearch: false,
|
||||
newDashboard: true,
|
||||
});
|
||||
});
|
||||
|
||||
module.controller('DashFromFileProvider', function($scope, $rootScope, $http, $routeParams, alertSrv) {
|
||||
module.controller('DashFromFileProvider', function($scope, $rootScope, $http, $routeParams, $route) {
|
||||
|
||||
var renderTemplate = function(json,params) {
|
||||
var _r;
|
||||
@@ -46,12 +52,17 @@ function (angular, $, config, _) {
|
||||
}
|
||||
return result.data;
|
||||
},function() {
|
||||
alertSrv.set('Error',"Could not load <i>dashboards/"+file+"</i>. Please make sure it exists" ,'error');
|
||||
$scope.appEvent('alert-error', ["Dashboard load failed", "Could not load <i>dashboards/"+file+"</i>. Please make sure it exists"]);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
file_load($routeParams.jsonFile).then(function(result) {
|
||||
var fileToLoad = $routeParams.jsonFile;
|
||||
if ($route.current.newDashboard) {
|
||||
fileToLoad = 'empty.json';
|
||||
}
|
||||
|
||||
file_load(fileToLoad).then(function(result) {
|
||||
$scope.initDashboard(result, $scope);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user