dashboard_loaders.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. define([
  2. '../core_module',
  3. ],
  4. function (coreModule) {
  5. "use strict";
  6. coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv, $location) {
  7. $scope.appEvent("dashboard-fetch-start");
  8. if (!$routeParams.slug) {
  9. backendSrv.get('/api/dashboards/home').then(function(homeDash) {
  10. if (homeDash.redirectUri) {
  11. $location.path('dashboard/' + homeDash.redirectUri);
  12. } else {
  13. var meta = homeDash.meta;
  14. meta.canSave = meta.canShare = meta.canStar = false;
  15. $scope.initDashboard(homeDash, $scope);
  16. }
  17. });
  18. return;
  19. }
  20. dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
  21. $scope.initDashboard(result, $scope);
  22. });
  23. });
  24. coreModule.default.controller('NewDashboardCtrl', function($scope) {
  25. $scope.initDashboard({
  26. meta: { canStar: false, canShare: false, isNew: true },
  27. dashboard: {
  28. title: "New dashboard",
  29. rows: [
  30. {
  31. title: 'Dashboard Row',
  32. height: '250px',
  33. panels:[],
  34. isNew: true,
  35. }
  36. ]
  37. },
  38. }, $scope);
  39. });
  40. });