Advertisement
Guest User

dashboard controller

a guest
Feb 11th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.51 KB | None | 0 0
  1.  
  2. function DashboardCtrl($scope, $http, $filter, $rootScope, $location, $timeout, $routeParams, HackerRank) {
  3. $rootScope.companyname = $routeParams.companyname;
  4. $rootScope.metaTitle = 'Find Jobs fast';
  5. $rootScope.metaDescription = 'The best jobs from a variety of employers across many industries.';
  6. $scope.$on('$locationChangeStart', function(event) {
  7. $('#JobModal').modal('hide');
  8. });
  9. $scope.WentRealInterview = false;
  10. $scope.WentRealInterviewStyle = '42%';
  11. $scope.progress = 0.50;
  12. $scope.IndustryFilter = '';
  13. $scope.FullPartFilter = '';
  14. $scope.CurrentQuestionTest = 'Describe your strengths and weaknesses';
  15. $scope.VisaStatus = '';
  16. $rootScope.CurrentList = [];
  17. $scope.TakeAptitudeTest = function(JobIDGiven) {
  18. console.log(JobIDGiven);
  19. $location.path('/aptitude-multiple-test/' + JobIDGiven);
  20. }
  21. $scope.TakeAptitudeTestMobile = function(JobIDGiven) {
  22. console.log(JobIDGiven);
  23. $location.path('/aptitude-multiple-test/' + JobIDGiven);
  24. }
  25. $scope.GoToRealInterview = function() {
  26. $http.post('GetVideoJobId.php', {
  27. "data": $scope.Job_id,
  28. Question: $scope.CurrentQuestion
  29. }).success(function(data, status) {
  30. for (var i = 0; i < $rootScope.CurrentList.length; i++) {
  31. if ($scope.Job_id == $rootScope.CurrentList[i].id) {
  32. $rootScope.CurrentList[i].VideoAnswers = [{
  33. location: '',
  34. student: ''
  35. }];
  36. }
  37. }
  38. }).error(function(data, status) {});
  39. // $scope.CurrentQuestion = $scope.VideoQuestions[0].questions;
  40. $('#WebCamModal').modal('hide');
  41. $scope.WentRealInterview = true;
  42. $scope.WentRealInterviewStyle = '';
  43. $('#WebCamModalTest').modal('show');
  44. }
  45. $scope.ShowModalVideoPlayer = function(Job) {
  46. $location.path('/practice-video/' + Job.id);
  47. //window.location.reload(true);
  48. // window.location = window.location.href + '?' + new Date().getTime();
  49. // location.reload(true); // works for safari
  50. // window.location.reload();
  51. }
  52. /*
  53. $scope.ShowModalVideoPlayer = function (Job) {
  54. $scope.WentRealInterviewStyle = '42%';
  55. $scope.VideoQuestions = Job.VideoQuestions;
  56. $scope.CurrentQuestion = Job.VideoQuestions[0].questions;
  57. $scope.Job_id = Job.id;
  58. $scope.name = Job.name;
  59. $scope.location = Job.location;
  60. $scope.Website = Job.website;
  61. $scope.PostDate = Job.CurDate;
  62. $scope.DaysDeadline = Job.DaysDeadline;
  63. $scope.biography = Job.biography;
  64. $scope.LocalInt = Job.LocalInt;
  65. $scope.type = Job.type;
  66. $scope.FullPart = Job.Fullpart;
  67. $scope.remuneration = Job.remuneration;
  68. $scope.profile = Job.profile
  69. $scope.Status = Job.Status;
  70. $scope.realtasks = Job.realtasks;
  71. $scope.DisplayMatchingModal = Job.DisplayMatching;
  72. $scope.DisplayNumberMatching = Job.Matching;
  73. $scope.realskills = Job.realskills;
  74. $scope.Perks = Job.Perks;
  75. $scope.Companyname = Job.Companyname;
  76. $scope.profile = Job.profile;
  77. $scope.Culture = Job.Culture;
  78. $scope.Life = Job.Life;
  79. $scope.deadline = Job.deadline;
  80. $scope.duration = Job.Duration;
  81. $scope.employerBiography = Job.employerBiography;
  82. $("#webcamModal").modal('show');
  83. $scope.WentRealInterview = false;
  84. }
  85. */
  86.  
  87. $scope.CloseVideoInterviewModal = function() {
  88. $("#webcamModal").modal('hide');
  89. }
  90.  
  91. $scope.ShowVideoRecordingVar = 1;
  92. $scope.VideoClassOne = 'video-tabs-active';
  93. $scope.VideoClassTwo = '';
  94. $scope.VideoClassThree = '';
  95. $scope.ShowVideoRecordingTap = function(num) {
  96. if (num == 1) {
  97. $scope.ShowVideoRecordingVar = 1;
  98. $scope.VideoClassOne = 'video-tabs-active';
  99. $scope.VideoClassTwo = '';
  100. $scope.VideoClassThree = '';
  101. } else if (num == 2) {
  102. $scope.ShowVideoRecordingVar = 2;
  103. $scope.VideoClassOne = '';
  104. $scope.VideoClassTwo = 'video-tabs-active';
  105. $scope.VideoClassThree = '';
  106. } else if (num == 3) {
  107. $scope.ShowVideoRecordingVar = 3;
  108. $scope.VideoClassOne = '';
  109. $scope.VideoClassTwo = '';
  110. $scope.VideoClassThree = 'video-tabs-active';
  111. }
  112. }
  113. $scope.PendingTableClass = 'sm-header-item sm-active active';
  114. $scope.ShortlistedTableClass = 'sm-header-item';
  115. $scope.ContactedTableClass = 'sm-header-item';
  116. $scope.DeclinedTableClass = 'sm-header-item';
  117. $scope.ShowGeneralJobs = true;
  118. $rootScope.CountPending = 0;
  119. $rootScope.CountShortlisted = 0;
  120. $rootScope.CountContacted = 0;
  121. $rootScope.CountDeclined = 0;
  122. $rootScope.CountPassed = 0;
  123. $rootScope.CountVideo = 0;
  124. $rootScope.CountPhone = 0;
  125. $rootScope.CountInterview = 0;
  126. $rootScope.CountDeclined = 0;
  127. $rootScope.ApplyGeneralJobModal = function() {
  128. $http.post('ApplyStudentJob.php', {
  129. "data": $scope.ModalJob.id
  130. }).success(function(data, status) {
  131. $rootScope.CountPending++;
  132. $scope.ModalJob.Status = 'pending';
  133. $rootScope.CurrentList.push($scope.ModalJob);
  134. }).error(function(data, status) {});
  135. }
  136. $scope.DisplayInDashboardModal = function(Job) {
  137. $scope.ModalJob = Job;
  138. $scope.ModalId = Job.id;
  139. $scope.GraduateInternship = Job.GraduateInternship;
  140. $scope.name = Job.name;
  141. $scope.VideoQuestions = Job.VideoQuestions;
  142. $scope.location = Job.location;
  143. $scope.Website = Job.website;
  144. $scope.PostDate = Job.CurDate;
  145. $scope.DaysDeadline = Job.DaysDeadline;
  146. $scope.biography = Job.biography;
  147. $scope.LocalInt = Job.LocalInt;
  148. $scope.type = Job.type;
  149. $scope.FullPart = Job.Fullpart;
  150. $scope.remuneration = Job.remuneration;
  151. $scope.profile = Job.profile;
  152. $scope.Status = Job.Status;
  153. $scope.realtasks = Job.realtasks;
  154. $scope.DisplayMatchingModal = Job.DisplayMatching;
  155. $scope.DisplayNumberMatching = Job.Matching;
  156. $scope.realskills = Job.realskills;
  157. $scope.Perks = Job.Perks;
  158. $scope.Companyname = Job.Companyname;
  159. $scope.nameSpace = $scope.name.replace(/[\s]/g, '-');
  160. $scope.CompanynameSpace = $scope.Companyname.replace(/[\s]/g, '-');
  161. $scope.profile = Job.profile;
  162. $scope.Culture = Job.Culture;
  163. $scope.Life = Job.Life;
  164. $scope.deadline = Job.deadline;
  165. $scope.duration = Job.Duration;
  166. $scope.employerBiography = Job.employerBiography;
  167. $scope.PictureOneModal = Job.PictureOne;
  168. $scope.PictureTwoModal = Job.PictureTwo;
  169. $scope.PictureThreeModal = Job.PictureThree;
  170. if ($scope.PictureThreeModal == '') {
  171. $scope.PictureThreeModal = 'New-Icons/Company_placeholder_2.jpg';
  172. }
  173. if ($scope.PictureTwoModal == '') {
  174. $scope.PictureTwoModal = 'New-Icons/Company_placeholder_2.jpg';
  175. }
  176. if ($scope.PictureOneModal == '') {
  177. $scope.PictureOneModal = 'New-Icons/Company_placeholder.jpg';
  178. }
  179. }
  180. $rootScope.ShortlistGeneralJobModal = function() {
  181. $http.post('ShortlistStudentJob.php', {
  182. "data": $scope.ModalJob.id
  183. }).success(function(data, status) {
  184. $rootScope.CountShortlisted++;
  185. $scope.ModalJob.Status = 'shortlisted';
  186. $rootScope.CurrentList.push($scope.ModalJob);
  187. }).error(function(data, status) {});
  188. }
  189. $rootScope.RemoveShortlistGeneralJobModal = function() {
  190. $http.post('RemoveShortlistStudentJob.php', {
  191. "data": $scope.ModalJob.id
  192. }).success(function(data, status) {
  193. $rootScope.CountShortlisted--;
  194. $scope.ModalJob.Status = '';
  195. for (var i = 0; i < $rootScope.CurrentList.length; i++) {
  196. if ($rootScope.CurrentList[i].id == $scope.ModalJob.id) {
  197. $rootScope.CurrentList.splice($rootScope.CurrentList.indexOf($rootScope.CurrentList[i]));
  198. }
  199. }
  200. }).error(function(data, status) {});
  201. }
  202. $rootScope.ApplyGeneralJob = function(App) {
  203. $http.post('ApplyStudentJob.php', {
  204. "data": App.id
  205. }).success(function(data, status) {
  206. $rootScope.CountPending++;
  207. App.Status = 'pending';
  208. $rootScope.CurrentList.push(App);
  209. }).error(function(data, status) {});
  210. }
  211. $rootScope.ShortlistGeneralJob = function(App) {
  212. if (App.Status != 'pending') {
  213. $http.post('ShortlistStudentJob.php', {
  214. "data": App.id
  215. }).success(function(data, status) {
  216. $rootScope.CountShortlisted++;
  217. App.Status = 'shortlisted';
  218. $rootScope.CurrentList.push(App);
  219. }).error(function(data, status) {});
  220. }
  221.  
  222. }
  223. $rootScope.RemoveShortlistGeneralJob = function(App) {
  224. $http.post('RemoveShortlistStudentJob.php', {
  225. "data": App.id
  226. }).success(function(data, status) {
  227. $rootScope.CountShortlisted--;
  228. App.Status = '';
  229. for (var i = 0; i < $rootScope.CurrentList.length; i++) {
  230. if ($rootScope.CurrentList[i].id == App.id) {
  231. $rootScope.CurrentList.splice($rootScope.CurrentList.indexOf($rootScope.CurrentList[i]), 1);
  232. }
  233. }
  234. }).error(function(data, status) {});
  235. }
  236. $scope.PendingTableClass = 'sm-header-item sm-active-dashboard';
  237. $scope.PassedTableClass = 'sm-header-item';
  238. $scope.ShortlistedTableClass = 'sm-header-item';
  239. $scope.VideoTableClass = 'sm-header-item';
  240. $scope.PhoneTableClass = 'sm-header-item';
  241. $scope.InterviewTableClass = 'sm-header-item';
  242. $scope.myFilter = {
  243. Status: 'pending'
  244. };
  245. $scope.ChangeBoxClass = function(num) {
  246. if (num == 1) {
  247. $scope.PendingTableClass = 'sm-header-item sm-active-dashboard';
  248. $scope.PassedTableClass = 'sm-header-item';
  249. $scope.ShortlistedTableClass = 'sm-header-item';
  250. $scope.VideoTableClass = 'sm-header-item';
  251. $scope.PhoneTableClass = 'sm-header-item';
  252. $scope.InterviewTableClass = 'sm-header-item';
  253. $scope.DeclinedTableClass = 'sm-header-item';
  254. $scope.ShowGeneralJobs = false;
  255. $scope.myFilter = {
  256. Status: 'pending'
  257. };
  258. } else if (num == 2) {
  259. $scope.PendingTableClass = 'sm-header-item';
  260. $scope.PassedTableClass = 'sm-header-item sm-active-dashboard';
  261. $scope.ShortlistedTableClass = 'sm-header-item';
  262. $scope.VideoTableClass = 'sm-header-item';
  263. $scope.PhoneTableClass = 'sm-header-item';
  264. $scope.InterviewTableClass = 'sm-header-item';
  265. $scope.DeclinedTableClass = 'sm-header-item';
  266. $scope.ShowGeneralJobs = false;
  267. $scope.myFilter = {
  268. Status: 'passed'
  269. };
  270. } else if (num == 3) {
  271. $scope.PendingTableClass = 'sm-header-item';
  272. $scope.PassedTableClass = 'sm-header-item';
  273. $scope.ShortlistedTableClass = 'sm-header-item sm-active-dashboard';
  274. $scope.VideoTableClass = 'sm-header-item';
  275. $scope.PhoneTableClass = 'sm-header-item';
  276. $scope.InterviewTableClass = 'sm-header-item';
  277. $scope.DeclinedTableClass = 'sm-header-item';
  278. $scope.ShowGeneralJobs = false;
  279. $scope.myFilter = {
  280. Status: 'EmployerShortlisted'
  281. };
  282. } else if (num == 4) {
  283. $scope.PendingTableClass = 'sm-header-item';
  284. $scope.PassedTableClass = 'sm-header-item';
  285. $scope.ShortlistedTableClass = 'sm-header-item';
  286. $scope.VideoTableClass = 'sm-header-item sm-active-dashboard';
  287. $scope.PhoneTableClass = 'sm-header-item';
  288. $scope.InterviewTableClass = 'sm-header-item';
  289. $scope.DeclinedTableClass = 'sm-header-item';
  290. $scope.ShowGeneralJobs = false;
  291. $scope.myFilter = {
  292. Status: 'Video'
  293. };
  294. } else if (num == 5) {
  295. $scope.PendingTableClass = 'sm-header-item';
  296. $scope.PassedTableClass = 'sm-header-item';
  297. $scope.ShortlistedTableClass = 'sm-header-item';
  298. $scope.VideoTableClass = 'sm-header-item';
  299. $scope.PhoneTableClass = 'sm-header-item sm-active-dashboard';
  300. $scope.InterviewTableClass = 'sm-header-item';
  301. $scope.DeclinedTableClass = 'sm-header-item';
  302. $scope.ShowGeneralJobs = false;
  303. $scope.myFilter = {
  304. Status: 'Phone'
  305. };
  306. } else if (num == 6) {
  307. $scope.PendingTableClass = 'sm-header-item';
  308. $scope.PassedTableClass = 'sm-header-item';
  309. $scope.ShortlistedTableClass = 'sm-header-item';
  310. $scope.VideoTableClass = 'sm-header-item';
  311. $scope.PhoneTableClass = 'sm-header-item';
  312. $scope.InterviewTableClass = 'sm-header-item sm-active-dashboard';
  313. $scope.DeclinedTableClass = 'sm-header-item';
  314. $scope.ShowGeneralJobs = false;
  315. $scope.myFilter = {
  316. Status: 'Interview'
  317. };
  318. } else if (num == 7) {
  319. $scope.PendingTableClass = 'sm-header-item';
  320. $scope.PassedTableClass = 'sm-header-item';
  321. $scope.ShortlistedTableClass = 'sm-header-item';
  322. $scope.VideoTableClass = 'sm-header-item';
  323. $scope.PhoneTableClass = 'sm-header-item';
  324. $scope.InterviewTableClass = 'sm-header-item';
  325. $scope.DeclinedTableClass = 'sm-header-item sm-active-dashboard';
  326. $scope.ShowGeneralJobs = false;
  327. $scope.myFilter = {
  328. Status: 'declined'
  329. };
  330. }
  331. }
  332.  
  333. var lockJobs = function() {
  334. $rootScope.CurrentList.forEach(function(el, i, arr) {
  335. arr[i].locked = true;
  336. });
  337. }
  338.  
  339.  
  340. $scope.getTestStatus = function() {
  341. // get all tests taken by user
  342. var email = $rootScope.email;
  343. console.log(email);
  344. $http.post("getApplicantTests.php", { "email": $rootScope.email }).then(function (data) {
  345. // iterate trough all jobs in CurrentList, change message on button
  346. var funData = data.data;
  347. console.log(funData);
  348. for (var j = 0; j < $rootScope.CurrentList.length; j++) {
  349. for (var k = 0; k < $rootScope.CurrentList[j].hrlinks.length; k++) {
  350. for (var i = 0; i < funData.length; i++) {
  351. if (funData[i].test_id === $rootScope.CurrentList[j].hrlinks[k].test_id) {
  352. if (funData[i].status === "incomplete" &&
  353. !$rootScope.CurrentList[j].hrlinks[k].name.startsWith("Invite sent!")) {
  354. $rootScope.CurrentList[j].hrlinks[k].name += " - Resend Invite";
  355. } else if (funData[i].status === "complete") {
  356. $rootScope.CurrentList[j].hrlinks[k].name += " - Completed";
  357. $rootScope.CurrentList[j].hrlinks[k].disabled = true;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. });
  364. }
  365.  
  366. $http.get('GetApplicantJobs.php').success(function(data) {
  367. $rootScope.CurrentList = data;
  368. for (var i = 0; i < $rootScope.CurrentList.length; i++) {
  369. if ($rootScope.CurrentList[i].Status == 'passed') {
  370. $rootScope.CountPassed++;
  371. } else if ($rootScope.CurrentList[i].Status == 'pending') {
  372. console.log($rootScope.CurrentList[i].Status);
  373. $rootScope.CountPending++;
  374. } else if ($rootScope.CurrentList[i].Status == 'EmployerShortlisted') {
  375. $rootScope.CountShortlisted++;
  376. } else if ($rootScope.CurrentList[i].Status == 'Video') {
  377. $rootScope.CountVideo++;
  378. } else if ($rootScope.CurrentList[i].Status == 'Phone') {
  379. $rootScope.CountPhone++;
  380. } else if ($rootScope.CurrentList[i].Status == 'Interview') {
  381. $rootScope.CountInterview++;
  382. } else if ($rootScope.CurrentList[i].Status == 'declined') {
  383. $rootScope.CountDeclined++;
  384. }
  385. }
  386. $scope.getTestStatus();
  387. }).error(function(data) {
  388. $scope.CurrentEmployerJobs = data || "Request failed";
  389. });
  390.  
  391. $scope.sendHackerRankInvite = function(job_id, test_id, employer_id) {
  392. var email = $rootScope.email;
  393. var jobIndex = -1;
  394. var testIndex = -1;
  395. // find the job so we can update the message
  396. for (var i = 0; i < $rootScope.CurrentList.length; i++) {
  397. if ($rootScope.CurrentList[i].id === job_id) {
  398. jobIndex = i;
  399. break;
  400. }
  401. }
  402.  
  403. // find the test so we can disable the button after sending.
  404. for (var i = 0; i < $rootScope.CurrentList[jobIndex].hrlinks.length; i++) {
  405. if ($rootScope.CurrentList[jobIndex].hrlinks[i].test_id === test_id) {
  406. testIndex = i;
  407. }
  408. }
  409. var oldName = $rootScope.CurrentList[jobIndex].hrlinks[testIndex].name;
  410. $rootScope.CurrentList[jobIndex].hrlinks[testIndex].name = "Sending invite...";
  411. $rootScope.CurrentList[jobIndex].hrlinks[testIndex].disabled = true;
  412. HackerRank.getAccount(employer_id).then(function (data) {
  413. $http.post("sendHackerRankEmail.php",
  414. { "username" : email,
  415. "send_email" : "true",
  416. "force" : "true",
  417. "hide_login_credentials" : "true",
  418. "test_result_url": "http://43.243.201.96/catchTestData.php",
  419. "access_token" : data.data.access_token,
  420. "test_id" : test_id,
  421. "job_id" : job_id
  422. }
  423. ).then(function(data2) {
  424. if (!data2.data.data) {
  425. $rootScope.CurrentList[jobIndex].message = "This employer's HackerRank account is unavailable at this time. "
  426. + " They will be contacted in order to rectify this issue.";
  427. $rootScope.CurrentList[jobIndex].hrlinks[testIndex].name = oldName;
  428. lockJobs();
  429. return;
  430. }
  431. if (data2.data.data.status === true) {
  432. $rootScope.CurrentList[jobIndex].message = null;
  433. $rootScope.CurrentList[jobIndex].hrlinks[testIndex].name = "Invite sent! "
  434. + "Check your email inbox.";
  435. } else {
  436. $rootScope.CurrentList[jobIndex].message = "Invite not sent. Have you already taken this test? Refresh the page to update any status, and try again if necessary.";
  437. }
  438. }, function(err) {
  439. console.log(err.message);
  440. });
  441. });
  442.  
  443. }
  444.  
  445.  
  446.  
  447.  
  448. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement