2015-05-09 19:00:14 +00:00
|
|
|
angular.module('SeHub')
|
2015-06-16 17:34:37 +00:00
|
|
|
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) {
|
2015-05-09 19:00:14 +00:00
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
var token = $cookies['com.sehub.www'];
|
2015-06-15 15:41:44 +00:00
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
$scope.loadingData = true;
|
|
|
|
$scope.isInRegisterMode = false;
|
2015-05-09 19:00:14 +00:00
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
apiService.getUserByToken(token).success(function(data) {
|
|
|
|
if (data.message == 'No User Found') {
|
|
|
|
console.error("No User Found!");
|
|
|
|
}
|
2015-06-16 20:32:10 +00:00
|
|
|
$scope.loadingData = false;
|
2015-06-16 17:34:37 +00:00
|
|
|
$scope.user = data;
|
2015-06-16 20:32:10 +00:00
|
|
|
console.log(data);
|
2015-06-16 17:34:37 +00:00
|
|
|
if ($scope.user.isFirstLogin) {
|
|
|
|
$scope.menuObj = {};
|
|
|
|
$scope.isInRegisterMode = true;
|
|
|
|
$scope.loadingData = false;
|
|
|
|
$location.path('/register')
|
|
|
|
} else {
|
|
|
|
$location.path('/home')
|
|
|
|
}
|
2015-06-16 11:15:59 +00:00
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
})
|
2015-05-09 19:00:14 +00:00
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
$scope.menuItems = [{
|
|
|
|
"title": "Home",
|
|
|
|
"icon": "fa fa-home",
|
|
|
|
"style": "selected",
|
2015-06-16 20:32:10 +00:00
|
|
|
"route": "/home"
|
2015-06-16 17:34:37 +00:00
|
|
|
}, {
|
|
|
|
"title": "My Campuses",
|
|
|
|
"icon": "fa fa-university",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 17:34:37 +00:00
|
|
|
"route": "/campuses"
|
|
|
|
}, {
|
|
|
|
"title": "My Classes",
|
|
|
|
"icon": "fa fa-graduation-cap",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 17:34:37 +00:00
|
|
|
"route": "/campuses"
|
|
|
|
}, {
|
|
|
|
"title": "My Projects",
|
|
|
|
"icon": "fa fa-cube",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 17:34:37 +00:00
|
|
|
"route": "/campuses"
|
|
|
|
}, {
|
|
|
|
"title": "Tasks",
|
|
|
|
"icon": "fa fa-clipboard",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 17:34:37 +00:00
|
|
|
"route": "/campuses"
|
|
|
|
}, {
|
|
|
|
"title": "Settings",
|
|
|
|
"icon": "fa fa-cogs",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 20:32:10 +00:00
|
|
|
"route": "/Settings"
|
2015-06-16 17:34:37 +00:00
|
|
|
}, {
|
|
|
|
"title": "Log Out",
|
|
|
|
"icon": "fa fa-power-off",
|
2015-06-16 19:45:06 +00:00
|
|
|
"style": "",
|
2015-06-16 20:32:10 +00:00
|
|
|
"route": "/logout"
|
2015-06-16 17:34:37 +00:00
|
|
|
}];
|
|
|
|
|
2015-06-16 20:32:10 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-16 17:34:37 +00:00
|
|
|
}]);
|