2015-06-24 18:35:55 +00:00
|
|
|
angular.module('SeHub')
|
2015-06-26 13:49:46 +00:00
|
|
|
.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope)
|
|
|
|
{
|
2015-07-01 04:05:13 +00:00
|
|
|
$scope.loadingData = true;
|
2015-06-27 09:45:44 +00:00
|
|
|
$scope.campusesEmpty = false;
|
2015-06-26 13:49:46 +00:00
|
|
|
var token = $cookies['com.sehub.www'];
|
2015-06-28 12:27:06 +00:00
|
|
|
|
2015-06-26 13:49:46 +00:00
|
|
|
var init = function()
|
|
|
|
{
|
2015-06-27 14:01:16 +00:00
|
|
|
$scope.threeSizedArray = [];
|
|
|
|
var tempArr = [];
|
|
|
|
var sizeOfSmallArrays = 3;
|
|
|
|
for (var i = 0 ; i < $scope.campuses.length ; i++) {
|
|
|
|
if(i % sizeOfSmallArrays !== 0){
|
|
|
|
tempArr.push($scope.campuses[i]);
|
|
|
|
}else{
|
|
|
|
if(i !== 0){
|
|
|
|
$scope.threeSizedArray.push(tempArr);
|
|
|
|
tempArr = [];
|
|
|
|
tempArr.push($scope.campuses[i]);
|
|
|
|
}else{
|
|
|
|
tempArr.push($scope.campuses[i]);
|
2015-06-27 11:20:21 +00:00
|
|
|
}
|
2015-06-27 14:01:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
$scope.threeSizedArray.push(tempArr);
|
2015-06-26 13:49:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-26 18:56:41 +00:00
|
|
|
$scope.goToCampus = function(campusId) // Will pass you to courses by specific campus
|
|
|
|
{
|
|
|
|
$location.path('/myClasses/' + campusId.toString());
|
|
|
|
}
|
2015-06-26 13:49:46 +00:00
|
|
|
|
2015-06-27 11:20:21 +00:00
|
|
|
$scope.displayCampuses = function()
|
|
|
|
{
|
|
|
|
apiService.getCampusesByUser(token).success(function(data) // Get all the campuses
|
|
|
|
{
|
2015-07-01 04:05:13 +00:00
|
|
|
$scope.loadingData = true;
|
2015-06-27 11:20:21 +00:00
|
|
|
$scope.campuses = data;
|
|
|
|
console.log("INSIDE " + $scope.campuses);
|
|
|
|
init(); // Executing the function to initialize campuses display
|
|
|
|
|
|
|
|
}).error(function()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
});
|
2015-06-28 12:27:06 +00:00
|
|
|
// console.log($scope.campuses.length.toString());
|
|
|
|
|
|
|
|
if(!$scope.campuses) // If campuses is empty
|
2015-06-27 11:20:21 +00:00
|
|
|
{
|
|
|
|
$scope.campusesEmpty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.displayCampuses(); // Displaying all campuses by user
|
|
|
|
|
2015-06-26 13:49:46 +00:00
|
|
|
|
2015-06-24 18:35:55 +00:00
|
|
|
|
2015-06-26 13:49:46 +00:00
|
|
|
}]);
|