Remember last dashboard

This commit is contained in:
Torkel Ödegaard 2015-01-06 14:15:48 +01:00
parent 49b18e17d7
commit 72974719ac
3 changed files with 10 additions and 6 deletions

View File

@ -6,7 +6,7 @@
<p>
This is just a test data source that generates random walk series. If this is your only data source
open the left side menu and goto data sources admin screen and add your data sources. You can change
open the left side menu and navigate to the data sources admin screen and add your data sources. You can change
data source using the button to the left of the <strong>Add query</strong> button.
</p>
</div>

View File

@ -24,10 +24,6 @@
<i class="icon-sitemap"></i>
Data sources
</a>
<a class="pro-sidemenu-link" href="admin">
<i class="icon-tasks"></i>
Global options
</a>
<a class="pro-sidemenu-link" href="account">
<i class="icon-user"></i>
Account settings

View File

@ -33,6 +33,9 @@ function (angular, store) {
});
});
// remember previous dashboard
var prevDashPath = null;
module.controller('DashFromDBProvider', function(
$scope, $rootScope, datasourceSrv, $routeParams,
alertSrv, $http, $location) {
@ -41,8 +44,12 @@ function (angular, store) {
var isTemp = window.location.href.indexOf('dashboard/temp') !== -1;
if (!$routeParams.id) {
var savedRoute = store.get('grafanaDashboardDefault');
// do we have a previous dash
if (prevDashPath) {
$location.path(prevDashPath);
}
var savedRoute = store.get('grafanaDashboardDefault');
if (!savedRoute) {
$http.get("app/dashboards/default.json?" + new Date().getTime()).then(function(result) {
var dashboard = angular.fromJson(result.data);
@ -61,6 +68,7 @@ function (angular, store) {
db.getDashboard($routeParams.id, isTemp)
.then(function(dashboard) {
prevDashPath = $location.path();
$scope.initDashboard(dashboard, $scope);
}).then(null, function(err) {
$scope.appEvent('alert-error', ['Load dashboard failed', err]);