2015-06-16 11:15:59 +00:00
|
|
|
angular.module('SeHub')
|
|
|
|
.controller('homeController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
|
|
|
{
|
2015-06-20 11:58:30 +00:00
|
|
|
$scope.isStudent = false;
|
2015-06-20 11:21:32 +00:00
|
|
|
$scope.addMsg = false;
|
|
|
|
$scope.msgToPost = "";
|
|
|
|
$scope.oldText = "";
|
2015-06-22 10:06:56 +00:00
|
|
|
$scope.messages = [];
|
2015-06-23 16:04:41 +00:00
|
|
|
$scope.msg = {};
|
|
|
|
|
|
|
|
$rootScope.seToken = $cookies['com.sehub.www'];
|
|
|
|
var token = $rootScope.seToken;
|
2015-06-20 11:21:32 +00:00
|
|
|
|
|
|
|
var imagePath = $scope.user.avatar_url;
|
2015-06-23 16:04:41 +00:00
|
|
|
//var campusName = '';
|
|
|
|
// $scope.campusName = '';
|
|
|
|
|
2015-06-20 11:21:32 +00:00
|
|
|
$scope.phones = [
|
|
|
|
{ type: 'Home', number: '(972) 865-82861' },
|
|
|
|
{ type: 'Cell', number: '(972) 5251-32309' },
|
|
|
|
];
|
2015-06-17 20:16:49 +00:00
|
|
|
|
2015-06-23 16:04:41 +00:00
|
|
|
|
|
|
|
|
2015-06-20 11:21:32 +00:00
|
|
|
if($scope.user.isLecturer)
|
|
|
|
{
|
2015-06-20 11:58:30 +00:00
|
|
|
$scope.isStudent = false;
|
2015-06-20 11:21:32 +00:00
|
|
|
console.log("Lecturer Mode!");
|
2015-06-23 16:04:41 +00:00
|
|
|
// console.log($scope.campusName);
|
2015-06-20 11:21:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-20 11:58:30 +00:00
|
|
|
$scope.isStudent = true;
|
2015-06-20 11:21:32 +00:00
|
|
|
console.log("Student Mode!");
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.addMessageClicked = function()
|
|
|
|
{
|
|
|
|
$scope.addMsg = true; // Reveal the "POST" Button
|
|
|
|
}
|
2015-06-22 10:06:56 +00:00
|
|
|
$scope.postMessageClicked = function() // Posting the message itself
|
2015-06-20 11:21:32 +00:00
|
|
|
{
|
2015-06-22 10:06:56 +00:00
|
|
|
if($scope.msg.msgToAdd != null)
|
2015-06-20 11:21:32 +00:00
|
|
|
{
|
2015-06-27 09:45:44 +00:00
|
|
|
jsonNewMsg = {
|
2015-06-30 23:35:23 +00:00
|
|
|
'courseName': 'Math', // TODO Should be ===> $scope.course.courseName
|
2015-06-27 09:45:44 +00:00
|
|
|
'message': $scope.msg.msgToAdd
|
|
|
|
};
|
|
|
|
|
|
|
|
// console.log("J: " + jsonNewMsg.toString() + "msg: " + $scope.msg.msgToAdd);
|
|
|
|
|
|
|
|
// apiService.createMessage(token, jsonNewMsg).success(function(data)
|
|
|
|
// {
|
|
|
|
// console.log("create Msg!");
|
|
|
|
// }).error(function(err)
|
|
|
|
// {
|
|
|
|
// console.log("Error: " + err);
|
|
|
|
// });
|
|
|
|
|
|
|
|
/*
|
|
|
|
'courseName': 'Advance Math',
|
|
|
|
'message': 'The lecture today is canceled'
|
|
|
|
*/
|
|
|
|
|
2015-06-22 10:06:56 +00:00
|
|
|
console.log($scope.msg.msgToAdd);
|
|
|
|
$scope.messages.push({"text": $scope.msg.msgToAdd});
|
2015-06-20 11:21:32 +00:00
|
|
|
}
|
2015-06-22 10:06:56 +00:00
|
|
|
$scope.msg.msgToAdd = null;
|
2015-06-20 11:21:32 +00:00
|
|
|
}
|
2015-06-16 11:15:59 +00:00
|
|
|
|
2015-07-01 04:05:13 +00:00
|
|
|
$scope.displayTasks = function()
|
|
|
|
{
|
|
|
|
// apiService.getAllFutureTasks(token, courseId).success(function(data) // need to check courseId
|
|
|
|
// {
|
|
|
|
|
|
|
|
// }).error(function(err)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.getCourses = function()
|
|
|
|
{
|
|
|
|
// apiService.getAllCoursesByCampus(token, campusId).success(function(data) // Shows all classes from this campus
|
|
|
|
// {
|
|
|
|
// $scope.loadingData = false;
|
|
|
|
// $scope.courses = data;
|
|
|
|
// console.log("success " + $scope.courses);
|
|
|
|
// init(); // Executing the function to initialize course display
|
|
|
|
// if($scope.courses && $scope.courses.length > 0)
|
|
|
|
// {
|
|
|
|
// $scope.coursesEmpty = false;
|
|
|
|
// }
|
|
|
|
// }).error(function(err)
|
|
|
|
// {
|
|
|
|
// console.log("error: " + err);
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
2015-06-20 11:21:32 +00:00
|
|
|
$scope.clearAllClicked = function() // Clear Screen from text
|
|
|
|
{
|
2015-06-22 10:06:56 +00:00
|
|
|
$scope.messages = [];
|
2015-06-20 11:21:32 +00:00
|
|
|
}
|
2015-06-17 21:04:36 +00:00
|
|
|
|
2015-06-22 10:06:56 +00:00
|
|
|
$scope.chooseCourseClicked = function()
|
|
|
|
{
|
|
|
|
console.log("choose course Clicked!!");
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.chooseProjectClicked = function()
|
|
|
|
{
|
|
|
|
console.log("choose project Clicked!!");
|
|
|
|
}
|
|
|
|
|
2015-06-20 11:21:32 +00:00
|
|
|
// animation
|
|
|
|
$scope.isEnterd = top.setIsEnterd;
|
2015-07-01 04:05:13 +00:00
|
|
|
$scope.getCourses(); // Get all the courses info
|
|
|
|
$scope.displayTasks(); // Display all tasks in task feed
|
2015-06-16 11:15:59 +00:00
|
|
|
}]);
|