2016-03-18 23:03:28 +01:00
|
|
|
app.config(function ($stateProvider, $couchPotatoProvider) {
|
|
|
|
$stateProvider.state('users', {
|
|
|
|
url: '/users',
|
|
|
|
templateUrl: '/view/abstract',
|
|
|
|
abstract: true
|
|
|
|
})
|
|
|
|
.state('users.add', {
|
|
|
|
url: '/add',
|
|
|
|
pageTitle: 'Add User',
|
|
|
|
templateUrl: "/public/html/user/add.html",
|
|
|
|
controller: 'AddUserCtrl',
|
|
|
|
resolve: {
|
|
|
|
dummy: $couchPotatoProvider.resolve(['controllers/user/add'])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('users.list', {
|
|
|
|
url: '/all',
|
|
|
|
pageTitle: 'Users',
|
|
|
|
templateUrl: "/public/html/user/list.html",
|
|
|
|
controller: 'UsersCtrl',
|
|
|
|
resolve: {
|
|
|
|
dummy: $couchPotatoProvider.resolve(['controllers/user/users'])
|
|
|
|
}
|
|
|
|
})
|
2015-01-31 19:38:58 +01:00
|
|
|
|
2016-03-18 23:03:28 +01:00
|
|
|
.state('user', {
|
|
|
|
abstract: true,
|
|
|
|
url: '/user/:user_id',
|
|
|
|
templateUrl: '/public/html/abstract.html',
|
|
|
|
controller: ['$scope', 'user', function ($scope, user) {
|
|
|
|
$scope.user = user;
|
|
|
|
}],
|
|
|
|
resolve: {
|
|
|
|
user: ['User', '$stateParams', '$q', '$state', function (User, $stateParams, $q, $state) {
|
|
|
|
var deferred = $q.defer();
|
2015-01-31 19:38:58 +01:00
|
|
|
|
2016-03-18 23:03:28 +01:00
|
|
|
var user = new User($stateParams.user_id)
|
|
|
|
user.get()
|
|
|
|
.success(function (data, status) {
|
|
|
|
user.data = data;
|
|
|
|
deferred.resolve(user);
|
|
|
|
})
|
|
|
|
.error(function (data, status) {
|
|
|
|
if (status == 404) {
|
|
|
|
$state.transitionTo('homepage');
|
|
|
|
return deferred.reject();
|
|
|
|
}
|
|
|
|
});
|
2015-01-31 19:38:58 +01:00
|
|
|
|
2016-03-18 23:03:28 +01:00
|
|
|
return deferred.promise;
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
})
|
2015-01-31 19:38:58 +01:00
|
|
|
|
2016-03-18 23:03:28 +01:00
|
|
|
.state('user.view', {
|
|
|
|
url: '/',
|
|
|
|
controller: 'UserCtrl',
|
|
|
|
templateUrl: '/public/html/user/view.html',
|
|
|
|
resolve: {
|
|
|
|
dummy: $couchPotatoProvider.resolve(['controllers/user/user'])
|
|
|
|
}
|
2015-01-31 19:38:58 +01:00
|
|
|
})
|
2016-03-18 23:03:28 +01:00
|
|
|
});
|