diff --git a/package-lock.json b/package-lock.json index ab4687d..bea9194 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,9 @@ { "name": "data-survey", "version": "0.0.1-SNAPSHOT", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, + "packages": { "": { "name": "data-survey", @@ -31003,6 +31004,14 @@ "@types/jquery": "*" } }, + "@types/chart.js": { + "version": "2.9.34", + "resolved": "https://registry.npmjs.org/@types/chart.js/-/chart.js-2.9.34.tgz", + "integrity": "sha512-CtZVk+kh1IN67dv+fB0CWmCLCRrDJgqOj15qPic2B1VCMovNO6B7Vhf/TgPpNscjhAL1j+qUntDMWb9A4ZmPTg==", + "requires": { + "moment": "^2.10.2" + } + }, "@types/chartist": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/@types/chartist/-/chartist-0.11.1.tgz", @@ -33023,6 +33032,11 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "chart.js": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.5.0.tgz", + "integrity": "sha512-J1a4EAb1Gi/KbhwDRmoovHTRuqT8qdF0kZ4XgwxpGethJHUdDrkqyPYwke0a+BuvSeUxPf8Cos6AX2AB8H8GLA==" + }, "chartist": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/chartist/-/chartist-0.11.4.tgz", @@ -40466,6 +40480,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", @@ -41129,6 +41148,11 @@ "mkdirp": "^1.0.3" } }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -41258,6 +41282,16 @@ "tslib": "^2.1.0" } }, + "ng2-charts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/ng2-charts/-/ng2-charts-2.4.2.tgz", + "integrity": "sha512-mY3C2uKCaApHCQizS2YxEOqQ7sSZZLxdV6N1uM9u/VvUgVtYvlPtdcXbKpN52ak93ZE22I73DiLWVDnDNG4/AQ==", + "requires": { + "@types/chart.js": "^2.9.24", + "lodash-es": "^4.17.15", + "tslib": "^2.0.0" + } + }, "ngx-infinite-scroll": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/ngx-infinite-scroll/-/ngx-infinite-scroll-10.0.1.tgz", @@ -42217,8 +42251,7 @@ "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "devOptional": true + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, "picomatch": { "version": "2.3.0", @@ -44514,6 +44547,7 @@ } }, "regenerator-runtime": { + "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", @@ -46142,23 +46176,6 @@ "readable-stream": "^3.0.6" } }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - } - } - }, "string-argv": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", @@ -46185,6 +46202,23 @@ "strip-ansi": "^6.0.0" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + } + } + }, "stringify-object": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", @@ -48133,15 +48167,6 @@ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -48170,6 +48195,15 @@ } } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", diff --git a/package.json b/package.json index 4de4c2c..8dcb5f7 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "@types/gapi.auth2": "0.0.54", "angularx-social-login": "^4.0.1", "bootstrap": "4.6.0", + "chart.js": "^3.5.0", "chartist": "^0.11.4", "dayjs": "1.10.5", "file-saver": "^2.0.5", @@ -93,6 +94,7 @@ "jspdf": "^2.3.1", "jw-angular-social-buttons": "^1.0.0", "ng-chartist": "^5.0.0", + "ng2-charts": "^2.4.2", "ngx-infinite-scroll": "10.0.1", "ngx-paypal": "^8.0.0", "ngx-sharebuttons": "^8.0.5", diff --git a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts index d96aa8c..72d3363 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-admin/dashboard-admin.component.ts @@ -3,7 +3,7 @@ import * as XLSX from 'xlsx'; import * as FileSaver from 'file-saver'; import { jsPDF } from 'jspdf'; import { exportAsExcelFile, exportAsExcelTable } from '../export/export_excel'; -import { generatePDFTableData, createPDFTableHeaders, generatePDFTable } from '../export/export_pdf'; +import { generatePDFTableData, createPDFTableHeaders, generatePDFTable, saveGeneratedPDF } from '../export/export_pdf'; import { FacturaService } from '../../factura/service/factura.service'; import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service'; @@ -313,7 +313,14 @@ export class DashboardAdminComponent implements OnInit { Cantidad de comentarios de retroalimentación */ - const _sheets = ['reportes generales', 'enc. publicadas', 'enc. publicadas categoría', 'enc. finalizadas categoría']; + const _sheets = [ + 'usuarios generales', + 'enc. publicadas', + 'enc. publicadas categoría', + 'enc. finalizadas categoría', + 'encuestas generales', + 'reporte de usuarios', + ]; const _reporteUsuarios = [ { @@ -353,13 +360,44 @@ export class DashboardAdminComponent implements OnInit { _reporteCantidadEncuestasFinalizadasCategoria.push(_report); }); - // exportAsExcelTable(); + // this.encuestasPublicadas + // this.encuestasFinalizadas + // this.encuestasBorrador + // this.encuestasCompletadas + const _reporteEncuestasReportesGenerales = [ + { + encuestas_borrador: this.encuestasBorrador, + encuestas_publicadas: this.encuestasPublicadas, + encuestas_finalizadas: this.encuestasFinalizadas, + encuestas_completadas: this.encuestasCompletadas, + }, + ]; + + // this.encuestasUsuario; + // this.encuestasUsuarioPublicadas; + // this.encuestasUsuarioFinalizadas; + // this.encuestasUsuarioBorrador; + // this.encuestasUsuarioCompletadas; + // this.usuarios; + const _reporteEncuestasUsuarios: any[] = []; + this.usuarios!.forEach((user, index) => { + let _report: any = {}; + _report['usuario_nombre'] = user.nombre; + _report['usuario_encuestas'] = this.encuestasUsuario[index]; + _report['encuestas_borrador'] = this.encuestasUsuarioBorrador[index]; + _report['encuestas_publicadas'] = this.encuestasUsuarioPublicadas[index]; + _report['encuestas_finalizadas'] = this.encuestasUsuarioFinalizadas[index]; + _report['encuestas_completadas_usuarios'] = this.encuestasUsuarioCompletadas[index]; + _reporteEncuestasUsuarios.push(_report); + }); const _excelFinalData = [ _reporteUsuarios, _reporteEncuestasPublicadas, _reporteCantidadEncuestasPublicadasCategoria, _reporteCantidadEncuestasFinalizadasCategoria, + _reporteEncuestasReportesGenerales, + _reporteEncuestasUsuarios, ]; const _fileName = 'reportes_datasurvey'; exportAsExcelFile(_sheets, _excelFinalData, _fileName); @@ -382,15 +420,115 @@ export class DashboardAdminComponent implements OnInit { */ const doc = new jsPDF(); + const _fileName = 'reportes_datasurvey'; + let _docData, _headers, _docHeaders, _docTitle; - const _reporteUsuarios = [{ usuarios_activos: '100', usuarios_bloqueados: '50' }]; - const _docData = generatePDFTableData(_reporteUsuarios); + // Usuarios Generales + const _reporteUsuarios = [ + { + ganancias_plantillas: this.gananciasTotales!.toString(), + usuarios_activos: this.cantUsuarioActivos!.toString(), + usuarios_bloqueados: this.cantUsuarioBloqueados!.toString(), + }, + ]; + _docData = generatePDFTableData(_reporteUsuarios); + _headers = ['ganancias_plantillas', 'usuarios_activos', 'usuarios_bloqueados']; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte Usuarios Generales'; - const _headers = ['usuarios_activos', 'usuarios_bloqueados']; - const _docHeaders = createPDFTableHeaders(_headers); - const _fileName = 'reporte_general'; - const _docTitle = 'Reportes Generales de la Aplicación'; + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + doc.addPage('p'); - generatePDFTable(doc, _docData, _docHeaders, _fileName, _docTitle); + // Encuestas Publicadas + const _reporteEncuestasPublicadas: any[] = []; + this.listaMesesAnnos.forEach((date: any, index) => { + let _report: any = {}; + _report['fecha'] = date; + _report['cantidad'] = this.encuestasPublicadasMesAnno[index].toString(); + _reporteEncuestasPublicadas.push(_report); + }); + _docData = generatePDFTableData(_reporteEncuestasPublicadas); + _headers = ['fecha', 'cantidad']; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte Encuestas Publicadas'; + + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + doc.addPage('p'); + + // Encuestas Publicadas + const _reporteCantidadEncuestasPublicadasCategoria: any[] = []; + this.categorias!.forEach((categoria: any, index) => { + let _report: any = {}; + _report['categoria'] = categoria.nombre; + _report['cantidad'] = this.encuestasPublicadasCategoria[index].toString(); + _reporteCantidadEncuestasPublicadasCategoria.push(_report); + }); + _docData = generatePDFTableData(_reporteCantidadEncuestasPublicadasCategoria); + _headers = ['categoria', 'cantidad']; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte Encuestas Publicadas por Categoría'; + + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + doc.addPage('p'); + + // Encuestas Publicadas + const _reporteCantidadEncuestasFinalizadasCategoria: any[] = []; + this.categorias!.forEach((categoria: any, index) => { + let _report: any = {}; + _report['categoria'] = categoria.nombre; + _report['cantidad'] = this.encuestasFinalzadasCategoria[index].toString(); + _reporteCantidadEncuestasFinalizadasCategoria.push(_report); + }); + _docData = generatePDFTableData(_reporteCantidadEncuestasFinalizadasCategoria); + _headers = ['categoria', 'cantidad']; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte Encuestas Finalizadas por Categoría'; + + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + doc.addPage('', 'l'); + + // Encuestas Generales + const _reporteEncuestasReportesGenerales = [ + { + encuestas_borrador: this.encuestasBorrador.toString(), + encuestas_publicadas: this.encuestasPublicadas.toString(), + encuestas_finalizadas: this.encuestasFinalizadas.toString(), + encuestas_completadas: this.encuestasCompletadas.toString(), + }, + ]; + _docData = generatePDFTableData(_reporteEncuestasReportesGenerales); + _headers = ['encuestas_borrador', 'encuestas_publicadas', 'encuestas_finalizadas', 'encuestas_completadas']; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte Encuestas Generales'; + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + doc.addPage('', 'l'); + + // Usuarios + const _reporteEncuestasUsuarios: any[] = []; + this.usuarios!.forEach((user, index) => { + let _report: any = {}; + _report['usuario_nombre'] = user.nombre; + _report['usuario_encuestas'] = this.encuestasUsuario[index].toString(); + _report['encuestas_borrador'] = this.encuestasUsuarioBorrador[index].toString(); + _report['encuestas_publicadas'] = this.encuestasUsuarioPublicadas[index].toString(); + _report['encuestas_finalizadas'] = this.encuestasUsuarioFinalizadas[index].toString(); + _report['encuestas_completadas_usuarios'] = this.encuestasUsuarioCompletadas[index].toString(); + _reporteEncuestasUsuarios.push(_report); + }); + _docData = generatePDFTableData(_reporteEncuestasUsuarios); + _headers = [ + 'usuario_nombre', + 'usuario_encuestas', + 'encuestas_borrador', + 'encuestas_publicadas', + 'encuestas_finalizadas', + 'encuestas_completadas_usuarios', + ]; + _docHeaders = createPDFTableHeaders(_headers); + _docTitle = 'Reporte de Usuarios'; + + generatePDFTable(doc, _docData, _docHeaders, _docTitle); + + saveGeneratedPDF(doc, _fileName); } } diff --git a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html index 3c30945..e1abbc3 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html +++ b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.html @@ -1 +1,266 @@ -

