Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui-router offers nested routes, which is useful for forcesched dialogs and direct access to the dialog From the URL of the builder, you can add /forceched/myforcesched to go to the forcesched dialog Some impact on how the plugins should register new routes. Plugins just have to use ui-router api to declare new routes. Simplifies the top menu Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
- Loading branch information
Pierre Tardy
committed
Oct 12, 2013
1 parent
4494c72
commit ddb758b
Showing
13 changed files
with
126 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
angular.module 'app', ['restangular', 'ui.bootstrap', 'templates-views', 'ngRoute', 'ngAnimate'] | ||
angular.module 'app', ['restangular', 'ui.bootstrap', 'templates-views', 'ui.router', 'ngAnimate'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
angular.module('app').controller 'builderController', | ||
['$log', '$scope', '$location', 'buildbotService', '$routeParams' | ||
($log, $scope, $location, buildbotService, $routeParams) -> | ||
builder = buildbotService.one('builder', $routeParams.builder) | ||
['$log', '$scope', '$location', 'buildbotService', '$stateParams' | ||
($log, $scope, $location, buildbotService, $stateParams) -> | ||
builder = buildbotService.one('builder', $stateParams.builder) | ||
builder.bind($scope, 'builder') | ||
builder.all('build').bind($scope, 'builds') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
angular.module('app').controller 'schedulersController', | ||
['$log', '$scope', '$location', 'buildbotService', '$routeParams' | ||
($log, $scope, $location, buildbotService, $routeParams) -> | ||
['$log', '$scope', '$location', 'buildbotService', '$stateParams' | ||
($log, $scope, $location, buildbotService, $stateParams) -> | ||
buildbotService.all('scheduler').getList().then (schedulers) -> | ||
$scope.schedulers = schedulers | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../bower_components/angular-ui-router/release/angular-ui-router.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,94 @@ | ||
angular.module('app').constant("route_config", | ||
home: | ||
caption: "Home" | ||
route: "/" | ||
builders: | ||
caption: "Builders" | ||
route: "/builders" | ||
# lastbuilds: | ||
# caption: "Last Builds" | ||
# route: "/lastbuilds" | ||
changes: | ||
caption: "Last Changes" | ||
route: "/changes" | ||
# buildslaves: | ||
# caption: "Build Slaves" | ||
# route: "/buildslaves" | ||
# buildmasters: | ||
# caption: "Build Masters" | ||
# route: "/buildmasters" | ||
schedulers: | ||
caption: "Schedulers" | ||
route: "/schedulers" | ||
# users: | ||
# caption: "Users" | ||
# route: "/users" | ||
# admin: | ||
# caption: "Admin" | ||
# route: "/admin" | ||
about: | ||
caption: "About" | ||
route: "/about" | ||
|
||
# order is important in the configuration stage | ||
# so we need to have this provider defined in routes.coffee | ||
# this provider holds the list of states (which unfortunatly not a feature of ui-router) | ||
# so that top menu can be autogenerated | ||
angular.module('app').provider 'topMenuStates', -> | ||
states = [] | ||
@state = (state) -> | ||
states.push(state) | ||
@$get = -> | ||
states | ||
|
||
builder: | ||
route: "/builders/:builder" | ||
tabid: "builders" | ||
build: | ||
route: "/builders/:builder/build/:build" | ||
tabid: "builders" | ||
step: | ||
route: "/builders/:builder/build/:build/steps/:step" | ||
tabid: "builders" | ||
log: | ||
route: "/builders/:builder/build/:build/steps/:step/logs/:log" | ||
tabid: "builders" | ||
angular.module('app').config [ "$stateProvider", "$urlRouterProvider", "topMenuStatesProvider" | ||
($stateProvider, $urlRouterProvider, topMenuStatesProvider) -> | ||
|
||
buildslave: | ||
route: "/buildslaves/:buildslave" | ||
tabid: "buildslaves" | ||
buildmaster: | ||
route: "/buildmasters/:buildmaster" | ||
tabid: "buildmasters" | ||
user: | ||
route: "/users/:user" | ||
tabid: "users" | ||
$urlRouterProvider.otherwise('/'); | ||
|
||
editconf: | ||
route: "/admin/:conffile" | ||
tabid: "admin" | ||
) | ||
route_config_fn = ($routeProvider, route_config, plugins_routes...) -> | ||
# agregate the base app route_config with plugin route config | ||
# :-/ need to watch for namespace clashes between plugins... | ||
for i in [0..plugins_routes.length - 1] | ||
plugin = plugin_names[i] | ||
plugin_routes = plugins_routes[i] | ||
for id, route_cfg of plugin_routes | ||
route_config[id] = route_cfg | ||
if !route_cfg.templateUrl | ||
route_cfg.templateUrl = "#{plugin}/views/#{id}.html" | ||
# by convention, in this module the key of the mapping | ||
# is the name of the template and of the controller | ||
# If the route has a caption, it is linked in the top menu | ||
# The route is configured in $routeProvider | ||
default_routes = | ||
home: | ||
caption: "Home" | ||
url: "/" | ||
builders: | ||
caption: "Builders" | ||
url: "/builders" | ||
# lastbuilds: | ||
# caption: "Last Builds" | ||
# url: "/lastbuilds" | ||
changes: | ||
caption: "Last Changes" | ||
url: "/changes" | ||
# buildslaves: | ||
# caption: "Build Slaves" | ||
# url: "/buildslaves" | ||
# buildmasters: | ||
# caption: "Build Masters" | ||
# url: "/buildmasters" | ||
schedulers: | ||
caption: "Schedulers" | ||
url: "/schedulers" | ||
# users: | ||
# caption: "Users" | ||
# url: "/users" | ||
# admin: | ||
# caption: "Admin" | ||
# url: "/admin" | ||
about: | ||
caption: "About" | ||
url: "/about" | ||
|
||
# by convention, the key of the first mapping | ||
# is the name of the template and of the controller | ||
# If the route has a caption, it is linked in the top menu | ||
# The route is configured in $routeProvider | ||
$.each route_config, (id, cfg) -> | ||
# needs to be a $.each to create a scope for changeTab.. | ||
cfg.tabid ?= id | ||
cfg.tabhash = "##{id}" | ||
if !cfg.controller | ||
cfg.controller = "#{id}Controller" | ||
if !cfg.templateUrl | ||
cfg.templateUrl = "views/#{id}.html" | ||
$routeProvider | ||
.when cfg.route, | ||
controller: cfg.controller | ||
reloadOnSearch: true | ||
templateUrl: cfg.templateUrl | ||
resolve: | ||
changeTab: ['$rootScope', ($rootScope) -> | ||
$rootScope.selectedTab = cfg | ||
] | ||
$routeProvider.otherwise redirectTo: '/' | ||
|
||
# generate the dependancy injection dynamically, given all plugins | ||
di = ['$routeProvider', 'route_config'] | ||
plugin_names = [] | ||
if @config? | ||
for plugin, cfg of @config.plugins | ||
di.push(plugin + "_route_config") | ||
plugin_names.push(plugin) | ||
builder: | ||
url: "/builders/:builder" | ||
tabid: "builders" | ||
build: | ||
url: "/builders/:builder/build/:build" | ||
tabid: "builders" | ||
step: | ||
url: "/builders/:builder/build/:build/steps/:step" | ||
tabid: "builders" | ||
log: | ||
url: "/builders/:builder/build/:build/steps/:step/logs/:log" | ||
tabid: "builders" | ||
|
||
di.push(route_config_fn) | ||
angular.module('app').config(di) | ||
buildslave: | ||
url: "/buildslaves/:buildslave" | ||
tabid: "buildslaves" | ||
buildmaster: | ||
url: "/buildmasters/:buildmaster" | ||
tabid: "buildmasters" | ||
user: | ||
url: "/users/:user" | ||
tabid: "users" | ||
|
||
editconf: | ||
url: "/admin/:conffile" | ||
tabid: "admin" | ||
|
||
for id, cfg of default_routes | ||
cfg.tabid ?= id | ||
cfg.tabhash = "##{id}" | ||
state = | ||
controller: "#{id}Controller" | ||
templateUrl: "views/#{id}.html" | ||
name: id | ||
url: cfg.url | ||
data: cfg | ||
|
||
$stateProvider.state(state) | ||
topMenuStatesProvider.state(state) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ul.nav.navbar-nav | ||
li(ng-repeat='tab in tabs', ng-class='{active:tab.selected}') | ||
a(href='{{tab.tabhash}}', ng-click='select(tab)') {{tab.caption}} | ||
li(ng-repeat='tab in tabs', ng-class='{active:tab.data.selected}') | ||
a(href='{{tab.data.tabhash}}') {{tab.data.caption}} |