From b594bd5b7efb730351d915fdcb4df895cfc75600 Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Wed, 26 Aug 2015 13:27:24 +0700 Subject: [PATCH 1/6] update translate --- .../webapp/assets/modules/translation/messages_vi.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/assets/modules/translation/messages_vi.json b/src/main/webapp/assets/modules/translation/messages_vi.json index 3cc5c24c8..2d3c1157a 100644 --- a/src/main/webapp/assets/modules/translation/messages_vi.json +++ b/src/main/webapp/assets/modules/translation/messages_vi.json @@ -682,15 +682,15 @@ "postAnEvent": "Tạo Sự Kiện", "webinar": "Webinar", "allEvents": "Tất cả Sự Kiện", - "whatDoWeOffer": "what do we offer?", + "whatDoWeOffer": "Phúc lợi công ty", "cannotInPast": "Trường này không được ở quá khứ.", "register": "Đăng Ký", "upcomingEvents": "Sự Kiện Sắp Diễn Ra", "viewMoreEvents": "Các Sự Kiện Khác", - "tellYourFriends": "Tell Your Friends", - "joinWithFacebook": "Join With Facebook", + "tellYourFriends": "Chia Sẻ Tới Bạn Bè", + "joinWithFacebook": "Tham Gia Ngay Với Facebook", "address": "Address", - "companyProfile": "Company Profile", + "companyProfile": "Sơ Lược Về Công Ty", "attendantsLabel": "Người tham gia", "eventsTitle": "Hãy cùng Gặp Gỡ và Giao Lưu thông qua các Sự Kiện Trực Tuyến" } From 4f2d96fe4f4591fca9b078e1e0f3b960bd228694 Mon Sep 17 00:00:00 2001 From: khoa-nd Date: Wed, 26 Aug 2015 13:38:11 +0700 Subject: [PATCH 2/6] Refactor job search {filter by last 30 days and set higher priority for job which has salary information} --- .../service/impl/JobAlertServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/techlooper/service/impl/JobAlertServiceImpl.java b/src/main/java/com/techlooper/service/impl/JobAlertServiceImpl.java index a563a2332..92845d7cf 100644 --- a/src/main/java/com/techlooper/service/impl/JobAlertServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/JobAlertServiceImpl.java @@ -10,8 +10,7 @@ import freemarker.template.Template; import org.apache.commons.lang3.StringUtils; import org.dozer.Mapper; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.*; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; import org.joda.time.DateTime; @@ -235,22 +234,23 @@ public Long countJob(JobListingCriteria criteria) { private NativeSearchQueryBuilder getJobListingQueryBuilder(JobListingCriteria criteria) { NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("job"); + QueryBuilder queryBuilder = null; if (StringUtils.isEmpty(criteria.getKeyword()) && StringUtils.isEmpty(criteria.getLocation())) { - searchQueryBuilder.withQuery(matchAllQuery()); + queryBuilder = matchAllQuery(); } else { - BoolQueryBuilder queryBuilder = boolQuery(); + queryBuilder = boolQuery(); if (StringUtils.isNotEmpty(criteria.getKeyword())) { - queryBuilder.must(queryString(criteria.getKeyword())); + ((BoolQueryBuilder)queryBuilder).must(queryString(criteria.getKeyword())); } if (StringUtils.isNotEmpty(criteria.getLocation())) { - queryBuilder.must(matchQuery("location", criteria.getLocation())); + ((BoolQueryBuilder)queryBuilder).must(matchQuery("location", criteria.getLocation())); } - - searchQueryBuilder.withQuery(queryBuilder); } + searchQueryBuilder.withQuery(filteredQuery(queryBuilder, FilterBuilders.rangeFilter("createdDateTime").from("now-30d/d"))); + searchQueryBuilder.withSort(SortBuilders.fieldSort("salary").missing("_last")); searchQueryBuilder.withSort(SortBuilders.fieldSort("createdDateTime").order(SortOrder.DESC)); searchQueryBuilder.withPageable(new PageRequest(criteria.getPage() - 1, NUMBER_OF_ITEMS_PER_PAGE)); return searchQueryBuilder; From 370433c43b06d27a85c8c792c520f31913b24f52 Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Wed, 26 Aug 2015 13:57:27 +0700 Subject: [PATCH 3/6] hide Job Priority Job box when dont have Item --- .../modules/job-listing/job-listing.html | 64 +++++++++---------- .../job-listing/jobListingController.js | 1 + src/main/webapp/assets/sass/job-listing.sass | 5 ++ 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/main/webapp/assets/modules/job-listing/job-listing.html b/src/main/webapp/assets/modules/job-listing/job-listing.html index d8ad2f9a9..69fd5c708 100644 --- a/src/main/webapp/assets/modules/job-listing/job-listing.html +++ b/src/main/webapp/assets/modules/job-listing/job-listing.html @@ -63,50 +63,48 @@

-
-
-
-

{{job.title}}

-
    -
  • {{job.postedOn}}
  • -
  • {{job.location}}
  • -
-

: - {{'negotiable' | translate}} - {{job.salary}}

-
-
    -
  • +
    +
    +

    {{job.title}}

    +
      +
    • {{job.postedOn}}
    • +
    • {{job.location}}
    • +
    +

    : + {{'negotiable' | translate}} + {{job.salary}}

    +
    +
      +
    • {{skill.skillName}} -
    • -
    -
    -
    -

    - -

    -
      -
    • - - {{offer.benefitValue}} -
    • -
    -
    +
  • +
-
+
+

+ +

    -
  • {{job.company}}
  • -
  • - +
  • + + {{offer.benefitValue}}
  • -
+
+
    +
  • {{job.company}}
  • +
  • + +
  • +
  • +
+
diff --git a/src/main/webapp/assets/modules/job-listing/jobListingController.js b/src/main/webapp/assets/modules/job-listing/jobListingController.js index 965728f92..05e950f95 100644 --- a/src/main/webapp/assets/modules/job-listing/jobListingController.js +++ b/src/main/webapp/assets/modules/job-listing/jobListingController.js @@ -10,6 +10,7 @@ techlooper.controller("jobListingController", function (apiService, $scope, vnwC $scope.totalJob = response.totalJob; $scope.page = response.page; $scope.jobs = response.jobs; + console.log($scope.jobs); }); } else { var searchParams = searchText.split("+"); diff --git a/src/main/webapp/assets/sass/job-listing.sass b/src/main/webapp/assets/sass/job-listing.sass index c93bff323..b2034b569 100644 --- a/src/main/webapp/assets/sass/job-listing.sass +++ b/src/main/webapp/assets/sass/job-listing.sass @@ -246,6 +246,11 @@ max-width: 100px .job-item:first-child border-top: 0 + .job-item.hot-job + border-top: 1px solid #9fd1ee + border-left: 1px solid #9fd1ee + border-right: 1px solid #9fd1ee + background-color: #f3fafe .hot-jobs display: inline-block clear: both From 4d3f9b401535d75a4c2cef67aac8639ad7604140 Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Wed, 26 Aug 2015 14:21:45 +0700 Subject: [PATCH 4/6] update translate --- src/main/webapp/assets/modules/translation/messages_en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/assets/modules/translation/messages_en.json b/src/main/webapp/assets/modules/translation/messages_en.json index 8821b5b1b..667e40c42 100644 --- a/src/main/webapp/assets/modules/translation/messages_en.json +++ b/src/main/webapp/assets/modules/translation/messages_en.json @@ -693,5 +693,5 @@ "address": "Address", "companyProfile": "Company Profile", "attendantsLabel": "Attendant(s)", - "eventsTitle": "Let's HangOut 'cause WE are AWESOME when getting TOGETHER" + "eventsTitle": "Let's Hang Out 'cause WE are AWESOME when getting TOGETHER" } \ No newline at end of file From 9c2b4b5ad81a153351ec35d2fd908fabaebad4cc Mon Sep 17 00:00:00 2001 From: khoa-nd Date: Wed, 26 Aug 2015 14:28:32 +0700 Subject: [PATCH 5/6] Fix the issue that reply to email has been set wrong --- .../service/impl/ChallengeServiceImpl.java | 681 +++++++++--------- 1 file changed, 338 insertions(+), 343 deletions(-) diff --git a/src/main/java/com/techlooper/service/impl/ChallengeServiceImpl.java b/src/main/java/com/techlooper/service/impl/ChallengeServiceImpl.java index 4731c54fe..b6550aafc 100644 --- a/src/main/java/com/techlooper/service/impl/ChallengeServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/ChallengeServiceImpl.java @@ -21,8 +21,6 @@ import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.metrics.sum.Sum; import org.elasticsearch.search.aggregations.metrics.sum.SumBuilder; -import org.elasticsearch.search.sort.SortBuilders; -import org.elasticsearch.search.sort.SortOrder; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; @@ -58,323 +56,320 @@ @Service public class ChallengeServiceImpl implements ChallengeService { - @Resource - private ElasticsearchTemplate elasticsearchTemplateUserImport; + @Resource + private ElasticsearchTemplate elasticsearchTemplateUserImport; - @Resource - private MimeMessage postChallengeMailMessage; + @Resource + private MimeMessage postChallengeMailMessage; - @Resource - private Template postChallengeMailTemplateEn; + @Resource + private Template postChallengeMailTemplateEn; - @Resource - private Template postChallengeMailTemplateVi; + @Resource + private Template postChallengeMailTemplateVi; - @Value("${mail.postChallenge.subject.vn}") - private String postChallengeMailSubjectVn; + @Value("${mail.postChallenge.subject.vn}") + private String postChallengeMailSubjectVn; - @Value("${mail.postChallenge.subject.en}") - private String postChallengeMailSubjectEn; + @Value("${mail.postChallenge.subject.en}") + private String postChallengeMailSubjectEn; - @Value("${mail.postChallenge.techloopies.mailSubject}") - private String postChallengeTechloopiesMailSubject; + @Value("${mail.postChallenge.techloopies.mailSubject}") + private String postChallengeTechloopiesMailSubject; - @Value("${mail.postChallenge.techloopies.mailList}") - private String postChallengeTechloopiesMailList; + @Value("${mail.postChallenge.techloopies.mailList}") + private String postChallengeTechloopiesMailList; - @Value("${web.baseUrl}") - private String webBaseUrl; + @Value("${web.baseUrl}") + private String webBaseUrl; - @Resource - private Template confirmUserJoinChallengeMailTemplateEn; + @Resource + private Template confirmUserJoinChallengeMailTemplateEn; - @Resource - private Template confirmUserJoinChallengeMailTemplateVi; + @Resource + private Template confirmUserJoinChallengeMailTemplateVi; - @Value("${mail.confirmUserJoinChallenge.subject.vn}") - private String confirmUserJoinChallengeMailSubjectVn; + @Value("${mail.confirmUserJoinChallenge.subject.vn}") + private String confirmUserJoinChallengeMailSubjectVn; - @Value("${mail.confirmUserJoinChallenge.subject.en}") - private String confirmUserJoinChallengeMailSubjectEn; + @Value("${mail.confirmUserJoinChallenge.subject.en}") + private String confirmUserJoinChallengeMailSubjectEn; - @Resource - private Template alertEmployerChallengeMailTemplateEn; + @Resource + private Template alertEmployerChallengeMailTemplateEn; - @Resource - private Template alertEmployerChallengeMailTemplateVi; + @Resource + private Template alertEmployerChallengeMailTemplateVi; - @Value("${mail.alertEmployerChallenge.subject.vn}") - private String alertEmployerChallengeMailSubjectVn; + @Value("${mail.alertEmployerChallenge.subject.vn}") + private String alertEmployerChallengeMailSubjectVn; - @Value("${mail.alertEmployerChallenge.subject.en}") - private String alertEmployerChallengeMailSubjectEn; + @Value("${mail.alertEmployerChallenge.subject.en}") + private String alertEmployerChallengeMailSubjectEn; - @Value("${mail.techlooper.reply_to}") - private String mailTechlooperReplyTo; + @Value("${mail.techlooper.reply_to}") + private String mailTechlooperReplyTo; - @Resource - private JavaMailSender mailSender; + @Resource + private JavaMailSender mailSender; - @Resource - private ChallengeRepository challengeRepository; + @Resource + private ChallengeRepository challengeRepository; - @Resource - private ChallengeRegistrantRepository challengeRegistrantRepository; + @Resource + private ChallengeRegistrantRepository challengeRegistrantRepository; - @Resource - private Mapper dozerMapper; + @Resource + private Mapper dozerMapper; - @Value("${elasticsearch.userimport.index.name}") - private String techlooperIndex; + @Value("${elasticsearch.userimport.index.name}") + private String techlooperIndex; - @Override - public ChallengeEntity savePostChallenge(ChallengeDto challengeDto) throws Exception { - ChallengeEntity challengeEntity = dozerMapper.map(challengeDto, ChallengeEntity.class); - challengeEntity.setChallengeId(new Date().getTime()); - challengeEntity.setStartDateTime(challengeDto.getStartDate()); - challengeEntity.setRegistrationDateTime(challengeDto.getRegistrationDate()); - challengeEntity.setSubmissionDateTime(challengeDto.getSubmissionDate()); - return challengeRepository.save(challengeEntity); - } - - @Override - public void sendPostChallengeEmailToEmployer(ChallengeEntity challengeEntity) - throws MessagingException, IOException, TemplateException { - String mailSubject = challengeEntity.getLang() == Language.vi ? postChallengeMailSubjectVn : postChallengeMailSubjectEn; - Address[] recipientAddresses = getRecipientAddresses(challengeEntity, true); - Template template = challengeEntity.getLang() == Language.vi ? postChallengeMailTemplateVi : postChallengeMailTemplateEn; - sendPostChallengeEmail(challengeEntity, mailSubject, recipientAddresses, template); - } - - @Override - public void sendPostChallengeEmailToTechloopies(ChallengeEntity challengeEntity) - throws MessagingException, IOException, TemplateException { - String mailSubject = postChallengeTechloopiesMailSubject; - Address[] recipientAddresses = InternetAddress.parse(postChallengeTechloopiesMailList); - sendPostChallengeEmail(challengeEntity, mailSubject, recipientAddresses, postChallengeMailTemplateEn); - } + @Override + public ChallengeEntity savePostChallenge(ChallengeDto challengeDto) throws Exception { + ChallengeEntity challengeEntity = dozerMapper.map(challengeDto, ChallengeEntity.class); + challengeEntity.setChallengeId(new Date().getTime()); + challengeEntity.setStartDateTime(challengeDto.getStartDate()); + challengeEntity.setRegistrationDateTime(challengeDto.getRegistrationDate()); + challengeEntity.setSubmissionDateTime(challengeDto.getSubmissionDate()); + return challengeRepository.save(challengeEntity); + } - @Override - public ChallengeDetailDto getChallengeDetail(Long challengeId) { - ChallengeEntity challengeEntity = challengeRepository.findOne(challengeId); - if (challengeEntity != null) { - ChallengeDetailDto challengeDetailDto = dozerMapper.map(challengeEntity, ChallengeDetailDto.class); - challengeDetailDto.setNumberOfRegistrants(getNumberOfRegistrants(challengeId)); - return challengeDetailDto; + @Override + public void sendPostChallengeEmailToEmployer(ChallengeEntity challengeEntity) + throws MessagingException, IOException, TemplateException { + String mailSubject = challengeEntity.getLang() == Language.vi ? postChallengeMailSubjectVn : postChallengeMailSubjectEn; + Address[] recipientAddresses = getRecipientAddresses(challengeEntity, true); + Template template = challengeEntity.getLang() == Language.vi ? postChallengeMailTemplateVi : postChallengeMailTemplateEn; + sendPostChallengeEmail(challengeEntity, mailSubject, recipientAddresses, template); } - return null; - } - - @Override - public Long getNumberOfRegistrants(Long challengeId) { - NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withSearchType(SearchType.COUNT); - searchQueryBuilder.withFilter(FilterBuilders.termFilter("challengeId", challengeId)); - return challengeRegistrantRepository.search(searchQueryBuilder.build()).getTotalElements(); - } - - @Override - public void sendApplicationEmailToContestant(ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity) throws MessagingException, IOException, TemplateException { - Template template = challengeRegistrantEntity.getLang() == Language.vi ? - confirmUserJoinChallengeMailTemplateVi : confirmUserJoinChallengeMailTemplateEn; - String mailSubject = challengeRegistrantEntity.getLang() == Language.vi ? - confirmUserJoinChallengeMailSubjectVn : confirmUserJoinChallengeMailSubjectEn; - mailSubject = String.format(mailSubject, challengeEntity.getChallengeName()); - Address[] emailAddress = InternetAddress.parse(challengeRegistrantEntity.getRegistrantEmail()); - sendContestApplicationEmail(template, mailSubject, emailAddress, challengeEntity, challengeRegistrantEntity, false); - } - - @Override - public void sendApplicationEmailToEmployer(ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity) throws MessagingException, IOException, TemplateException { - Template template = challengeRegistrantEntity.getLang() == Language.vi ? - alertEmployerChallengeMailTemplateVi : alertEmployerChallengeMailTemplateEn; - String mailSubject = challengeRegistrantEntity.getLang() == Language.vi ? - alertEmployerChallengeMailSubjectVn : alertEmployerChallengeMailSubjectEn; - mailSubject = String.format(mailSubject, challengeEntity.getChallengeName()); - Address[] emailAddress = getRecipientAddresses(challengeEntity, false); - sendContestApplicationEmail(template, mailSubject, emailAddress, challengeEntity, challengeRegistrantEntity, true); - } - - @Override - public long joinChallenge(ChallengeRegistrantDto challengeRegistrantDto) throws MessagingException, IOException, TemplateException { - Long challengeId = challengeRegistrantDto.getChallengeId(); - boolean isExist = checkIfChallengeRegistrantExist(challengeId, challengeRegistrantDto.getRegistrantEmail()); - - if (!isExist) { - ChallengeRegistrantEntity challengeRegistrantEntity = dozerMapper.map(challengeRegistrantDto, ChallengeRegistrantEntity.class); - ChallengeEntity challengeEntity = challengeRepository.findOne(challengeId); - sendApplicationEmailToContestant(challengeEntity, challengeRegistrantEntity); - sendApplicationEmailToEmployer(challengeEntity, challengeRegistrantEntity); - challengeRegistrantEntity.setMailSent(Boolean.TRUE); - challengeRegistrantEntity.setRegistrantId(new Date().getTime()); - challengeRegistrantRepository.save(challengeRegistrantEntity); + + @Override + public void sendPostChallengeEmailToTechloopies(ChallengeEntity challengeEntity) + throws MessagingException, IOException, TemplateException { + String mailSubject = postChallengeTechloopiesMailSubject; + Address[] recipientAddresses = InternetAddress.parse(postChallengeTechloopiesMailList); + sendPostChallengeEmail(challengeEntity, mailSubject, recipientAddresses, postChallengeMailTemplateEn); } - return getNumberOfRegistrants(challengeId); - } - - @Override - public List listChallenges() { - List challenges = new ArrayList<>(); - Iterator challengeIter = challengeRepository.findAll().iterator(); - while (challengeIter.hasNext()) { - ChallengeEntity challengeEntity = challengeIter.next(); - ChallengeDetailDto challengeDetailDto = dozerMapper.map(challengeEntity, ChallengeDetailDto.class); - challengeDetailDto.setNumberOfRegistrants(getNumberOfRegistrants(challengeEntity.getChallengeId())); - challenges.add(challengeDetailDto); + @Override + public ChallengeDetailDto getChallengeDetail(Long challengeId) { + ChallengeEntity challengeEntity = challengeRepository.findOne(challengeId); + if (challengeEntity != null) { + ChallengeDetailDto challengeDetailDto = dozerMapper.map(challengeEntity, ChallengeDetailDto.class); + challengeDetailDto.setNumberOfRegistrants(getNumberOfRegistrants(challengeId)); + return challengeDetailDto; + } + return null; } - return sortChallengesByDescendingStartDate(challenges); - } - private void sendContestApplicationEmail(Template template, String mailSubject, Address[] recipientAddresses, - ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity, boolean hasReplyTo) - throws MessagingException, IOException, TemplateException { - postChallengeMailMessage.setRecipients(Message.RecipientType.TO, recipientAddresses); + @Override + public Long getNumberOfRegistrants(Long challengeId) { + NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withSearchType(SearchType.COUNT); + searchQueryBuilder.withFilter(FilterBuilders.termFilter("challengeId", challengeId)); + return challengeRegistrantRepository.search(searchQueryBuilder.build()).getTotalElements(); + } - if (hasReplyTo) { - postChallengeMailMessage.setReplyTo(InternetAddress.parse(challengeRegistrantEntity.getRegistrantEmail())); + @Override + public void sendApplicationEmailToContestant(ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity) throws MessagingException, IOException, TemplateException { + Template template = challengeRegistrantEntity.getLang() == Language.vi ? + confirmUserJoinChallengeMailTemplateVi : confirmUserJoinChallengeMailTemplateEn; + String mailSubject = challengeRegistrantEntity.getLang() == Language.vi ? + confirmUserJoinChallengeMailSubjectVn : confirmUserJoinChallengeMailSubjectEn; + mailSubject = String.format(mailSubject, challengeEntity.getChallengeName()); + Address[] emailAddress = InternetAddress.parse(challengeRegistrantEntity.getRegistrantEmail()); + sendContestApplicationEmail(template, mailSubject, emailAddress, challengeEntity, challengeRegistrantEntity, false); } - else { - postChallengeMailMessage.setReplyTo(InternetAddress.parse(mailTechlooperReplyTo)); + + @Override + public void sendApplicationEmailToEmployer(ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity) throws MessagingException, IOException, TemplateException { + Template template = challengeRegistrantEntity.getLang() == Language.vi ? + alertEmployerChallengeMailTemplateVi : alertEmployerChallengeMailTemplateEn; + String mailSubject = challengeRegistrantEntity.getLang() == Language.vi ? + alertEmployerChallengeMailSubjectVn : alertEmployerChallengeMailSubjectEn; + mailSubject = String.format(mailSubject, challengeEntity.getChallengeName()); + Address[] emailAddress = getRecipientAddresses(challengeEntity, false); + sendContestApplicationEmail(template, mailSubject, emailAddress, challengeEntity, challengeRegistrantEntity, true); } - StringWriter stringWriter = new StringWriter(); - Map templateModel = new HashMap<>(); - templateModel.put("webBaseUrl", webBaseUrl); - templateModel.put("challengeName", challengeEntity.getChallengeName()); - templateModel.put("businessRequirement", challengeEntity.getBusinessRequirement()); - templateModel.put("generalNote", challengeEntity.getGeneralNote()); - templateModel.put("technologies", StringUtils.join(challengeEntity.getTechnologies(), "
")); - templateModel.put("documents", challengeEntity.getDocuments()); - templateModel.put("deliverables", challengeEntity.getDeliverables()); - templateModel.put("receivedEmails", StringUtils.join(challengeEntity.getReceivedEmails(), "
")); - templateModel.put("reviewStyle", challengeEntity.getReviewStyle()); - templateModel.put("startDate", challengeEntity.getStartDateTime()); - templateModel.put("registrationDate", challengeEntity.getRegistrationDateTime()); - templateModel.put("submissionDate", challengeEntity.getSubmissionDateTime()); - templateModel.put("qualityIdea", challengeEntity.getQualityIdea()); - templateModel.put("firstPlaceReward", challengeEntity.getFirstPlaceReward() != null ? challengeEntity.getFirstPlaceReward() : 0); - templateModel.put("secondPlaceReward", challengeEntity.getSecondPlaceReward() != null ? challengeEntity.getSecondPlaceReward() : 0); - templateModel.put("thirdPlaceReward", challengeEntity.getThirdPlaceReward() != null ? challengeEntity.getThirdPlaceReward() : 0); - templateModel.put("challengeId", challengeEntity.getChallengeId().toString()); - templateModel.put("authorEmail", challengeEntity.getAuthorEmail()); - templateModel.put("challengeOverview", challengeEntity.getChallengeOverview()); - templateModel.put("firstName", challengeRegistrantEntity.getRegistrantFirstName()); - templateModel.put("lastName", challengeRegistrantEntity.getRegistrantLastName()); - templateModel.put("registrantEmail", challengeRegistrantEntity.getRegistrantEmail()); - templateModel.put("challengeNameAlias", challengeEntity.getChallengeName().replaceAll("\\W", "-")); - - template.process(templateModel, stringWriter); - postChallengeMailMessage.setSubject(MimeUtility.encodeText(mailSubject, "UTF-8", null)); - postChallengeMailMessage.setText(stringWriter.toString(), "UTF-8", "html"); - - stringWriter.flush(); - postChallengeMailMessage.saveChanges(); - mailSender.send(postChallengeMailMessage); - } - - private void sendPostChallengeEmail(ChallengeEntity challengeEntity, String mailSubject, - Address[] recipientAddresses, Template template) throws MessagingException, IOException, TemplateException { - postChallengeMailMessage.setRecipients(Message.RecipientType.TO, recipientAddresses); - StringWriter stringWriter = new StringWriter(); - - Map templateModel = new HashMap<>(); - templateModel.put("webBaseUrl", webBaseUrl); - templateModel.put("challengeName", challengeEntity.getChallengeName()); - templateModel.put("businessRequirement", challengeEntity.getBusinessRequirement()); - templateModel.put("generalNote", challengeEntity.getGeneralNote()); - templateModel.put("technologies", StringUtils.join(challengeEntity.getTechnologies(), "
")); - templateModel.put("documents", challengeEntity.getDocuments()); - templateModel.put("deliverables", challengeEntity.getDeliverables()); - templateModel.put("receivedEmails", StringUtils.join(challengeEntity.getReceivedEmails(), "
")); - templateModel.put("reviewStyle", challengeEntity.getReviewStyle()); - templateModel.put("startDate", challengeEntity.getStartDateTime()); - templateModel.put("registrationDate", challengeEntity.getRegistrationDateTime()); - templateModel.put("submissionDate", challengeEntity.getSubmissionDateTime()); - templateModel.put("qualityIdea", challengeEntity.getQualityIdea()); - templateModel.put("firstPlaceReward", challengeEntity.getFirstPlaceReward() != null ? challengeEntity.getFirstPlaceReward() : 0); - templateModel.put("secondPlaceReward", challengeEntity.getSecondPlaceReward() != null ? challengeEntity.getSecondPlaceReward() : 0); - templateModel.put("thirdPlaceReward", challengeEntity.getThirdPlaceReward() != null ? challengeEntity.getThirdPlaceReward() : 0); - templateModel.put("challengeId", challengeEntity.getChallengeId().toString()); - templateModel.put("authorEmail", challengeEntity.getAuthorEmail()); - templateModel.put("challengeOverview", challengeEntity.getChallengeOverview()); - templateModel.put("challengeNameAlias", challengeEntity.getChallengeName().replaceAll("\\W", "-")); - - template.process(templateModel, stringWriter); - mailSubject = String.format(mailSubject, challengeEntity.getAuthorEmail(), challengeEntity.getChallengeName()); - postChallengeMailMessage.setSubject(MimeUtility.encodeText(mailSubject, "UTF-8", null)); - postChallengeMailMessage.setText(stringWriter.toString(), "UTF-8", "html"); - - stringWriter.flush(); - postChallengeMailMessage.saveChanges(); - mailSender.send(postChallengeMailMessage); - } - - private Address[] getRecipientAddresses(ChallengeEntity challengeEntity, boolean includeAuthor) throws AddressException { - Set emails = new HashSet<>(challengeEntity.getReceivedEmails()); - if (includeAuthor) { - emails.add(challengeEntity.getAuthorEmail()); + @Override + public long joinChallenge(ChallengeRegistrantDto challengeRegistrantDto) throws MessagingException, IOException, TemplateException { + Long challengeId = challengeRegistrantDto.getChallengeId(); + boolean isExist = checkIfChallengeRegistrantExist(challengeId, challengeRegistrantDto.getRegistrantEmail()); + + if (!isExist) { + ChallengeRegistrantEntity challengeRegistrantEntity = dozerMapper.map(challengeRegistrantDto, ChallengeRegistrantEntity.class); + ChallengeEntity challengeEntity = challengeRepository.findOne(challengeId); + sendApplicationEmailToContestant(challengeEntity, challengeRegistrantEntity); + sendApplicationEmailToEmployer(challengeEntity, challengeRegistrantEntity); + challengeRegistrantEntity.setMailSent(Boolean.TRUE); + challengeRegistrantEntity.setRegistrantId(new Date().getTime()); + challengeRegistrantRepository.save(challengeRegistrantEntity); + } + + return getNumberOfRegistrants(challengeId); } - return InternetAddress.parse(StringUtils.join(emails, ',')); - } - - private List sortChallengesByDescendingStartDate(List challenges) { - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - return challenges.stream().sorted((challenge1, challenge2) -> { - try { - long challenge2StartDate = sdf.parse(challenge2.getStartDateTime()).getTime(); - long challenge1StartDate = sdf.parse(challenge1.getStartDateTime()).getTime(); - if (challenge2StartDate - challenge1StartDate > 0) { - return 1; + + @Override + public List listChallenges() { + List challenges = new ArrayList<>(); + Iterator challengeIter = challengeRepository.findAll().iterator(); + while (challengeIter.hasNext()) { + ChallengeEntity challengeEntity = challengeIter.next(); + ChallengeDetailDto challengeDetailDto = dozerMapper.map(challengeEntity, ChallengeDetailDto.class); + challengeDetailDto.setNumberOfRegistrants(getNumberOfRegistrants(challengeEntity.getChallengeId())); + challenges.add(challengeDetailDto); } - else if (challenge2StartDate - challenge1StartDate < 0) { - return -1; + return sortChallengesByDescendingStartDate(challenges); + } + + private void sendContestApplicationEmail(Template template, String mailSubject, Address[] recipientAddresses, + ChallengeEntity challengeEntity, ChallengeRegistrantEntity challengeRegistrantEntity, boolean hasReplyTo) + throws MessagingException, IOException, TemplateException { + postChallengeMailMessage.setRecipients(Message.RecipientType.TO, recipientAddresses); + + if (hasReplyTo) { + postChallengeMailMessage.setReplyTo(InternetAddress.parse(challengeRegistrantEntity.getRegistrantEmail())); + } else { + postChallengeMailMessage.setReplyTo(InternetAddress.parse(mailTechlooperReplyTo)); } - else { - return 0; + + StringWriter stringWriter = new StringWriter(); + Map templateModel = new HashMap<>(); + templateModel.put("webBaseUrl", webBaseUrl); + templateModel.put("challengeName", challengeEntity.getChallengeName()); + templateModel.put("businessRequirement", challengeEntity.getBusinessRequirement()); + templateModel.put("generalNote", challengeEntity.getGeneralNote()); + templateModel.put("technologies", StringUtils.join(challengeEntity.getTechnologies(), "
")); + templateModel.put("documents", challengeEntity.getDocuments()); + templateModel.put("deliverables", challengeEntity.getDeliverables()); + templateModel.put("receivedEmails", StringUtils.join(challengeEntity.getReceivedEmails(), "
")); + templateModel.put("reviewStyle", challengeEntity.getReviewStyle()); + templateModel.put("startDate", challengeEntity.getStartDateTime()); + templateModel.put("registrationDate", challengeEntity.getRegistrationDateTime()); + templateModel.put("submissionDate", challengeEntity.getSubmissionDateTime()); + templateModel.put("qualityIdea", challengeEntity.getQualityIdea()); + templateModel.put("firstPlaceReward", challengeEntity.getFirstPlaceReward() != null ? challengeEntity.getFirstPlaceReward() : 0); + templateModel.put("secondPlaceReward", challengeEntity.getSecondPlaceReward() != null ? challengeEntity.getSecondPlaceReward() : 0); + templateModel.put("thirdPlaceReward", challengeEntity.getThirdPlaceReward() != null ? challengeEntity.getThirdPlaceReward() : 0); + templateModel.put("challengeId", challengeEntity.getChallengeId().toString()); + templateModel.put("authorEmail", challengeEntity.getAuthorEmail()); + templateModel.put("challengeOverview", challengeEntity.getChallengeOverview()); + templateModel.put("firstName", challengeRegistrantEntity.getRegistrantFirstName()); + templateModel.put("lastName", challengeRegistrantEntity.getRegistrantLastName()); + templateModel.put("registrantEmail", challengeRegistrantEntity.getRegistrantEmail()); + templateModel.put("challengeNameAlias", challengeEntity.getChallengeName().replaceAll("\\W", "-")); + + template.process(templateModel, stringWriter); + postChallengeMailMessage.setSubject(MimeUtility.encodeText(mailSubject, "UTF-8", null)); + postChallengeMailMessage.setText(stringWriter.toString(), "UTF-8", "html"); + + stringWriter.flush(); + postChallengeMailMessage.saveChanges(); + mailSender.send(postChallengeMailMessage); + } + + private void sendPostChallengeEmail(ChallengeEntity challengeEntity, String mailSubject, + Address[] recipientAddresses, Template template) throws MessagingException, IOException, TemplateException { + postChallengeMailMessage.setRecipients(Message.RecipientType.TO, recipientAddresses); + postChallengeMailMessage.setReplyTo(InternetAddress.parse(mailTechlooperReplyTo)); + StringWriter stringWriter = new StringWriter(); + + Map templateModel = new HashMap<>(); + templateModel.put("webBaseUrl", webBaseUrl); + templateModel.put("challengeName", challengeEntity.getChallengeName()); + templateModel.put("businessRequirement", challengeEntity.getBusinessRequirement()); + templateModel.put("generalNote", challengeEntity.getGeneralNote()); + templateModel.put("technologies", StringUtils.join(challengeEntity.getTechnologies(), "
")); + templateModel.put("documents", challengeEntity.getDocuments()); + templateModel.put("deliverables", challengeEntity.getDeliverables()); + templateModel.put("receivedEmails", StringUtils.join(challengeEntity.getReceivedEmails(), "
")); + templateModel.put("reviewStyle", challengeEntity.getReviewStyle()); + templateModel.put("startDate", challengeEntity.getStartDateTime()); + templateModel.put("registrationDate", challengeEntity.getRegistrationDateTime()); + templateModel.put("submissionDate", challengeEntity.getSubmissionDateTime()); + templateModel.put("qualityIdea", challengeEntity.getQualityIdea()); + templateModel.put("firstPlaceReward", challengeEntity.getFirstPlaceReward() != null ? challengeEntity.getFirstPlaceReward() : 0); + templateModel.put("secondPlaceReward", challengeEntity.getSecondPlaceReward() != null ? challengeEntity.getSecondPlaceReward() : 0); + templateModel.put("thirdPlaceReward", challengeEntity.getThirdPlaceReward() != null ? challengeEntity.getThirdPlaceReward() : 0); + templateModel.put("challengeId", challengeEntity.getChallengeId().toString()); + templateModel.put("authorEmail", challengeEntity.getAuthorEmail()); + templateModel.put("challengeOverview", challengeEntity.getChallengeOverview()); + templateModel.put("challengeNameAlias", challengeEntity.getChallengeName().replaceAll("\\W", "-")); + + template.process(templateModel, stringWriter); + mailSubject = String.format(mailSubject, challengeEntity.getAuthorEmail(), challengeEntity.getChallengeName()); + postChallengeMailMessage.setSubject(MimeUtility.encodeText(mailSubject, "UTF-8", null)); + postChallengeMailMessage.setText(stringWriter.toString(), "UTF-8", "html"); + + stringWriter.flush(); + postChallengeMailMessage.saveChanges(); + mailSender.send(postChallengeMailMessage); + } + + private Address[] getRecipientAddresses(ChallengeEntity challengeEntity, boolean includeAuthor) throws AddressException { + Set emails = new HashSet<>(challengeEntity.getReceivedEmails()); + if (includeAuthor) { + emails.add(challengeEntity.getAuthorEmail()); } - } - catch (ParseException e) { - return 0; - } - }).collect(Collectors.toList()); - } - - public boolean checkIfChallengeRegistrantExist(Long challengeId, String email) { - NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder(); - searchQueryBuilder.withQuery(QueryBuilders.boolQuery() - .must(QueryBuilders.matchPhraseQuery("registrantEmail", email)) - .must(QueryBuilders.termQuery("challengeId", challengeId)) - .must(QueryBuilders.termQuery("mailSent", true))); - - long total = challengeRegistrantRepository.search(searchQueryBuilder.build()).getTotalElements(); - return (total > 0); - } - - @Override - public Long getTotalNumberOfChallenges() { - return challengeRepository.count(); - } - - @Override - public Double getTotalAmountOfPrizeValues() { - NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withSearchType(SearchType.COUNT); - searchQueryBuilder.withQuery(QueryBuilders.matchAllQuery()); - - SumBuilder sumPrizeBuilder = sum("sumPrize").script("doc['firstPlaceReward'].value + doc['secondPlaceReward'].value + doc['thirdPlaceReward'].value"); - searchQueryBuilder.addAggregation(sumPrizeBuilder); - - Aggregations aggregations = elasticsearchTemplateUserImport.query(searchQueryBuilder.build(), SearchResponse::getAggregations); - Sum sumReponse = aggregations.get("sumPrize"); - return sumReponse != null ? sumReponse.getValue() : 0D; - } - - @Override - public Long getTotalNumberOfRegistrants() { - return challengeRegistrantRepository.count(); - } - - @Override - public ChallengeDetailDto getTheLatestChallenge() { + return InternetAddress.parse(StringUtils.join(emails, ',')); + } + + private List sortChallengesByDescendingStartDate(List challenges) { + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + return challenges.stream().sorted((challenge1, challenge2) -> { + try { + long challenge2StartDate = sdf.parse(challenge2.getStartDateTime()).getTime(); + long challenge1StartDate = sdf.parse(challenge1.getStartDateTime()).getTime(); + if (challenge2StartDate - challenge1StartDate > 0) { + return 1; + } else if (challenge2StartDate - challenge1StartDate < 0) { + return -1; + } else { + return 0; + } + } catch (ParseException e) { + return 0; + } + }).collect(Collectors.toList()); + } + + public boolean checkIfChallengeRegistrantExist(Long challengeId, String email) { + NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder(); + searchQueryBuilder.withQuery(QueryBuilders.boolQuery() + .must(QueryBuilders.matchPhraseQuery("registrantEmail", email)) + .must(QueryBuilders.termQuery("challengeId", challengeId)) + .must(QueryBuilders.termQuery("mailSent", true))); + + long total = challengeRegistrantRepository.search(searchQueryBuilder.build()).getTotalElements(); + return (total > 0); + } + + @Override + public Long getTotalNumberOfChallenges() { + return challengeRepository.count(); + } + + @Override + public Double getTotalAmountOfPrizeValues() { + NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withSearchType(SearchType.COUNT); + searchQueryBuilder.withQuery(QueryBuilders.matchAllQuery()); + + SumBuilder sumPrizeBuilder = sum("sumPrize").script("doc['firstPlaceReward'].value + doc['secondPlaceReward'].value + doc['thirdPlaceReward'].value"); + searchQueryBuilder.addAggregation(sumPrizeBuilder); + + Aggregations aggregations = elasticsearchTemplateUserImport.query(searchQueryBuilder.build(), SearchResponse::getAggregations); + Sum sumReponse = aggregations.get("sumPrize"); + return sumReponse != null ? sumReponse.getValue() : 0D; + } + + @Override + public Long getTotalNumberOfRegistrants() { + return challengeRegistrantRepository.count(); + } + + @Override + public ChallengeDetailDto getTheLatestChallenge() { // NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder(); // searchQueryBuilder.withQuery(QueryBuilders.matchAllQuery()); // searchQueryBuilder.withSort(SortBuilders.fieldSort("challengeId").order(SortOrder.DESC)); @@ -385,70 +380,70 @@ public ChallengeDetailDto getTheLatestChallenge() { // ChallengeEntity challengeEntity = challengeEntities.get(0); // return dozerMapper.map(challengeEntity, ChallengeDetailDto.class); // } - return listChallenges().get(0); - } - - public Collection findByOwnerAndCondition(String owner, - Predicate condition) { - NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challenge"); - QueryStringQueryBuilder query = QueryBuilders.queryString(owner).defaultField("authorEmail"); - queryBuilder.withFilter(FilterBuilders.queryFilter(query)); - - int pageIndex = 0; - Set challenges = new HashSet<>(); - while (true) { - queryBuilder.withPageable(new PageRequest(pageIndex++, 100)); - FacetedPage page = challengeRepository.search(queryBuilder.build()); - if (!page.hasContent()) { - break; - } - - page.spliterator().forEachRemaining(challenge -> { - if (condition.test(challenge)) { - ChallengeDetailDto challengeDetailDto = dozerMapper.map(challenge, ChallengeDetailDto.class); - challengeDetailDto.setNumberOfRegistrants(countRegistrantsByChallengeId(challenge.getChallengeId())); - challenges.add(challengeDetailDto); + return listChallenges().get(0); + } + + public Collection findByOwnerAndCondition(String owner, + Predicate condition) { + NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challenge"); + QueryStringQueryBuilder query = QueryBuilders.queryString(owner).defaultField("authorEmail"); + queryBuilder.withFilter(FilterBuilders.queryFilter(query)); + + int pageIndex = 0; + Set challenges = new HashSet<>(); + while (true) { + queryBuilder.withPageable(new PageRequest(pageIndex++, 100)); + FacetedPage page = challengeRepository.search(queryBuilder.build()); + if (!page.hasContent()) { + break; + } + + page.spliterator().forEachRemaining(challenge -> { + if (condition.test(challenge)) { + ChallengeDetailDto challengeDetailDto = dozerMapper.map(challenge, ChallengeDetailDto.class); + challengeDetailDto.setNumberOfRegistrants(countRegistrantsByChallengeId(challenge.getChallengeId())); + challenges.add(challengeDetailDto); + } + }); } - }); + return challenges; } - return challenges; - } - - public Collection findInProgressChallenges(String owner) { - DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy"); - return findByOwnerAndCondition(owner, challengeEntity -> { - DateTime startDate = dateTimeFormatter.parseDateTime(challengeEntity.getStartDateTime()); - DateTime submissionDate = dateTimeFormatter.parseDateTime(challengeEntity.getSubmissionDateTime()); - DateTime now = DateTime.now(); - boolean inRange = now.isAfter(startDate) && now.isBefore(submissionDate); - boolean atBoundary = now.isEqual(startDate) || now.isEqual(submissionDate); - return inRange || atBoundary; - }); - } - - public Collection findRegistrantsByChallengeId(Long challengeId) { - NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challengeRegistrant"); - queryBuilder.withFilter(FilterBuilders.queryFilter(QueryBuilders.termQuery("challengeId", challengeId))); - - int pageIndex = 0; - Set registrants = new HashSet<>(); - while (true) { - queryBuilder.withPageable(new PageRequest(pageIndex++, 100)); - FacetedPage page = challengeRegistrantRepository.search(queryBuilder.build()); - if (!page.hasContent()) { - break; - } - - page.spliterator().forEachRemaining(registrant -> registrants.add(dozerMapper.map(registrant, ChallengeRegistrantDto.class))); + + public Collection findInProgressChallenges(String owner) { + DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy"); + return findByOwnerAndCondition(owner, challengeEntity -> { + DateTime startDate = dateTimeFormatter.parseDateTime(challengeEntity.getStartDateTime()); + DateTime submissionDate = dateTimeFormatter.parseDateTime(challengeEntity.getSubmissionDateTime()); + DateTime now = DateTime.now(); + boolean inRange = now.isAfter(startDate) && now.isBefore(submissionDate); + boolean atBoundary = now.isEqual(startDate) || now.isEqual(submissionDate); + return inRange || atBoundary; + }); } - return registrants; - } + public Collection findRegistrantsByChallengeId(Long challengeId) { + NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challengeRegistrant"); + queryBuilder.withFilter(FilterBuilders.queryFilter(QueryBuilders.termQuery("challengeId", challengeId))); + + int pageIndex = 0; + Set registrants = new HashSet<>(); + while (true) { + queryBuilder.withPageable(new PageRequest(pageIndex++, 100)); + FacetedPage page = challengeRegistrantRepository.search(queryBuilder.build()); + if (!page.hasContent()) { + break; + } - public Long countRegistrantsByChallengeId(Long challengeId) { - NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challengeRegistrant"); - queryBuilder.withFilter(FilterBuilders.queryFilter(QueryBuilders.termQuery("challengeId", challengeId))) - .withSearchType(SearchType.COUNT); - return challengeRegistrantRepository.search(queryBuilder.build()).getTotalElements(); - } + page.spliterator().forEachRemaining(registrant -> registrants.add(dozerMapper.map(registrant, ChallengeRegistrantDto.class))); + } + + return registrants; + } + + public Long countRegistrantsByChallengeId(Long challengeId) { + NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withIndices(techlooperIndex).withTypes("challengeRegistrant"); + queryBuilder.withFilter(FilterBuilders.queryFilter(QueryBuilders.termQuery("challengeId", challengeId))) + .withSearchType(SearchType.COUNT); + return challengeRegistrantRepository.search(queryBuilder.build()).getTotalElements(); + } } From 45c261157aea8f7544dfd04935ed0ff9bd46cb24 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Wed, 26 Aug 2015 14:40:54 +0700 Subject: [PATCH 6/6] Fix route users to not correct pages --- .../webapp/assets/modules/common/apiService.js | 3 --- .../assets/modules/common/joinNowSerivce.js | 17 +++++++++++++++++ .../assets/modules/common/securityService.js | 14 +++++++------- .../modules/event-details/event-details.html | 2 +- .../event-details/eventDetailsController.js | 10 +++++++--- .../assets/modules/home-page/homeController.js | 1 - .../modules/loading-box/loadingBoxController.js | 9 ++++++++- 7 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 src/main/webapp/assets/modules/common/joinNowSerivce.js diff --git a/src/main/webapp/assets/modules/common/apiService.js b/src/main/webapp/assets/modules/common/apiService.js index d8198b4b6..b0e5d65dd 100644 --- a/src/main/webapp/assets/modules/common/apiService.js +++ b/src/main/webapp/assets/modules/common/apiService.js @@ -66,10 +66,7 @@ techlooper.factory("apiService", function ($rootScope, $location, jsonValue, $ht $('.loading-data').css("height", $(window).height()); $('body').addClass('noscroll'); utils.sendNotification(jsonValue.notifications.loading); - //localStorageService.set("lastFoot", $location.url()); - utils.sendNotification(jsonValue.notifications.loading); instance.getFBLoginUrl().success(function (url) { - //localStorageService.set("lastFoot", $location.url()); localStorageService.set("joinNow", true); window.location = url; }); diff --git a/src/main/webapp/assets/modules/common/joinNowSerivce.js b/src/main/webapp/assets/modules/common/joinNowSerivce.js new file mode 100644 index 000000000..261171078 --- /dev/null +++ b/src/main/webapp/assets/modules/common/joinNowSerivce.js @@ -0,0 +1,17 @@ +techlooper.factory("joinNowService", function(apiService, localStorageService) { + + var from = localStorageService.get("joinForm"); + var id = localStorageService.get("id"); + switch (from) { + case "webinar": + + break; + } + + localStorageService.remove("joinForm"); + localStorageService.remove("id"); + + return { + initialize: function() {} + } +}); \ No newline at end of file diff --git a/src/main/webapp/assets/modules/common/securityService.js b/src/main/webapp/assets/modules/common/securityService.js index d9c39c493..8c967fddf 100644 --- a/src/main/webapp/assets/modules/common/securityService.js +++ b/src/main/webapp/assets/modules/common/securityService.js @@ -78,7 +78,7 @@ techlooper.factory("securityService", function (apiService, $rootScope, $q, util }; return apiService.login(auth) .success(function (data, status, headers, config) { - instance.getCurrentUser().success(function () { + instance.getCurrentUser().then(function () { instance.routeByRole(); }); }); @@ -124,12 +124,12 @@ techlooper.factory("securityService", function (apiService, $rootScope, $q, util $rootScope.$on("$routeChangeSuccess", function (event, next, current) { var fromLastPrint = localStorageService.get("lastFoot"); if (fromLastPrint) { - var uiView = utils.getUiView(); - var roles = uiView.roles || []; - if (roles.length == 0) { - localStorageService.remove("lastFoot"); - return $location.url(fromLastPrint); - } + // //var uiView = utils.getUiView(); + // //var roles = uiView.roles || []; + // //if (roles.length == 0) { + // // localStorageService.remove("lastFoot"); + // // return $location.url(fromLastPrint); + // //} return event.preventDefault(); } diff --git a/src/main/webapp/assets/modules/event-details/event-details.html b/src/main/webapp/assets/modules/event-details/event-details.html index cd258468f..29a604613 100644 --- a/src/main/webapp/assets/modules/event-details/event-details.html +++ b/src/main/webapp/assets/modules/event-details/event-details.html @@ -34,7 +34,7 @@

{{webinar.name}}

- +
diff --git a/src/main/webapp/assets/modules/event-details/eventDetailsController.js b/src/main/webapp/assets/modules/event-details/eventDetailsController.js index 56f418726..7cc041431 100644 --- a/src/main/webapp/assets/modules/event-details/eventDetailsController.js +++ b/src/main/webapp/assets/modules/event-details/eventDetailsController.js @@ -1,4 +1,4 @@ -techlooper.controller("eventDetailsController", function ($scope, apiService, $routeParams) { +techlooper.controller("eventDetailsController", function ($scope, apiService, $routeParams, joinNowService, localStorageService) { var parts = $routeParams.id.split("-"); @@ -7,9 +7,13 @@ techlooper.controller("eventDetailsController", function ($scope, apiService, $r apiService.findWebinarById(webinarId) .success(function(webinar) { - console.log(webinar); $scope.webinar = webinar; - }); + + $scope.joinNow = function() { + localStorageService.set("joinForm", "webinar"); + localStorageService.set("id", webinarId); + apiService.joinNowByFB(); + } }); diff --git a/src/main/webapp/assets/modules/home-page/homeController.js b/src/main/webapp/assets/modules/home-page/homeController.js index 69e15fabf..a95e44b80 100644 --- a/src/main/webapp/assets/modules/home-page/homeController.js +++ b/src/main/webapp/assets/modules/home-page/homeController.js @@ -6,7 +6,6 @@ techlooper.controller("homeController", function ($scope, securityService, apiSe $scope.homePage.termStatistic.logo = "images/" + $.grep(jsonValue.technicalSkill, function (skill) { return skill.term == $scope.homePage.termStatistic.term; })[0].logo; - console.log($scope.homePage); }); $timeout(function () { diff --git a/src/main/webapp/assets/modules/loading-box/loadingBoxController.js b/src/main/webapp/assets/modules/loading-box/loadingBoxController.js index 238da71fc..f6f9bfa04 100644 --- a/src/main/webapp/assets/modules/loading-box/loadingBoxController.js +++ b/src/main/webapp/assets/modules/loading-box/loadingBoxController.js @@ -1,7 +1,14 @@ -techlooper.controller("loadingBoxController", function (utils, jsonValue, $scope) { +techlooper.controller("loadingBoxController", function (utils, jsonValue, $scope, localStorageService, $location) { utils.sendNotification(jsonValue.notifications.loading, $(window).height()); $scope.$on('$destroy', function () { utils.sendNotification(jsonValue.notifications.loaded); }); + + var joinNow = localStorageService.get("joinNow"); + if (joinNow == true) { + var fromLastPrint = localStorageService.get("lastFoot"); + localStorageService.remove("lastFoot"); + return $location.url(fromLastPrint); + } }); \ No newline at end of file