diff --git a/src/app/controllers/sidemenuCtrl.js b/src/app/controllers/sidemenuCtrl.js index ec6cab8d8ef..0f671446da6 100644 --- a/src/app/controllers/sidemenuCtrl.js +++ b/src/app/controllers/sidemenuCtrl.js @@ -20,7 +20,7 @@ function (angular, _, $, config) { text: "Dashbords", icon: "fa fa-th-large", href: $scope.getUrl("/"), - startsWith: config.appSubUrl + '/dashboard/', + //startsWith: config.appSubUrl + '/dashboard/', }); $scope.menu.push({ diff --git a/src/app/features/grafanaDatasource/datasource.js b/src/app/features/grafanaDatasource/datasource.js index 15d6f895f2b..5ab1118a4ce 100644 --- a/src/app/features/grafanaDatasource/datasource.js +++ b/src/app/features/grafanaDatasource/datasource.js @@ -19,13 +19,13 @@ function (angular, _, kbn) { } GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) { - var url = '/dashboard/' + slug; + var url = '/dashboards/' + slug; if (isTemp) { url = '/temp/' + slug; } - return backendSrv.get('/api/dashboard/' + slug); + return backendSrv.get('/api/dashboards/db/' + slug); }; GrafanaDatasource.prototype.query = function(options) { @@ -50,7 +50,7 @@ function (angular, _, kbn) { dashboard.id = null; } - return backendSrv.post('/api/dashboard/', { dashboard: dashboard }) + return backendSrv.post('/api/dashboards/db/', { dashboard: dashboard }) .then(function(data) { return { title: dashboard.title, url: '/dashboard/db/' + data.slug }; }, function(err) { @@ -61,7 +61,7 @@ function (angular, _, kbn) { }; GrafanaDatasource.prototype.deleteDashboard = function(id) { - return backendSrv.delete('/api/dashboard/' + id); + return backendSrv.delete('/api/dashboards/db/' + id); }; GrafanaDatasource.prototype.searchDashboards = function(query) { diff --git a/src/app/routes/backend/dashboard.js b/src/app/routes/backend/dashboard.js index 5622a1f0a57..8b28e79906e 100644 --- a/src/app/routes/backend/dashboard.js +++ b/src/app/routes/backend/dashboard.js @@ -2,47 +2,27 @@ define([ 'angular', 'store', ], -function (angular, store) { +function (angular) { "use strict"; var module = angular.module('grafana.routes'); - // remember previous dashboard - var prevDashPath = null; - - module.controller('DashFromDBProvider', function( - $scope, $rootScope, datasourceSrv, $routeParams, - alertSrv, $http, $location) { + module.controller('DashFromDBProvider', function($scope, datasourceSrv, $routeParams, backendSrv) { var db = datasourceSrv.getGrafanaDB(); - var isTemp = window.location.href.indexOf('dashboard/temp') !== -1; if (!$routeParams.id) { - // do we have a previous dash - if (prevDashPath) { - $location.path(prevDashPath); - return; - } + backendSrv.get('api/dashboards/home').then(function(result) { + $scope.initDashboard(result, $scope); + },function() { + $scope.initDashboard({}, $scope); + $scope.appEvent('alert-error', ['Load dashboard failed', '']); + }); - 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); - $scope.initDashboard({model: dashboard, meta: {}}, $scope); - },function() { - $scope.initDashboard({}, $scope); - $scope.appEvent('alert-error', ['Load dashboard failed', '']); - }); - return; - } - else { - $location.path(savedRoute); - return; - } + return; } - db.getDashboard($routeParams.id, isTemp).then(function(result) { - prevDashPath = $location.path(); + db.getDashboard($routeParams.id, false).then(function(result) { $scope.initDashboard(result, $scope); }).then(null, function() { $scope.initDashboard({