2015-03-02 22:24:01 +01:00
|
|
|
define([
|
2015-09-15 08:52:53 +02:00
|
|
|
'../core_module',
|
2015-03-02 22:24:01 +01:00
|
|
|
],
|
2015-09-15 08:52:53 +02:00
|
|
|
function (coreModule) {
|
2015-03-02 22:24:01 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
2015-12-16 12:21:13 +01:00
|
|
|
coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) {
|
2015-03-02 22:24:01 +01:00
|
|
|
|
|
|
|
|
if (!$routeParams.slug) {
|
|
|
|
|
backendSrv.get('/api/dashboards/home').then(function(result) {
|
2015-04-23 15:26:39 +02:00
|
|
|
var meta = result.meta;
|
2015-10-26 18:54:32 +01:00
|
|
|
meta.canSave = meta.canShare = meta.canStar = false;
|
2015-03-02 22:24:01 +01:00
|
|
|
$scope.initDashboard(result, $scope);
|
2015-05-12 14:11:30 +02:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-12 17:39:56 +02:00
|
|
|
dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
|
2015-05-12 14:11:30 +02:00
|
|
|
$scope.initDashboard(result, $scope);
|
2015-03-02 22:24:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-12-16 12:21:13 +01:00
|
|
|
coreModule.default.controller('DashFromImportCtrl', function($scope, $location, alertSrv) {
|
2015-05-12 14:11:30 +02:00
|
|
|
if (!window.grafanaImportDashboard) {
|
|
|
|
|
alertSrv.set('Not found', 'Cannot reload page with unsaved imported dashboard', 'warning', 7000);
|
|
|
|
|
$location.path('');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$scope.initDashboard({
|
|
|
|
|
meta: { canShare: false, canStar: false },
|
|
|
|
|
dashboard: window.grafanaImportDashboard
|
|
|
|
|
}, $scope);
|
|
|
|
|
});
|
|
|
|
|
|
2015-12-16 12:21:13 +01:00
|
|
|
coreModule.default.controller('NewDashboardCtrl', function($scope) {
|
2015-05-12 14:11:30 +02:00
|
|
|
$scope.initDashboard({
|
|
|
|
|
meta: { canStar: false, canShare: false },
|
|
|
|
|
dashboard: {
|
|
|
|
|
title: "New dashboard",
|
|
|
|
|
rows: [{ height: '250px', panels:[] }]
|
|
|
|
|
},
|
|
|
|
|
}, $scope);
|
|
|
|
|
});
|
|
|
|
|
|
2015-03-02 22:24:01 +01:00
|
|
|
});
|