Commit bc673fd9 by Torkel Ödegaard

Worked on loading a home dashboard through backend

parent a127f2d5
......@@ -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({
......
......@@ -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) {
......
......@@ -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;
}
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);
backendSrv.get('api/dashboards/home').then(function(result) {
$scope.initDashboard(result, $scope);
},function() {
$scope.initDashboard({}, $scope);
$scope.appEvent('alert-error', ['Load dashboard failed', '']);
});
return;
}
else {
$location.path(savedRoute);
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({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment