Skip to content

Commit

Permalink
Merge pull request #462 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Dec 3, 2015
2 parents af0757f + fd5503d commit e965ece
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 793 deletions.
31 changes: 6 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,35 +493,16 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.8</version>
</dependency>

<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.8</version>
</dependency>


<!--<dependency>-->
<!--<groupId>org.jfree</groupId>-->
<!--<artifactId>jfreechart</artifactId>-->
<!--<version>1.0.19</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>net.sourceforge.htmlunit</groupId>-->
<!--<artifactId>htmlunit</artifactId>-->
<!--<version>2.19</version>-->
<!--<groupId>com.itextpdf</groupId>-->
<!--<artifactId>itextpdf</artifactId>-->
<!--<version>5.5.8</version>-->
<!--</dependency>-->

<!--<dependency>-->
<!--<groupId>commons-io</groupId>-->
<!--<artifactId>commons-io</artifactId>-->
<!--<version>2.42.4</version>-->
<!--<groupId>com.itextpdf.tool</groupId>-->
<!--<artifactId>xmlworker</artifactId>-->
<!--<version>5.5.8</version>-->
<!--</dependency>-->

<dependency>
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/com/techlooper/aspect/Main2.java

This file was deleted.

15 changes: 9 additions & 6 deletions src/main/java/com/techlooper/config/CoreConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.CalendarScopes;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.BaseFont;
import com.techlooper.converter.ListCSVStringConverter;
import com.techlooper.converter.LocaleConverter;
import com.techlooper.converter.ProfileNameConverter;
Expand Down Expand Up @@ -47,6 +49,7 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.xhtmlrenderer.pdf.ITextRenderer;

import javax.annotation.Resource;
import javax.mail.internet.MimeMessage;
Expand Down Expand Up @@ -366,10 +369,10 @@ public Template finalChallengeReportVi(freemarker.template.Configuration freemak
return freemakerConfig.getTemplate("FINAL_CHALLENGE_REPORT_VI.ftl");
}

// @Bean
// public ITextRenderer reportRender() throws IOException, DocumentException {
// ITextRenderer renderer = new ITextRenderer();
// renderer.getFontResolver().addFont("font/verdana.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
// return renderer;
// }
@Bean
public ITextRenderer reportRender() throws IOException, DocumentException {
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("font/verdana.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
return renderer;
}
}
16 changes: 14 additions & 2 deletions src/main/java/com/techlooper/controller/SharingController.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.techlooper.controller;

import com.techlooper.dto.ResourceDto;
import com.techlooper.entity.ChallengeEntity;
import com.techlooper.repository.elasticsearch.ChallengeRepository;
import com.techlooper.repository.elasticsearch.ProjectRepository;
import com.techlooper.repository.elasticsearch.SalaryReviewRepository;
import com.techlooper.service.ChallengeService;
import com.techlooper.service.ReportService;
import com.techlooper.service.WebinarService;
import com.techlooper.util.DateTimeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -21,6 +25,9 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
* Created by phuonghqh on 5/11/15.
Expand Down Expand Up @@ -49,7 +56,7 @@ public class SharingController {
private ReportService reportService;

@Resource
private ViewResolver viewResolver;
private ChallengeRepository challengeRepository;

@RequestMapping(value = "renderSalaryReport/{language}/{salaryReviewId}")
public String renderReport(@PathVariable String language, @PathVariable Long salaryReviewId, ModelMap model) {
Expand Down Expand Up @@ -109,7 +116,12 @@ public void renderFinalChallengeReport(@PathVariable Long challengeId, HttpServl

byte[] data = os.toByteArray();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment;filename=report.pdf");

ChallengeEntity challenge = challengeRepository.findOne(challengeId);
String reportName = String.format("attachment;filename=%s-%s.pdf",
StringUtils.stripAccents(challenge.getChallengeName()).replaceAll("\\W", "-"),
DateTimeUtils.currentDate());
response.setHeader("Content-disposition", reportName);
response.setContentLength(data.length);
response.getOutputStream().write(data);
response.getOutputStream().flush();
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/techlooper/dto/FinalChallengeReportDto.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.techlooper.dto;

import com.techlooper.entity.ChallengeRegistrantDto;
import com.techlooper.entity.ChallengeRegistrantEntity;
import com.techlooper.model.ChallengeDto;
import com.techlooper.model.ChallengePhaseEnum;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
Expand All @@ -25,8 +22,6 @@ public class FinalChallengeReportDto extends ChallengeDto {

private String phaseOptions = "";

// private static final ChallengePhaseEnum[] ALL_OPTS = new ChallengePhaseEnum[] {ChallengePhaseEnum.IDEA, ChallengePhaseEnum.UIUX, ChallengePhaseEnum.PROTOTYPE};

public String getBaseUrl() {
return baseUrl;
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/com/techlooper/service/impl/ReportServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.techlooper.service.impl;

import com.itextpdf.text.pdf.BaseFont;
import com.lowagie.text.PageSize;
import com.techlooper.dto.FinalChallengeReportDto;
import com.techlooper.dto.PhaseEntry;
import com.techlooper.dto.PhaseEntry.PhaseEntryBuilder;
Expand Down Expand Up @@ -60,8 +60,8 @@ public class ReportServiceImpl implements ReportService {
@Value("${web.baseUrl}")
private String baseUrl;

// @Resource
// private ITextRenderer reportRender;
@Resource
private ITextRenderer reportRender;

public ByteArrayOutputStream generateFinalChallengeReport(String challengeAuthorEmail, Long challengeId) {
ChallengeEntity challenge = challengeRepository.findOne(challengeId);
Expand Down Expand Up @@ -111,12 +111,15 @@ public ByteArrayOutputStream generateFinalChallengeReport(String challengeAuthor

ByteArrayOutputStream os = new ByteArrayOutputStream();

ITextRenderer reportRender = new ITextRenderer();
reportRender.getFontResolver().addFont("font/verdana.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
// ITextRenderer reportRender = new ITextRenderer();
// reportRender.getFontResolver().addFont("font/verdana.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
reportRender.setDocumentFromString(stringWriter.toString());
reportRender.layout();
reportRender.createPDF(os);
reportRender.finishPDF();
// reportRender.getWriter().setMarginMirroring(true);
// reportRender.getWriter().setMargins(0, 0, 0, 0);
// reportRender.getWriter().setPageSize(PageSize.A4);
// reportRender.finishPDF();
stringWriter.flush();
return os;
}
Expand Down
11 changes: 0 additions & 11 deletions src/main/resources/template/CHALLENGE_DAILY_SUMMARY_EN.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,6 @@
<img height="15px" width="1" src="http://images.vietnamworks.com/x.gif" style="display:block; border: 0px" />
</td>
</tr>
<tr>
<td style="text-align: center; padding: 10px 0">
<table border="0" cellspacing="0" cellpadding="0" align="center" style="margin: 0 auto; width: auto" class="fullWidth">
<tbody><tr>
<td bgcolor="#277cbd" width="100%" style="padding: 7px 20px; font-weight: 700; -webkit-border-radius:3px; border-radius:3px; text-align: center">
<a href="" target="_blank" style="font-family: Arial, sans-serif; font-size: 14px; color: #ffffff; text-decoration: none; display: block; width: 100%">Accept Submissions</a>
</td>
</tr>
</tbody></table>
</td>
</tr>
</table>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<table width="300px" border="0" cellspacing="0" cellpadding="0" align="center" style="margin: 0 auto;" class="fullWidth">
<tr>
<td bgcolor="#277cbd" width="100%" style="padding: 10px 5px; -webkit-border-radius:3px; border-radius:3px; text-align: center">
<a href="${webBaseUrl}#/challenge-detail/${challengeNameAlias}-${challengeId}-id?toPhase=evaluationCriteria&utm_source=updatecriteria&utm_medium=updatebtn&utm_campaign=onlinecontest" target="_blank" style="font-family: Arial, sans-serif; font-size: 16px; color: #ffffff; text-decoration: none; display: block; width: 100%">Update judging & scoring criteria</a>
<a href="${webBaseUrl}#/challenge-detail/${challengeNameAlias}-${challengeId}-id?a=evaluationCriteria&utm_source=updatecriteria&utm_medium=updatebtn&utm_campaign=onlinecontest" target="_blank" style="font-family: Arial, sans-serif; font-size: 16px; color: #ffffff; text-decoration: none; display: block; width: 100%">Update judging & scoring criteria</a>
</td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<table width="300px" border="0" cellspacing="0" cellpadding="0" align="center" style="margin: 0 auto;" class="fullWidth">
<tr>
<td bgcolor="#277cbd" width="100%" style="padding: 10px 5px; -webkit-border-radius:3px; border-radius:3px; text-align: center">
<a href="${webBaseUrl}#/challenge-detail/${challengeNameAlias}-${challengeId}-id?toPhase=evaluationCriteria&utm_source=updatecriteria&utm_medium=updatebtn&utm_campaign=onlinecontest" target="_blank" style="font-family: Arial, sans-serif; font-size: 16px; color: #ffffff; text-decoration: none; display: block; width: 100%">Thiết lập ngay</a>
<a href="${webBaseUrl}#/challenge-detail/${challengeNameAlias}-${challengeId}-id?a=evaluationCriteria&utm_source=updatecriteria&utm_medium=updatebtn&utm_campaign=onlinecontest" target="_blank" style="font-family: Arial, sans-serif; font-size: 16px; color: #ffffff; text-decoration: none; display: block; width: 100%">Thiết lập ngay</a>
</td>
</tr>
</table>
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/template/FINAL_CHALLENGE_REPORT_EN.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<th align="left">
<h2 style="font-size: 18px; font-weight: normal; text-transform: capitalize;color: #898989;">
<h2 style="font-size: 18px; font-weight: normal; text-transform: capitalize;color: #000;">
${challengeName}
<span style="font-size: 25px; font-weight: normal; color:#1c7abc">$${totalPlaceReward?string["0.####"]}</span>
</h2>
Expand All @@ -37,9 +37,11 @@
</table>
</td>
</tr>
<tr>
<td align="left" style="height: 50px;"></td>
</tr>
<tr>
<td align="center">
<br/>
<#if winnersInfo?size != 0>
<span style="font-size: 12px; font-weight: normal"><strong style="font-size: 25px; color:#bf3a2f">${winnersInfo?size}</strong> winner(s)</span>
<#list winnersInfo as winnerInfo>
Expand All @@ -65,7 +67,7 @@
<td align="left" style="height: 1px; background-color: #8d8d8d;"></td>
</tr>
<tr>
<td align="left" style="height: 30px;"></td>
<td align="left" style="height: 5px;"></td>
</tr>
<tr>
<td align="left" width="100%">
Expand Down
Binary file modified src/main/webapp/assets/images/full-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/idea-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/idea-prototype-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/idea-uiux-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/prototype-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/three-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/tip-for-qualify-all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/tip-for-qualify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/uiux-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/assets/images/uiux-prototype-phase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/main/webapp/assets/modules/common/onFinishRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ techlooper.directive("onFinishRender", function ($timeout, jsonValue, utils) {
restrict: "A",
link: function (scope, element, attr) {
if (scope.$last === true) {
scope.$emit(attr.onFinishRender);
$timeout(function () {
scope.$emit(attr.onFinishRender);
});
utils.sendNotification(jsonValue.notifications.loaded, $(window).height());
}
}
}
Expand Down
Loading

0 comments on commit e965ece

Please sign in to comment.