mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
define([
|
|
'../core_module',
|
|
],
|
|
function (coreModule) {
|
|
"use strict";
|
|
|
|
coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv, $location) {
|
|
$scope.appEvent("dashboard-fetch-start");
|
|
|
|
if (!$routeParams.slug) {
|
|
backendSrv.get('/api/dashboards/home').then(function(homeDash) {
|
|
if (homeDash.redirectUri) {
|
|
$location.path('dashboard/' + homeDash.redirectUri);
|
|
} else {
|
|
var meta = homeDash.meta;
|
|
meta.canSave = meta.canShare = meta.canStar = false;
|
|
$scope.initDashboard(homeDash, $scope);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
|
|
dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
|
|
$scope.initDashboard(result, $scope);
|
|
});
|
|
|
|
});
|
|
|
|
coreModule.default.controller('NewDashboardCtrl', function($scope) {
|
|
$scope.initDashboard({
|
|
meta: { canStar: false, canShare: false, isNew: true },
|
|
dashboard: {
|
|
title: "New dashboard",
|
|
rows: [
|
|
{
|
|
title: 'Dashboard Row',
|
|
height: '250px',
|
|
panels:[],
|
|
isNew: true,
|
|
}
|
|
]
|
|
},
|
|
}, $scope);
|
|
});
|
|
|
|
});
|