Semaphore/public/js/routes/router.js

71 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-03-18 23:03:28 +01:00
app.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $couchPotatoProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$urlRouterProvider.otherwise('/');
$stateProvider
.state('dashboard', {
2016-03-18 23:03:28 +01:00
url: '/',
pageTitle: 'Dashboard',
templateUrl: '/tpl/dashboard.html',
controller: 'DashboardCtrl',
resolve: {
$d: $couchPotatoProvider.resolveDependencies(['controllers/dashboard'])
2016-03-18 23:03:28 +01:00
}
})
.state('users', {
url: '/users',
abstract: true,
templateUrl: '/tpl/abstract.html'
})
.state('users.list', {
url: '',
pageTitle: 'Users',
2016-05-17 17:18:26 +02:00
templateUrl: '/tpl/users/list.html',
controller: 'UsersCtrl',
resolve: {
$d: $couchPotatoProvider.resolve(['controllers/users'])
}
2016-05-17 17:18:26 +02:00
})
.state('users.user', {
url: '/:user_id',
pageTitle: 'User',
templateUrl: '/tpl/users/user.html',
controller: 'UserCtrl',
resolve: {
$d: $couchPotatoProvider.resolve(['controllers/user']),
user: ['$http', '$stateParams', function ($http, $stateParams) {
return $http.get('/users/' + $stateParams.user_id);
}]
}
})
2016-05-17 17:18:26 +02:00
.state('admin', {
url: '/admin',
pageTitle: 'System Info',
templateUrl: '/tpl/admin.html',
controller: 'AdminCtrl',
resolve: {
$d: $couchPotatoProvider.resolve(['controllers/admin'])
}
})
.state('user', {
url: '/user',
pageTitle: 'User',
templateUrl: '/tpl/users/user.html',
controller: 'UserCtrl',
resolve: {
$d: $couchPotatoProvider.resolve(['controllers/user']),
user: ['$http', function ($http) {
return $http.get('/user');
}]
}
});
2016-03-18 23:03:28 +01:00
});
app.run(function($rootScope, $state, $stateParams, $http) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
});