se-hub/templates/js/controllers/mainController.js

76 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-05-09 19:00:14 +00:00
angular.module('SeHub')
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) {
2015-05-09 19:00:14 +00:00
var token = $cookies['com.sehub.www'];
$scope.loadingData = true;
$scope.isInRegisterMode = false;
2015-05-09 19:00:14 +00:00
apiService.getUserByToken(token).success(function(data) {
if (data.message == 'No User Found') {
console.error("No User Found!");
}
2015-05-09 19:00:14 +00:00
$scope.user = data;
if ($scope.user.isFirstLogin) {
$scope.menuObj = {};
$scope.isInRegisterMode = true;
$scope.loadingData = false;
$location.path('/register')
} else {
$location.path('/home')
}
})
2015-05-09 19:00:14 +00:00
apiService.getUserByToken(token).success(function(data) // Get user token
{
$scope.user = data;
$scope.loadingData = false;
2015-05-09 19:00:14 +00:00
apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses
{
$scope.campuses = data;
}).error(function() {
});
});
$scope.menuItems = [{
"title": "Home",
"icon": "fa fa-home",
"style": "selected",
2015-06-16 19:45:06 +00:00
"route": "#/home"
}, {
"title": "My Campuses",
"icon": "fa fa-university",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "/campuses"
}, {
"title": "My Classes",
"icon": "fa fa-graduation-cap",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "/campuses"
}, {
"title": "My Projects",
"icon": "fa fa-cube",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "/campuses"
}, {
"title": "Tasks",
"icon": "fa fa-clipboard",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "/campuses"
}, {
"title": "Settings",
"icon": "fa fa-cogs",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "#/Settings"
}, {
"title": "Log Out",
"icon": "fa fa-power-off",
2015-06-16 19:45:06 +00:00
"style": "",
"route": "#/logout"
}];
}]);