Skip to content

Commit 78bbd28

Browse files
committed
poc(): dashboard loading via route resolve
1 parent b5dc172 commit 78bbd28

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

public/app/core/routes/dash_loader.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
///<reference path="../../headers/common.d.ts" />
2+
3+
export class DashLoader {
4+
dashboard: any;
5+
defered: any;
6+
7+
constructor() {
8+
this.dashboard = ["$q", "$route", "$rootScope", ($q, $route, $rootScope) => {
9+
return $q(function(resolve, reject) {
10+
setTimeout(function() {
11+
resolve(123);
12+
}, 1000);
13+
});
14+
}];
15+
16+
}
17+
}

public/app/core/routes/dashboard_loaders.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function (coreModule) {
55
"use strict";
66

77
coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) {
8+
console.log($scope);
89

910
if (!$routeParams.slug) {
1011
backendSrv.get('/api/dashboards/home').then(function(result) {

public/app/core/routes/routes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@ import './dashboard_loaders';
55
import angular from 'angular';
66
import coreModule from 'app/core/core_module';
77
import {BundleLoader} from './bundle_loader';
8+
import {DashLoader} from './dash_loader';
89

910
/** @ngInject **/
1011
function setupAngularRoutes($routeProvider, $locationProvider) {
1112
$locationProvider.html5Mode(true);
1213

1314
var loadOrgBundle = new BundleLoader('app/features/org/all');
1415
var loadAppsBundle = new BundleLoader('app/features/apps/all');
16+
var dashLoader = new DashLoader();
1517

1618
$routeProvider
1719
.when('/', {
1820
templateUrl: 'public/app/partials/dashboard.html',
1921
controller : 'LoadDashboardCtrl',
2022
reloadOnSearch: false,
23+
resolve: dashLoader,
2124
})
2225
.when('/dashboard/:type/:slug', {
2326
templateUrl: 'public/app/partials/dashboard.html',
2427
controller : 'LoadDashboardCtrl',
2528
reloadOnSearch: false,
29+
resolve: dashLoader,
2630
})
2731
.when('/dashboard-solo/:type/:slug', {
2832
templateUrl: 'public/app/features/panel/partials/soloPanel.html',

0 commit comments

Comments
 (0)