diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js
index 3abcf4ec0a3..0b755ccbdb7 100644
--- a/src/app/controllers/search.js
+++ b/src/app/controllers/search.js
@@ -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');
};
});
diff --git a/src/app/routes/backend/all.js b/src/app/routes/backend/all.js
index be10fbbdfe6..863be089243 100644
--- a/src/app/routes/backend/all.js
+++ b/src/app/routes/backend/all.js
@@ -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',
diff --git a/src/app/routes/backend/dashboard.js b/src/app/routes/backend/dashboard.js
index 9ce60c10348..919151c2aca 100644
--- a/src/app/routes/backend/dashboard.js
+++ b/src/app/routes/backend/dashboard.js
@@ -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);
+ });
+
});
diff --git a/src/app/routes/standalone/fromFile.js b/src/app/routes/standalone/fromFile.js
index fce9394789a..0eafa0ed650 100644
--- a/src/app/routes/standalone/fromFile.js
+++ b/src/app/routes/standalone/fromFile.js
@@ -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 dashboards/"+file+". Please make sure it exists" ,'error');
+ $scope.appEvent('alert-error', ["Dashboard load failed", "Could not load dashboards/"+file+". 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);
});