Introduces dynamic routing

This commit is contained in:
Frédéric Vachon 2015-03-25 16:56:14 -04:00
parent 5d3e632a48
commit 4bd1253337
3 changed files with 35 additions and 1 deletions

View File

@ -110,6 +110,7 @@ module.exports = function (grunt) {
'<%= project.app %>/components/table/cell_host_address/cell_host_address.js',
'<%= project.app %>/components/table/cell_host_status/cell_host_status.js',
'<%= project.app %>/dashboard/dashboard.js',
'<%= project.app %>/routing_view/routing_view.js',
'<%= project.app %>/single_table/single_table.js'
]
}],
@ -143,6 +144,7 @@ module.exports = function (grunt) {
'<%= project.build %>/components/table/cell_host_address/cell_host_address.js': '<%= project.app %>/components/table/cell_host_address/cell_host_address.js',
'<%= project.build %>/components/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js',
'<%= project.build %>/dashboard/dashboard.js': '<%= project.app %>/dashboard/dashboard.js',
'<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js',
'<%= project.build %>/single_table/single_table.js' : '<%= project.app %>/single_table/single_table.js'
},
{
@ -170,6 +172,7 @@ module.exports = function (grunt) {
'<%= project.build %>/components/table/cell_host_address/cell_host_address.js',
'<%= project.build %>/components/table/cell_host_status/cell_host_status.js',
'<%= project.build %>/dashboard/dashboard.js',
'<%= project.build %>/routing_view/routing_view.js',
'<%= project.build %>/single_table/single_table.js'
]
}

View File

@ -19,7 +19,8 @@ angular.module('adagios', [
'adagios.topbar',
'adagios.config',
'adagios.view.dashboard',
'adagios.view.singleTable'
'adagios.view.singleTable',
'adagios.view'
])
.config(['$routeProvider', function ($routeProvider) {

View File

@ -0,0 +1,30 @@
'use strict';
angular.module('adagios.view', ['ngRoute',
'adagios.config'
])
.value('viewsTemplate', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/view', {
controller: 'ViewCtrl',
template: '<div ng-include="templateUrl">Loading...</div>'
});
}])
.controller('ViewCtrl', ['$scope', '$routeParams', 'viewsTemplate',
function ($scope, $routeParams, viewsTemplate) {
var templateName = viewsTemplate[$routeParams.view],
templateUrl = templateName + '/' + templateName + '.html';
$scope.templateUrl = templateUrl;
}])
.run(['readConfig', 'viewsTemplate', function (readConfig, viewsTemplate) {
var viewsConfig = readConfig.data;
angular.forEach(viewsConfig, function (config, view) {
viewsTemplate[view] = config.template;
});
}]);