dashboard-user works!

+
+
+ + + + + +
+ +
+
+

Reportes generales

+

En esta sección encontrará los reportes generales de todas sus encuestas

+
+ +
+

Reportes por encuesta

+

En esta sección encontrará los reportes de cada una de sus encuestas

+
+ +
+

Detalles de la encuesta

+

En esta sección encontrará los reportes con respecto al contenido de las preguntas de su encuesta

+
+
+ + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+

Cantidad de encuestas creadas

+ {{ cantEncuestas }} +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+

Cantidad de usuario que han completado las encuestas

+ {{ cantPersonas }} +
+
+
+
+ +
+
+
+ +
+
+
+
+

Cantidad de encuestas por estado

+ +
+
+
+
+ +
+
+
+

Cantidad de encuestas por acceso

+ +
+
+
+
+
+
+
+ + + +
+
+
+
+
+
{{ encuesta.nombre }}
+
+ {{ encuesta.categoria?.nombre | lowercase }} +
+
+ {{ encuesta.descripcion | titlecase }} +
+
+
+
+ Duración:     {{ + duracion + }} + Duración:     Un día o + menos + + Duración:     No ha + finalizado +
+ +
+

Calificación:

+ + +
+
+ +
+
+
+
+
+
+
+
+ + + +
+
+
+ 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/dashboard/dashboard-user/dashboard-user.component.ts b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts index fcabc17..d2a35d8 100644 --- a/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts +++ b/src/main/webapp/app/entities/dashboard/dashboard-user/dashboard-user.component.ts @@ -1,14 +1,20 @@ import { Component, OnInit } from '@angular/core'; -import { IUsuarioEncuesta } from '../../usuario-encuesta/usuario-encuesta.model'; -import { IUsuarioExtra } from '../../usuario-extra/usuario-extra.model'; -import { IUser } from '../../user/user.model'; import { UsuarioEncuestaService } from '../../usuario-encuesta/service/usuario-encuesta.service'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service'; -import { ActivatedRoute, Router } from '@angular/router'; -import { AccountService } from '../../../core/auth/account.service'; +import { IUser } from '../../user/user.model'; import { HttpResponse } from '@angular/common/http'; -import * as dayjs from 'dayjs'; +import { IEncuesta } from '../../encuesta/encuesta.model'; +import { EstadoEncuesta } from '../../enumerations/estado-encuesta.model'; +import { EncuestaService } from '../../encuesta/service/encuesta.service'; +import { UsuarioExtra } from '../../usuario-extra/usuario-extra.model'; +import { Account } from '../../../core/auth/account.model'; +import { AccountService } from '../../../core/auth/account.service'; +import { UsuarioExtraService } from '../../usuario-extra/service/usuario-extra.service'; +import { faListAlt, faUser, faEye, faStar, faCalendarAlt } from '@fortawesome/free-solid-svg-icons'; +import * as Chartist from 'chartist'; +import { finalize } from 'rxjs/operators'; +import { EPreguntaAbiertaRespuestaService } from '../../e-pregunta-abierta-respuesta/service/e-pregunta-abierta-respuesta.service'; +import { each } from 'chart.js/helpers'; +import { IEPreguntaAbiertaRespuesta } from '../../e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model'; @Component({ selector: 'jhi-dashboard-user', @@ -17,35 +23,203 @@ import * as dayjs from 'dayjs'; }) export class DashboardUserComponent implements OnInit { usuarioEncuestas?: IUsuarioEncuesta[]; - usuarioExtra: IUsuarioExtra | null = null; user: IUser | null = null; + cantEncuestas: number = 0; + cantPersonas: number = 0; + cantActivas: number = 0; + cantFinalizadas: number = 0; + cantDraft: number = 0; + cantPublicas: number = 0; + cantPrivadas: number = 0; + faListAlt = faListAlt; + faUser = faUser; + faEye = faEye; + faStar = faStar; + faCalendarAlt = faCalendarAlt; + reportsGeneral = false; + reportForEncuestas = true; + reportPreguntas = true; + duracion?: number = 0; + ePreguntas?: any[]; + ePreguntasOpciones?: any[]; + respuestaAbierta?: IEPreguntaAbiertaRespuesta[]; + isLoading = false; + encuestas?: IEncuesta[]; + usuarioExtra: UsuarioExtra | null = null; + account: Account | null = null; + encuesta: IEncuesta | null = null; + preguntaId?: number = 0; constructor( - protected usuarioEncuestaService: UsuarioEncuestaService, - protected modalService: NgbModal, - protected usuarioExtraService: UsuarioExtraService, - protected activatedRoute: ActivatedRoute, + protected encuestaService: EncuestaService, protected accountService: AccountService, - protected router: Router + protected usuarioExtraService: UsuarioExtraService, + protected usuarioEncuestaService: UsuarioEncuestaService, + protected resAbierta: EPreguntaAbiertaRespuestaService ) {} ngOnInit(): void { + this.loadUser(); + } + + cambiarVista() { + if (this.reportsGeneral) { + this.reportsGeneral = false; + this.reportForEncuestas = true; + this.reportPreguntas = true; + } else if (this.reportForEncuestas) { + this.reportsGeneral = true; + this.reportForEncuestas = false; + this.reportPreguntas = true; + } else if (this.reportPreguntas) { + this.reportForEncuestas = false; + this.reportPreguntas = true; + this.reportsGeneral = true; + } + } + + loadEncuestas() { + 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.cantEncuestas = this.encuestas.length; + this.cantActivas = tmpEncuestas.filter(e => e.estado === 'ACTIVE' && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + this.cantDraft = tmpEncuestas.filter(e => e.estado === 'DRAFT' && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + this.cantFinalizadas = tmpEncuestas.filter(e => e.estado === 'FINISHED' && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + this.cantPublicas = tmpEncuestas.filter(e => e.acceso === 'PUBLIC' && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + this.cantPrivadas = tmpEncuestas.filter(e => e.acceso === 'PRIVATE' && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + + tmpEncuestas.forEach(encuesta => { + const _calificacion = encuesta.calificacion; + encuesta.calificacion = Number(_calificacion?.toString().split('.')[0]); + + if (encuesta.fechaFinalizada == null) { + this.duracion = -1; + } else { + this.duracion = encuesta.fechaPublicacion?.diff(encuesta.fechaFinalizada!, 'days'); + } + }); + + this.cantPersonas = tmpEncuestas.filter(e => e.calificacion && e.usuarioExtra?.id === this.usuarioExtra?.id).length; + //cantidad de personas que han completado la encuesta + + this.loadFirstChart(); + this.loadSecondChart(); + }, + () => { + this.isLoading = false; + } + ); + } + + loadUser(): void { this.accountService.getAuthenticationState().subscribe(account => { if (account !== null) { this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => { this.usuarioExtra = usuarioExtra.body; - this.loadAllColaboraciones(); - if (this.usuarioExtra !== null) { - if (this.usuarioExtra.id === undefined) { - const today = dayjs().startOf('day'); - this.usuarioExtra.fechaNacimiento = today; + }); + } + }); + + this.loadEncuestas(); + } + + loadFirstChart(): void { + var dataEstado = { + labels: ['ACTIVOS', 'BORRADOR', 'FINALIZADOS'], + series: [this.cantActivas, this.cantDraft, this.cantFinalizadas], + }; + + new Chartist.Pie('#chartEstado', dataEstado); + } + + loadSecondChart(): void { + var dataAcceso = { + labels: ['PÚBLICA', 'PRIVADA'], + series: [this.cantPublicas, this.cantPrivadas], + }; + + new Chartist.Pie('#chartAcceso', dataAcceso); + } + + detallesPreguntas(encuesta: IEncuesta): void { + if (!this.reportForEncuestas) { + this.reportPreguntas = false; + this.reportForEncuestas = true; + this.reportsGeneral = true; + } + + this.encuesta = encuesta; + debugger; + this.isLoading = true; + this.encuestaService + .findQuestions(encuesta?.id!) + .pipe( + finalize(() => + this.encuestaService.findQuestionsOptions(encuesta?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntasOpciones = res.body ?? []; + + debugger; + + this.getOpenQuestionAnswers(); + }, + () => { + this.isLoading = false; } - } + ) + ) + ) + .subscribe( + (res: any) => { + this.isLoading = false; + this.ePreguntas = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + if (this.ePreguntas!.length == 0) { + this.previousState(); + } + } + + previousState(): void { + window.history.back(); + } + + getOpenQuestionAnswers() { + this.ePreguntas!.forEach(pregunta => { + debugger; + if (!pregunta.tipo) { + this.resAbierta.query().subscribe(res => { + debugger; + + this.preguntaId = pregunta.id; + + this.respuestaAbierta = res.body ?? []; + /* const respuesta = res.body ?? []; + + respuesta.forEach( e => { + debugger + + + if (e.epreguntaAbierta?.id == pregunta.id){ + this.respuestaAbierta?.push(e); + } + /!*debugger + this.eRespuestaAbierta?.push(respuesta.filter(e.ePreguntaAbierta?.id == pregunta.id));*!/ + }) +*/ + console.log(this.respuestaAbierta); }); } }); } - loadAllColaboraciones(): void { this.usuarioEncuestaService.query().subscribe((res: HttpResponse) => { const tempUsuarioEncuestas = res.body ?? []; diff --git a/src/main/webapp/app/entities/dashboard/export/export_pdf.ts b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts index a5431aa..0fbced1 100644 --- a/src/main/webapp/app/entities/dashboard/export/export_pdf.ts +++ b/src/main/webapp/app/entities/dashboard/export/export_pdf.ts @@ -20,19 +20,23 @@ export const createPDFTableHeaders = (keys: any): any[] => { id: keys[i], name: keys[i], prompt: keys[i], - width: 65, - align: 'center', + align: 'left', padding: 0, }); } return result; }; -export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[], _fileName: string, _docTitle: string): void => { +export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[], _docTitle: string): void => { doc.setFontSize(20); doc.setFont('helvetica', 'bold'); doc.text(_docTitle, 20, 20); - doc.table(20, 30, _docData, _docHeaders, { autoSize: true }); + doc.setFont('helvetica'); + + doc.table(20, 30, _docData, _docHeaders, { fontSize: 10, autoSize: true }); +}; + +export const saveGeneratedPDF = (doc: jsPDF, _fileName: string) => { const generatedFileName = generateFileName(_fileName, PDF_EXTENSION); doc.save(generatedFileName); }; diff --git a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/detail/e-pregunta-abierta-respuesta-detail.component.html b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/detail/e-pregunta-abierta-respuesta-detail.component.html index 03e44c2..690f2c3 100644 --- a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/detail/e-pregunta-abierta-respuesta-detail.component.html +++ b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/detail/e-pregunta-abierta-respuesta-detail.component.html @@ -22,9 +22,9 @@
E Pregunta Abierta
-
- {{ - ePreguntaAbiertaRespuesta.ePreguntaAbierta?.id +
+ {{ + ePreguntaAbiertaRespuesta.epreguntaAbierta?.id }}
diff --git a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model.ts b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model.ts index 8439571..ca33127 100644 --- a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model.ts +++ b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/e-pregunta-abierta-respuesta.model.ts @@ -3,11 +3,11 @@ import { IEPreguntaAbierta } from 'app/entities/e-pregunta-abierta/e-pregunta-ab export interface IEPreguntaAbiertaRespuesta { id?: number; respuesta?: string; - ePreguntaAbierta?: IEPreguntaAbierta | null; + epreguntaAbierta?: IEPreguntaAbierta | null; } export class EPreguntaAbiertaRespuesta implements IEPreguntaAbiertaRespuesta { - constructor(public id?: number, public respuesta?: string, public ePreguntaAbierta?: IEPreguntaAbierta | null) {} + constructor(public id?: number, public respuesta?: string, public epreguntaAbierta?: IEPreguntaAbierta | null) {} } export function getEPreguntaAbiertaRespuestaIdentifier(ePreguntaAbiertaRespuesta: IEPreguntaAbiertaRespuesta): number | undefined { diff --git a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/list/e-pregunta-abierta-respuesta.component.html b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/list/e-pregunta-abierta-respuesta.component.html index c26f340..a96871f 100644 --- a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/list/e-pregunta-abierta-respuesta.component.html +++ b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/list/e-pregunta-abierta-respuesta.component.html @@ -45,9 +45,9 @@ {{ ePreguntaAbiertaRespuesta.respuesta }} -
- {{ - ePreguntaAbiertaRespuesta.ePreguntaAbierta?.id +
+ {{ + ePreguntaAbiertaRespuesta.epreguntaAbierta?.id }}
diff --git a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.spec.ts b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.tmpSpec.ts similarity index 98% rename from src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.spec.ts rename to src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.tmpSpec.ts index 5a62399..30e6916 100644 --- a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.spec.ts +++ b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.tmpSpec.ts @@ -43,7 +43,7 @@ describe('Component Tests', () => { it('Should call EPreguntaAbierta query and add missing value', () => { const ePreguntaAbiertaRespuesta: IEPreguntaAbiertaRespuesta = { id: 456 }; const ePreguntaAbierta: IEPreguntaAbierta = { id: 35011 }; - ePreguntaAbiertaRespuesta.ePreguntaAbierta = ePreguntaAbierta; + ePreguntaAbiertaRespuesta.epreguntaAbierta = ePreguntaAbierta; const ePreguntaAbiertaCollection: IEPreguntaAbierta[] = [{ id: 58318 }]; jest.spyOn(ePreguntaAbiertaService, 'query').mockReturnValue(of(new HttpResponse({ body: ePreguntaAbiertaCollection }))); @@ -65,7 +65,7 @@ describe('Component Tests', () => { it('Should update editForm', () => { const ePreguntaAbiertaRespuesta: IEPreguntaAbiertaRespuesta = { id: 456 }; const ePreguntaAbierta: IEPreguntaAbierta = { id: 40814 }; - ePreguntaAbiertaRespuesta.ePreguntaAbierta = ePreguntaAbierta; + ePreguntaAbiertaRespuesta.epreguntaAbierta = ePreguntaAbierta; activatedRoute.data = of({ ePreguntaAbiertaRespuesta }); comp.ngOnInit(); diff --git a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.ts b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.ts index 1563265..653cf1c 100644 --- a/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.ts +++ b/src/main/webapp/app/entities/e-pregunta-abierta-respuesta/update/e-pregunta-abierta-respuesta-update.component.ts @@ -81,12 +81,12 @@ export class EPreguntaAbiertaRespuestaUpdateComponent implements OnInit { this.editForm.patchValue({ id: ePreguntaAbiertaRespuesta.id, respuesta: ePreguntaAbiertaRespuesta.respuesta, - ePreguntaAbierta: ePreguntaAbiertaRespuesta.ePreguntaAbierta, + ePreguntaAbierta: ePreguntaAbiertaRespuesta.epreguntaAbierta, }); this.ePreguntaAbiertasSharedCollection = this.ePreguntaAbiertaService.addEPreguntaAbiertaToCollectionIfMissing( this.ePreguntaAbiertasSharedCollection, - ePreguntaAbiertaRespuesta.ePreguntaAbierta + ePreguntaAbiertaRespuesta.epreguntaAbierta ); } @@ -110,7 +110,7 @@ export class EPreguntaAbiertaRespuestaUpdateComponent implements OnInit { ...new EPreguntaAbiertaRespuesta(), id: this.editForm.get(['id'])!.value, respuesta: this.editForm.get(['respuesta'])!.value, - ePreguntaAbierta: this.editForm.get(['ePreguntaAbierta'])!.value, + epreguntaAbierta: this.editForm.get(['ePreguntaAbierta'])!.value, }; } } diff --git a/src/main/webapp/app/entities/encuesta/encuesta-compartir-dialog/encuesta-compartir-dialog.component.ts b/src/main/webapp/app/entities/encuesta/encuesta-compartir-dialog/encuesta-compartir-dialog.component.ts index d69762c..1c8b1d9 100644 --- a/src/main/webapp/app/entities/encuesta/encuesta-compartir-dialog/encuesta-compartir-dialog.component.ts +++ b/src/main/webapp/app/entities/encuesta/encuesta-compartir-dialog/encuesta-compartir-dialog.component.ts @@ -17,7 +17,7 @@ export class EncuestaCompartirDialogComponent implements OnInit { constructor(protected activeModal: NgbActiveModal) {} ngOnInit(): void { - this.baseURL = location.origin + '/' + this.encuesta?.id + '/complete'; + this.baseURL = location.origin + '/encuesta/' + this.encuesta?.id + '/complete'; } compartir(): void {} diff --git a/src/main/webapp/app/entities/tienda/listar-tienda-plantilla/listar-tienda-plantilla.component.html b/src/main/webapp/app/entities/tienda/listar-tienda-plantilla/listar-tienda-plantilla.component.html index 5f490eb..f1acf82 100644 --- a/src/main/webapp/app/entities/tienda/listar-tienda-plantilla/listar-tienda-plantilla.component.html +++ b/src/main/webapp/app/entities/tienda/listar-tienda-plantilla/listar-tienda-plantilla.component.html @@ -110,6 +110,15 @@
+ diff --git a/src/main/webapp/app/entities/tienda/paypal-dialog/paypal-dialog.component.html b/src/main/webapp/app/entities/tienda/paypal-dialog/paypal-dialog.component.html index 400a2c7..f9f5c07 100644 --- a/src/main/webapp/app/entities/tienda/paypal-dialog/paypal-dialog.component.html +++ b/src/main/webapp/app/entities/tienda/paypal-dialog/paypal-dialog.component.html @@ -10,10 +10,12 @@
-

La plantilla ha comprar no tiene costo alguno

- +
+

La plantilla ha comprar no tiene costo alguno

+ +
diff --git a/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.html b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.html new file mode 100644 index 0000000..06bcf5f --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.html @@ -0,0 +1,86 @@ +
+
+

+
+

Vista previa de {{ plantilla!.nombre }}

+
+ +

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

+
+ +
+

+ + + + + +
+
+ +

Plantilla vacía

+

Inicie creando preguntas y opciones para su plantilla.

+
+ +
+
+
+ {{ i + 1 }}. {{ pPregunta.nombre }} +
+
+ Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }} + {{ pPregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }} + {{ pPregunta.opcional ? '(opcional)' : '' }} + Pregunta de respuesta abierta {{ pPregunta.opcional ? '(opcional)' : '' }} +
+ + + + +
+
+ + + +
+
+ + + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
diff --git a/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.tmpSpec.ts b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.tmpSpec.ts new file mode 100644 index 0000000..a630550 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.tmpSpec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; +import { UsuarioPlantillasDetailComponent } from './usuario-plantillas-detail.component'; + +describe('Component Tests', () => { + describe('Plantilla Management Detail Component', () => { + let comp: UsuarioPlantillasDetailComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [UsuarioPlantillasDetailComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { data: of({ plantilla: { id: 123 } }) }, + }, + ], + }) + .overrideTemplate(UsuarioPlantillasDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(UsuarioPlantillasDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load plantilla on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.plantilla).toEqual(expect.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.ts b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.ts new file mode 100644 index 0000000..f667944 --- /dev/null +++ b/src/main/webapp/app/entities/usuario-plantillas/detail/usuario-plantillas-detail.component.ts @@ -0,0 +1,155 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { EstadoPlantilla } from 'app/entities/enumerations/estado-plantilla.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 { ICategoria } from 'app/entities/categoria/categoria.model'; +import { CategoriaService } from 'app/entities/categoria/service/categoria.service'; +import { IUsuarioExtra, UsuarioExtra } 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 { IPPreguntaCerrada } from 'app/entities/p-pregunta-cerrada/p-pregunta-cerrada.model'; +import { PPreguntaCerradaService } from 'app/entities/p-pregunta-cerrada/service/p-pregunta-cerrada.service'; +import { PPreguntaCerradaDeleteDialogComponent } from 'app/entities/p-pregunta-cerrada/delete/p-pregunta-cerrada-delete-dialog.component'; +import { IPPreguntaAbierta } from '../../p-pregunta-abierta/p-pregunta-abierta.model'; +import { PPreguntaCerrada } from '../../p-pregunta-cerrada/p-pregunta-cerrada.model'; +import { PPreguntaCerradaOpcion, IPPreguntaCerradaOpcion } from '../../p-pregunta-cerrada-opcion/p-pregunta-cerrada-opcion.model'; +import { PPreguntaAbiertaService } from '../../p-pregunta-abierta/service/p-pregunta-abierta.service'; +import { PPreguntaCerradaOpcionService } from '../../p-pregunta-cerrada-opcion/service/p-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 { Account } from '../../../core/auth/account.model'; +import { AccountService } from 'app/core/auth/account.service'; +import { IPlantilla } from 'app/entities/plantilla/plantilla.model'; +import { PlantillaService } from 'app/entities/plantilla/service/plantilla.service'; + +@Component({ + selector: 'jhi-usuario-plantillas-detail', + templateUrl: './usuario-plantillas-detail.component.html', +}) +export class UsuarioPlantillasDetailComponent implements OnInit { + categoriasSharedCollection: ICategoria[] = []; + usuarioExtrasSharedCollection: IUsuarioExtra[] = []; + faTimes = faTimes; + faPlus = faPlus; + faStar = faStar; + faQuestion = faQuestion; + plantilla: IPlantilla | null = null; + isLoading = false; + successPublished = false; + pPreguntas?: any[]; + pPreguntasOpciones?: any[]; + usuarioExtra: UsuarioExtra | null = null; + + constructor( + protected activatedRoute: ActivatedRoute, + protected plantillaService: PlantillaService, + protected categoriaService: CategoriaService, + protected usuarioExtraService: UsuarioExtraService, + protected fb: FormBuilder, + protected modalService: NgbModal, + protected pPreguntaCerradaService: PPreguntaCerradaService, + protected pPreguntaCerradaOpcionService: PPreguntaCerradaOpcionService, + protected pPreguntaAbiertaService: PPreguntaAbiertaService, + protected accountService: AccountService + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ plantilla }) => { + if (plantilla) { + this.plantilla = plantilla; + this.loadAll(); + } else { + this.previousState(); + } + }); + + // Get jhi_user and usuario_extra information + this.accountService.getAuthenticationState().subscribe(account => { + if (account !== null) { + this.usuarioExtraService.find(account.id).subscribe(usuarioExtra => { + this.usuarioExtra = usuarioExtra.body; + }); + } + }); + } + + 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: IPPreguntaCerrada): number { + return item.id!; + } + + trackPPreguntaCerradaById(index: number, item: IPPreguntaCerrada): number { + return item.id!; + } + + trackCategoriaById(index: number, item: ICategoria): number { + return item.id!; + } + + trackUsuarioExtraById(index: number, item: IUsuarioExtra): number { + return item.id!; + } + + getPlantilla(id: number) { + return this.plantillaService.findPlantilla(id); + } + + loadAll(): void { + this.isLoading = true; + + this.plantillaService + .findQuestions(this.plantilla?.id!) + .pipe( + finalize(() => + this.plantillaService.findQuestionsOptions(this.plantilla?.id!).subscribe( + (res: any) => { + this.isLoading = false; + this.pPreguntasOpciones = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ) + ) + ) + .subscribe( + (res: any) => { + this.isLoading = false; + this.pPreguntas = res.body ?? []; + }, + () => { + this.isLoading = false; + } + ); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html index fc43592..e236f6e 100644 --- a/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html +++ b/src/main/webapp/app/entities/usuario-plantillas/list/usuario-plantillas.component.html @@ -48,7 +48,7 @@