mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
define([
|
|
'angular',
|
|
'jquery',
|
|
],
|
|
function (angular, $) {
|
|
"use strict";
|
|
|
|
var module = angular.module('grafana.routes');
|
|
|
|
module.controller('SoloPanelCtrl', function(
|
|
$scope,
|
|
backendSrv,
|
|
$routeParams,
|
|
dashboardSrv,
|
|
timeSrv,
|
|
$location,
|
|
templateValuesSrv,
|
|
contextSrv) {
|
|
|
|
var panelId;
|
|
|
|
$scope.init = function() {
|
|
contextSrv.sidemenu = false;
|
|
|
|
var params = $location.search();
|
|
panelId = parseInt(params.panelId);
|
|
|
|
var request;
|
|
|
|
if ($routeParams.slug) {
|
|
request = backendSrv.getDashboard($routeParams.slug);
|
|
} else {
|
|
request = backendSrv.get('/api/snapshots/' + $routeParams.key);
|
|
}
|
|
|
|
request.then(function(dashboard) {
|
|
$scope.initPanelScope(dashboard);
|
|
}).then(null, function(err) {
|
|
$scope.appEvent('alert-error', ['Load panel error', err.message]);
|
|
});
|
|
};
|
|
|
|
$scope.initPanelScope = function(dashData) {
|
|
$scope.dashboard = dashboardSrv.create(dashData.model, dashData.meta);
|
|
|
|
$scope.row = {
|
|
height: ($(window).height() - 10) + 'px',
|
|
};
|
|
|
|
$scope.test = "Hej";
|
|
$scope.$index = 0;
|
|
$scope.panel = $scope.dashboard.getPanelById(panelId);
|
|
|
|
if (!$scope.panel) {
|
|
$scope.appEvent('alert-error', ['Panel not found', '']);
|
|
return;
|
|
}
|
|
|
|
$scope.panel.span = 12;
|
|
$scope.dashboardViewState = { registerPanel: function() { }, state: {}};
|
|
|
|
timeSrv.init($scope.dashboard);
|
|
templateValuesSrv.init($scope.dashboard, $scope.dashboardViewState);
|
|
};
|
|
|
|
if (!$scope.skipAutoInit) {
|
|
$scope.init();
|
|
}
|
|
|
|
});
|
|
|
|
});
|