From d1ae77aa015b48205591759c3738f59afe709e16 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 18 Oct 2018 11:09:44 +0530 Subject: [PATCH] merged emailValidationCheck into develop --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 2 +- 400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 173 insertions(+), 51 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 827400d..6f489e6 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -822,7 +822,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.LogoutUser = function () { localStorage.removeItem('loggedInUserDetails'); - // localStorage.clear(); + localStorage.clear(); document.location = '/'; $rootScope.isVisibleLogin = true; } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index 2f1ed77..27db114 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -193,10 +193,11 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, } }); $timeout(function () { + if ($scope.SavedLabExercise != undefined && $scope.SavedLabExercise.lastQuestion > 0) { if ($scope.isResetClicked != true) { $scope.ShowSavedLabExercise(); - + } else { $rootScope.isLoading = false; @@ -204,10 +205,22 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $scope.isResetClicked = false; } } + //else if ($scope.LabExerciseUserData != undefined && $scope.LabExerciseUserData.length > 0) { + // if ($scope.isResetClicked != true) { + // $scope.ShowSavedLabExercise(); + + // } + // else { + // $rootScope.isLoading = false; + // $('#spinner').css('visibility', 'hidden'); + // $scope.isResetClicked = false; + // } + //} else { $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } + }, 100); @@ -1122,6 +1135,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $scope.correctResponseForSavingDatabase = $scope.correctResponseForSavingDatabase.replace(/,$/, ''); } + $scope.getDragItems = function () { var OptionBoxes = $("div[id*='block-']"); @@ -1329,61 +1343,133 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, } $scope.reportCopyStatus = false; $scope.SendLabEXMailToUser = function (User) { + - var reportHtml = ''; - - reportHtml += ''; - $("#resultLabData tr").each(function () { - reportHtml += ''; - $(this).children("td").each(function () { - if ($(this).text() == " Review") { - } - else{ - reportHtml += ''; - } - }); - reportHtml += ''; + // email validation code + + var senderEmails = $("#emailTo").val().split(", "); + $scope.isSenderEmailValid = false; + for (var i = 0; i <= senderEmails.length - 1; i++) { + + var sEmail = senderEmails[i]; + if ($.trim(sEmail).length == 0) { + //alert('*Email To email address is empty'); + $scope.isSenderEmailValid = false; + // event.preventDefault(); + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("Email Address address is empty"); + return false; + } + if ($scope.validateEmail(sEmail)) { + $scope.isSenderEmailValid = true; + } + else { + // alert('*Email To email is not valid'); + $scope.isSenderEmailValid = false; + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("Email Address is not valid"); + // event.preventDefault(); + return false; + } + } + + + $scope.isReceiverEmailValid = false; + var receiverEmail = $("#userEmailID").val(); + var rEmail = receiverEmail; + if ($.trim(rEmail).length == 0) { + $scope.isReceiverEmailValid = false; + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("Your Email Address is empty"); + return false; + } + if ($scope.validateEmail(rEmail)) { + $scope.isReceiverEmailValid = true; + } + else { + $scope.isReceiverEmailValid = false; + $("#alertPopUp").css("display", "block"); + $("#messageBody").text("Your Email Address is not valid"); + return false; + } + + // email validation code ends + + + if ($scope.isSenderEmailValid == true && $scope.isReceiverEmailValid == true) { + + var reportHtml = ''; + reportHtml += '
QuestionActivity TitleStatus
' + $(this).text() + '
'; + $("#resultLabData tr").each(function () { + reportHtml += ''; + $(this).children("td").each(function () { + if ($(this).text() == " Review") { + } + else { + reportHtml += ''; + } }); - reportHtml += '
QuestionActivity TitleStatus
' + $(this).text() + '
'; - - //if ($("#emailComment").val() == undefined || $("#emailComment").val() == "") { - - // $scope.reportImage = "

Report Result:


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; - //} - //else { - - // $scope.reportImage = "
" + $("#emailComment").val() + "

Report Result:


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; - //} - - if ($("#emailComment").val() == undefined || $("#emailComment").val() == "") { + reportHtml += ''; - $scope.reportImage = "

Name: " + User.Name + "


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; - } - else { + }); + reportHtml += ''; - $scope.reportImage = "

Name: " + User.Name + "


" + $("#emailComment").val() + "

" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; - } + //if ($("#emailComment").val() == undefined || $("#emailComment").val() == "") { - $scope.reportTitle = "Lab Exercise Report for " + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text(); - $scope.receiverEmails = $("#emailTo").val(); - - - LabExerciseService.LabExerciseReport(User, $scope.reportImage, $scope.reportTitle, $scope.reportCopyStatus, $scope.receiverEmails).then( + // $scope.reportImage = "

Report Result:


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; + //} + //else { - function (result) { - console.log(result); - }, - function (error) { - console.log(error.statusText); + // $scope.reportImage = "
" + $("#emailComment").val() + "

Report Result:


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; + //} + + if ($("#emailComment").val() == undefined || $("#emailComment").val() == "") { + + $scope.reportImage = "

Name: " + User.Name + "


" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; + } + else { + + $scope.reportImage = "

Name: " + User.Name + "


" + $("#emailComment").val() + "

" + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text() + "Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; + } + + $scope.reportTitle = "Lab Exercise Report for " + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text(); + $scope.receiverEmails = $("#emailTo").val(); + + + LabExerciseService.LabExerciseReport(User, $scope.reportImage, $scope.reportTitle, $scope.reportCopyStatus, $scope.receiverEmails).then( + + function (result) { + console.log(result); + }, + function (error) { + console.log(error.statusText); + } +) + // for closing email popup + $rootScope.closeLabExEmailModel(); + + document.getElementById('labExEmailSentModalID').style.display = "block"; + document.getElementById('labExModalbackground').style.display = "block"; + + + + + } + + } + + $scope.validateEmail = function (sEmail) { + var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; + if (filter.test(sEmail)) { + return true; + } + else { + return false; } - ) - // for closing email popup - $rootScope.closeLabExEmailModel(); - - document.getElementById('labExEmailSentModalID').style.display = "block"; - document.getElementById('labExModalbackground').style.display = "block"; } + + $rootScope.closeLabExEmailModel = function () { document.getElementById("LabExerciseForm").reset(); $scope.LabExForm.$setPristine(); @@ -1405,6 +1491,10 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, document.getElementById('labExModalbackground').style.display = "none"; } + + + + }] ); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index f54294d..6479a63 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -1,5 +1,11 @@  +
@@ -38,10 +44,13 @@
- + +
*Use ',' to separate multiple email ids.
+ -
+ +
@@ -61,7 +70,7 @@
- + @@ -108,6 +117,29 @@
+ + + + + + +