Merge branch 'dev' into fix/templates-register

This commit is contained in:
Pablo Bonilla 2021-08-01 20:36:01 -06:00
commit 55c58358ff
No known key found for this signature in database
GPG Key ID: 46877262B8DE47E2
13 changed files with 1000 additions and 27 deletions

View File

@ -5,6 +5,7 @@ import java.util.Locale;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.datasurvey.domain.User;
import org.datasurvey.domain.UsuarioEncuesta;
import org.datasurvey.domain.UsuarioExtra;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -111,6 +112,22 @@ public class MailService {
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async
public void sendEmailFromTemplateUsuarioEncuesta(User user, UsuarioEncuesta usuarioEncuesta, String templateName, String titleKey) {
if (user.getEmail() == null) {
log.debug("Email doesn't exist for user '{}'", user.getLogin());
return;
}
Locale locale = Locale.forLanguageTag(user.getLangKey());
Context context = new Context(locale);
context.setVariable(USER, user);
context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
context.setVariable("colaborador", usuarioEncuesta);
String content = templateEngine.process(templateName, context);
String subject = messageSource.getMessage(titleKey, null, locale);
sendEmail(user.getEmail(), subject, content, false, true);
}
@Async
public void sendActivationEmail(User user) {
log.debug("Sending activation email to '{}'", user.getEmail());
@ -164,4 +181,26 @@ public class MailService {
log.debug("Sending encuesta deletion notification mail to '{}'", user.getUser().getEmail());
sendEmailFromTemplate(user.getUser(), "mail/encuestaDeletedEmail", "email.encuestaDeleted.title");
}
@Async
public void sendInvitationColaborator(UsuarioEncuesta user) {
log.debug("Sending encuesta invitation collaboration notification mail to '{}'", user.getUsuarioExtra().getUser().getEmail());
sendEmailFromTemplateUsuarioEncuesta(
user.getUsuarioExtra().getUser(),
user,
"mail/invitationColaboratorEmail",
"email.invitation.title"
);
}
@Async
public void sendNotifyDeleteColaborator(UsuarioEncuesta user) {
log.debug("Sending delete collaboration notification mail to '{}'", user.getUsuarioExtra().getUser().getEmail());
sendEmailFromTemplateUsuarioEncuesta(
user.getUsuarioExtra().getUser(),
user,
"mail/deleteColaboratorEmail",
"email.deleteColaborator.title"
);
}
}

View File

@ -9,13 +9,11 @@ import java.util.Optional;
import java.util.stream.Collectors;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.datasurvey.domain.Encuesta;
import org.datasurvey.domain.UsuarioEncuesta;
import org.datasurvey.domain.UsuarioExtra;
import org.datasurvey.repository.UsuarioEncuestaRepository;
import org.datasurvey.service.EncuestaService;
import org.datasurvey.service.UsuarioEncuestaQueryService;
import org.datasurvey.service.UsuarioEncuestaService;
import org.datasurvey.service.UsuarioExtraService;
import org.datasurvey.service.*;
import org.datasurvey.service.criteria.UsuarioEncuestaCriteria;
import org.datasurvey.web.rest.errors.BadRequestAlertException;
import org.slf4j.Logger;
@ -48,18 +46,22 @@ public class UsuarioEncuestaResource {
private final UsuarioEncuestaQueryService usuarioEncuestaQueryService;
private final MailService mailService;
public UsuarioEncuestaResource(
UsuarioEncuestaService usuarioEncuestaService,
UsuarioEncuestaRepository usuarioEncuestaRepository,
UsuarioEncuestaQueryService usuarioEncuestaQueryService,
UsuarioExtraService usuarioExtraService,
EncuestaService encuestaService
EncuestaService encuestaService,
MailService mailService
) {
this.usuarioEncuestaService = usuarioEncuestaService;
this.usuarioEncuestaRepository = usuarioEncuestaRepository;
this.usuarioEncuestaQueryService = usuarioEncuestaQueryService;
this.usuarioExtraService = usuarioExtraService;
this.encuestaService = encuestaService;
this.mailService = mailService;
}
/**
@ -77,6 +79,9 @@ public class UsuarioEncuestaResource {
throw new BadRequestAlertException("A new usuarioEncuesta cannot already have an ID", ENTITY_NAME, "idexists");
}
UsuarioEncuesta result = usuarioEncuestaService.save(usuarioEncuesta);
if (result.getId() != null) {
mailService.sendInvitationColaborator(usuarioEncuesta);
}
return ResponseEntity
.created(new URI("/api/usuario-encuestas/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
@ -200,7 +205,11 @@ public class UsuarioEncuestaResource {
@DeleteMapping("/usuario-encuestas/{id}")
public ResponseEntity<Void> deleteUsuarioEncuesta(@PathVariable Long id) {
log.debug("REST request to delete UsuarioEncuesta : {}", id);
Optional<UsuarioEncuesta> usuarioEncuesta = usuarioEncuestaService.findOne(id);
usuarioEncuestaService.delete(id);
if (usuarioEncuesta != null) {
mailService.sendNotifyDeleteColaborator(usuarioEncuesta.get());
}
return ResponseEntity
.noContent()
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString()))
@ -225,4 +234,11 @@ public class UsuarioEncuestaResource {
}
return ResponseEntity.ok().body(usuariosEncuestas);
}
@PostMapping("/usuario-encuestas/notify/{id}")
public ResponseEntity<Void> notifyInvitationColaborator(@PathVariable Long id, @Valid @RequestBody UsuarioEncuesta usuarioEncuesta) {
log.debug("REST request to notify {} of invitation to Encuesta", usuarioEncuesta.getUsuarioExtra().getUser().getEmail());
mailService.sendInvitationColaborator(usuarioEncuesta);
return ResponseEntity.noContent().build();
}
}

View File

@ -42,13 +42,25 @@ email.suspended.text2=Saludos,
#PublicEncuesta
email.public.title=Su encuesta ha sido publicada
email.public.greeting=¡Felicidades {0}!
email.public.greeting=¡Felicidades {0}!
email.public.text1=Su encuesta ha sido publicada de manera publica
email.public.text2=Saludos,
#PrivateEncuesta
email.private.title=Su encuesta ha sido publicada de manera privada
email.private.greeting=¡Felicidades {0}!
email.private.text1=Su encuesta ha sdo publicada de manera privada. Su contraseña de acceso es: {0}
email.private.greeting=¡Felicidades {0}!
email.private.text1=Su encuesta ha sdo publicada de manera privada. Su contraseña de acceso es: {0}
email.private.text2=Saludos,
#Invitation Colaborator
email.invitation.title=Se le ha invitado a colaborar en una encuesta
email.invitation.greeting=¡Nueva invitación, {0}!
email.invitation.text1=Fue invitado a la encuesta "{0}(#{1})". Para aceptar la solicitud de colaborador, ingrese al área de colaboraciones
email.invitation.text2=Saludos,
#Delete Colaborator
email.deleteColaborator.title=Se le ha expulsado de una encuesta como colaborador
email.deleteColaborator.greeting=¡Se le ha expulsado, {0}!
email.deleteColaborator.text1=Fue expulsado de la encuesta {0}(#{1})"
email.deleteColaborator.text2=Saludos,

View File

@ -0,0 +1,322 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.deleteColaborator.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<style>
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, 0.8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #007bff;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Noto Sans JP', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, 0.4);
}
a {
color: #30e3ca;
}
table {
}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, 0.3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {
}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, 0.8);
}
.heading-section-white h2 {
/*font-family: ;*/
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, 0.4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
.footer {
border-top: 1px solid rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0">
<img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333882/email_v7pjtv.png"
alt=""
style="width: 250px; max-width: 600px; height: auto; margin: auto; display: block"
/>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center">
<h2 th:text="#{email.deleteColaborator.greeting(${user.login})}">¡Hola!</h2>
<h3 th:text="#{email.deleteColaborator.text1(${colaborador.encuesta.nombre}, ${colaborador.encuesta.id})}">
Your JHipster account has been created, please click on the URL below to activate it:
</h3>
<p>
<a th:with="url=(@{|${baseUrl}/colaboraciones|})" th:href="${url}" class="btn btn-primary">Ir a Colaboraciones</a>
</p>
</div>
<div class="text" style="padding: 1em 2.5em; text-align: center">
<p>
<span th:text="#{email.deleteColaborator.text2}">Regards, </span>
<br />
<em th:text="#{email.signature}">JHipster.</em>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

@ -0,0 +1,322 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" th:lang="${#locale.language}" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width" />
<!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting" />
<!-- Disable auto-scale in iOS 10 Mail entirely -->
<title th:text="#{email.invitation.title}">JHipster activation</title>
<link rel="icon" th:href="@{|${baseUrl}/favicon.ico|}" />
<link href="https://fonts.googleapis.com/css?family=NotoSansSP:300,400,700" rel="stylesheet" />
<link rel="manifest" href="manifest.webapp" />
<style>
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, 0.8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #007bff;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Noto Sans JP', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, 0.4);
}
a {
color: #30e3ca;
}
table {
}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, 0.3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {
}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, 0.4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, 0.8);
}
.heading-section-white h2 {
/*font-family: ;*/
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, 0.4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
.footer {
border-top: 1px solid rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1">
<center style="width: 100%; background-color: #f1f1f1">
<div
style="
display: none;
font-size: 1px;
max-height: 0px;
max-width: 0px;
opacity: 0;
overflow: hidden;
mso-hide: all;
font-family: sans-serif;
"
>
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center">
<h1>
<a href="#"
><img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333881/DataSurveyLogo2_smr2ok.png"
alt=""
width="300"
/></a>
</h1>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0">
<img
src="https://res.cloudinary.com/marielascloud/image/upload/v1626333882/email_v7pjtv.png"
alt=""
style="width: 250px; max-width: 600px; height: auto; margin: auto; display: block"
/>
</td>
</tr>
<!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center">
<h2 th:text="#{email.invitation.greeting(${user.login})}">¡Hola!</h2>
<h3 th:text="#{email.invitation.text1(${colaborador.encuesta.nombre}, ${colaborador.encuesta.id})}">
Your JHipster account has been created, please click on the URL below to activate it:
</h3>
<p>
<a th:with="url=(@{|${baseUrl}/colaboraciones|})" th:href="${url}" class="btn btn-primary">Ir a Colaboraciones</a>
</p>
</div>
<div class="text" style="padding: 1em 2.5em; text-align: center">
<p>
<span th:text="#{email.reactivation.text2}">Regards, </span>
<br />
<em th:text="#{email.signature}">JHipster.</em>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: auto">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px">
<h3 class="heading">Acerca de</h3>
<p>DataSurvey es su compañero más cercano para poder recolectar información valiosa para usted</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<ul>
<li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center">
<p><a href="https://datasurvey.org" style="color: rgba(0, 0, 0, 0.8)">DataSurvey.org</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

@ -102,6 +102,10 @@ export class EncuestaService {
return this.http.delete(`${this.resourceUrl}/notify/${encuesta.id}`, { observe: 'response' });
}
/*sendCorreoInvitacion(correo: string) {
return this.http.post(`${this.resourceUrl}/notify/${encuesta.id}`, { observe: 'response' });
}*/
addEncuestaToCollectionIfMissing(encuestaCollection: IEncuesta[], ...encuestasToCheck: (IEncuesta | null | undefined)[]): IEncuesta[] {
const encuestas: IEncuesta[] = encuestasToCheck.filter(isPresent);
if (encuestas.length > 0) {

View File

@ -16,7 +16,7 @@
<div class="col-12 ds-list-collabs">
<div class="row" style="flex-direction: row-reverse">
<div class="col-mb-2 iconos-colab">
<div class="add-collab" *ngIf="isAutor()">
<div class="add-collab" data-toggle="modal" data-target="#modalAddColaborators">
<fa-icon icon="sync" [icon]="faPlus"></fa-icon>
</div>
</div>
@ -448,7 +448,7 @@
<!-- ------------------------------------------------------------------------------------------------- -->
<!-- Survey Parameters Information -->
<!-- Survey Update Colaborator -->
<div
class="modal fade ds-modal"
id="modalUpdateColaborators"
@ -503,3 +503,105 @@
</div>
<!-- ------------------------------------------------------------------------------------------------- -->
<!-- Survey Add Colaborator -->
<div
class="modal fade ds-modal"
id="modalAddColaborators"
tabindex="-1"
role="dialog"
aria-labelledby="verColaboradoresTitle"
aria-hidden="true"
*ngIf="isAutor()"
>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<form class="ds-form" name="editFormAddCollab" role="form" (ngSubmit)="saveAddCollab()" [formGroup]="editFormAddCollab">
<div class="modal-header">
<h1 class="modal-title" id="modalAddColaboradores">Añadir Colaborador</h1>
</div>
<div class="modal-body">
<div *ngIf="userCollabNotExist" class="alert alert-danger alert-dismissible fade show" role="alert">
No existe un usuario con ese correo
</div>
<div *ngIf="userCollabIsCollab" class="alert alert-danger alert-dismissible fade show" role="alert">
Este usuario ya se encuentra colaborando
</div>
<div *ngIf="userCollabIsAutor" class="alert alert-danger alert-dismissible fade show" role="alert">
Usted es el autor de la encuesta, no puede ser colaborador
</div>
<div>
<div class="mb-5">
<p class="ds-subtitle">Correo electrónico</p>
<input type="email" class="form-control" name="email_add" id="field_add_email" data-cy="email" formControlName="email_add" />
<div
*ngIf="
editFormAddCollab.get('email_add')!.invalid &&
(editFormAddCollab.get('email_add')!.dirty || editFormAddCollab.get('email_add')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="editFormAddCollab.get('email_add')?.errors?.required"
jhiTranslate="entity.validation.required"
>
This field is required.
</small>
<small
class="form-text text-danger"
*ngIf="editFormAddCollab.get('email_add')?.errors?.invalid"
jhiTranslate="global.messages.validate.email.invalid"
>
Your email is invalid.
</small>
</div>
</div>
<div>
<label for="field_update_rol">Rol</label>
<select class="form-control" name="rol_add" formControlName="rol_add" id="field_rol_add" data-cy="rol_add">
<option value="READ">Lector</option>
<option value="WRITE">Escritor</option>
</select>
<div
*ngIf="
editFormAddCollab.get('rol_add')!.invalid &&
(editFormAddCollab.get('rol_add')!.dirty || editFormAddCollab.get('rol_add')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="editFormAddCollab.get('rol_add')?.errors?.required"
jhiTranslate="entity.validation.required"
>
This field is required.
</small>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button
id="btnCancelAddColaboradores"
(click)="resetFormAddCollab()"
type="button"
class="ds-btn ds-btn--secondary"
data-dismiss="modal"
>
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;<span>Cancelar</span>
</button>
<button
id="btnAddColaboradores"
type="submit"
class="ds-btn ds-btn--primary"
data-cy="entityAddButton"
[disabled]="editFormAddCollab.invalid || isSavingAddCollab"
>
<span>Añadir</span>
</button>
</div>
</form>
</div>
</div>
</div>
<!-- ------------------------------------------------------------------------------------------------- -->

View File

@ -1,19 +1,19 @@
import { EPreguntaAbierta, IEPreguntaAbierta } from './../../e-pregunta-abierta/e-pregunta-abierta.model';
import { EPreguntaCerrada } from './../../e-pregunta-cerrada/e-pregunta-cerrada.model';
import { EPreguntaCerradaOpcion, IEPreguntaCerradaOpcion } from './../../e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.model';
import { IEPreguntaCerradaOpcion } from './../../e-pregunta-cerrada-opcion/e-pregunta-cerrada-opcion.model';
import { EPreguntaAbiertaService } from './../../e-pregunta-abierta/service/e-pregunta-abierta.service';
import { EPreguntaCerradaOpcionService } from './../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service';
import { AfterViewChecked, Component, OnInit } from '@angular/core';
import { HttpResponse } from '@angular/common/http';
import { FormBuilder, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { finalize, map } from 'rxjs/operators';
import { finalize } from 'rxjs/operators';
import * as dayjs from 'dayjs';
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
import { IEncuesta, Encuesta } from '../encuesta.model';
import { Encuesta } from '../encuesta.model';
import { EncuestaService } from '../service/encuesta.service';
import { ICategoria } from 'app/entities/categoria/categoria.model';
import { CategoriaService } from 'app/entities/categoria/service/categoria.service';
@ -25,28 +25,26 @@ import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-ce
import { EPreguntaCerradaService } from 'app/entities/e-pregunta-cerrada/service/e-pregunta-cerrada.service';
import { EPreguntaCerradaDeleteDialogComponent } from 'app/entities/e-pregunta-cerrada/delete/e-pregunta-cerrada-delete-dialog.component';
import { faTimes, faPlus, faQuestion, faPollH, faEye } from '@fortawesome/free-solid-svg-icons';
import { faEye, faPlus, faPollH, faQuestion, faTimes } from '@fortawesome/free-solid-svg-icons';
import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model';
import { EncuestaDeleteQuestionDialogComponent } from '../encuesta-delete-question-dialog/encuesta-delete-question-dialog.component';
import { EncuestaDeleteOptionDialogComponent } from '../encuesta-delete-option-dialog/encuesta-delete-option-dialog.component';
import { ParametroAplicacionService } from './../../parametro-aplicacion/service/parametro-aplicacion.service';
import { IParametroAplicacion } from './../../parametro-aplicacion/parametro-aplicacion.model';
import { Router } from '@angular/router';
import { UsuarioEncuestaService } from 'app/entities/usuario-encuesta/service/usuario-encuesta.service';
import { IUsuarioEncuesta, UsuarioEncuesta } from '../../usuario-encuesta/usuario-encuesta.model';
import { RolColaborador } from '../../enumerations/rol-colaborador.model';
import { Account } from '../../../core/auth/account.model';
import { AccountService } from 'app/core/auth/account.service';
import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component';
import { EncuestaFinalizarDialogComponent } from '../encuesta-finalizar-dialog/encuesta-finalizar-dialog.component';
import { EncuestaDeleteDialogComponent } from '../delete/encuesta-delete-dialog.component';
import { EncuestaDeleteColaboratorDialogComponent } from '../encuesta-delete-colaborator-dialog/encuesta-delete-colaborator-dialog.component';
import { IUser } from '../../user/user.model';
import * as $ from 'jquery';
import { UserService } from '../../user/user.service';
import { EstadoColaborador } from '../../enumerations/estado-colaborador.model';
@Component({
selector: 'jhi-encuesta-update',
@ -62,6 +60,7 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
isSaving = false;
isSavingQuestion = false;
isSavingCollab = false;
isSavingAddCollab = false;
finalizada = false;
public rolSeleccionado: RolColaborador | undefined = undefined;
categoriasSharedCollection: ICategoria[] = [];
@ -108,6 +107,11 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
rol: [null, [Validators.required]],
});
editFormAddCollab = this.fb.group({
email_add: [null, [Validators.required, Validators.email]],
rol_add: [null, [Validators.required]],
});
ePreguntas?: any[];
ePreguntasOpciones?: any[];
encuesta: Encuesta | null = null;
@ -119,6 +123,11 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
createAnotherQuestion: Boolean = false;
selectedQuestionToCreateOption: IEPreguntaCerrada | null = null;
userPublicCollab: IUser | null = null;
usuarioExtraCollab: UsuarioExtra | null = null;
userCollabNotExist: boolean = false;
userCollabIsCollab: boolean = false;
userCollabIsAutor: boolean = false;
constructor(
protected encuestaService: EncuestaService,
protected categoriaService: CategoriaService,
@ -132,7 +141,8 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
protected ePreguntaAbiertaService: EPreguntaAbiertaService,
protected usuarioEncuestaService: UsuarioEncuestaService,
protected router: Router,
protected accountService: AccountService
protected accountService: AccountService,
protected userService: UserService
) {}
loadAll(): void {
@ -628,6 +638,13 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
// }
/* methods for colaborators*/
protected createFromFormCollab(): UsuarioEncuesta {
return {
id: undefined,
rol: this.editFormAddCollab.get(['rol_add'])!.value,
};
}
selectColaborator(c: IUsuarioEncuesta) {
this.colaborador = c;
this.rolSeleccionado = c.rol;
@ -648,6 +665,69 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
}
}
resetFormAddCollab(): void {
this.editFormAddCollab.reset();
this.userPublicCollab = null;
}
saveAddCollab(): void {
this.isSavingAddCollab = true;
this.userCollabIsAutor = false;
this.userCollabIsCollab = false;
this.userCollabNotExist = false;
const collab = this.createFromFormCollab();
let rol = this.editFormAddCollab.get('rol_add')!.value;
if (rol === 'READ') {
collab.rol = RolColaborador.READ;
} else if (rol === 'WRITE') {
collab.rol = RolColaborador.WRITE;
}
let correoCollab = this.editFormAddCollab.get('email_add')!.value;
this.userService
.retrieveAllPublicUsers()
.pipe(
finalize(() => {
if (this.userPublicCollab?.id !== undefined) {
if (correoCollab === this.usuarioExtra?.user?.login) {
this.userCollabIsAutor = true;
this.isSavingAddCollab = false;
} else if (this.validarUserIsCollab(correoCollab)) {
this.userCollabIsCollab = true;
this.isSavingAddCollab = false;
} else {
this.usuarioExtraService.find(this.userPublicCollab?.id).subscribe(res => {
this.usuarioExtraCollab = res.body;
let now = new Date();
collab.fechaAgregado = dayjs(now);
collab.usuarioExtra = this.usuarioExtraCollab;
collab.estado = EstadoColaborador.PENDING;
collab.encuesta = this.encuesta;
let id = 0;
this.subscribeToSaveResponseAddCollab(this.usuarioEncuestaService.create(collab));
});
}
} else {
this.userCollabNotExist = true;
this.isSavingAddCollab = false;
}
this.resetFormAddCollab();
})
)
.subscribe(res => {
res.forEach(user => {
if (user.login === correoCollab) {
this.userPublicCollab = user;
}
if (user.id === this.usuarioExtra?.id) {
// @ts-ignore
this.usuarioExtra?.user?.login = user.login;
}
});
});
}
protected subscribeToSaveResponseUpdateCollab(result: Observable<HttpResponse<IUsuarioEncuesta>>): void {
result.pipe(finalize(() => this.onSaveFinalizeUpdateCollab())).subscribe(
() => this.onSaveSuccessUpdateCollab(),
@ -668,6 +748,25 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
this.isSavingCollab = false;
}
protected subscribeToSaveResponseAddCollab(result: Observable<HttpResponse<IUsuarioEncuesta>>): void {
result.pipe(finalize(() => this.onSaveFinalizeAddCollab())).subscribe(
() => this.onSaveSuccessAddCollab(),
() => this.onSaveErrorAddCollab()
);
}
protected onSaveSuccessAddCollab(): void {
this.loadAll();
$('#btnCancelAddColaboradores').click();
}
protected onSaveErrorAddCollab(): void {
// Api for inheritance.
}
protected onSaveFinalizeAddCollab(): void {
this.isSavingAddCollab = false;
}
deleteCollab(collab: IUsuarioEncuesta) {
//$('#btnCancelUbdateColaboradores').click();
//setTimeout(() => {
@ -699,6 +798,16 @@ export class EncuestaUpdateComponent implements OnInit, AfterViewChecked {
return escritor;
}
validarUserIsCollab(correoCollab: string) {
let isCollab = false;
this.usuariosColaboradores.forEach(c => {
if (c.usuarioExtra?.id === this.userPublicCollab?.id) {
isCollab = true;
}
});
return isCollab;
}
finalizar(): void {
const modalRef = this.modalService.open(EncuestaFinalizarDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.encuesta = this.encuesta;

View File

@ -22,6 +22,10 @@ export class UserService {
return this.http.get<IUser[]>(this.resourceUrl, { params: options, observe: 'response' });
}
retrieveAllPublicUsers(): Observable<IUser[]> {
return this.http.get<IUser[]>(this.resourceUrl);
}
addUserToCollectionIfMissing(userCollection: IUser[], ...usersToCheck: (IUser | null | undefined)[]): IUser[] {
const users: IUser[] = usersToCheck.filter(isPresent);
if (users.length > 0) {

View File

@ -64,6 +64,7 @@
<td class="text-right">
<div class="btn-group" *ngIf="usuarioEncuesta.encuesta">
<button
*ngIf="usuarioEncuesta.estado === 'ACTIVE'"
type="button"
[routerLink]="['/encuesta', usuarioEncuesta.encuesta.id, 'edit']"
class="ds-btn ds-btn--primary"
@ -71,6 +72,15 @@
>
<span>Editar encuesta</span>
</button>
<button
*ngIf="usuarioEncuesta.estado === 'PENDING'"
type="button"
(click)="aceptarInvitacion(usuarioEncuesta)"
class="ds-btn btn-success"
[disabled]="isLoading"
>
<span>Aceptar invitación</span>
</button>
<button type="submit" (click)="delete(usuarioEncuesta)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton">
<fa-icon icon="sign-out-alt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.usuarioEncuesta.delete.getOut">Get Out</span>

View File

@ -6,14 +6,18 @@ import { IUsuarioEncuesta } from '../usuario-encuesta.model';
import { UsuarioEncuestaService } from '../service/usuario-encuesta.service';
import { UsuarioEncuestaDeleteDialogComponent } from '../delete/usuario-encuesta-delete-dialog.component';
import * as dayjs from 'dayjs';
import { faPollH, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
import { faPencilAlt, faPollH } from '@fortawesome/free-solid-svg-icons';
import { AccountService } from 'app/core/auth/account.service';
import { Account } from 'app/core/auth/account.model';
import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model';
import { IUser } from '../../user/user.model';
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
import { ActivatedRoute, Router } from '@angular/router';
import { EstadoColaborador } from '../../enumerations/estado-colaborador.model';
import { Observable } from 'rxjs';
import { finalize } from 'rxjs/operators';
import * as $ from 'jquery';
import { DATE_TIME_FORMAT } from '../../../config/input.constants';
@Component({
selector: 'jhi-usuario-encuesta',
@ -27,7 +31,7 @@ export class UsuarioEncuestaComponent implements OnInit {
isLoading = false;
usuarioExtra: IUsuarioExtra | null = null;
user: IUser | null = null;
isSavingCollab = false;
public searchRol: string;
public searchEstado: string;
@ -93,4 +97,29 @@ export class UsuarioEncuestaComponent implements OnInit {
}
});
}
aceptarInvitacion(usuarioEncuesta: IUsuarioEncuesta) {
usuarioEncuesta.estado = EstadoColaborador.ACTIVE;
usuarioEncuesta.fechaAgregado = dayjs(usuarioEncuesta.fechaAgregado, DATE_TIME_FORMAT);
this.subscribeToSaveResponseCollab(this.usuarioEncuestaService.update(usuarioEncuesta));
}
protected subscribeToSaveResponseCollab(result: Observable<HttpResponse<IUsuarioEncuesta>>): void {
result.pipe(finalize(() => this.onSaveFinalizeCollab())).subscribe(
() => this.onSaveSuccessCollab(),
() => this.onSaveErrorCollab()
);
}
protected onSaveSuccessCollab(): void {
this.loadAll();
}
protected onSaveErrorCollab(): void {
// Api for inheritance.
}
protected onSaveFinalizeCollab(): void {
this.isSavingCollab = false;
}
}

View File

@ -68,6 +68,10 @@ export class UsuarioEncuestaService {
return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });
}
sendCorreoInvitacion(colaborator: IUsuarioEncuesta) {
return this.http.post(`${this.resourceUrl}/notify/${colaborator.id}`, { body: colaborator, observe: 'response' });
}
addUsuarioEncuestaToCollectionIfMissing(
usuarioEncuestaCollection: IUsuarioEncuesta[],
...usuarioEncuestasToCheck: (IUsuarioEncuesta | null | undefined)[]

View File

@ -8,8 +8,8 @@
"createOrEditLabel": "Crear o editar Colaborador",
"notFound": "Ningún Colaborador encontrado"
},
"created": "Un nuevo Usuario Encuesta ha sido creado con el identificador {{ param }}",
"updated": "Un Usuario Encuesta ha sido actualizado con el identificador {{ param }}",
"created": "Un Colaborador ha sido creado con el identificador {{ param }}",
"updated": "Ha aceptado la colaboración en la encuesta #{{ param }}",
"deleted": "Un Colaborador ha sido expulsado de la encuesta",
"delete": {
"question": "¿Seguro que quiere expulsar al colaborador de la encuesta?",