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

78 lines
1.8 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!");
}
$scope.loadingData = false;
$scope.user = data;
console.log(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
$scope.menuItems = [{
"title": "Home",
"icon": "fa fa-home",
"style": "selected",
"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"
}];
$scope.menuClicked = function(item){
var route = ""
for (var i = $scope.menuItems.length - 1; i >= 0; i--) {
if($scope.menuItems[i].title === item.title){
$scope.menuItems[i].style="selected";
route = $scope.menuItems[i].route;
}else{
$scope.menuItems[i].style = "";
}
};
$location.path(route);
}
}]);