diff --git a/src/main/java/org/datasurvey/config/CacheConfiguration.java b/src/main/java/org/datasurvey/config/CacheConfiguration.java index 0836c99..0e82862 100644 --- a/src/main/java/org/datasurvey/config/CacheConfiguration.java +++ b/src/main/java/org/datasurvey/config/CacheConfiguration.java @@ -24,13 +24,13 @@ public class CacheConfiguration { private final javax.cache.configuration.Configuration jcacheConfiguration; public CacheConfiguration(JHipsterProperties jHipsterProperties) { - JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache(); + //JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache(); jcacheConfiguration = Eh107Configuration.fromEhcacheCacheConfiguration( CacheConfigurationBuilder - .newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder.heap(ehcache.getMaxEntries())) - .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ehcache.getTimeToLiveSeconds()))) + .newCacheConfigurationBuilder(Object.class, Object.class, ResourcePoolsBuilder.heap(100L)) + .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(1))) .build() ); } @@ -82,6 +82,7 @@ public class CacheConfiguration { private void createCache(javax.cache.CacheManager cm, String cacheName) { javax.cache.Cache cache = cm.getCache(cacheName); + if (cache != null) { cache.clear(); } else { diff --git a/src/main/java/org/datasurvey/service/MailService.java b/src/main/java/org/datasurvey/service/MailService.java index c40c4fe..23ee9fe 100644 --- a/src/main/java/org/datasurvey/service/MailService.java +++ b/src/main/java/org/datasurvey/service/MailService.java @@ -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.UsuarioExtra; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; @@ -29,6 +30,8 @@ public class MailService { private static final String USER = "user"; + private static final String CONTRASENNA = "contrasenna"; + private static final String BASE_URL = "baseUrl"; private final JHipsterProperties jHipsterProperties; @@ -92,6 +95,22 @@ public class MailService { sendEmail(user.getEmail(), subject, content, false, true); } + @Async + public void sendEmailFromTemplateEncuesta(User user, String templateName, String titleKey, String contrasenna) { + 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(CONTRASENNA, contrasenna); + context.setVariable(USER, user); + context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl()); + 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()); @@ -115,4 +134,33 @@ public class MailService { log.debug("Sending password restored email to '{}'", user.getEmail()); sendEmailFromTemplate(user, "mail/passwordRestoredEmail", "email.restored.title"); } + + @Async + public void sendSuspendedAccountMail(UsuarioExtra user) { + log.debug("Sending suspended account mail to '{}'", user.getUser().getEmail()); + sendEmailFromTemplate(user.getUser(), "mail/suspendedAccountEmail", "email.suspended.title"); + } + + @Async + public void sendActivatedAccountMail(UsuarioExtra user) { + log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail()); + sendEmailFromTemplate(user.getUser(), "mail/reactivatedAccountEmail", "email.reactivation.title"); + } + + @Async + public void sendPublishedPrivateMail(UsuarioExtra user, String contrasenna) { + log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail()); + sendEmailFromTemplateEncuesta(user.getUser(), "mail/encuestaPrivadaEmail", "email.private.title", contrasenna); + } + + @Async + public void sendPublishedPublicMail(UsuarioExtra user) { + log.debug("Sending reactivated account mail to '{}'", user.getUser().getEmail()); + sendEmailFromTemplate(user.getUser(), "mail/encuestaPublicaEmail", "email.public.title"); + } + + public void sendEncuestaDeleted(UsuarioExtra user) { + log.debug("Sending encuesta deletion notification mail to '{}'", user.getUser().getEmail()); + sendEmailFromTemplate(user.getUser(), "mail/encuestaDeletedEmail", "email.encuestaDeleted.title"); + } } diff --git a/src/main/java/org/datasurvey/service/UserService.java b/src/main/java/org/datasurvey/service/UserService.java index 227c590..76f47ec 100644 --- a/src/main/java/org/datasurvey/service/UserService.java +++ b/src/main/java/org/datasurvey/service/UserService.java @@ -76,6 +76,19 @@ public class UserService { ); } + public Optional modifyStatus(String login, Boolean estado) { + return userRepository + .findOneByLogin(login) + .map( + user -> { + // activate given user for the registration key. + user.setActivated(estado); + log.debug("Activated user: {}", user); + return user; + } + ); + } + public Optional completePasswordReset(String newPassword, String key) { log.debug("Reset user password for reset key {}", key); return userRepository @@ -381,11 +394,16 @@ public class UserService { @Transactional(readOnly = true) public Optional getUserWithAuthoritiesByLogin(String login) { return userRepository.findOneWithAuthoritiesByLogin(login); + //cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).clear(); } @Transactional(readOnly = true) public Optional getUserWithAuthorities() { return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneWithAuthoritiesByLogin); + //findOneWithAuthoritiesByLogin + //cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).clear(); + + //return user; } /** diff --git a/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java b/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java index 61604a7..07e194d 100644 --- a/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java +++ b/src/main/java/org/datasurvey/web/rest/EPreguntaCerradaOpcionResource.java @@ -2,11 +2,13 @@ package org.datasurvey.web.rest; import java.net.URI; import java.net.URISyntaxException; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.Optional; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import org.datasurvey.domain.EPreguntaCerrada; import org.datasurvey.domain.EPreguntaCerradaOpcion; import org.datasurvey.repository.EPreguntaCerradaOpcionRepository; import org.datasurvey.service.EPreguntaCerradaOpcionQueryService; @@ -58,10 +60,15 @@ public class EPreguntaCerradaOpcionResource { * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new ePreguntaCerradaOpcion, or with status {@code 400 (Bad Request)} if the ePreguntaCerradaOpcion has already an ID. * @throws URISyntaxException if the Location URI syntax is incorrect. */ - @PostMapping("/e-pregunta-cerrada-opcions") + @PostMapping("/e-pregunta-cerrada-opcions/{id}") public ResponseEntity createEPreguntaCerradaOpcion( - @Valid @RequestBody EPreguntaCerradaOpcion ePreguntaCerradaOpcion + @Valid @RequestBody EPreguntaCerradaOpcion ePreguntaCerradaOpcion, + @PathVariable(value = "id", required = false) final Long id ) throws URISyntaxException { + EPreguntaCerrada ePreguntaCerrada = new EPreguntaCerrada(); + ePreguntaCerrada.setId(id); + ePreguntaCerradaOpcion.setEPreguntaCerrada(ePreguntaCerrada); + log.debug("REST request to save EPreguntaCerradaOpcion : {}", ePreguntaCerradaOpcion); if (ePreguntaCerradaOpcion.getId() != null) { throw new BadRequestAlertException("A new ePreguntaCerradaOpcion cannot already have an ID", ENTITY_NAME, "idexists"); @@ -76,7 +83,7 @@ public class EPreguntaCerradaOpcionResource { /** * {@code PUT /e-pregunta-cerrada-opcions/:id} : Updates an existing ePreguntaCerradaOpcion. * - * @param id the id of the ePreguntaCerradaOpcion to save. + * @param id the id of the ePreguntaCerradaOpcion to save. * @param ePreguntaCerradaOpcion the ePreguntaCerradaOpcion to update. * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated ePreguntaCerradaOpcion, * or with status {@code 400 (Bad Request)} if the ePreguntaCerradaOpcion is not valid, @@ -110,7 +117,7 @@ public class EPreguntaCerradaOpcionResource { /** * {@code PATCH /e-pregunta-cerrada-opcions/:id} : Partial updates given fields of an existing ePreguntaCerradaOpcion, field will ignore if it is null * - * @param id the id of the ePreguntaCerradaOpcion to save. + * @param id the id of the ePreguntaCerradaOpcion to save. * @param ePreguntaCerradaOpcion the ePreguntaCerradaOpcion to update. * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated ePreguntaCerradaOpcion, * or with status {@code 400 (Bad Request)} if the ePreguntaCerradaOpcion is not valid, @@ -196,4 +203,15 @@ public class EPreguntaCerradaOpcionResource { .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) .build(); } + + @PostMapping("/e-pregunta-cerrada-opcions/deleteMany") + public ResponseEntity deleteManyEPreguntaCerradaOpcion(@Valid @RequestBody int[] ids) { + for (int id : ids) { + ePreguntaCerradaOpcionService.delete((long) id); + } + return ResponseEntity + .noContent() + .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, Arrays.toString(ids))) + .build(); + } } diff --git a/src/main/java/org/datasurvey/web/rest/EncuestaResource.java b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java index bcf74c8..e96ac07 100644 --- a/src/main/java/org/datasurvey/web/rest/EncuestaResource.java +++ b/src/main/java/org/datasurvey/web/rest/EncuestaResource.java @@ -2,15 +2,25 @@ package org.datasurvey.web.rest; import java.net.URI; import java.net.URISyntaxException; +import java.time.ZonedDateTime; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import org.datasurvey.domain.EPreguntaAbierta; +import org.datasurvey.domain.EPreguntaCerrada; +import org.datasurvey.domain.EPreguntaCerradaOpcion; import org.datasurvey.domain.Encuesta; +import org.datasurvey.domain.enumeration.AccesoEncuesta; import org.datasurvey.repository.EncuestaRepository; +import org.datasurvey.service.*; import org.datasurvey.service.EncuestaQueryService; import org.datasurvey.service.EncuestaService; +import org.datasurvey.service.MailService; import org.datasurvey.service.criteria.EncuestaCriteria; import org.datasurvey.web.rest.errors.BadRequestAlertException; import org.slf4j.Logger; @@ -41,14 +51,30 @@ public class EncuestaResource { private final EncuestaQueryService encuestaQueryService; + private final MailService mailService; + + private final EPreguntaCerradaService ePreguntaCerradaService; + + private final EPreguntaAbiertaService ePreguntaAbiertaService; + + private final EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService; + public EncuestaResource( EncuestaService encuestaService, EncuestaRepository encuestaRepository, - EncuestaQueryService encuestaQueryService + EncuestaQueryService encuestaQueryService, + MailService mailService, + EPreguntaCerradaService ePreguntaCerradaService, + EPreguntaAbiertaService ePreguntaAbiertaService, + EPreguntaCerradaOpcionService ePreguntaCerradaOpcionService ) { this.encuestaService = encuestaService; this.encuestaRepository = encuestaRepository; this.encuestaQueryService = encuestaQueryService; + this.mailService = mailService; + this.ePreguntaCerradaService = ePreguntaCerradaService; + this.ePreguntaAbiertaService = ePreguntaAbiertaService; + this.ePreguntaCerradaOpcionService = ePreguntaCerradaOpcionService; } /** @@ -74,7 +100,7 @@ public class EncuestaResource { /** * {@code PUT /encuestas/:id} : Updates an existing encuesta. * - * @param id the id of the encuesta to save. + * @param id the id of the encuesta to save. * @param encuesta the encuesta to update. * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated encuesta, * or with status {@code 400 (Bad Request)} if the encuesta is not valid, @@ -99,6 +125,39 @@ public class EncuestaResource { } Encuesta result = encuestaService.save(encuesta); + + mailService.sendEncuestaDeleted(encuesta.getUsuarioExtra()); + + return ResponseEntity + .ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString())) + .body(result); + } + + @PutMapping("/encuestas/publish/{id}") + public ResponseEntity publishEncuesta( + @PathVariable(value = "id", required = false) final Long id, + @Valid @RequestBody Encuesta encuesta + ) throws URISyntaxException { + log.debug("REST request to update Encuesta : {}, {}", id, encuesta); + if (encuesta.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, encuesta.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!encuestaRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + Encuesta result = encuestaService.save(encuesta); + + if (result.getAcceso().equals(AccesoEncuesta.PRIVATE)) { + mailService.sendPublishedPrivateMail(result.getUsuarioExtra(), result.getContrasenna()); + } else { + mailService.sendPublishedPublicMail(result.getUsuarioExtra()); + } return ResponseEntity .ok() .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, encuesta.getId().toString())) @@ -108,7 +167,7 @@ public class EncuestaResource { /** * {@code PATCH /encuestas/:id} : Partial updates given fields of an existing encuesta, field will ignore if it is null * - * @param id the id of the encuesta to save. + * @param id the id of the encuesta to save. * @param encuesta the encuesta to update. * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated encuesta, * or with status {@code 400 (Bad Request)} if the encuesta is not valid, @@ -154,6 +213,55 @@ public class EncuestaResource { return ResponseEntity.ok().body(entityList); } + @GetMapping("/encuestas/preguntas/{id}") + public ResponseEntity> getPreguntasByIdEncuesta(@PathVariable Long id) { + List preguntasCerradas = ePreguntaCerradaService.findAll(); + List preguntasAbiertas = ePreguntaAbiertaService.findAll(); + List preguntas = Stream.concat(preguntasCerradas.stream(), preguntasAbiertas.stream()).collect(Collectors.toList()); + List preguntasFiltered = new ArrayList<>(); + + for (Object obj : preguntas) { + if (obj.getClass() == EPreguntaCerrada.class) { + if (((EPreguntaCerrada) obj).getEncuesta() != null) { + if (((EPreguntaCerrada) obj).getEncuesta().getId().equals(id)) { + preguntasFiltered.add(obj); + } + } + } else if (obj.getClass() == EPreguntaAbierta.class) { + if (((EPreguntaAbierta) obj).getEncuesta() != null) { + if (((EPreguntaAbierta) obj).getEncuesta().getId().equals(id)) { + preguntasFiltered.add(obj); + } + } + } + } + return ResponseEntity.ok().body(preguntasFiltered); + } + + @GetMapping("/encuestas/preguntas-opciones/{id}") + public ResponseEntity>> getPreguntaCerradaOpcionByIdEncuesta(@PathVariable Long id) { + List> res = new ArrayList<>(); + List preguntasCerradas = ePreguntaCerradaService.findAll(); + List preguntasCerradasFiltered = preguntasCerradas + .stream() + .filter(p -> Objects.nonNull(p.getEncuesta())) + .filter(p -> p.getEncuesta().getId().equals(id)) + .collect(Collectors.toList()); + List opciones = ePreguntaCerradaOpcionService.findAll(); + + for (EPreguntaCerrada ePreguntaCerrada : preguntasCerradasFiltered) { + long preguntaCerradaId = ePreguntaCerrada.getId(); + List opcionesFiltered = opciones + .stream() + .filter(o -> Objects.nonNull(o.getEPreguntaCerrada())) + .filter(o -> o.getEPreguntaCerrada().getId().equals(preguntaCerradaId)) + .collect(Collectors.toList()); + res.add(opcionesFiltered); + } + + return ResponseEntity.ok().body(res); + } + /** * {@code GET /encuestas/count} : count all the encuestas. * @@ -194,4 +302,78 @@ public class EncuestaResource { .headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())) .build(); } + + @DeleteMapping("encuestas/notify/{id}") + public ResponseEntity notifyEncuestaDeleted(@PathVariable Long id, @Valid @RequestBody Encuesta encuesta) { + log.debug("REST request to notify {} of deleted Encuesta", encuesta.getUsuarioExtra().getUser().getEmail()); + mailService.sendEncuestaDeleted(encuesta.getUsuarioExtra()); + return ResponseEntity.noContent().build(); + } + + @GetMapping("/encuestas/duplicate/{id}") + public ResponseEntity getAllEncuestas(@PathVariable Long id) { + Optional encuesta = encuestaService.findOne(id); + Encuesta newEncuesta = new Encuesta(); + + if (encuesta.isPresent()) { + // Encuesta + newEncuesta.setNombre(encuesta.get().getNombre()); + newEncuesta.setDescripcion(encuesta.get().getDescripcion()); + newEncuesta.setFechaCreacion(ZonedDateTime.now()); + newEncuesta.setCalificacion(5d); + newEncuesta.setAcceso(encuesta.get().getAcceso()); + newEncuesta.setEstado(encuesta.get().getEstado()); + newEncuesta.setCategoria(encuesta.get().getCategoria()); + newEncuesta.setUsuarioExtra(encuesta.get().getUsuarioExtra()); + + Encuesta encuestaCreated = encuestaService.save(newEncuesta); + + // Preguntas cerradas + List preguntasCerradas = ePreguntaCerradaService.findAll(); + for (EPreguntaCerrada ePreguntaCerrada : preguntasCerradas) { + if (ePreguntaCerrada.getEncuesta().getId().equals(id)) { + EPreguntaCerrada newEPreguntaCerrada = new EPreguntaCerrada(); + newEPreguntaCerrada.setNombre(ePreguntaCerrada.getNombre()); + newEPreguntaCerrada.setTipo(ePreguntaCerrada.getTipo()); + newEPreguntaCerrada.setOpcional(ePreguntaCerrada.getOpcional()); + newEPreguntaCerrada.setOrden(ePreguntaCerrada.getOrden()); + newEPreguntaCerrada.setEncuesta(encuestaCreated); + + ePreguntaCerradaService.save(newEPreguntaCerrada); + + // Opciones de preguntas cerradas + List opciones = ePreguntaCerradaOpcionService.findAll(); + for (EPreguntaCerradaOpcion ePreguntaCerradaOpcion : opciones) { + if (ePreguntaCerradaOpcion.getEPreguntaCerrada().getId().equals(ePreguntaCerrada.getId())) { + EPreguntaCerradaOpcion newEPreguntaCerradaOpcion = new EPreguntaCerradaOpcion(); + newEPreguntaCerradaOpcion.setNombre(ePreguntaCerradaOpcion.getNombre()); + newEPreguntaCerradaOpcion.setOrden(ePreguntaCerradaOpcion.getOrden()); + newEPreguntaCerradaOpcion.setCantidad(0); + newEPreguntaCerradaOpcion.setEPreguntaCerrada(newEPreguntaCerrada); + + ePreguntaCerradaOpcionService.save(newEPreguntaCerradaOpcion); + } + } + } + } + + // Preguntas abiertas + List preguntasAbiertas = ePreguntaAbiertaService.findAll(); + for (EPreguntaAbierta ePreguntaAbierta : preguntasAbiertas) { + if (ePreguntaAbierta.getEncuesta().getId().equals(id)) { + EPreguntaAbierta newEPreguntaAbierta = new EPreguntaAbierta(); + newEPreguntaAbierta.setNombre(ePreguntaAbierta.getNombre()); + newEPreguntaAbierta.setOpcional(ePreguntaAbierta.getOpcional()); + newEPreguntaAbierta.setOrden(ePreguntaAbierta.getOrden()); + newEPreguntaAbierta.setEncuesta(encuestaCreated); + + ePreguntaAbiertaService.save(newEPreguntaAbierta); + } + } + + return ResponseEntity.ok().body(encuestaCreated); + } + + return ResponseEntity.ok().body(null); + } } diff --git a/src/main/java/org/datasurvey/web/rest/UserJWTController.java b/src/main/java/org/datasurvey/web/rest/UserJWTController.java index 3ab2601..441b8dd 100644 --- a/src/main/java/org/datasurvey/web/rest/UserJWTController.java +++ b/src/main/java/org/datasurvey/web/rest/UserJWTController.java @@ -40,6 +40,7 @@ public class UserJWTController { Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); SecurityContextHolder.getContext().setAuthentication(authentication); String jwt = tokenProvider.createToken(authentication, loginVM.isRememberMe()); + HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer " + jwt); return new ResponseEntity<>(new JWTToken(jwt), httpHeaders, HttpStatus.OK); diff --git a/src/main/java/org/datasurvey/web/rest/UsuarioExtraResource.java b/src/main/java/org/datasurvey/web/rest/UsuarioExtraResource.java index 9914108..78b9e32 100644 --- a/src/main/java/org/datasurvey/web/rest/UsuarioExtraResource.java +++ b/src/main/java/org/datasurvey/web/rest/UsuarioExtraResource.java @@ -9,6 +9,8 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.datasurvey.domain.UsuarioExtra; import org.datasurvey.repository.UsuarioExtraRepository; +import org.datasurvey.service.MailService; +import org.datasurvey.service.UserService; import org.datasurvey.service.UsuarioExtraQueryService; import org.datasurvey.service.UsuarioExtraService; import org.datasurvey.service.criteria.UsuarioExtraCriteria; @@ -41,14 +43,22 @@ public class UsuarioExtraResource { private final UsuarioExtraQueryService usuarioExtraQueryService; + private final MailService mailService; + + private final UserService userService; + public UsuarioExtraResource( UsuarioExtraService usuarioExtraService, UsuarioExtraRepository usuarioExtraRepository, - UsuarioExtraQueryService usuarioExtraQueryService + UsuarioExtraQueryService usuarioExtraQueryService, + MailService mailService, + UserService userService ) { this.usuarioExtraService = usuarioExtraService; this.usuarioExtraRepository = usuarioExtraRepository; this.usuarioExtraQueryService = usuarioExtraQueryService; + this.mailService = mailService; + this.userService = userService; } /** @@ -99,6 +109,40 @@ public class UsuarioExtraResource { } UsuarioExtra result = usuarioExtraService.save(usuarioExtra); + + return ResponseEntity + .ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, usuarioExtra.getId().toString())) + .body(result); + } + + @PutMapping("/usuario-extras-estado/{id}") + public ResponseEntity updateUsuarioExtraEstado( + @PathVariable(value = "id", required = false) final Long id, + @Valid @RequestBody UsuarioExtra usuarioExtra + ) throws URISyntaxException { + log.debug("REST request to update UsuarioExtra : {}, {}", id, usuarioExtra); + if (usuarioExtra.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + if (!Objects.equals(id, usuarioExtra.getId())) { + throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid"); + } + + if (!usuarioExtraRepository.existsById(id)) { + throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound"); + } + + UsuarioExtra result = usuarioExtraService.save(usuarioExtra); + + if (usuarioExtra.getEstado().name().equals("SUSPENDED")) { + this.userService.modifyStatus(usuarioExtra.getUser().getLogin(), false); + mailService.sendSuspendedAccountMail(usuarioExtra); //se manda el correo de la suspecion + } else { + this.userService.modifyStatus(usuarioExtra.getUser().getLogin(), true); + mailService.sendActivatedAccountMail(usuarioExtra); //se manda el correo de reactivacion + } + return ResponseEntity .ok() .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, usuarioExtra.getId().toString())) diff --git a/src/main/resources/i18n/messages.properties b/src/main/resources/i18n/messages.properties index 52b6575..6dfbafb 100644 --- a/src/main/resources/i18n/messages.properties +++ b/src/main/resources/i18n/messages.properties @@ -27,3 +27,28 @@ email.restored.text1=Your DataSurvey password has been successfully reset.. email.restored.text2=Regards, email.restored.text3=If you did not make this change, please notify the following email immediately: email.restored.email=datasurvey@gmail.com + +#reactivar la cuenta +email.reactivation.title=Your account has been reactivated +email.reactivation.greeting=Hello, {0}! +email.reactivation.text1=Your account has been reactivated. Please click on the link so you can keep enjoying DataSurvey: +email.reactivation.text2=Regards, + +#suspended accounr +email.suspended.title=Your account has been suspended +email.suspended.greeting=Dear {0} +email.suspended.text1=Su cuenta en DataSurvey se encuentra temporalmente suspendida. Si cree que es un error por favor haga clic en el siguiente enlace para enviar una solicitud para reactivar su cuenta: +email.suspended.text2=Saludos, + +#PublicEncuesta +email.public.title=Su encuesta ha sido publicada +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.text2=Saludos, + diff --git a/src/main/resources/i18n/messages_es.properties b/src/main/resources/i18n/messages_es.properties index 77121fd..b9c87f1 100644 --- a/src/main/resources/i18n/messages_es.properties +++ b/src/main/resources/i18n/messages_es.properties @@ -28,3 +28,33 @@ email.restored.text2=Saludos, email.restored.text3=Si usted no realizó este cambio, favor notifique inmediatamente al siguiente correo: email.restored.email=datasurvey@gmail.com +#reactivate account +email.reactivation.title=Su cuenta ha sido reactivada +email.reactivation.greeting=¡Hola, {0}! +email.reactivation.text1=Su cuenta en DataSurvey ha sido reactivada. Por favor haga clic en el siguiente enlace para iniciar sesión y disfrutar de DataSurvey: +email.reactivation.text2=Saludos, + + +#suspended accounr +email.suspended.title=Su cuenta ha sido suspendida +email.suspended.greeting=Estimado {0} +email.suspended.text1=Lamentamos informarle que su cuenta en DataSurvey se encuentra temporalmente suspendida. Si cree que es un error por favor responda a este correo +email.suspended.text2=Saludos, + +#PublicEncuesta +email.public.title=Su encuesta ha sido publicada +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.text2=Saludos, + +#DeletedEncuesta +email.encuestaDeleted.title=Su encuesta ha sido eliminada +email.encuestaDeleted.greeting=Estimado {0} +email.encuestaDeleted.text1=Lamentamos informarle que su encuesta ha sido eliminada por un administrador +email.encuestaDeleted.text2=Saludos, diff --git a/src/main/resources/templates/mail/activationEmail.html b/src/main/resources/templates/mail/activationEmail.html index 673edc0..34a97d2 100644 --- a/src/main/resources/templates/mail/activationEmail.html +++ b/src/main/resources/templates/mail/activationEmail.html @@ -244,7 +244,7 @@ diff --git a/src/main/resources/templates/mail/creationEmail.html b/src/main/resources/templates/mail/creationEmail.html index 68b86f5..70fe68f 100644 --- a/src/main/resources/templates/mail/creationEmail.html +++ b/src/main/resources/templates/mail/creationEmail.html @@ -244,7 +244,7 @@ @@ -264,7 +264,7 @@ th:with="url=(@{|${baseUrl}/account/reset/finish?key=${user.resetKey}|})" th:href="${url}" class="btn btn-primary" - >Iniciar sesiónIniciar Sesión

diff --git a/src/main/resources/templates/mail/encuestaDeletedEmail.html b/src/main/resources/templates/mail/encuestaDeletedEmail.html new file mode 100644 index 0000000..207f19a --- /dev/null +++ b/src/main/resources/templates/mail/encuestaDeletedEmail.html @@ -0,0 +1,310 @@ + + + + + + + + + + + Encuesta Eliminada + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
+ + diff --git a/src/main/resources/templates/mail/encuestaPrivadaEmail.html b/src/main/resources/templates/mail/encuestaPrivadaEmail.html new file mode 100644 index 0000000..4acd28a --- /dev/null +++ b/src/main/resources/templates/mail/encuestaPrivadaEmail.html @@ -0,0 +1,319 @@ + + + + + + + + + + + JHipster activation + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
+ + diff --git a/src/main/resources/templates/mail/encuestaPublicaEmail.html b/src/main/resources/templates/mail/encuestaPublicaEmail.html new file mode 100644 index 0000000..67a14a9 --- /dev/null +++ b/src/main/resources/templates/mail/encuestaPublicaEmail.html @@ -0,0 +1,319 @@ + + + + + + + + + + + JHipster activation + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
+ + diff --git a/src/main/resources/templates/mail/passwordResetEmail.html b/src/main/resources/templates/mail/passwordResetEmail.html index 1742a3f..8c6b549 100644 --- a/src/main/resources/templates/mail/passwordResetEmail.html +++ b/src/main/resources/templates/mail/passwordResetEmail.html @@ -244,7 +244,7 @@ diff --git a/src/main/resources/templates/mail/passwordRestoredEmail.html b/src/main/resources/templates/mail/passwordRestoredEmail.html index 6dcebd1..5374e25 100644 --- a/src/main/resources/templates/mail/passwordRestoredEmail.html +++ b/src/main/resources/templates/mail/passwordRestoredEmail.html @@ -244,7 +244,7 @@ diff --git a/src/main/resources/templates/mail/reactivatedAccountEmail.html b/src/main/resources/templates/mail/reactivatedAccountEmail.html new file mode 100644 index 0000000..f0b0767 --- /dev/null +++ b/src/main/resources/templates/mail/reactivatedAccountEmail.html @@ -0,0 +1,322 @@ + + + + + + + + + + + JHipster activation + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
+ + diff --git a/src/main/resources/templates/mail/suspendedAccountEmail.html b/src/main/resources/templates/mail/suspendedAccountEmail.html new file mode 100644 index 0000000..217aedf --- /dev/null +++ b/src/main/resources/templates/mail/suspendedAccountEmail.html @@ -0,0 +1,319 @@ + + + + + + + + + + + JHipster activation + + + + + + + +
+
+ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  +
+ +
+ + diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index 738b1c0..a840991 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -1,172 +1,3 @@ - -
diff --git a/src/main/webapp/app/account/settings/settings.component.ts b/src/main/webapp/app/account/settings/settings.component.ts index 55335fd..561635e 100644 --- a/src/main/webapp/app/account/settings/settings.component.ts +++ b/src/main/webapp/app/account/settings/settings.component.ts @@ -136,10 +136,6 @@ export class SettingsComponent implements OnInit { save(): void { this.isSaving = true; const usuarioExtra = this.createFromForm(); - - console.log(usuarioExtra.iconoPerfil); - console.log(usuarioExtra.fechaNacimiento); - this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra)); } diff --git a/src/main/webapp/app/config/error.constants.ts b/src/main/webapp/app/config/error.constants.ts index ea24e19..e0721f2 100644 --- a/src/main/webapp/app/config/error.constants.ts +++ b/src/main/webapp/app/config/error.constants.ts @@ -3,3 +3,4 @@ export const EMAIL_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/email-already-used'; export const LOGIN_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/login-already-used'; export const EMAIL_NOT_EXISTS_TYPE = PROBLEM_BASE_URL + '/email-not-exists'; export const USER_IS_GOOGLE_TYPE = PROBLEM_BASE_URL + '/user-is-google'; +export const USER_IS_SUSPENDED = PROBLEM_BASE_URL + '/user-is-suspended'; diff --git a/src/main/webapp/app/core/auth/account.service.ts b/src/main/webapp/app/core/auth/account.service.ts index 324c77e..b28fd53 100644 --- a/src/main/webapp/app/core/auth/account.service.ts +++ b/src/main/webapp/app/core/auth/account.service.ts @@ -72,6 +72,7 @@ export class AccountService { shareReplay() ); } + return this.accountCache$; } diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html index ceb258b..d1ad4e4 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.html @@ -2,24 +2,25 @@ diff --git a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts index df89d70..8d665e3 100644 --- a/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/categoria/delete/categoria-delete-dialog.component.ts @@ -10,10 +10,13 @@ import { finalize, map } from 'rxjs/operators'; import { Categoria, ICategoria } from '../categoria.model'; import { CategoriaService } from '../service/categoria.service'; +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; @Component({ templateUrl: './categoria-delete-dialog.component.html', }) export class CategoriaDeleteDialogComponent { + faExchangeAlt = faExchangeAlt; + categoria?: ICategoria; encuestas?: IEncuesta[]; encuestasFiltradas?: IEncuesta[]; diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.html b/src/main/webapp/app/entities/categoria/list/categoria.component.html index 2ee3101..b486a5d 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.html +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.html @@ -1,6 +1,9 @@

- Categorias +
+ Categorias +

Categorice las encuestas de la aplicación

+
-
-
No categorias found
@@ -59,7 +67,8 @@ Edit -

diff --git a/src/main/webapp/app/entities/categoria/list/categoria.component.ts b/src/main/webapp/app/entities/categoria/list/categoria.component.ts index 10caf63..869e3c8 100644 --- a/src/main/webapp/app/entities/categoria/list/categoria.component.ts +++ b/src/main/webapp/app/entities/categoria/list/categoria.component.ts @@ -6,11 +6,15 @@ import { ICategoria } from '../categoria.model'; import { CategoriaService } from '../service/categoria.service'; import { CategoriaDeleteDialogComponent } from '../delete/categoria-delete-dialog.component'; +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; + @Component({ selector: 'jhi-categoria', templateUrl: './categoria.component.html', }) export class CategoriaComponent implements OnInit { + faExchangeAlt = faExchangeAlt; + categorias?: ICategoria[]; isLoading = false; public searchString: string; diff --git a/src/main/webapp/app/entities/categoria/update/categoria-update.component.html b/src/main/webapp/app/entities/categoria/update/categoria-update.component.html index 827ff29..0ad506f 100644 --- a/src/main/webapp/app/entities/categoria/update/categoria-update.component.html +++ b/src/main/webapp/app/entities/categoria/update/categoria-update.component.html @@ -46,10 +46,10 @@ type="button" id="cancel-save" data-cy="entityCreateCancelButton" - class="btn btn-secondary ds-btn ds-btn-secondary" + class="ds-btn ds-btn--secondary" (click)="previousState()" > -  Cancel +   Cancel diff --git a/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts b/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts index a3daca3..0f02ff1 100644 --- a/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts +++ b/src/main/webapp/app/entities/e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service.ts @@ -16,8 +16,8 @@ export class EPreguntaCerradaOpcionService { constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} - create(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion): Observable { - return this.http.post(this.resourceUrl, ePreguntaCerradaOpcion, { observe: 'response' }); + create(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion, preguntaId?: number): Observable { + return this.http.post(`${this.resourceUrl}/${preguntaId}`, ePreguntaCerradaOpcion, { observe: 'response' }); } update(ePreguntaCerradaOpcion: IEPreguntaCerradaOpcion): Observable { @@ -49,6 +49,10 @@ export class EPreguntaCerradaOpcionService { return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); } + deleteMany(ids: number[]): Observable { + return this.http.post(`${this.resourceUrl}/deleteMany`, ids, { observe: 'response' }); + } + addEPreguntaCerradaOpcionToCollectionIfMissing( ePreguntaCerradaOpcionCollection: IEPreguntaCerradaOpcion[], ...ePreguntaCerradaOpcionsToCheck: (IEPreguntaCerradaOpcion | null | undefined)[] diff --git a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.html b/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.html index dfe7349..8fd4065 100644 --- a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.html +++ b/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.html @@ -1,24 +1,28 @@ -
+ diff --git a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.spec.ts b/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.spec.ts deleted file mode 100644 index cee92bc..0000000 --- a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -jest.mock('@ng-bootstrap/ng-bootstrap'); - -import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { of } from 'rxjs'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - -import { EncuestaService } from '../service/encuesta.service'; - -import { EncuestaDeleteDialogComponent } from './encuesta-delete-dialog.component'; - -describe('Component Tests', () => { - describe('Encuesta Management Delete Component', () => { - let comp: EncuestaDeleteDialogComponent; - let fixture: ComponentFixture; - let service: EncuestaService; - let mockActiveModal: NgbActiveModal; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - declarations: [EncuestaDeleteDialogComponent], - providers: [NgbActiveModal], - }) - .overrideTemplate(EncuestaDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(EncuestaDeleteDialogComponent); - comp = fixture.componentInstance; - service = TestBed.inject(EncuestaService); - mockActiveModal = TestBed.inject(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.close).toHaveBeenCalledWith('deleted'); - }) - )); - - it('Should not call delete service on clear', () => { - // GIVEN - jest.spyOn(service, 'delete'); - - // WHEN - comp.cancel(); - - // THEN - expect(service.delete).not.toHaveBeenCalled(); - expect(mockActiveModal.close).not.toHaveBeenCalled(); - expect(mockActiveModal.dismiss).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.ts b/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.ts index 573c319..2a86796 100644 --- a/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/encuesta/delete/encuesta-delete-dialog.component.ts @@ -1,14 +1,16 @@ import { Component } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - import { IEncuesta } from '../encuesta.model'; import { EncuestaService } from '../service/encuesta.service'; +import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model'; +import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; @Component({ templateUrl: './encuesta-delete-dialog.component.html', }) export class EncuestaDeleteDialogComponent { encuesta?: IEncuesta; + usuarioExtra?: IUsuarioExtra; constructor(protected encuestaService: EncuestaService, protected activeModal: NgbActiveModal) {} @@ -16,9 +18,11 @@ export class EncuestaDeleteDialogComponent { this.activeModal.dismiss(); } - confirmDelete(id: number): void { - this.encuestaService.delete(id).subscribe(() => { + confirmDelete(encuesta: IEncuesta): void { + encuesta.estado = EstadoEncuesta.DELETED; + this.encuestaService.deleteEncuesta(encuesta).subscribe(() => { this.activeModal.close('deleted'); }); + //this.encuestaService.deletedNotification(encuesta); } } diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html index 6873d16..1ecca8f 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.html @@ -1,80 +1,201 @@ -
-
-
-

Encuesta

+
+
+

+

+ Vista previa de {{ encuesta!.nombre }} + +

-
+

Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}

+
+ + + + +
+

- - - - -
-
ID
-
- {{ encuesta.id }} -
-
Nombre
-
- {{ encuesta.nombre }} -
-
Descripcion
-
- {{ encuesta.descripcion }} -
-
Fecha Creacion
-
- {{ encuesta.fechaCreacion | formatMediumDatetime }} -
-
Fecha Publicacion
-
- {{ encuesta.fechaPublicacion | formatMediumDatetime }} -
-
Fecha Finalizar
-
- {{ encuesta.fechaFinalizar | formatMediumDatetime }} -
-
Fecha Finalizada
-
- {{ encuesta.fechaFinalizada | formatMediumDatetime }} -
-
Calificacion
-
- {{ encuesta.calificacion }} -
-
Acceso
-
- {{ encuesta.acceso }} -
-
Contrasenna
-
- {{ encuesta.contrasenna }} -
-
Estado
-
- {{ encuesta.estado }} -
-
Categoria
-
- -
-
Usuario Extra
-
- -
-
- - +
- + + +
+ No se encontraron preguntas +
+ +
+
+
+
+
+ {{ i + 1 }}. {{ ePregunta.nombre }} +
+
+ Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }} +
+ + + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
+
+
diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.spec.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.tmpSpec.ts similarity index 100% rename from src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.spec.ts rename to src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.tmpSpec.ts diff --git a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts index f04d377..8344581 100644 --- a/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts +++ b/src/main/webapp/app/entities/encuesta/detail/encuesta-detail.component.ts @@ -1,20 +1,160 @@ import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; +import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model'; -import { IEncuesta } from '../encuesta.model'; +import { Observable } from 'rxjs'; +import { finalize, map } from 'rxjs/operators'; + +import * as dayjs from 'dayjs'; +import { DATE_TIME_FORMAT } from 'app/config/input.constants'; + +import { IEncuesta, 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'; +import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; +import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service'; + +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-cerrada.model'; +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 { 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 { EPreguntaAbiertaService } from '../../e-pregunta-abierta/service/e-pregunta-abierta.service'; +import { EPreguntaCerradaOpcionService } from '../../e-pregunta-cerrada-opcion/service/e-pregunta-cerrada-opcion.service'; +import { PreguntaCerradaTipo } from 'app/entities/enumerations/pregunta-cerrada-tipo.model'; + +import { faTimes, faPlus, faStar, faQuestion } from '@fortawesome/free-solid-svg-icons'; +import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; @Component({ selector: 'jhi-encuesta-detail', templateUrl: './encuesta-detail.component.html', }) export class EncuestaDetailComponent implements OnInit { + categoriasSharedCollection: ICategoria[] = []; + usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + faTimes = faTimes; + faPlus = faPlus; + faStar = faStar; + faQuestion = faQuestion; encuesta: IEncuesta | null = null; + isLoading = false; + successPublished = false; + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; - constructor(protected activatedRoute: ActivatedRoute) {} + constructor( + protected activatedRoute: ActivatedRoute, + protected encuestaService: EncuestaService, + protected categoriaService: CategoriaService, + protected usuarioExtraService: UsuarioExtraService, + protected fb: FormBuilder, + protected modalService: NgbModal, + protected ePreguntaCerradaService: EPreguntaCerradaService, + protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, + protected ePreguntaAbiertaService: EPreguntaAbiertaService + ) {} ngOnInit(): void { this.activatedRoute.data.subscribe(({ encuesta }) => { - this.encuesta = encuesta; + if (encuesta) { + this.encuesta = encuesta; + this.loadAll(); + } else { + this.previousState(); + } + }); + } + + ngAfterViewChecked(): void { + this.initListeners(); + } + + initListeners(): void { + const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); + for (let i = 0; i < checkboxes.length; i++) { + checkboxes[i].addEventListener('click', e => { + if ((e.target as HTMLInputElement).checked) { + (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + } else { + (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); + } + }); + } + } + + trackId(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + trackEPreguntaCerradaById(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + trackCategoriaById(index: number, item: ICategoria): number { + return item.id!; + } + + trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + return item.id!; + } + + getEncuesta(id: number) { + return this.encuestaService.findEncuesta(id); + } + + loadAll(): void { + this.isLoading = true; + + this.encuestaService + .findQuestions(this.encuesta?.id!) + .pipe( + finalize(() => + this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ) + ) + ) + .subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntas = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + + /* this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + );*/ + } + publishSurvey(): void { + const modalRef = this.modalService.open(EncuestaPublishDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuesta; + // unsubscribe not needed because closed completes on modal close + modalRef.closed.subscribe(reason => { + if (reason === 'published') { + this.successPublished = true; + this.loadAll(); + } }); } diff --git a/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.html new file mode 100644 index 0000000..2845052 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.html @@ -0,0 +1,24 @@ + + + + + + + diff --git a/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.ts new file mode 100644 index 0000000..82d1896 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-delete-option-dialog/encuesta-delete-option-dialog.component.ts @@ -0,0 +1,17 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + templateUrl: './encuesta-delete-option-dialog.component.html', +}) +export class EncuestaDeleteOptionDialogComponent { + constructor(protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(): void { + this.activeModal.close('confirm'); + } +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.html new file mode 100644 index 0000000..d6eb620 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.ts new file mode 100644 index 0000000..56c7347 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-delete-question-dialog/encuesta-delete-question-dialog.component.ts @@ -0,0 +1,17 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + templateUrl: './encuesta-delete-question-dialog.component.html', +}) +export class EncuestaDeleteQuestionDialogComponent { + constructor(protected activeModal: NgbActiveModal) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(): void { + this.activeModal.close('confirm'); + } +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.html b/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.html new file mode 100644 index 0000000..0baeb1f --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.html @@ -0,0 +1,61 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.scss b/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.ts new file mode 100644 index 0000000..1bd7127 --- /dev/null +++ b/src/main/webapp/app/entities/encuesta/encuesta-publish-dialog/encuesta-publish-dialog.component.ts @@ -0,0 +1,134 @@ +import { Component, OnInit } from '@angular/core'; +import { IEncuesta } from '../encuesta.model'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { EncuestaService } from '../service/encuesta.service'; +import { EstadoEncuesta } from '../../enumerations/estado-encuesta.model'; +import { AccesoEncuesta } from '../../enumerations/acceso-encuesta.model'; +import { passwordResetFinishRoute } from '../../../account/password-reset/finish/password-reset-finish.route'; +import { FormBuilder, Validators } from '@angular/forms'; +import { IParametroAplicacion } from 'app/entities/parametro-aplicacion/parametro-aplicacion.model'; +import { ParametroAplicacionService } from 'app/entities/parametro-aplicacion/service/parametro-aplicacion.service'; +import { HttpResponse } from '@angular/common/http'; +import { DATE_FORMAT, DATE_TIME_FORMAT } from '../../../config/input.constants'; +import * as dayjs from 'dayjs'; +import { finalize } from 'rxjs/operators'; + +@Component({ + selector: 'jhi-encuesta-publish-dialog', + templateUrl: './encuesta-publish-dialog.component.html', + styleUrls: ['./encuesta-publish-dialog.component.scss'], +}) +export class EncuestaPublishDialogComponent implements OnInit { + encuesta?: IEncuesta; + //fechaFinalizacion?: Date; + fechaFinalizarInvalid?: boolean = false; + fechaFinalizarInvalidMax?: boolean = false; + isLoading?: boolean; + parametroAplicacions?: IParametroAplicacion[]; + isMin = false; + isMax = false; + datoMin?: number; + datoMax?: number; + now = new Date(); + fechaForm = this.fb.group({ + fechaFinalizacion: [null, [Validators.required]], + }); + + constructor( + protected parametroAplicacionService: ParametroAplicacionService, + protected encuestaService: EncuestaService, + protected fb: FormBuilder, + protected activeModal: NgbActiveModal + ) {} + + ngOnInit(): void { + this.loadAll(); + } + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmPublish(encuesta: IEncuesta): void { + this.fechaFinalizarInvalid = false; + this.fechaFinalizarInvalidMax = false; + + const now = dayjs(); + + /*this.loadAll() + + this.parametroAplicacions?.forEach(datos => { + this.datoMin = datos.minDiasEncuesta; + this.datoMax = datos.maxDiasEncuesta; + });*/ + + encuesta.fechaFinalizar = dayjs(this.fechaForm.get(['fechaFinalizacion'])!.value); + encuesta.fechaPublicacion = dayjs(now, DATE_TIME_FORMAT); + + if (this.fechaFinalizacionIsInvalid(encuesta.fechaFinalizar, encuesta.fechaPublicacion)) { + if (encuesta.estado === 'DRAFT') { + encuesta.estado = EstadoEncuesta.ACTIVE; + } + + if (encuesta.acceso === AccesoEncuesta.PRIVATE) { + encuesta.contrasenna = this.generatePassword(); + } + + this.encuestaService.update(encuesta).subscribe(() => { + this.activeModal.close('published'); + }); + } + } + + loadAll(): void { + this.isLoading = true; + + this.parametroAplicacionService + .query() + .pipe(finalize(() => this.onLoadFinalize())) + .subscribe( + (res: HttpResponse) => { + this.isLoading = false; + this.parametroAplicacions = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + } + + onLoadFinalize() { + this.parametroAplicacions?.forEach(datos => { + this.datoMin = datos.minDiasEncuesta; + this.datoMax = datos.maxDiasEncuesta; + }); + this.isLoading = false; + } + + fechaFinalizacionIsInvalid(fechaFinalizar: dayjs.Dayjs, fechaPublicacion: dayjs.Dayjs): boolean { + let numberDays: number; + debugger; + + numberDays = fechaFinalizar?.diff(fechaPublicacion, 'days'); + + if (numberDays <= this.datoMin!) { + this.fechaFinalizarInvalid = true; + return false; + } else if (numberDays >= this.datoMax!) { + this.fechaFinalizarInvalidMax = true; + return false; + } else { + return true; + } + } + + generatePassword(): string { + const alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + + let password = ''; + for (let i = 0; i < 5; i++) { + password += alpha.charAt(Math.floor(Math.random() * alpha.length)); + } + return password; + } +} diff --git a/src/main/webapp/app/entities/encuesta/encuesta.module.ts b/src/main/webapp/app/entities/encuesta/encuesta.module.ts index 6cd231e..86a1c11 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta.module.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta.module.ts @@ -6,10 +6,21 @@ import { EncuestaUpdateComponent } from './update/encuesta-update.component'; import { EncuestaDeleteDialogComponent } from './delete/encuesta-delete-dialog.component'; import { EncuestaRoutingModule } from './route/encuesta-routing.module'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; +import { EncuestaPublishDialogComponent } from './encuesta-publish-dialog/encuesta-publish-dialog.component'; +import { EncuestaDeleteQuestionDialogComponent } from './encuesta-delete-question-dialog/encuesta-delete-question-dialog.component'; +import { EncuestaDeleteOptionDialogComponent } from './encuesta-delete-option-dialog/encuesta-delete-option-dialog.component'; @NgModule({ imports: [SharedModule, EncuestaRoutingModule, FontAwesomeModule], - declarations: [EncuestaComponent, EncuestaDetailComponent, EncuestaUpdateComponent, EncuestaDeleteDialogComponent], + declarations: [ + EncuestaComponent, + EncuestaDetailComponent, + EncuestaUpdateComponent, + EncuestaDeleteDialogComponent, + EncuestaPublishDialogComponent, + EncuestaDeleteQuestionDialogComponent, + EncuestaDeleteOptionDialogComponent, + ], entryComponents: [EncuestaDeleteDialogComponent], }) export class EncuestaModule {} diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html index f0545aa..613dd54 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.html +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.html @@ -1,9 +1,13 @@

-
+
Encuestas -

Cree encuestas y publiquelas mundialmente.

+

Administre las encuestas de todos los usuarios

+
+
+ Encuestas +

Cree encuestas y publiquelas mundialmente

@@ -27,61 +31,110 @@

- + - - -
- No encuestas found + +
+ No surveys found +
+ +
+
+
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+ -
+
    -
  • -
  • -
  • - +
  • +
  • -
  • - -
  • -
  • -
  • -
  • - +
  • +
  • +
  • + +
  • +
  • - +
-
@@ -149,139 +202,77 @@ >
- -
+
+ + + + + + + + + + + + + + + + + + + + + - - -
NombreFecha CreaciónAccesoEstadoCategoriaCorreo Usuario
{{ encuesta.nombre }}{{ encuesta.fechaCreacion | formatShortDatetime | titlecase }}{{ encuesta.acceso }}{{ encuesta.estado }} +
+ + {{ encuesta.categoria?.nombre }} +
+
+
+ {{ encuesta.usuarioExtra?.user?.login }} +
+
+
+ - - - - -
-
-
--> + +
+ + + + +
@@ -303,8 +294,6 @@ - - - - diff --git a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts index 6fccf6b..afb3beb 100644 --- a/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts +++ b/src/main/webapp/app/entities/encuesta/list/encuesta.component.ts @@ -22,6 +22,8 @@ import { EstadoEncuesta } from 'app/entities/enumerations/estado-encuesta.model' import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/auth/account.model'; import { Router } from '@angular/router'; +import { EncuestaPublishDialogComponent } from '../encuesta-publish-dialog/encuesta-publish-dialog.component'; +import { IUser } from '../../user/user.model'; import { faShareAlt, @@ -34,6 +36,8 @@ import { faTrashAlt, faPlus, faStar, + faUpload, + faPollH, } from '@fortawesome/free-solid-svg-icons'; import * as $ from 'jquery'; @@ -54,17 +58,30 @@ export class EncuestaComponent implements OnInit, AfterViewInit { faTrashAlt = faTrashAlt; faPlus = faPlus; faStar = faStar; - + faUpload = faUpload; + isPublished: Boolean = false; + successPublished = false; + faPollH = faPollH; account: Account | null = null; usuarioExtra: UsuarioExtra | null = null; + estadoDeleted = EstadoEncuesta.DELETED; encuestas?: IEncuesta[]; isLoading = false; - + selectedSurvey?: IEncuesta | null = null; + idEncuesta: number | null = null; isSaving = false; categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + userSharedCollection: IUser[] = []; + + encuestaencontrada: IEncuesta | null = null; + + public searchString: string; + public accesoEncuesta: string; + //public categoriaEncuesta: string; + public estadoEncuesta: string; editForm = this.fb.group({ id: [], @@ -83,6 +100,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { }); createAnother: Boolean = false; + selectedSurveyId: number | null = null; constructor( protected encuestaService: EncuestaService, @@ -93,7 +111,11 @@ export class EncuestaComponent implements OnInit, AfterViewInit { protected fb: FormBuilder, protected accountService: AccountService, protected router: Router - ) {} + ) { + this.searchString = ''; + this.accesoEncuesta = ''; + this.estadoEncuesta = ''; + } resetForm(): void { this.editForm.reset(); @@ -102,19 +124,70 @@ export class EncuestaComponent implements OnInit, AfterViewInit { loadAll(): void { this.isLoading = true; - this.encuestaService.query().subscribe( - (res: HttpResponse) => { - this.isLoading = false; - const tmpEncuestas = res.body ?? []; - this.encuestas = tmpEncuestas.filter(e => e.usuarioExtra?.id === this.usuarioExtra?.id); - }, - () => { - this.isLoading = false; - } - ); + this.usuarioExtraService + .retrieveAllPublicUsers() + .pipe(finalize(() => this.loadPublicUser())) + .subscribe(res => { + this.userSharedCollection = res; + }); + } + + loadPublicUser(): void { + this.usuarioExtraService + .retrieveAllPublicUsers() + .pipe(finalize(() => this.loadUserExtras())) + .subscribe(res => { + this.userSharedCollection = res; + }); + } + + loadUserExtras() { + this.usuarioExtraService + .query() + .pipe( + finalize(() => + this.encuestaService.query().subscribe( + (res: HttpResponse) => { + this.isLoading = false; + const tmpEncuestas = res.body ?? []; + if (this.isAdmin()) { + this.encuestas = tmpEncuestas.filter(e => e.estado !== EstadoEncuesta.DELETED); + + this.encuestas.forEach(e => { + e.usuarioExtra = this.usuarioExtrasSharedCollection?.find(pU => pU.id == e.usuarioExtra?.id); + }); + } else { + this.encuestas = tmpEncuestas + .filter(e => e.usuarioExtra?.id === this.usuarioExtra?.id) + .filter(e => e.estado !== EstadoEncuesta.DELETED); + } + }, + () => { + this.isLoading = false; + } + ) + ) + ) + .subscribe( + (res: HttpResponse) => { + this.isLoading = false; + this.usuarioExtrasSharedCollection = res.body ?? []; + this.usuarioExtrasSharedCollection.forEach(uE => { + uE.user = this.userSharedCollection?.find(pU => pU.id == uE.user?.id); + }); + }, + () => { + this.isLoading = false; + } + ); } ngOnInit(): void { + this.searchString = ''; + this.accesoEncuesta = ''; + //this.categoriaEncuesta = ''; + this.estadoEncuesta = ''; + document.body.addEventListener('click', e => { document.getElementById('contextmenu')!.classList.add('ds-contextmenu--closed'); document.getElementById('contextmenu')!.classList.remove('ds-contextmenu--open'); @@ -147,6 +220,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => { this.usuarioExtra = usuarioExtra.body; this.loadAll(); + this.loadRelationshipsOptions(); if (this.usuarioExtra !== null) { if (this.usuarioExtra.id === undefined) { @@ -163,7 +237,7 @@ export class EncuestaComponent implements OnInit, AfterViewInit { ngAfterViewInit(): void {} - trackId(index: number, item: IEncuesta): number { + trackId(_index: number, item: IEncuesta): number { return item.id!; } @@ -178,6 +252,48 @@ export class EncuestaComponent implements OnInit, AfterViewInit { }); } + deleteSurvey(): void { + if (this.selectedSurveyId != null) { + this.getEncuesta(this.selectedSurveyId) + .pipe( + finalize(() => { + const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.encuestaencontrada; + + modalRef.closed.subscribe(reason => { + if (reason === 'deleted') { + this.loadAll(); + } + }); + }) + ) + .subscribe(data => { + this.encuestaencontrada = data; + }); + + /*const modalRef = this.modalService.open(EncuestaDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.getEncuesta(this.selectedSurvey) + .pipe(finalize(() => + modalRef.closed.subscribe(reason => { + if (reason === 'deleted') { + this.loadAll(); + } + }) + )) + .subscribe(data=> { + console.log(data); + //this.encuestaencontrada = data; + }); +*/ + + // unsubscribe not needed because closed completes on modal close + } + } + + getEncuesta(id: number) { + return this.encuestaService.findEncuesta(id); + } + previousState(): void { window.history.back(); } @@ -193,11 +309,11 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } } - trackCategoriaById(index: number, item: ICategoria): number { + trackCategoriaById(_index: number, item: ICategoria): number { return item.id!; } - trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + trackUsuarioExtraById(_index: number, item: IUsuarioExtra): number { return item.id!; } @@ -307,11 +423,17 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } openSurvey(event: any): void { - const surveyId = event.target.getAttribute('data-id'); - this.router.navigate(['/encuesta', surveyId, 'edit']); + if (event === null) { + const surveyId = this.selectedSurveyId; + this.router.navigate(['/encuesta', surveyId, 'edit']); + } else { + const surveyId = event.target.dataset.id; + this.router.navigate(['/encuesta', surveyId, 'edit']); + } } selectSurvey(event: any): void { + this.idEncuesta = event.target.getAttribute('data-id'); document.querySelectorAll('.ds-list--entity').forEach(e => { e.classList.remove('active'); }); @@ -320,35 +442,45 @@ export class EncuestaComponent implements OnInit, AfterViewInit { } } - counter(i: number) { - return new Array(i); + openPreview() { + const surveyId = this.selectedSurveyId; + this.router.navigate(['/encuesta', surveyId, 'preview']); } - testMe(something: any) { - return 5 - something; - } - - openContextMenu(event: any): void { - document.querySelectorAll('.ds-list--entity').forEach(e => { - e.classList.remove('active'); - }); - + async openContextMenu(event: any): Promise { if (event.type === 'contextmenu') { event.preventDefault(); - - document.getElementById('contextmenu-create--separator')!.style.display = 'block'; - document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; - document.getElementById('contextmenu-delete--separator')!.style.display = 'block'; - document.getElementById('contextmenu-edit')!.style.display = 'block'; - document.getElementById('contextmenu-duplicate')!.style.display = 'block'; - document.getElementById('contextmenu-rename')!.style.display = 'block'; - document.getElementById('contextmenu-share')!.style.display = 'block'; + if (event.target === null) return; + document.querySelectorAll('.ds-list--entity').forEach(e => { + e.classList.remove('active'); + }); if ((event.target as HTMLElement).classList.contains('ds-list')) { + document.getElementById('contextmenu-create--separator')!.style.display = 'block'; document.getElementById('contextmenu-edit--separator')!.style.display = 'none'; document.getElementById('contextmenu-delete--separator')!.style.display = 'none'; } else if ((event.target as HTMLElement).classList.contains('ds-list--entity')) { + this.selectedSurveyId = Number(event.target.dataset.id); event.target.classList.add('active'); + + let res = await this.encuestaService.find(this.selectedSurveyId).toPromise(); + this.selectedSurvey = res.body; + this.isPublished = this.selectedSurvey!.estado === 'ACTIVE' || this.selectedSurvey!.estado === 'FINISHED'; // QUE SE LE MUESTRE CUANDO ESTE EN DRAFT + + document.getElementById('contextmenu-create--separator')!.style.display = 'none'; + document.getElementById('contextmenu-edit--separator')!.style.display = 'block'; + document.getElementById('contextmenu-delete--separator')!.style.display = 'block'; + document.getElementById('contextmenu-edit')!.style.display = 'block'; + document.getElementById('contextmenu-preview')!.style.display = 'block'; + + if (!this.isPublished) { + document.getElementById('contextmenu-publish')!.style.display = 'block'; + document.getElementById('contextmenu-duplicate')!.style.display = 'block'; + } else { + document.getElementById('contextmenu-publish')!.style.display = 'none'; + document.getElementById('contextmenu-duplicate')!.style.display = 'none'; + } + // document.getElementById('contextmenu-share')!.style.display = 'block'; document.getElementById('contextmenu-create--separator')!.style.display = 'none'; } @@ -359,4 +491,21 @@ export class EncuestaComponent implements OnInit, AfterViewInit { document.getElementById('contextmenu')!.style.maxHeight = '100%'; } } + + publish(): void { + const modalRef = this.modalService.open(EncuestaPublishDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.encuesta = this.selectedSurvey; + // unsubscribe not needed because closed completes on modal close + modalRef.closed.subscribe(reason => { + if (reason === 'published') { + this.successPublished = true; + this.loadAll(); + } + }); + } + + async duplicateSurvey(): Promise { + const res = await this.encuestaService.duplicate(this.selectedSurveyId!).toPromise(); + this.loadAll(); + } } diff --git a/src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.spec.ts b/src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.tmpSpec.ts similarity index 97% rename from src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.spec.ts rename to src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.tmpSpec.ts index c658abb..5c031c9 100644 --- a/src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.spec.ts +++ b/src/main/webapp/app/entities/encuesta/route/encuesta-routing-resolve.service.tmpSpec.ts @@ -34,7 +34,7 @@ describe('Service Tests', () => { describe('resolve', () => { it('should return IEncuesta returned by find', () => { // GIVEN - service.find = jest.fn(id => of(new HttpResponse({ body: { id } }))); + // service.find = jest.fn(id => of(new HttpResponse({ body: { id } }))); mockActivatedRouteSnapshot.params = { id: 123 }; // WHEN diff --git a/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts b/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts index 56c3558..df9a23d 100644 --- a/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts +++ b/src/main/webapp/app/entities/encuesta/route/encuesta-routing.module.ts @@ -14,7 +14,7 @@ const encuestaRoute: Routes = [ canActivate: [UserRouteAccessService], }, { - path: ':id/view', + path: ':id/preview', component: EncuestaDetailComponent, resolve: { encuesta: EncuestaRoutingResolveService, diff --git a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts index ef95403..6e489b4 100644 --- a/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts +++ b/src/main/webapp/app/entities/encuesta/service/encuesta.service.ts @@ -15,6 +15,7 @@ export type EntityArrayResponseType = HttpResponse; @Injectable({ providedIn: 'root' }) export class EncuestaService { protected resourceUrl = this.applicationConfigService.getEndpointFor('api/encuestas'); + protected resourceUrlPublish = this.applicationConfigService.getEndpointFor('api/encuestas/publish'); constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} @@ -28,7 +29,7 @@ export class EncuestaService { update(encuesta: IEncuesta): Observable { const copy = this.convertDateFromClient(encuesta); return this.http - .put(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, copy, { observe: 'response' }) + .put(`${this.resourceUrlPublish}/${getEncuestaIdentifier(encuesta) as number}`, copy, { observe: 'response' }) .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } @@ -39,12 +40,44 @@ export class EncuestaService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } - find(id: number): Observable { + find(id: Number): Observable { return this.http .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } + findEncuesta(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`); + } + + findQuestions(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/preguntas/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + findQuestionsOptions(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/preguntas-opciones/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + duplicate(id: number): Observable { + return this.http.get(`${this.resourceUrl}/duplicate/${id}`, { observe: 'response' }); + } + + publishEncuesta(encuesta: IEncuesta): Observable { + //const copy = this.convertDateFromClient(encuesta); + return this.http.put(`${this.resourceUrl}/publish/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { + observe: 'response', + }); + } + + deleteEncuesta(encuesta: IEncuesta): Observable { + //const copy = this.convertDateFromClient(encuesta); + return this.http.put(`${this.resourceUrl}/${getEncuestaIdentifier(encuesta) as number}`, encuesta, { observe: 'response' }); + } + query(req?: any): Observable { const options = createRequestOption(req); return this.http @@ -56,6 +89,10 @@ export class EncuestaService { return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); } + deletedNotification(encuesta: IEncuesta): Observable> { + return this.http.delete(`${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) { diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html index f097553..bc0f16b 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.html @@ -1,262 +1,402 @@ -
-
-
-

- Create or edit a Encuesta -

+
+

+
+

{{ encuesta!.nombre }}

+    +    +
-
- +

Creada el día {{ encuesta!.fechaCreacion | formatShortDatetime | lowercase }}

-
- - -
+
+ + -
- - -
- - This field is required. - - - This field is required to be at least 1 characters. - - - This field cannot be longer than 50 characters. - -
-
+ +
+

-
- - -
+ -
- -
- -
+ + + + +
+
+ +

Encuesta en progreso

+

No puede modificar la encuesta debido a que esta ya está en progreso.

+
+ +

Encuesta finalizada

+

No puede modificar la encuesta debido a que esta ya ha concluido.

+
+ +

Encuesta vacía

+

Inicie creando preguntas y opciones para su encuesta.

+
+ +
- - This field is required. - - - This field should be a date and time. - +
+ {{ i + 1 }}. {{ ePregunta.nombre }} + +
+
+ Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }} + {{ ePregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }} +
+ + + + +
+ + + +
+
+
+
+
+ + Añadir opción +
+
+
+ +
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- - -
- - This field is required. - - - This field should be a number. - -
-
- -
- - -
- - This field is required. - -
-
- -
- - -
- -
- - -
- - This field is required. - -
-
- -
- - -
- -
- - -
-
- -
- - - -
- + +
+ + + + + + + + + + + + + + + diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.spec.ts b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.tmpSpec.ts similarity index 100% rename from src/main/webapp/app/entities/encuesta/update/encuesta-update.component.spec.ts rename to src/main/webapp/app/entities/encuesta/update/encuesta-update.component.tmpSpec.ts diff --git a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts index 5ac48c3..b079f9b 100644 --- a/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts +++ b/src/main/webapp/app/entities/encuesta/update/encuesta-update.component.ts @@ -1,4 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { 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 { 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'; @@ -15,82 +20,276 @@ import { CategoriaService } from 'app/entities/categoria/service/categoria.servi import { IUsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { IEPreguntaCerrada } from 'app/entities/e-pregunta-cerrada/e-pregunta-cerrada.model'; +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 { 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'; + @Component({ selector: 'jhi-encuesta-update', templateUrl: './encuesta-update.component.html', }) -export class EncuestaUpdateComponent implements OnInit { +export class EncuestaUpdateComponent implements OnInit, AfterViewChecked { + faTimes = faTimes; + faPlus = faPlus; + faPollH = faPollH; + faQuestion = faQuestion; + faEye = faEye; + isSaving = false; + isSavingQuestion = false; categoriasSharedCollection: ICategoria[] = []; usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + // editForm = this.fb.group({ + // id: [], + // nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]], + // descripcion: [], + // fechaCreacion: [null, [Validators.required]], + // fechaPublicacion: [], + // fechaFinalizar: [], + // fechaFinalizada: [], + // calificacion: [null, [Validators.required]], + // acceso: [null, [Validators.required]], + // contrasenna: [], + // estado: [null, [Validators.required]], + // categoria: [], + // usuarioExtra: [], + // }); + editForm = this.fb.group({ id: [], - nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]], - descripcion: [], - fechaCreacion: [null, [Validators.required]], - fechaPublicacion: [], - fechaFinalizar: [], - fechaFinalizada: [], - calificacion: [null, [Validators.required]], - acceso: [null, [Validators.required]], - contrasenna: [], - estado: [null, [Validators.required]], - categoria: [], - usuarioExtra: [], + nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(500)]], + // orden: [null, [Validators.required]], + // cantidad: [null, [Validators.required]], + // ePreguntaCerrada: [], }); + editFormQuestion = this.fb.group({ + id: [], + nombre: [null, [Validators.required, Validators.minLength(1), Validators.maxLength(500)]], + tipo: [PreguntaCerradaTipo.SINGLE], + opcional: [false], + tipopregunta: ['CLOSED'], + }); + + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; + encuesta: Encuesta | null = null; + parametrosAplicacion?: IParametroAplicacion | null = null; + + isLoading = false; + + createAnother: Boolean = false; + createAnotherQuestion: Boolean = false; + selectedQuestionToCreateOption: IEPreguntaCerrada | null = null; + constructor( protected encuestaService: EncuestaService, protected categoriaService: CategoriaService, protected usuarioExtraService: UsuarioExtraService, protected activatedRoute: ActivatedRoute, - protected fb: FormBuilder + protected fb: FormBuilder, + protected modalService: NgbModal, + protected ePreguntaCerradaService: EPreguntaCerradaService, + protected ePreguntaCerradaOpcionService: EPreguntaCerradaOpcionService, + protected parametroAplicacionService: ParametroAplicacionService, + protected ePreguntaAbiertaService: EPreguntaAbiertaService, + protected router: Router ) {} + loadAll(): void { + this.isLoading = true; + + this.encuestaService.findQuestions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntas = res.body ?? []; + console.log(this.ePreguntas); + }, + () => { + this.isLoading = false; + } + ); + + this.encuestaService.findQuestionsOptions(this.encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + } + + async loadAplicationParameters(): Promise { + const params = await this.parametroAplicacionService.find(1).toPromise(); + this.parametrosAplicacion = params.body; + //console.log(this.parametrosAplicacion); + } + ngOnInit(): void { this.activatedRoute.data.subscribe(({ encuesta }) => { - console.log(this.activatedRoute.data); - console.log(encuesta); - if (encuesta.id === undefined) { const today = dayjs().startOf('day'); encuesta.fechaCreacion = today; encuesta.fechaPublicacion = today; encuesta.fechaFinalizar = today; encuesta.fechaFinalizada = today; + } else { + this.encuesta = encuesta; + this.loadAll(); + this.loadAplicationParameters(); } - this.updateForm(encuesta); + // this.updateForm(encuesta); - this.loadRelationshipsOptions(); + // this.loadRelationshipsOptions(); }); } + ngAfterViewChecked(): void { + this.initListeners(); + } + + trackId(index: number, item: IEPreguntaCerrada): number { + return item.id!; + } + + delete(ePreguntaCerrada: IEPreguntaCerrada): void { + const modalRef = this.modalService.open(EPreguntaCerradaDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.ePreguntaCerrada = ePreguntaCerrada; + // unsubscribe not needed because closed completes on modal close + modalRef.closed.subscribe(reason => { + if (reason === 'deleted') { + this.loadAll(); + } + }); + } + + initListeners(): void { + const checkboxes = document.getElementsByClassName('ds-survey--checkbox'); + for (let i = 0; i < checkboxes.length; i++) { + checkboxes[i].addEventListener('click', e => { + if ((e.target as HTMLInputElement).checked) { + (e.target as HTMLElement).offsetParent!.classList.add('ds-survey--closed-option--active'); + } else { + (e.target as HTMLElement).offsetParent!.classList.remove('ds-survey--closed-option--active'); + } + }); + } + } + previousState(): void { window.history.back(); } - save(): void { - this.isSaving = true; - const encuesta = this.createFromForm(); - if (encuesta.id !== undefined) { - this.subscribeToSaveResponse(this.encuestaService.update(encuesta)); - } else { - this.subscribeToSaveResponse(this.encuestaService.create(encuesta)); + publishSurvey(): void {} + + finishSurvey(): void {} + + addOption(event: any): void {} + + openPreview() { + const surveyId = this.encuesta?.id; + this.router.navigate(['/encuesta', surveyId, 'preview']); + } + + resetForm(event: any): void { + this.editForm.reset(); + if (event !== null) { + const id = event.target.dataset.id; + this.ePreguntaCerradaService.find(id).subscribe(e => { + this.selectedQuestionToCreateOption = e.body; + }); } } - trackCategoriaById(index: number, item: ICategoria): number { + deleteQuestion(event: any) { + const modalRef = this.modalService.open(EncuestaDeleteQuestionDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.closed.subscribe(reason => { + if (reason === 'confirm') { + const id = event.target.dataset.id; + if (event.target.dataset.type) { + // Delete closed question + const questionElement = (event.target as HTMLElement).parentElement?.parentElement; + const optionIdsToDelete: number[] = []; + + // Get options IDs + questionElement?.childNodes.forEach((e, i) => { + if (e.nodeName !== 'DIV') return; + if (i === 0) return; + if ((e as HTMLElement).dataset.id === undefined) return; + if (!(e as HTMLElement).classList.contains('can-delete')) return; + let optionId = (e as HTMLElement).dataset.id; + optionIdsToDelete.push(+optionId!); + }); + + if (optionIdsToDelete.length === 0) { + this.ePreguntaCerradaService.delete(id).subscribe(e => { + this.loadAll(); + }); + } else { + // Delete question options + this.ePreguntaCerradaOpcionService.deleteMany(optionIdsToDelete).subscribe(e => { + // Delete question + this.ePreguntaCerradaService.delete(id).subscribe(e => { + this.loadAll(); + }); + }); + } + } else { + // Delete open question + this.ePreguntaAbiertaService.delete(id).subscribe(e => { + this.loadAll(); + }); + } + } + }); + } + + deleteOption(event: any): void { + const modalRef = this.modalService.open(EncuestaDeleteOptionDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.closed.subscribe(reason => { + if (reason === 'confirm') { + const id = event.target.dataset.optionid; + this.ePreguntaCerradaOpcionService.delete(id).subscribe(e => { + this.ePreguntas = []; + this.ePreguntasOpciones = []; + this.loadAll(); + }); + } + }); + } + + save(): void { + this.isSaving = true; + const ePreguntaCerradaOpcion = this.createFromForm(); + if (ePreguntaCerradaOpcion.id !== undefined) { + this.subscribeToSaveResponse(this.ePreguntaCerradaOpcionService.update(ePreguntaCerradaOpcion)); + } else { + this.subscribeToSaveResponse( + this.ePreguntaCerradaOpcionService.create(ePreguntaCerradaOpcion, this.selectedQuestionToCreateOption?.id!) + ); + } + } + + trackEPreguntaCerradaById(index: number, item: IEPreguntaCerrada): number { return item.id!; } - trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { - return item.id!; - } - - protected subscribeToSaveResponse(result: Observable>): void { + protected subscribeToSaveResponse(result: Observable>): void { result.pipe(finalize(() => this.onSaveFinalize())).subscribe( () => this.onSaveSuccess(), () => this.onSaveError() @@ -98,7 +297,14 @@ export class EncuestaUpdateComponent implements OnInit { } protected onSaveSuccess(): void { - this.previousState(); + // this.previousState(); + this.resetForm(null); + this.ePreguntas = []; + this.ePreguntasOpciones = []; + this.loadAll(); + if (!this.createAnother) { + $('#cancelBtn').click(); + } } protected onSaveError(): void { @@ -109,79 +315,221 @@ export class EncuestaUpdateComponent implements OnInit { this.isSaving = false; } - protected updateForm(encuesta: IEncuesta): void { - this.editForm.patchValue({ - id: encuesta.id, - nombre: encuesta.nombre, - descripcion: encuesta.descripcion, - fechaCreacion: encuesta.fechaCreacion ? encuesta.fechaCreacion.format(DATE_TIME_FORMAT) : null, - fechaPublicacion: encuesta.fechaPublicacion ? encuesta.fechaPublicacion.format(DATE_TIME_FORMAT) : null, - fechaFinalizar: encuesta.fechaFinalizar ? encuesta.fechaFinalizar.format(DATE_TIME_FORMAT) : null, - fechaFinalizada: encuesta.fechaFinalizada ? encuesta.fechaFinalizada.format(DATE_TIME_FORMAT) : null, - calificacion: encuesta.calificacion, - acceso: encuesta.acceso, - contrasenna: encuesta.contrasenna, - estado: encuesta.estado, - categoria: encuesta.categoria, - usuarioExtra: encuesta.usuarioExtra, - }); - - this.categoriasSharedCollection = this.categoriaService.addCategoriaToCollectionIfMissing( - this.categoriasSharedCollection, - encuesta.categoria - ); - this.usuarioExtrasSharedCollection = this.usuarioExtraService.addUsuarioExtraToCollectionIfMissing( - this.usuarioExtrasSharedCollection, - encuesta.usuarioExtra - ); - } - - protected loadRelationshipsOptions(): void { - this.categoriaService - .query() - .pipe(map((res: HttpResponse) => res.body ?? [])) - .pipe( - map((categorias: ICategoria[]) => - this.categoriaService.addCategoriaToCollectionIfMissing(categorias, this.editForm.get('categoria')!.value) - ) - ) - .subscribe((categorias: ICategoria[]) => (this.categoriasSharedCollection = categorias)); - - this.usuarioExtraService - .query() - .pipe(map((res: HttpResponse) => res.body ?? [])) - .pipe( - map((usuarioExtras: IUsuarioExtra[]) => - this.usuarioExtraService.addUsuarioExtraToCollectionIfMissing(usuarioExtras, this.editForm.get('usuarioExtra')!.value) - ) - ) - .subscribe((usuarioExtras: IUsuarioExtra[]) => (this.usuarioExtrasSharedCollection = usuarioExtras)); - } - - protected createFromForm(): IEncuesta { + protected createFromForm(): IEPreguntaCerradaOpcion { return { - ...new Encuesta(), - id: this.editForm.get(['id'])!.value, + // ...new EPreguntaCerradaOpcion(), + id: undefined, nombre: this.editForm.get(['nombre'])!.value, - descripcion: this.editForm.get(['descripcion'])!.value, - fechaCreacion: this.editForm.get(['fechaCreacion'])!.value - ? dayjs(this.editForm.get(['fechaCreacion'])!.value, DATE_TIME_FORMAT) - : undefined, - fechaPublicacion: this.editForm.get(['fechaPublicacion'])!.value - ? dayjs(this.editForm.get(['fechaPublicacion'])!.value, DATE_TIME_FORMAT) - : undefined, - fechaFinalizar: this.editForm.get(['fechaFinalizar'])!.value - ? dayjs(this.editForm.get(['fechaFinalizar'])!.value, DATE_TIME_FORMAT) - : undefined, - fechaFinalizada: this.editForm.get(['fechaFinalizada'])!.value - ? dayjs(this.editForm.get(['fechaFinalizada'])!.value, DATE_TIME_FORMAT) - : undefined, - calificacion: this.editForm.get(['calificacion'])!.value, - acceso: this.editForm.get(['acceso'])!.value, - contrasenna: this.editForm.get(['contrasenna'])!.value, - estado: this.editForm.get(['estado'])!.value, - categoria: this.editForm.get(['categoria'])!.value, - usuarioExtra: this.editForm.get(['usuarioExtra'])!.value, + orden: 10, + cantidad: 0, + ePreguntaCerrada: this.selectedQuestionToCreateOption, }; } + + createAnotherChange(event: any) { + this.createAnother = event.target.checked; + } + + createQuestion(): void { + const surveyId = this.encuesta?.id; + console.log(surveyId); + } + + protected createFromFormClosedQuestion(): IEPreguntaCerrada { + return { + // ...new EPreguntaCerrada(), + id: undefined, + nombre: this.editFormQuestion.get(['nombre'])!.value, + tipo: this.editFormQuestion.get(['tipo'])!.value, + opcional: this.editFormQuestion.get(['opcional'])!.value, + orden: 10, + encuesta: this.encuesta, + }; + } + + protected createFromFormOpenQuestion(): IEPreguntaAbierta { + return { + // ...new EPreguntaAbierta(), + id: undefined, + nombre: this.editFormQuestion.get(['nombre'])!.value, + opcional: this.editFormQuestion.get(['opcional'])!.value, + orden: 10, + encuesta: this.encuesta, + }; + } + + createAnotherQuestionChange(event: any) { + this.createAnotherQuestion = event.target.checked; + } + + saveQuestion(): void { + this.isSavingQuestion = true; + const tipoPregunta = this.editFormQuestion.get(['tipopregunta'])!.value; + + if (tipoPregunta === 'CLOSED') { + const ePreguntaCerrada = this.createFromFormClosedQuestion(); + if (ePreguntaCerrada.id !== undefined) { + this.subscribeToSaveResponseQuestionClosed(this.ePreguntaCerradaService.update(ePreguntaCerrada)); + } else { + this.subscribeToSaveResponseQuestionClosed(this.ePreguntaCerradaService.create(ePreguntaCerrada)); + } + } else if (tipoPregunta === 'OPEN') { + const ePreguntaAbierta = this.createFromFormOpenQuestion(); + if (ePreguntaAbierta.id !== undefined) { + this.subscribeToSaveResponseQuestionOpen(this.ePreguntaAbiertaService.update(ePreguntaAbierta)); + } else { + this.subscribeToSaveResponseQuestionOpen(this.ePreguntaAbiertaService.create(ePreguntaAbierta)); + } + } + } + + protected subscribeToSaveResponseQuestionClosed(result: Observable>): void { + result.pipe(finalize(() => this.onSaveFinalizeQuestion())).subscribe( + () => this.onSaveSuccessQuestion(), + () => this.onSaveErrorQuestion() + ); + } + + protected subscribeToSaveResponseQuestionOpen(result: Observable>): void { + result.pipe(finalize(() => this.onSaveFinalizeQuestion())).subscribe( + () => this.onSaveSuccessQuestion(), + () => this.onSaveErrorQuestion() + ); + } + + protected onSaveSuccessQuestion(): void { + this.editFormQuestion.reset({ tipo: PreguntaCerradaTipo.SINGLE, tipopregunta: 'CLOSED', opcional: false }); + this.editForm.reset(); + this.ePreguntas = []; + this.ePreguntasOpciones = []; + this.loadAll(); + if (!this.createAnotherQuestion) { + $('#cancelBtnQuestion').click(); + } + } + + protected onSaveErrorQuestion(): void { + // Api for inheritance. + } + + protected onSaveFinalizeQuestion(): void { + this.isSavingQuestion = false; + } + + // previousState(): void { + // window.history.back(); + // } + + // save(): void { + // this.isSaving = true; + // const encuesta = this.createFromForm(); + // if (encuesta.id !== undefined) { + // this.subscribeToSaveResponse(this.encuestaService.update(encuesta)); + // } else { + // this.subscribeToSaveResponse(this.encuestaService.create(encuesta)); + // } + // } + + trackCategoriaById(index: number, item: ICategoria): number { + return item.id!; + } + + trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + return item.id!; + } + + // protected subscribeToSaveResponse(result: Observable>): void { + // result.pipe(finalize(() => this.onSaveFinalize())).subscribe( + // () => this.onSaveSuccess(), + // () => this.onSaveError() + // ); + // } + + // protected onSaveSuccess(): void { + // this.previousState(); + // } + + // protected onSaveError(): void { + // // Api for inheritance. + // } + + // protected onSaveFinalize(): void { + // this.isSaving = false; + // } + + // protected updateForm(encuesta: IEncuesta): void { + // this.editForm.patchValue({ + // id: encuesta.id, + // nombre: encuesta.nombre, + // descripcion: encuesta.descripcion, + // fechaCreacion: encuesta.fechaCreacion ? encuesta.fechaCreacion.format(DATE_TIME_FORMAT) : null, + // fechaPublicacion: encuesta.fechaPublicacion ? encuesta.fechaPublicacion.format(DATE_TIME_FORMAT) : null, + // fechaFinalizar: encuesta.fechaFinalizar ? encuesta.fechaFinalizar.format(DATE_TIME_FORMAT) : null, + // fechaFinalizada: encuesta.fechaFinalizada ? encuesta.fechaFinalizada.format(DATE_TIME_FORMAT) : null, + // calificacion: encuesta.calificacion, + // acceso: encuesta.acceso, + // contrasenna: encuesta.contrasenna, + // estado: encuesta.estado, + // categoria: encuesta.categoria, + // usuarioExtra: encuesta.usuarioExtra, + // }); + + // this.categoriasSharedCollection = this.categoriaService.addCategoriaToCollectionIfMissing( + // this.categoriasSharedCollection, + // encuesta.categoria + // ); + // this.usuarioExtrasSharedCollection = this.usuarioExtraService.addUsuarioExtraToCollectionIfMissing( + // this.usuarioExtrasSharedCollection, + // encuesta.usuarioExtra + // ); + // } + + // protected loadRelationshipsOptions(): void { + // this.categoriaService + // .query() + // .pipe(map((res: HttpResponse) => res.body ?? [])) + // .pipe( + // map((categorias: ICategoria[]) => + // this.categoriaService.addCategoriaToCollectionIfMissing(categorias, this.editForm.get('categoria')!.value) + // ) + // ) + // .subscribe((categorias: ICategoria[]) => (this.categoriasSharedCollection = categorias)); + + // this.usuarioExtraService + // .query() + // .pipe(map((res: HttpResponse) => res.body ?? [])) + // .pipe( + // map((usuarioExtras: IUsuarioExtra[]) => + // this.usuarioExtraService.addUsuarioExtraToCollectionIfMissing(usuarioExtras, this.editForm.get('usuarioExtra')!.value) + // ) + // ) + // .subscribe((usuarioExtras: IUsuarioExtra[]) => (this.usuarioExtrasSharedCollection = usuarioExtras)); + // } + + // protected createFromForm(): IEncuesta { + // return { + // ...new Encuesta(), + // id: this.editForm.get(['id'])!.value, + // nombre: this.editForm.get(['nombre'])!.value, + // descripcion: this.editForm.get(['descripcion'])!.value, + // fechaCreacion: this.editForm.get(['fechaCreacion'])!.value + // ? dayjs(this.editForm.get(['fechaCreacion'])!.value, DATE_TIME_FORMAT) + // : undefined, + // fechaPublicacion: this.editForm.get(['fechaPublicacion'])!.value + // ? dayjs(this.editForm.get(['fechaPublicacion'])!.value, DATE_TIME_FORMAT) + // : undefined, + // fechaFinalizar: this.editForm.get(['fechaFinalizar'])!.value + // ? dayjs(this.editForm.get(['fechaFinalizar'])!.value, DATE_TIME_FORMAT) + // : undefined, + // fechaFinalizada: this.editForm.get(['fechaFinalizada'])!.value + // ? dayjs(this.editForm.get(['fechaFinalizada'])!.value, DATE_TIME_FORMAT) + // : undefined, + // calificacion: this.editForm.get(['calificacion'])!.value, + // acceso: this.editForm.get(['acceso'])!.value, + // contrasenna: this.editForm.get(['contrasenna'])!.value, + // estado: this.editForm.get(['estado'])!.value, + // categoria: this.editForm.get(['categoria'])!.value, + // usuarioExtra: this.editForm.get(['usuarioExtra'])!.value, + // }; + // } } diff --git a/src/main/webapp/app/entities/parametro-aplicacion/update/parametro-aplicacion-update.component.html b/src/main/webapp/app/entities/parametro-aplicacion/update/parametro-aplicacion-update.component.html index 612a6f7..6b7f066 100644 --- a/src/main/webapp/app/entities/parametro-aplicacion/update/parametro-aplicacion-update.component.html +++ b/src/main/webapp/app/entities/parametro-aplicacion/update/parametro-aplicacion-update.component.html @@ -1,17 +1,14 @@
-
-
-
-
-

Configuración

-
+
+ +
La cantidad mínima de los días, debe ser inferior a la cantidad máxima
diff --git a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html index 805ea79..e550920 100644 --- a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html +++ b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.html @@ -1,29 +1,23 @@ -
+
diff --git a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.spec.ts b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.spec.ts deleted file mode 100644 index 4649c87..0000000 --- a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -jest.mock('@ng-bootstrap/ng-bootstrap'); - -import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { of } from 'rxjs'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - -import { UsuarioExtraService } from '../service/usuario-extra.service'; - -import { UsuarioExtraDeleteDialogComponent } from './usuario-extra-delete-dialog.component'; - -describe('Component Tests', () => { - describe('UsuarioExtra Management Delete Component', () => { - let comp: UsuarioExtraDeleteDialogComponent; - let fixture: ComponentFixture; - let service: UsuarioExtraService; - let mockActiveModal: NgbActiveModal; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - declarations: [UsuarioExtraDeleteDialogComponent], - providers: [NgbActiveModal], - }) - .overrideTemplate(UsuarioExtraDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(UsuarioExtraDeleteDialogComponent); - comp = fixture.componentInstance; - service = TestBed.inject(UsuarioExtraService); - mockActiveModal = TestBed.inject(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - jest.spyOn(service, 'delete').mockReturnValue(of(new HttpResponse({}))); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.close).toHaveBeenCalledWith('deleted'); - }) - )); - - it('Should not call delete service on clear', () => { - // GIVEN - jest.spyOn(service, 'delete'); - - // WHEN - comp.cancel(); - - // THEN - expect(service.delete).not.toHaveBeenCalled(); - expect(mockActiveModal.close).not.toHaveBeenCalled(); - expect(mockActiveModal.dismiss).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.tmpSpec.ts b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.tmpSpec.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.ts b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.ts index 1f610cc..47b381c 100644 --- a/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.ts +++ b/src/main/webapp/app/entities/usuario-extra/delete/usuario-extra-delete-dialog.component.ts @@ -3,11 +3,16 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { IUsuarioExtra } from '../usuario-extra.model'; import { UsuarioExtraService } from '../service/usuario-extra.service'; +import { EstadoUsuario } from '../../enumerations/estado-usuario.model'; + +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; @Component({ templateUrl: './usuario-extra-delete-dialog.component.html', }) export class UsuarioExtraDeleteDialogComponent { + faExchangeAlt = faExchangeAlt; + usuarioExtra?: IUsuarioExtra; constructor(protected usuarioExtraService: UsuarioExtraService, protected activeModal: NgbActiveModal) {} @@ -16,8 +21,13 @@ export class UsuarioExtraDeleteDialogComponent { this.activeModal.dismiss(); } - confirmDelete(id: number): void { - this.usuarioExtraService.delete(id).subscribe(() => { + confirmDelete(usuarioExtra: IUsuarioExtra): void { + if (usuarioExtra.estado == EstadoUsuario.ACTIVE) { + usuarioExtra.estado = EstadoUsuario.SUSPENDED; + } else { + usuarioExtra.estado = EstadoUsuario.ACTIVE; + } + this.usuarioExtraService.updateEstado(usuarioExtra).subscribe(() => { this.activeModal.close('deleted'); }); } diff --git a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html index a4ce1c6..a5894cb 100644 --- a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html +++ b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.html @@ -1,6 +1,9 @@

- Usuarios +
+ Usuarios +

Administre los usuarios registrados en la aplicación

+
+
No usuarioExtras found
- +
+
+
+
+ +
+
+
+ +
+
+
@@ -26,13 +50,20 @@ + - + + + - diff --git a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.ts b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.ts index 3588bf3..7dd0a57 100644 --- a/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.ts +++ b/src/main/webapp/app/entities/usuario-extra/list/usuario-extra.component.ts @@ -8,17 +8,27 @@ import { UsuarioExtraDeleteDialogComponent } from '../delete/usuario-extra-delet import { IUser } from '../../user/user.model'; import { finalize } from 'rxjs/operators'; +import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons'; + @Component({ selector: 'jhi-usuario-extra', templateUrl: './usuario-extra.component.html', styleUrls: ['./usuario-extra.component.scss'], }) export class UsuarioExtraComponent implements OnInit { + faExchangeAlt = faExchangeAlt; + usuarioExtras?: IUsuarioExtra[]; publicUsers?: IUser[]; isLoading = false; + successChange = false; + public searchNombreUsuario: string; + public searchEstadoUsuario: string; - constructor(protected usuarioExtraService: UsuarioExtraService, protected modalService: NgbModal) {} + constructor(protected usuarioExtraService: UsuarioExtraService, protected modalService: NgbModal) { + this.searchNombreUsuario = ''; + this.searchEstadoUsuario = ''; + } loadPublicUser(): void { this.usuarioExtraService @@ -60,6 +70,8 @@ export class UsuarioExtraComponent implements OnInit { } ngOnInit(): void { + this.searchNombreUsuario = ''; + this.searchEstadoUsuario = ''; this.loadAll(); } @@ -73,6 +85,7 @@ export class UsuarioExtraComponent implements OnInit { // unsubscribe not needed because closed completes on modal close modalRef.closed.subscribe(reason => { if (reason === 'deleted') { + this.successChange = true; this.loadAll(); } }); diff --git a/src/main/webapp/app/entities/usuario-extra/service/usuario-extra.service.ts b/src/main/webapp/app/entities/usuario-extra/service/usuario-extra.service.ts index ff2d74b..b8ee9c4 100644 --- a/src/main/webapp/app/entities/usuario-extra/service/usuario-extra.service.ts +++ b/src/main/webapp/app/entities/usuario-extra/service/usuario-extra.service.ts @@ -18,6 +18,7 @@ export type EntityArrayUserPublicResponseType = HttpResponse; @Injectable({ providedIn: 'root' }) export class UsuarioExtraService { protected resourceUrl = this.applicationConfigService.getEndpointFor('api/usuario-extras'); + protected resourceUrlEstado = this.applicationConfigService.getEndpointFor('api/usuario-extras-estado'); protected resourceUrlPublicUser = this.applicationConfigService.getEndpointFor('api'); constructor(protected http: HttpClient, protected applicationConfigService: ApplicationConfigService) {} @@ -36,6 +37,13 @@ export class UsuarioExtraService { .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } + updateEstado(usuarioExtra: IUsuarioExtra): Observable { + const copy = this.convertDateFromClient(usuarioExtra); + return this.http + .put(`${this.resourceUrlEstado}/${getUsuarioExtraIdentifier(usuarioExtra) as number}`, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + partialUpdate(usuarioExtra: IUsuarioExtra): Observable { const copy = this.convertDateFromClient(usuarioExtra); return this.http diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index 80b9fdf..b7739b0 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -1,78 +1,275 @@
-
- -
+
+ + diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.component.html b/src/main/webapp/app/layouts/sidebar/sidebar.component.html index 0c862fa..04fe706 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.component.html +++ b/src/main/webapp/app/layouts/sidebar/sidebar.component.html @@ -1,7 +1,7 @@ @@ -103,7 +103,7 @@
  • -

    Cerrar Sesion

    +

    Cerrar Sesión

  • diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.component.ts b/src/main/webapp/app/layouts/sidebar/sidebar.component.ts index 93e4ddb..7632d25 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.component.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.component.ts @@ -61,8 +61,11 @@ export class SidebarComponent { if (account !== null) { this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => { this.usuarioExtra = usuarioExtra.body; - this.usuarioExtra!.nombre = - usuarioExtra.body!.nombre!.trim().split(' ')[0] + ' ' + usuarioExtra.body!.nombre!.trim().split(' ')[1]; + const fullName = this.usuarioExtra!.nombre; + const firstName = fullName?.split(' ')[0] === undefined ? '' : fullName?.split(' ')[0]; + const lastName = fullName?.split(' ')[1] === undefined ? '' : fullName?.split(' ')[1]; + + this.usuarioExtra!.nombre = `${firstName} ${lastName}`; }); } }); diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts index 91fb6bd..8d46c5c 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.constants.ts @@ -16,24 +16,24 @@ export interface ChildrenItems { } export const ADMIN_ROUTES: RouteInfo[] = [ - { - path: '/dashboard', - title: 'Dashboard', - type: 'link', - icontype: 'nc-icon nc-chart-bar-32', - }, + // { + // path: '/dashboard', + // title: 'Dashboard', + // type: 'link', + // icontype: 'nc-icon nc-chart-bar-32', + // }, { path: '/encuesta', title: 'Encuestas', type: 'link', icontype: 'nc-icon nc-paper', }, - { - path: '/plantilla', - title: 'Plantillas', - type: 'link', - icontype: 'nc-icon nc-album-2', - }, + // { + // path: '/plantilla', + // title: 'Plantillas', + // type: 'link', + // icontype: 'nc-icon nc-album-2', + // }, { path: '/categoria', title: 'Categorías', @@ -61,22 +61,22 @@ export const USER_ROUTES: RouteInfo[] = [ type: 'link', icontype: 'nc-icon nc-paper', }, - { - path: '/tienda', - title: 'Tienda', - type: 'link', - icontype: 'nc-icon nc-cart-simple', - }, - { - path: '/plantilla', - title: 'Plantillas', - type: 'link', - icontype: 'nc-icon nc-album-2', - }, - { - path: '/colaboraciones', - title: 'Colaboraciones', - type: 'link', - icontype: 'nc-icon nc-world-2', - }, + // { + // path: '/tienda', + // title: 'Tienda', + // type: 'link', + // icontype: 'nc-icon nc-cart-simple', + // }, + // { + // path: '/plantilla', + // title: 'Plantillas', + // type: 'link', + // icontype: 'nc-icon nc-album-2', + // }, + // { + // path: '/colaboraciones', + // title: 'Colaboraciones', + // type: 'link', + // icontype: 'nc-icon nc-world-2', + // }, ]; diff --git a/src/main/webapp/app/login/login.component.html b/src/main/webapp/app/login/login.component.html index 1a2c917..836a3c5 100644 --- a/src/main/webapp/app/login/login.component.html +++ b/src/main/webapp/app/login/login.component.html @@ -62,7 +62,7 @@
    -
    +
    @@ -76,13 +76,20 @@
    Failed to sign in! Please check your credentials and try again.
    +
    +
    diff --git a/src/main/webapp/app/login/login.component.ts b/src/main/webapp/app/login/login.component.ts index b0a4685..2c79da7 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -9,8 +9,10 @@ import { GoogleLoginProvider } from 'angularx-social-login'; import { RegisterService } from '../account/register/register.service'; import { TranslateService } from '@ngx-translate/core'; import { HttpErrorResponse } from '@angular/common/http'; -import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../config/error.constants'; +import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE, USER_IS_SUSPENDED } from '../config/error.constants'; import { LocalStorageService } from 'ngx-webstorage'; +import { UsuarioExtra } from '../entities/usuario-extra/usuario-extra.model'; +import { Account } from '../core/auth/account.model'; @Component({ selector: 'jhi-login', @@ -25,6 +27,8 @@ export class LoginComponent implements OnInit, AfterViewInit { error = false; errorEmailExists = false; errorUserExists = false; + userSuspended = false; + imprimir = false; loginForm = this.fb.group({ username: [null, [Validators.required, Validators.email, Validators.maxLength(254)]], @@ -48,18 +52,6 @@ export class LoginComponent implements OnInit, AfterViewInit { ) {} ngOnInit(): void { - //Servicio para verificar si el usuario se encuentra loggeado - /*this.authService.authState.subscribe(user => { - this.user = user; - this.loggedIn = user != null; - - /!* console.log('correo: ' + user.email); - console.log('correo: ' + user.name); - console.log('ID: ' + this.user.id);*!/ - - this.authenticacionGoogle(); - }); -*/ // if already authenticated then navigate to home page this.accountService.identity().subscribe(() => { if (this.accountService.isAuthenticated()) { @@ -89,7 +81,10 @@ export class LoginComponent implements OnInit, AfterViewInit { } authenticacionGoogle(): void { - this.loginService.login({ username: this.user.email, password: this.user.id, rememberMe: true }).subscribe( + this.error = false; + this.userSuspended = false; + + this.loginService.login({ username: this.user.email, password: this.user.id, rememberMe: false }).subscribe( () => { this.authenticationError = false; if (!this.router.getCurrentNavigation()) { @@ -98,21 +93,14 @@ export class LoginComponent implements OnInit, AfterViewInit { this.router.navigate(['']); } }, - () => this.activateGoogle() - /*this.registerService - .save({ - login: this.user.email, - email: this.user.email, - password: this.user.id, - langKey: this.translateService.currentLang, - name: this.user.name, - profileIcon: this.randomProfilePic(), - isAdmin: 0, - }) - .subscribe( - () => (this.success = true), - response => this.processError(response) - ) */ //console.log("Usuario no existe") + response => { + debugger; + if (response.status == 401 && response.error.detail == 'Bad credentials') { + this.activateGoogle(); + } else { + this.processError(response); + } + } ); } @@ -121,10 +109,13 @@ export class LoginComponent implements OnInit, AfterViewInit { } processError(response: HttpErrorResponse): void { + debugger; if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) { this.errorUserExists = true; } else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) { this.errorEmailExists = true; + } else if (response.status === 401) { + this.userSuspended = true; } else { this.error = true; } @@ -135,6 +126,9 @@ export class LoginComponent implements OnInit, AfterViewInit { } activateGoogle(): void { + this.error = false; + this.userSuspended = false; + this.registerService .save({ login: this.user.email, @@ -157,6 +151,9 @@ export class LoginComponent implements OnInit, AfterViewInit { } login(): void { + this.error = false; + this.userSuspended = false; + debugger; this.loginService .login({ username: this.loginForm.get('username')!.value, @@ -164,14 +161,30 @@ export class LoginComponent implements OnInit, AfterViewInit { rememberMe: this.loginForm.get('rememberMe')!.value, }) .subscribe( - () => { + value => { + debugger; + console.log(value); + + /*if (value?.activated == false){ + this.userSuspended = true; + + console.log(value.activated) + }else {*/ this.authenticationError = false; if (!this.router.getCurrentNavigation()) { // There were no routing during login (eg from navigationToStoredUrl) this.router.navigate(['']); } + // } }, - () => (this.authenticationError = true) + response => { + debugger; + if (response.status == 401 && response.error.detail == 'Bad credentials') { + this.error = true; + } else { + this.processError(response); + } + } ); } } diff --git a/src/main/webapp/app/login/login.service.ts b/src/main/webapp/app/login/login.service.ts index bc97be6..8e24e3d 100644 --- a/src/main/webapp/app/login/login.service.ts +++ b/src/main/webapp/app/login/login.service.ts @@ -12,6 +12,7 @@ export class LoginService { constructor(private accountService: AccountService, private authServerProvider: AuthServerProvider) {} login(credentials: Login): Observable { + debugger; return this.authServerProvider.login(credentials).pipe(mergeMap(() => this.accountService.identity(true))); } diff --git a/src/main/webapp/content/css/loading-2.css b/src/main/webapp/content/css/loading-2.css new file mode 100644 index 0000000..01f9598 --- /dev/null +++ b/src/main/webapp/content/css/loading-2.css @@ -0,0 +1,57 @@ +.app-loading .container { + margin: auto auto; + height: 100vh; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +.app-loading .tittle { + margin-bottom: 40px; + color: #44b9ff; + letter-spacing: 4px; + text-transform: uppercase; +} +.app-loading .square-container { + list-style-type: none; + display: flex; + position: relative; +} +.app-loading .square { + margin: 4px; + width: 30px; + height: 30px; + border-radius: 7px; + animation: rotating 2s ease infinite; +} +.app-loading .square1 { + background: #192e4d; + animation-delay: 0.2s; +} +.app-loading .square2 { + background: #018adf; + animation-delay: 0.4s; +} +.app-loading .square3 { + background: #20a9fe; + animation-delay: 0.6s; +} +.app-loading .square4 { + background: #00e0ac; + animation-delay: 0.8s; +} +.app-loading .square5 { + background: #70ffde; + animation-delay: 1s; +} +@keyframes rotating { + 0% { + transform: rotate(0) scale(1); + } + 50% { + transform: rotate(90deg) scale(0.6); + } + 100% { + transform: rotate(90deg) scale(1); + } +} diff --git a/src/main/webapp/content/css/loading-boxes.css b/src/main/webapp/content/css/loading-boxes.css new file mode 100644 index 0000000..4c4bd36 --- /dev/null +++ b/src/main/webapp/content/css/loading-boxes.css @@ -0,0 +1,199 @@ +.loader { + height: 100%; + width: 100%; +} +.loader .l_main { + position: absolute; + top: 20%; + left: 50%; + width: 172px; + height: 128px; + margin: 0; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); +} +@media (max-width: 550px) { + .loader { + -webkit-transform: scale(0.75); + transform: scale(0.75); + } +} +@media (max-width: 440px) { + .loader { + -webkit-transform: scale(0.5); + transform: scale(0.5); + } +} +.l_square { + position: relative; +} +.l_square:nth-child(1) { + margin-left: 0px; +} +.l_square:nth-child(2) { + margin-left: 44px; +} +.l_square:nth-child(3) { + margin-left: 88px; +} +.l_square:nth-child(4) { + margin-left: 132px; +} +.l_square span { + position: absolute; + top: 0px; + left: 20px; + height: 36px; + width: 36px; + border-radius: 2px; + background-color: #1c44b2; +} +.l_square span:nth-child(1) { + top: 0px; +} +.l_square span:nth-child(2) { + top: 44px; +} +.l_square span:nth-child(3) { + top: 88px; +} +.l_square:nth-child(1) span { + -webkit-animation: animsquare1 2s infinite ease-in; + animation: animsquare1 2s infinite ease-in; +} +.l_square:nth-child(2) span { + -webkit-animation: animsquare2 2s infinite ease-in; + animation: animsquare2 2s infinite ease-in; +} +.l_square:nth-child(3) span { + -webkit-animation: animsquare3 2s infinite ease-in; + animation: animsquare3 2s infinite ease-in; +} +.l_square:nth-child(4) span { + -webkit-animation: animsquare4 2s infinite ease-in; + animation: animsquare4 2s infinite ease-in; +} +.l_square span:nth-child(1) { + -webkit-animation-delay: 0s; + animation-delay: 0s; +} +.l_square span:nth-child(2) { + -webkit-animation-delay: 0.15s; + animation-delay: 0.15s; +} +.l_square span:nth-child(3) { + -webkit-animation-delay: 0.3s; + animation-delay: 0.3s; +} +@-webkit-keyframes animsquare1 { + 0%, + 5%, + 95%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 30%, + 70% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@keyframes animsquare1 { + 0%, + 5%, + 95%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 30%, + 70% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@-webkit-keyframes animsquare2 { + 0%, + 10%, + 90%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 35%, + 65% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@keyframes animsquare2 { + 0%, + 10%, + 90%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 35%, + 65% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@-webkit-keyframes animsquare3 { + 0%, + 15%, + 85%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 40%, + 60% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@keyframes animsquare3 { + 0%, + 15%, + 85%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 40%, + 60% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@-webkit-keyframes animsquare4 { + 0%, + 20%, + 80%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 45%, + 55% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} +@keyframes animsquare4 { + 0%, + 20%, + 80%, + 100% { + -webkit-transform: translate(0px, 0px) rotate(0deg); + transform: translate(0px, 0px) rotate(0deg); + } + 45%, + 55% { + -webkit-transform: translate(-40px, 0px) rotate(-90deg); + transform: translate(-40px, 0px) rotate(-90deg); + } +} diff --git a/src/main/webapp/content/css/loading.css b/src/main/webapp/content/css/loading.css index b2c6626..b2f5d31 100644 --- a/src/main/webapp/content/css/loading.css +++ b/src/main/webapp/content/css/loading.css @@ -102,7 +102,7 @@ font-weight: normal; } -.app-loading .lds-pacman { +/*.app-loading .lds-pacman { position: relative; margin: auto; width: 200px !important; @@ -149,4 +149,4 @@ .app-loading .lds-pacman > div:nth-child(1) div:nth-child(3) { -webkit-animation-delay: 0s; animation-delay: 0s; -} +}*/ diff --git a/src/main/webapp/content/img_datasurvey/background encuestas landing.png b/src/main/webapp/content/img_datasurvey/background encuestas landing.png new file mode 100644 index 0000000..e4e1f3d Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/background encuestas landing.png differ diff --git a/src/main/webapp/content/img_datasurvey/banner1.webp b/src/main/webapp/content/img_datasurvey/banner1.webp new file mode 100644 index 0000000..bc6de52 Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/banner1.webp differ diff --git a/src/main/webapp/content/img_datasurvey/banner2.png b/src/main/webapp/content/img_datasurvey/banner2.png new file mode 100644 index 0000000..1e64ef1 Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/banner2.png differ diff --git a/src/main/webapp/content/img_datasurvey/banner2.webp b/src/main/webapp/content/img_datasurvey/banner2.webp new file mode 100644 index 0000000..e4be6b4 Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/banner2.webp differ diff --git a/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black-PNG.png b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black-PNG.png new file mode 100644 index 0000000..0452249 Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black-PNG.png differ diff --git a/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black.svg b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black.svg index 4ae0c82..293be43 100644 --- a/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black.svg +++ b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-black.svg @@ -1 +1 @@ -Asset 5DATASURVEY \ No newline at end of file +Asset 5DATASURVEY \ No newline at end of file diff --git a/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-white-PNG.png b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-white-PNG.png new file mode 100644 index 0000000..333b2f7 Binary files /dev/null and b/src/main/webapp/content/img_datasurvey/datasurvey-logo-text-white-PNG.png differ diff --git a/src/main/webapp/content/scss/paper-dashboard.scss b/src/main/webapp/content/scss/paper-dashboard.scss index 3eab78d..711d10e 100644 --- a/src/main/webapp/content/scss/paper-dashboard.scss +++ b/src/main/webapp/content/scss/paper-dashboard.scss @@ -98,3 +98,7 @@ @import 'paper-dashboard/datasurvey-list'; @import 'paper-dashboard/datasurvey-table'; @import 'paper-dashboard/datasurvey-contextmenu'; +@import 'paper-dashboard/datasurvey-survey-update'; +@import 'paper-dashboard/datasurvey-home'; +@import 'paper-dashboard/datasurvey-filter'; +@import 'paper-dashboard/datasurvey-survey'; diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss index ccb1547..d0c0c24 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-buttons.scss @@ -61,12 +61,21 @@ } .ds-btn--danger { - background-color: transparent; - color: #e73636; + background-color: #e73636; + color: #fff; &:hover { - background-color: #f7f9ff; - color: #d33232; + background-color: #d33232; + } + + &--light { + background-color: transparent; + color: #e73636; + + &:hover { + background-color: #f7f9ff; + color: #d33232; + } } } diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-filter.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-filter.scss new file mode 100644 index 0000000..65d0420 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-filter.scss @@ -0,0 +1,3 @@ +.ds-filter:not(:first-of-type) { + margin-left: 2rem; +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-form.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-form.scss index 5ffb44f..7f23355 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-form.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-form.scss @@ -75,7 +75,9 @@ $form-background: #f1f5f9; } label { + font-size: 0.8rem; color: #757d94; + margin-bottom: 0.5rem; } } diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss index da1c023..f2f63e5 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-global.scss @@ -11,6 +11,14 @@ font-size: 1.2rem; } +.ds-title--small { + color: #313747; + font-weight: 900; + letter-spacing: 0.025rem; + text-transform: uppercase; + font-size: 1.1rem; +} + .ds-subtitle { color: #757d94; font-size: 0.9rem; @@ -19,3 +27,22 @@ p { margin: 0 !important; } + +.ds-info--icon { + border-radius: 50%; + background-color: #f1f5f9; + cursor: pointer; + transition: background-color 0.2s ease-in-out; + width: 20px; + height: 20px; + font-size: 0.7rem; + color: #313747; + pointer-events: visible !important; + display: flex; + align-items: center; + justify-content: center; + + &:hover { + background-color: #e3e6e9; + } +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-home.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-home.scss new file mode 100644 index 0000000..73ef822 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-home.scss @@ -0,0 +1,112 @@ +/** + Cards +**/ +.lift { + box-shadow: 0 0.15rem 1.75rem 0 rgba(33, 40, 50, 0.15); + transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out; +} +.lift:hover { + transform: translateY(-0.3333333333rem); + box-shadow: 0 0.5rem 2rem 0 rgba(33, 40, 50, 0.25); +} +.lift:active { + transform: none; + box-shadow: 0 0.15rem 1.75rem 0 rgba(33, 40, 50, 0.15); +} + +.lift-sm { + box-shadow: 0 0.125rem 0.25rem 0 rgba(33, 40, 50, 0.2); +} +.lift-sm:hover { + transform: translateY(-0.1666666667rem); + box-shadow: 0 0.25rem 1rem 0 rgba(33, 40, 50, 0.25); +} +.lift-sm:active { + transform: none; + box-shadow: 0 0.125rem 0.25rem 0 rgba(33, 40, 50, 0.2); +} + +.card-encuesta { + border-radius: 12px; + background-color: #ffffff; + margin-bottom: 20px; + position: relative; + border: 0 none; +} + +.card-encuesta.lift { + text-decoration: none; + color: inherit; +} + +.card-flag { + position: absolute; + font-size: 0.7rem; + padding: 0.3rem 0.5rem; + line-height: 1; +} + +.card-flag-dark { + background-color: rgba(33, 40, 50, 0.7); + color: #fff; +} + +.card-flag-light { + background-color: rgba(255, 255, 255, 0.7); + color: #69707a; +} + +.card-flag-lg { + font-size: 0.9rem; + padding: 0.5rem 0.65rem; +} + +.card-flag-top-right { + border-top-left-radius: 0.25rem; + border-bottom-left-radius: 0.25rem; + top: 0.5rem; + right: 0; +} + +.card-flag-top-left { + border-top-right-radius: 0.25rem; + border-bottom-right-radius: 0.25rem; + top: 0.5rem; + left: 0; +} + +.card-encuesta .entity-icon--star { + color: #ffcc47; + margin-right: 0.2rem; +} + +.card-encuesta .card-title { + font-size: 2em; +} + +.card-encuesta .tag { + font-size: 0.8rem; + color: #f8f8f8; + margin-top: 0.5rem; + padding: 0.2rem 1.5rem; + background-color: #2962ff94; + border-radius: 15px; +} + +.card-encuesta .subtitle { + color: rgba(0, 0, 0, 0.54); + font-size: 0.9rem; +} + +.card-encuesta .btn-card { + padding: 11px 10px !important; +} + +.border-cyan { + border-color: #00cfd5 !important; +} + +.py-10 { + padding-top: 6rem !important; + padding-bottom: 6rem !important; +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-list.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-list.scss index 7bd5f80..4d212aa 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-list.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-list.scss @@ -31,8 +31,15 @@ padding: 0.5rem; margin: 1rem; word-wrap: break-word; + transition: all 0.1s ease-in-out; - *:not(div) { + &:hover { + // top: -3px; + // box-shadow: rgba(80, 80, 80, 0.15) 0px 5px 15px; + background-color: #f5f9fd; + } + + * { pointer-events: none; } @@ -78,6 +85,7 @@ width: 25px; height: 25px; color: #313747; + pointer-events: visible !important; } .entity-share:hover { diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-modal.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-modal.scss index f821633..f784c9f 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-modal.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-modal.scss @@ -12,7 +12,13 @@ .modal-header, .modal-footer { border: none; - padding: 2rem; + padding: 2rem !important; + display: flex; + align-items: center; + + label { + margin: 0 0.2rem 0 0; + } } .modal-body { diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey-update.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey-update.scss new file mode 100644 index 0000000..2c9bfa6 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey-update.scss @@ -0,0 +1,164 @@ +.ds-survey { + display: flex; + + &--titulo { + display: flex; + justify-content: space-between; + align-items: center; + + &--name { + color: #1f3779; + } + + &--icon { + border-radius: 50%; + background-color: #f1f5f9; + cursor: pointer; + display: flex; + justify-content: center; + align-items: center; + transition: background-color 0.2s ease-in-out; + font-size: 1rem; + padding: 0.8rem; + width: 25px; + height: 25px; + color: #1f3779; + pointer-events: visible !important; + transition: all 0.1s ease-in-out; + + * { + pointer-events: none; + } + + &:hover { + background-color: #e73636; + color: #fff; + } + + &--small { + font-size: 0.8rem; + padding: 0.3rem; + } + } + } + + &--all-question-wrapper { + display: flex; + flex-direction: column; + border: 2px dashed #f1f1f1; + border-radius: $border-radius-x-large; + padding: 2rem 5rem; + margin: 0 auto; + } + + &--question-wrapper { + margin: 0 auto; + } + + &--question { + display: flex; + flex-direction: column; + font-size: 1.2rem; + color: #15131d; + padding: 2rem; + border-bottom: 1px solid #e9e9e9; + } + + &--option { + display: flex; + align-items: center; + margin: 0.5rem 0; + border-radius: 5px; + font-weight: 500; + letter-spacing: 0.025rem; + color: #787878; + background-color: transparent; + position: relative; + top: 0; + transition: all 0.1s ease-in-out; + + &--base { + border: 1px solid #e6e6e6; + } + + &--add { + border: 2px dashed #9c9c9c; + transition: all 0.1s ease-in-out; + + &:hover { + border: 2px dashed #727272; + } + + &:hover .ds-survey--add-option { + color: #727272; + } + + &:hover .ds-survey--add-option--icon { + color: #727272; + } + } + } + + &--closed-option { + display: flex; + width: 25rem; + align-items: center; + font-size: 0.9rem; + color: #15131d; + padding: 1rem; + transition: all 0.1s ease-in-out; + cursor: pointer; + position: relative; + + label { + width: 100%; + margin: 0; + color: #1f3779; + } + } + + &--open-option { + display: flex; + align-items: center; + font-size: 0.9rem; + color: #15131d; + transition: all 0.1s ease-in-out; + position: relative; + + & textarea { + width: 25rem; + height: 20rem; + padding: 1rem 3rem; + color: #787878; + border: none; + resize: none; + + &:disabled { + background-color: transparent; + } + } + } + + &--add-option { + width: 100%; + color: #919191; + transition: all 0.1s ease-in-out; + pointer-events: none; + + &--icon { + margin: 0 1rem; + display: flex; + justify-content: center; + align-items: center; + width: 25px; + height: 25px; + color: #919191; + pointer-events: visible !important; + transition: all 0.1s ease-in-out; + + * { + pointer-events: none; + } + } + } +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss new file mode 100644 index 0000000..a4d72a9 --- /dev/null +++ b/src/main/webapp/content/scss/paper-dashboard/_datasurvey-survey.scss @@ -0,0 +1,115 @@ +.preview-survey { + /* --------------------------------------- */ + /* ----- Radio Button */ + /* --------------------------------------- */ + /* --------------------------------------- */ + /* ----- Checkbox */ + /* --------------------------------------- */ +} +.preview-survey h2 { + font-size: 16px; + color: #001f3f; + margin-bottom: 20px; + margin-left: 20px; +} +.preview-survey > div { + padding: 20px 0; + border-bottom: 1px solid #ccc; +} +.preview-survey .radio label, +.preview-survey .checkbox label { + display: inline-block; + cursor: pointer; + color: #00b88d; + position: relative; + padding: 5px 15px 5px 51px; + font-size: 1em; + border-radius: 5px; + -webkit-transition: all 0.3s ease; + -o-transition: all 0.3s ease; + transition: all 0.3s ease; +} +.preview-survey .radio label:hover, +.preview-survey .checkbox label:hover { + background: rgba(0, 184, 141, 0.1); +} +.preview-survey .radio label:before, +.preview-survey .checkbox label:before { + content: ''; + display: inline-block; + width: 17px; + height: 17px; + position: absolute; + left: 15px; + border-radius: 50%; + background: none; + border: 3px solid #00b88d; +} +.preview-survey input[type='radio'] { + display: none; +} +.preview-survey input[type='radio']:checked + label:before { + display: none; +} +.preview-survey input[type='radio']:checked + label { + padding: 5px 15px; + background: #00b88d; + border-radius: 2px; + color: #fff; +} +.preview-survey .checkbox label:before { + border-radius: 3px; +} +.preview-survey .checkbox input[type='checkbox'] { + display: none; +} +.preview-survey .checkbox input[type='checkbox']:checked + label:before { + display: none; +} +.preview-survey .checkbox input[type='checkbox']:checked + label { + background: #00b88d; + color: #fff; + padding: 5px 15px; +} + +.preview-survey .ds-survey--open-option textarea { + border: 3px solid #00b88d; +} + +.preview-survey .entity-icon--star { + color: #ffcc47; + margin-right: 0.2rem; +} + +.preview-survey dt { + margin-bottom: 10px; +} + +.preview-survey dd { + margin-left: 40px; +} + +.ds-survey--all-question-wrapper, +.info-encuesta { + @media screen and (max-width: 991px) { + padding: 2rem 0rem; + flex-basis: 0; + flex-grow: 1; + max-width: 100%; + } +} + +.ds-survey--option { + @media screen and (max-width: 991px) { + width: 21rem !important; + } + @media screen and (max-width: 500px) { + width: 12rem !important; + } +} + +.preview-survey { + @media screen and (max-width: 991px) { + flex-direction: column-reverse; + } +} diff --git a/src/main/webapp/content/scss/paper-dashboard/_modals.scss b/src/main/webapp/content/scss/paper-dashboard/_modals.scss index 669a8a8..0d480a4 100644 --- a/src/main/webapp/content/scss/paper-dashboard/_modals.scss +++ b/src/main/webapp/content/scss/paper-dashboard/_modals.scss @@ -1,5 +1,6 @@ .modal-header { - border-bottom: 1px solid $medium-gray; + // border-bottom: 1px solid $medium-gray; + border: none !important; padding: 20px; text-align: center; display: block !important; @@ -41,9 +42,9 @@ } .modal-content { - border: 0 none; - border-radius: 10px; - box-shadow: 0 0 15px rgba(0, 0, 0, 0.15), 0 0 1px 1px rgba(0, 0, 0, 0.1); + border: none !important; + border-radius: 3px !important; + box-shadow: none !important; .modal-header { h6 { margin-top: 10px; @@ -59,8 +60,9 @@ color: #000; } .modal-footer { - border-top: 1px solid $medium-gray; - padding: 0px; + // border-top: 1px solid $medium-gray; + border: none !important; + // padding: 0px; &.no-border-footer { border-top: 0 none; diff --git a/src/main/webapp/i18n/es/ePreguntaCerrada.json b/src/main/webapp/i18n/es/ePreguntaCerrada.json index 943a041..7aa5b9a 100644 --- a/src/main/webapp/i18n/es/ePreguntaCerrada.json +++ b/src/main/webapp/i18n/es/ePreguntaCerrada.json @@ -23,7 +23,8 @@ "opcional": "Opcional", "orden": "Orden", "ePreguntaCerradaOpcion": "E Pregunta Cerrada Opcion", - "encuesta": "Encuesta" + "encuesta": "Encuesta", + "tiporespuesta": "Tipo de respuesta" } } } diff --git a/src/main/webapp/i18n/es/encuesta.json b/src/main/webapp/i18n/es/encuesta.json index d2b259a..37fb2fe 100644 --- a/src/main/webapp/i18n/es/encuesta.json +++ b/src/main/webapp/i18n/es/encuesta.json @@ -4,35 +4,37 @@ "home": { "title": "Encuestas", "refreshListLabel": "Refrescar lista", - "createLabel": "Crear nuevo Encuesta", - "createOrEditLabel": "Crear o editar Encuesta", - "notFound": "Ningún Encuestas encontrado" + "createLabel": "Crear nueva encuesta", + "createOrEditLabel": "Crear o editar encuesta", + "notFound": "Ninguna encuesta fue encontrada" }, - "created": "Un nuevo Encuesta ha sido creado con el identificador {{ param }}", - "updated": "Un Encuesta ha sido actualizado con el identificador {{ param }}", - "deleted": "Un Encuesta ha sido eliminado con el identificador {{ param }}", + "created": "Una nueva encuesta ha sido creada con el identificador {{ param }}", + "updated": "Una encuesta ha sido actualizado con el identificador {{ param }}", + "deleted": "Una encuesta ha sido eliminada con el identificador {{ param }}", "delete": { - "question": "¿Seguro que quiere eliminar Encuesta {{ id }}?" + "question": "¿Seguro que quiere eliminar la encuesta?", + "deletequestion": "¿Seguro que quiere eliminar esta pregunta?", + "deleteoption": "¿Seguro que quiere eliminar esta opción?" }, "detail": { "title": "Encuesta" }, "id": "ID", "nombre": "Nombre", - "descripcion": "Descripcion", - "fechaCreacion": "Fecha Creacion", - "fechaPublicacion": "Fecha Publicacion", + "descripcion": "Descripción", + "fechaCreacion": "Fecha Creación", + "fechaPublicacion": "Fecha Publicación", "fechaFinalizar": "Fecha Finalizar", "fechaFinalizada": "Fecha Finalizada", - "calificacion": "Calificacion", + "calificacion": "Calificación", "acceso": "Acceso", - "contrasenna": "Contrasenna", + "contrasenna": "Contraseña", "estado": "Estado", "usuarioEncuesta": "Usuario Encuesta", - "ePreguntaAbierta": "E Pregunta Abierta", - "ePreguntaCerrada": "E Pregunta Cerrada", + "ePreguntaAbierta": "Pregunta Abierta", + "ePreguntaCerrada": "Pregunta Cerrada", "categoria": "Categoría", - "usuarioExtra": "Usuario Extra" + "usuarioExtra": "Correo Usuario" } } } diff --git a/src/main/webapp/i18n/es/global.json b/src/main/webapp/i18n/es/global.json index 0da30ff..42d43b3 100644 --- a/src/main/webapp/i18n/es/global.json +++ b/src/main/webapp/i18n/es/global.json @@ -129,14 +129,16 @@ "create": "Crear", "enable": "Habilitar", "disable": "Deshabilitar", - "toggleStatus": "Cambiar Estado" + "toggleStatus": "Cambiar Estado", + "publish": "Publicar" }, "detail": { "field": "Campo", "value": "Valor" }, "delete": { - "title": "Confirmar operación de borrado" + "title": "Confirmar de operación", + "status": "Confirmar cambio de estado" }, "validation": { "required": "Este campo es obligatorio.", @@ -150,6 +152,11 @@ "number": "Este campo debe ser un número.", "integerNumber": "Este campo debe ser un número entero.", "datetimelocal": "Este campo debe ser una fecha y hora." + }, + "publish": { + "title": "Publicar encuesta", + "detail": "¿Está seguro de querer publicar esta encuesta?", + "success": "Su encuesta fue publicada exitosamente" } }, "error": { diff --git a/src/main/webapp/i18n/es/login.json b/src/main/webapp/i18n/es/login.json index 9266406..8409cd1 100644 --- a/src/main/webapp/i18n/es/login.json +++ b/src/main/webapp/i18n/es/login.json @@ -10,7 +10,8 @@ "messages": { "error": { "authentication": "Revise las credenciales e intente de nuevo ", - "isGoogle": "Al haber ingresado por medio de Google no cuenta con los permisos para modificar su contraseña" + "isGoogle": "Al haber ingresado por medio de Google no cuenta con los permisos para modificar su contraseña", + "userSuspended": "No cuenta con los permisos para iniciar sesión. Su cuenta se encuentra suspendida" } }, "password": { diff --git a/src/main/webapp/i18n/es/usuarioExtra.json b/src/main/webapp/i18n/es/usuarioExtra.json index 40c7603..1052496 100644 --- a/src/main/webapp/i18n/es/usuarioExtra.json +++ b/src/main/webapp/i18n/es/usuarioExtra.json @@ -12,7 +12,7 @@ "updated": "El usuario con el identificador {{ param }} ha sido actualizado", "deleted": "El usuario con el identificador {{ param }} ha sido eliminado", "delete": { - "question": "¿Seguro que quiere eliminar el usuario {{ id }}?" + "question": "¿Seguro que quiere cambiar el estado del usuario?" }, "detail": { "title": "Usuario" diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 6299be5..0fb2516 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -13,6 +13,8 @@ + + @@ -24,16 +26,23 @@
    -
    -
    -
    -
    -
    +
    +
    +
    +
    +
    +
    -
    -
    -
    -
    +
    + +
    +

    Cargando

    +
    +
     
    +
     
    +
     
    +
     
    +
     
  • Icono Nombre Usuario Correo electrónicoFecha de nacimiento Estado
    • @@ -45,6 +76,8 @@
    {{ usuarioExtra.nombre }} {{ usuarioExtra.user.email }}No establecida{{ usuarioExtra.fechaNacimiento | formatMediumDate }} {{ usuarioExtra.estado }} +
    -    -