2015-03-02 15:24:01 -06:00
|
|
|
define([
|
|
|
|
'angular',
|
|
|
|
'lodash',
|
|
|
|
'kbn',
|
|
|
|
'moment',
|
|
|
|
'jquery',
|
|
|
|
],
|
2015-05-12 10:39:56 -05:00
|
|
|
function (angular) {
|
2015-03-02 15:24:01 -06:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var module = angular.module('grafana.routes');
|
|
|
|
|
2015-05-12 10:39:56 -05:00
|
|
|
module.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) {
|
2015-03-02 15:24:01 -06:00
|
|
|
|
|
|
|
if (!$routeParams.slug) {
|
|
|
|
backendSrv.get('/api/dashboards/home').then(function(result) {
|
2015-04-23 08:26:39 -05:00
|
|
|
var meta = result.meta;
|
|
|
|
meta.canSave = meta.canShare = meta.canEdit = meta.canStar = false;
|
2015-03-02 15:24:01 -06:00
|
|
|
$scope.initDashboard(result, $scope);
|
2015-05-12 07:11:30 -05:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-12 10:39:56 -05:00
|
|
|
dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
|
2015-05-12 07:11:30 -05:00
|
|
|
$scope.initDashboard(result, $scope);
|
2015-03-02 15:24:01 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-05-12 07:11:30 -05:00
|
|
|
module.controller('DashFromImportCtrl', function($scope, $location, alertSrv) {
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
|
|
|
module.controller('NewDashboardCtrl', function($scope) {
|
|
|
|
$scope.initDashboard({
|
|
|
|
meta: { canStar: false, canShare: false },
|
|
|
|
dashboard: {
|
|
|
|
title: "New dashboard",
|
|
|
|
rows: [{ height: '250px', panels:[] }]
|
|
|
|
},
|
|
|
|
}, $scope);
|
|
|
|
});
|
|
|
|
|
2015-03-02 15:24:01 -06:00
|
|
|
});
|