Fixed solo panel view (used for png rendering)

This commit is contained in:
Torkel Ödegaard 2015-02-28 11:07:22 +01:00
parent 232f980c72
commit c283f0996d
4 changed files with 13 additions and 12 deletions

View File

@ -7,15 +7,14 @@ function (angular, $) {
var module = angular.module('grafana.routes');
module.controller('SoloPanelCtrl', function($scope, $rootScope, datasourceSrv, $routeParams, dashboardSrv, timeSrv, $location) {
module.controller('SoloPanelCtrl', function($scope, backendSrv, $routeParams, dashboardSrv, timeSrv, $location, templateValuesSrv) {
var panelId;
$scope.init = function() {
var db = datasourceSrv.getGrafanaDB();
var params = $location.search();
panelId = parseInt(params.panelId);
db.getDashboard($routeParams.id, false)
backendSrv.getDashboard($routeParams.slug)
.then(function(dashboard) {
$scope.initPanelScope(dashboard);
}).then(null, function(error) {
@ -41,12 +40,10 @@ function (angular, $) {
}
$scope.panel.span = 12;
$scope.dashboardViewState = {
registerPanel: function() {
}
};
$scope.dashboardViewState = { registerPanel: function() { }, state: {}};
timeSrv.init($scope.dashboard);
templateValuesSrv.init($scope.dashboard, $scope.dashboardViewState);
};
$scope.getPanelById = function(id) {

View File

@ -15,12 +15,12 @@ define([
controller : 'DashFromDBProvider',
reloadOnSearch: false,
})
.when('/dashboard/db/:id', {
.when('/dashboard/db/:slug', {
templateUrl: 'app/partials/dashboard.html',
controller : 'DashFromDBProvider',
reloadOnSearch: false,
})
.when('/dashboard/import/:id', {
.when('/dashboard/import/:file', {
templateUrl: 'app/partials/dashboard.html',
controller : 'DashFromImportCtrl',
reloadOnSearch: false,
@ -93,7 +93,7 @@ define([
templateUrl: 'app/partials/login.html',
controller : 'LoginCtrl',
})
.when('/dashboard/solo/:id/', {
.when('/dashboard/solo/:slug/', {
templateUrl: 'app/features/panel/partials/soloPanel.html',
controller : 'SoloPanelCtrl',
})

View File

@ -9,7 +9,7 @@ function (angular) {
module.controller('DashFromDBProvider', function($scope, $routeParams, backendSrv) {
if (!$routeParams.id) {
if (!$routeParams.slug) {
backendSrv.get('/api/dashboards/home').then(function(result) {
$scope.initDashboard(result, $scope);
},function() {
@ -20,7 +20,7 @@ function (angular) {
return;
}
return backendSrv.get('/api/dashboards/db/' + $routeParams.id).then(function(result) {
return backendSrv.getDashboard($routeParams.slug).then(function(result) {
$scope.initDashboard(result, $scope);
}, function() {
$scope.initDashboard({

View File

@ -81,6 +81,10 @@ function (angular, _, config) {
return this.get('/api/search', query);
};
this.getDashboard = function(slug) {
return this.get('/api/dashboards/db/' + slug);
};
this.saveDashboard = function(dash) {
return this.post('/api/dashboards/db/', {dashboard: dash});
};