Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI

This commit is contained in:
Matan Bar Yosef 2015-06-24 14:26:13 +03:00
commit 1b3aaea1ff
4 changed files with 149 additions and 161 deletions

View file

@ -1,12 +1,10 @@
angular.module('SeHub') angular.module('SeHub')
.controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) .controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) {
{
$scope.userHasNoName = false; $scope.userHasNoName = false;
$scope.campusChecked = false; $scope.campusChecked = false;
$scope.createCampusClicked = false; $scope.createCampusClicked = false;
$scope.isEmpty = true; // if the academic email line is empty $scope.isEmpty = true; // if the academic email line is empty
$scope.jsonCreateCampus = $scope.jsonCreateCampus = {
{
"title": "Create Campus", "title": "Create Campus",
"email": "email_ending", "email": "email_ending",
"avatar": "self.avatar.url" "avatar": "self.avatar.url"
@ -23,24 +21,21 @@ angular.module('SeHub')
console.error("No User Found!"); console.error("No User Found!");
console.log(data); console.log(data);
if($scope.user.name === ";") if ($scope.user.name === ";") {
{
$scope.user.name = ""; $scope.user.name = "";
$scope.user.name = $scope.user.username; $scope.user.name = $scope.user.username;
$scope.userHasNoName = true; $scope.userHasNoName = true;
} }
apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses apiService.getAllCampuses(token).success(function(data) // Get all the campuses
{ {
$scope.campuses = data; $scope.campuses = data;
}).error(function() }).error(function() {
{
// TODO // TODO
}); });
}); });
$scope.dropdownClicked = function() $scope.dropdownClicked = function() {
{
if ($scope.campus) { if ($scope.campus) {
$scope.campusChecked = true; $scope.campusChecked = true;
$scope.campusObj = null; $scope.campusObj = null;
@ -54,66 +49,58 @@ angular.module('SeHub')
}; };
$scope.submitClicked = function(ev) $scope.submitClicked = function(ev) {
{
var emailValid = false; var emailValid = false;
var jsonUpdateUser =
{
"lecturerStat": "$scope.user.isLecturer",
"campName": "$scope.campusName"
}
if($scope.user.AcMail != null) if ($scope.user.AcMail != null) {
{
var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user
apiService.updateUser($scope.user.seToken, jsonUpdateUser).success(function(data) apiService.updateUser(token, $scope.user).success(function(data) {
{
}).error(function() }).error(function() {
{
// TODO Error // TODO Error
console.log("Error occured on updateUser"); console.log("Error occured on updateUser");
}); });
console.log("Mail: " + fullMail); console.log("Mail: " + fullMail);
apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) apiService.sendValidationMail(token, fullMail).success(function(data) {
{
console.log("DONE - 200"); console.log("DONE - 200");
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') $mdDialog
.ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); // Pop-up alert for e-mail verification .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))
.then(function() {
// TODO ADD- delete cookies and redirect only after pressed 'Got it' // TODO ADD- delete cookies and redirect only after pressed 'Got it'
$cookieStore.remove("com.sehub.www"); // Removing the cookies $cookieStore.remove("com.sehub.www"); // Removing the cookies
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page $window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
}).error(function()
{ }); // Pop-up alert for e-mail verification
}).error(function() {
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') $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)); .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
}); });
} } else // TODO Fix when success to show mdDialog until 'Got it' clicked
else // TODO Fix when success to show mdDialog until 'Got it' clicked
{ {
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') $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)); .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev));
}; };
}; };
$scope.createCampus = function(ev) $scope.createCampus = function(ev) {
{
$scope.createCampusClicked = true; $scope.createCampusClicked = true;
if (!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing) if (!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing)
{ {
if($scope.user.campusMail != null) if ($scope.user.campusMail != null) {
{
validateEmail($scope.user.campusMail); // Verify the email according to "xxx@name.suffix" validateEmail($scope.user.campusMail); // Verify the email according to "xxx@name.suffix"
} }
} }
} }
validateEmail = function(email) validateEmail = function(email) {
{
var result = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; var result = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (!result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked if (!result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
{ {
@ -123,16 +110,14 @@ angular.module('SeHub')
if (result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked if (result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked
{ {
console.log("Im good"); console.log("Im good");
apiService.sendValidationMail($scope.user.seToken, email).success(function(data) apiService.sendValidationMail(token, email).success(function(data) {
{
console.log("DONE - 200"); console.log("DONE - 200");
$mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') $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(email)); // Pop-up alert for e-mail verification .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(email)); // Pop-up alert for e-mail verification
// TODO ADD delete cookies and redirect only after pressed 'Got it' // TODO ADD delete cookies and redirect only after pressed 'Got it'
$cookieStore.remove("com.sehub.www"); // Removing the cookies $cookieStore.remove("com.sehub.www"); // Removing the cookies
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page $window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
}).error(function() }).error(function() {
{
$mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.') $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.')
.ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email)); .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email));
}); });

View file

@ -7,7 +7,7 @@ angular.module('SeHub')
{ {
var taskName = name; var taskName = name;
console.log("task created! " + taskName); console.log("task created! " + taskName);
$window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page $location.path("/tasks/new"); // Reference to 'newTask' page
} }

View file

@ -37,7 +37,7 @@ service.factory('apiService', ['$http', function($http) {
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token; var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token;
req = { req = {
method: "POST", method: "PUT",
url: url, url: url,
data: payLoad data: payLoad
}; };

View file

@ -1,6 +1,7 @@
<div layout-padding> <div layout-padding>
<div layout="row"> <div layout="row">
<div flex="20" layout-padding> <div flex="20" layout-padding>
<md-card layout-padding>
<h2> <h2>
<i class="fa fa-info-circle"></i> Task Info: <i class="fa fa-info-circle"></i> Task Info:
</h2> </h2>
@ -34,10 +35,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </md-card>
<div layout="column" layout-padding>
<div layout="column" flex="30" layout-padding> <md-card layout-padding>
<div> <div>
<h2> <h2>
<i class="fa fa-cubes"></i> Add A component: <i class="fa fa-cubes"></i> Add A component:
@ -64,9 +64,12 @@
<div flex="65"></div> <div flex="65"></div>
<md-button class="md-raised" ng-click="addComponent()"><i class="fa fa-plus"></i> Add To Task</md-button> <md-button class="md-raised" ng-click="addComponent()"><i class="fa fa-plus"></i> Add To Task</md-button>
</div> </div>
</md-card>
</div>
</div> </div>
<div flex="50" layout-padding>
<div flex="80" layout-padding>
<!-- <md-card style="background-image: url('http://www.stationeryhq.com/content/images/thumbs/0000324_clipboard_500.png')"> <!-- <md-card style="background-image: url('http://www.stationeryhq.com/content/images/thumbs/0000324_clipboard_500.png')">
</md-card> --> </md-card> -->