Merge pull request #21 from sagidayan/matanBranch

Matan branch
This commit is contained in:
Sagi Dayan 2015-06-14 22:06:50 +03:00
commit c32e0ad971
2 changed files with 57 additions and 49 deletions

View file

@ -1,33 +1,30 @@
angular.module('SeHub')
.controller('registerController', ['$scope', '$location', '$cookies', 'apiService', '$rootScope', function ($scope, $location, $cookies, apiService ,$rootScope) {
.controller('registerController', ['$scope', '$cookies', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $location, $mdToast, $mdDialog, apiService ,$rootScope)
{
$scope.userHasNoName = false;
$scope.campusChecked = false;
$scope.isEmpty = true; // if the academic email line is empty
// $scope.fullMail = $scope.academicEmail + $scope.campusObj.email_ending; // Will hold the full academic email of the user
$rootScope.seToken = $cookies['com.sehub.www'];
var token = $rootScope.seToken;
apiService.getUserByToken(token).success(function(data){
apiService.getUserByToken(token).success(function(data) // Get user token
{
$scope.user = data;
console.log(data);
if(data.message == 'No User Found')
console.error("No User Found!");
console.log(data);
$scope.user = data;
$rootScope.user = data;
if($scope.user.isFirstLogin)
$location.path('/register')
if($scope.user.name === ";"){
if($scope.user.name === ";")
{
$scope.user.name = "";
$scope.user.name = $scope.user.username
$scope.userHasNoName = true;
}
apiService.getAllCampuses($scope.user.seToken).success(function(data)
apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses
{
$scope.campuses = data;
}).error(function()
@ -37,9 +34,6 @@ angular.module('SeHub')
});
$scope.dropdownClicked = function()
{
if($scope.campus){
@ -51,40 +45,54 @@ angular.module('SeHub')
console.log($scope.campusObj); // TODO REMOVE!!
}
};
}
};
};
$scope.submitClicked = function()
$scope.submitClicked = function(ev)
{
console.log($scope.user.AcMail);
$scope.mail = 'pin';
console.log($scope.mail);
};
apiService.getAllCampuses($scope.user.seToken).success(function(data)
if($scope.user.AcMail != null)
{
$scope.campuses = data;
var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user
apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data)
{
console.log("DONE - 200");
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.')
.ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev));
// TODO - ADD DELETE COOKIES
$cookies.remove("com.sehub.www");
// $location.path("templates/views/home.html"); // Redirecting to home page // TODO REMOVE REMOVE!!
}).error(function()
{
// TODO
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.')
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
});
// apiService.sendValidationMail($scope.user.seToken, $scope.fullMail).success(function(data) // TODO: Add 2nd parameter email type Email
// {
// console.log($scope.fullMail);
// console.log("200");
// // TODO
// }).error(function()
// {
// });
};
};
// TODO FOR LATER
// TODO FOR LATER
$scope.getPopWindowPosition = function()
{
return Object.keys($scope.toastPosition).filter(function(pos)
{
return $scope.toastPosition[pos];
}).join(' ');
};
$scope.toastPosition =
{
bottom: false,
top: true,
left: false,
right: true
};
// TODO FOR LATER
// TODO FOR LATER
}]);

View file

@ -18,7 +18,7 @@
</div>
<div layout="row" layout-align="center center">
Are You A Lecturer?
<md-switch ng-model="user.isLecturer" aria-label="Switch 1">
<md-switch class="md-primary" md-no-ink aria-label="Switch No Ink" ng-model="data.cb5">
</md-switch>
</div>
</div>
@ -37,7 +37,7 @@
</div>
<div>
<div class = "disabledSubmitButton">
<md-button ng-click="submitClicked()" ng-disabled="!campusChecked" class="md-raised md-primary">Submit</md-button>
<md-button ng-click="submitClicked($event)" ng-disabled="!campusChecked" class="md-raised md-primary">Submit</md-button>
</div>
</div>
</div>