add reportes de colaboraciones, cambios de estilos

This commit is contained in:
Mariela Bonilla 2021-08-15 16:09:24 -06:00
parent ac864a5739
commit d01f11ab99
7 changed files with 420 additions and 60 deletions

114
package-lock.json generated
View File

@ -1,9 +1,8 @@
{
"name": "data-survey",
"version": "0.0.1-SNAPSHOT",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "data-survey",
@ -30,6 +29,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",
@ -37,6 +37,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",
@ -4395,6 +4396,14 @@
"@types/jquery": "*"
}
},
"node_modules/@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==",
"dependencies": {
"moment": "^2.10.2"
}
},
"node_modules/@types/chartist": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/@types/chartist/-/chartist-0.11.1.tgz",
@ -6959,6 +6968,11 @@
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true
},
"node_modules/chart.js": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.5.0.tgz",
"integrity": "sha512-J1a4EAb1Gi/KbhwDRmoovHTRuqT8qdF0kZ4XgwxpGethJHUdDrkqyPYwke0a+BuvSeUxPf8Cos6AX2AB8H8GLA=="
},
"node_modules/chartist": {
"version": "0.11.4",
"resolved": "https://registry.npmjs.org/chartist/-/chartist-0.11.4.tgz",
@ -16609,6 +16623,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/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=="
},
"node_modules/lodash.clonedeep": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
@ -17459,6 +17478,14 @@
"node": ">=10"
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -17619,6 +17646,22 @@
"chartist": ">=0.11.4"
}
},
"node_modules/ng2-charts": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/ng2-charts/-/ng2-charts-2.4.3.tgz",
"integrity": "sha512-tPrhHSS2DfVyipXQ0gykOPc8zFNnj2b7sAebUVty392vHnEGYCwsP6YbFfpr1iXu4yBSRm4Gt5lffR5w0uyYSw==",
"dependencies": {
"@types/chart.js": "^2.9.24",
"lodash-es": "^4.17.15",
"tslib": "^2.0.0"
},
"peerDependencies": {
"@angular/common": ">=7.2.0",
"@angular/core": ">=7.2.0",
"chart.js": "^2.9.3",
"rxjs": "^6.3.3"
}
},
"node_modules/ngx-infinite-scroll": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/ngx-infinite-scroll/-/ngx-infinite-scroll-10.0.1.tgz",
@ -23821,11 +23864,6 @@
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
},
"bin": {
"sshpk-conv": "bin/sshpk-conv",
"sshpk-sign": "bin/sshpk-sign",
"sshpk-verify": "bin/sshpk-verify"
},
"engines": {
"node": ">=0.10.0"
}
@ -41283,9 +41321,9 @@
}
},
"ng2-charts": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/ng2-charts/-/ng2-charts-2.4.2.tgz",
"integrity": "sha512-mY3C2uKCaApHCQizS2YxEOqQ7sSZZLxdV6N1uM9u/VvUgVtYvlPtdcXbKpN52ak93ZE22I73DiLWVDnDNG4/AQ==",
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/ng2-charts/-/ng2-charts-2.4.3.tgz",
"integrity": "sha512-tPrhHSS2DfVyipXQ0gykOPc8zFNnj2b7sAebUVty392vHnEGYCwsP6YbFfpr1iXu4yBSRm4Gt5lffR5w0uyYSw==",
"requires": {
"@types/chart.js": "^2.9.24",
"lodash-es": "^4.17.15",
@ -42251,7 +42289,8 @@
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"devOptional": true
},
"picomatch": {
"version": "2.3.0",
@ -44547,7 +44586,6 @@
}
},
"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==",
@ -46176,6 +46214,23 @@
"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",
@ -46202,23 +46257,6 @@
"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",
@ -48167,6 +48205,15 @@
"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",
@ -48195,15 +48242,6 @@
}
}
},
"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",

View File

@ -43,10 +43,7 @@ public class UsuarioEncuesta implements Serializable {
private UsuarioExtra usuarioExtra;
@ManyToOne
@JsonIgnoreProperties(
value = { "usuarioEncuestas", "ePreguntaAbiertas", "ePreguntaCerradas", "categoria", "usuarioExtra" },
allowSetters = true
)
@JsonIgnoreProperties(value = { "usuarioEncuestas", "usuarioExtra" }, allowSetters = true)
private Encuesta encuesta;
// jhipster-needle-entity-add-field - JHipster will add fields here

View File

@ -432,7 +432,7 @@ public class EncuestaResource {
newEncuesta.setNombre(encuesta.get().getNombre());
newEncuesta.setDescripcion(encuesta.get().getDescripcion());
newEncuesta.setFechaCreacion(ZonedDateTime.now());
newEncuesta.setCalificacion(5d);
newEncuesta.setCalificacion(5.1d);
newEncuesta.setAcceso(encuesta.get().getAcceso());
newEncuesta.setEstado(encuesta.get().getEstado());
newEncuesta.setCategoria(encuesta.get().getCategoria());

View File

@ -4,7 +4,7 @@
<button type="button" class="ds-btn ds-btn&#45;&#45;primary" (click)="exportReportesGeneralesUserPDF()">Exportar como PDF</button>-->
<button
type="button"
[hidden]="!reportsGeneral || reportForEncuestas"
[hidden]="!reportsGeneral || (reportForEncuestas && reportColaboraciones)"
class="ds-btn ds-btn--primary"
style="float: right"
(click)="cambiarVista()"
@ -13,16 +13,34 @@
</button>
<button
type="button"
[hidden]="!reportForEncuestas || reportsGeneral"
[hidden]="!reportForEncuestas || (reportsGeneral && reportColaboraciones)"
class="ds-btn ds-btn--primary"
style="float: right"
(click)="cambiarVista()"
>
Ver reportes por encuestas
</button>
<button
type="button"
[hidden]="!reportColaboraciones || (reportsGeneral && reportForEncuestas)"
class="ds-btn ds-btn--primary"
style="float: right"
(click)="cambiarVistaColaboracion('colaboracion')"
>
Ver reportes de colaboraciones
</button>
<button type="button" [hidden]="reportPreguntas" class="ds-btn ds-btn--primary" style="float: right" (click)="cambiarVista()">
Volver
<button type="button" [hidden]="reportPreguntas" class="ds-btn ds-btn--secondary" style="float: right" (click)="cambiarVista()">
<fa-icon icon="arrow-left"></fa-icon>&nbsp; Volver
</button>
<button
type="button"
[hidden]="reportColaboracionPreguntas"
class="ds-btn ds-btn--secondary"
style="float: right"
(click)="cambiarVista()"
>
<fa-icon icon="arrow-left"></fa-icon>&nbsp; Volver
</button>
</div>
@ -41,6 +59,14 @@
<h1>Detalles de la encuesta</h1>
<h2>En esta sección encontrará los reportes con respecto al contenido de las preguntas de su encuesta</h2>
</div>
<div class="py-2" [hidden]="reportColaboraciones">
<h1>Reportes de colaboraciones</h1>
<h2>En esta sección encontrará los reportes generales de todas las colaboraciones en las que esté participando</h2>
</div>
<div class="py-2" [hidden]="reportColaboracionPreguntas">
<h1>Detalles de la encuesta en la que colabora</h1>
<h2>En esta sección encontrará los reportes con respecto al contenido de las preguntas de la encuesta a la que colabora</h2>
</div>
<hr />
<!--REPORTES GENERALES-->
@ -123,6 +149,13 @@
<!--REPORTE POR ENCUESTA-->
<div class="container-fluid" [hidden]="reportForEncuestas">
<div class="ds-survey" id="entitiesEncuestas" *ngIf="encuestas && encuestas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No posee encuestas</p>
</ng-container>
</div>
</div>
<div class="row gx-5" *ngIf="encuestas && encuestas.length > 0">
<div class="col-xl-4 col-lg-4 col-md-6 mb-5" *ngFor="let encuesta of encuestas">
<div class="card-encuesta lift h-100" [attr.data-id]="encuesta.id">
@ -178,11 +211,14 @@
<!--REPORTES DE LAS PREGUNTAS-->
<div class="container-fluid" *ngIf="encuesta" [hidden]="reportPreguntas">
<div>
<div class="alert alert-warning" id="no-result" *ngIf="ePreguntas?.length === 0">
<span>No se encontraron preguntas</span>
<div class="ds-survey" id="entitiesPreguntas" *ngIf="ePreguntas && ePreguntas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No se encontraron preguntas</p>
</ng-container>
</div>
</div>
<div>
<div class="ds-survey preview-survey" id="entities" *ngIf="ePreguntas && ePreguntas.length > 0">
<div class="ds-survey--all-question-wrapper col-8">
<div class="ds-survey--question-wrapper card-encuesta" *ngFor="let ePregunta of ePreguntas; let i = index">
@ -262,5 +298,171 @@
</div>
</div>
</div>
<!--REPORTE POR COLABORACION-->
<div class="container-fluid" [hidden]="reportColaboraciones">
<div class="ds-survey" id="entitiesColaboraciones" *ngIf="usuarioEncuestas && usuarioEncuestas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No posee colaboraciones</p>
</ng-container>
</div>
</div>
<div class="row gx-5" *ngIf="usuarioEncuestas && usuarioEncuestas.length > 0">
<div class="col-xl-4 col-lg-4 col-md-6 mb-5" *ngFor="let colaboracion of usuarioEncuestas">
<div class="card-encuesta lift h-100" *ngIf="colaboracion.encuesta" [attr.data-id]="colaboracion.encuesta.id">
<div class="card-body p-3">
<div class="card-title mb-0">{{ colaboracion.encuesta.nombre }}</div>
<div class="entity-body--row m-2">
<span class="tag mt-2">{{ colaboracion.encuesta.categoria?.nombre | lowercase }}</span>
</div>
<div class="entity-body--row m-2">
<span class="subtitle mt-2">{{ colaboracion.encuesta.descripcion | titlecase }}</span>
</div>
<div class="text-xs text-gray-500">
<div class="entity-body">
<div class="entity-body--row m-2">
<span class="mt-2" *ngIf="duracionColaboracion! > 0"
><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración: &nbsp;&nbsp;&nbsp;&nbsp;{{
duracionColaboracion
}}</span
>
<span class="mt-2" *ngIf="duracionColaboracion! == 0"
><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración: &nbsp;&nbsp;&nbsp;&nbsp;Un día o
menos</span
>
<span class="mt-2" *ngIf="duracionColaboracion! == -1"
><fa-icon class="entity-icon--access" [icon]="faCalendarAlt"></fa-icon> Duración: &nbsp;&nbsp;&nbsp;&nbsp;No ha
finalizado</span
>
</div>
<div class="entity-body--row m-2">
<p>Calificación:</p>
<fa-icon
*ngFor="let i of [].constructor(colaboracion.encuesta.calificacion)"
class="entity-icon--star"
[icon]="faStar"
></fa-icon>
<fa-icon
*ngFor="let i of [].constructor(5 - colaboracion.encuesta.calificacion!)"
class="entity-icon--star--off"
[icon]="faStar"
></fa-icon>
</div>
<div class="entity-body--row m-2">
<button (click)="detallesPreguntasColaboracion(colaboracion.encuesta)" class="ds-btn btn-card ds-btn--primary">
<fa-icon [icon]="faEye"></fa-icon>&nbsp;&nbsp;Detalle
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--REPORTES DE LAS PREGUNTAS DE LA COLABORACION-->
<div class="container-fluid" *ngIf="encuesta" [hidden]="reportColaboracionPreguntas">
<div>
<div
class="ds-survey"
id="entitiesPreguntasColaboracion"
*ngIf="ePreguntasOpcionesColaboracion && ePreguntasOpcionesColaboracion?.length === 0"
>
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No se encontraron preguntas</p>
</ng-container>
</div>
</div>
<div
class="ds-survey preview-survey"
id="entitiesColaboration"
*ngIf="ePreguntasOpcionesColaboracion && ePreguntasOpcionesColaboracion.length > 0"
>
<div class="ds-survey--all-question-wrapper col-8">
<div class="ds-survey--question-wrapper card-encuesta" *ngFor="let ePregunta of ePreguntasOpcionesColaboracion; let i = index">
<div
[attr.data-index]="ePregunta.id"
[attr.data-tipo]="ePregunta.tipo"
[attr.data-opcional]="ePregunta.opcional"
class="ds-survey--question"
>
<div class="ds-survey--titulo">
<span class="ds-survey--titulo--name">{{ i + 1 }}. {{ ePregunta.nombre }}</span>
</div>
<div>
<span *ngIf="ePregunta.tipo === 'SINGLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.SINGLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="ePregunta.tipo === 'MULTIPLE'" class="ds-subtitle"
>Pregunta de respuesta {{ 'dataSurveyApp.PreguntaCerradaTipo.MULTIPLE' | translate | lowercase }}
{{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
<span *ngIf="!ePregunta.tipo" class="ds-subtitle"
>Pregunta de respuesta abierta {{ ePregunta.opcional ? '(opcional)' : '' }}</span
>
</div>
<ng-container *ngIf="ePregunta.tipo">
<ng-container *ngFor="let ePreguntaOpcion of ePreguntasOpcionesColaboracion; let j = index">
<ng-container *ngFor="let ePreguntaOpcionFinal of ePreguntaOpcion">
<ng-container *ngIf="ePregunta.id === ePreguntaOpcionFinal.epreguntaCerrada.id">
<div
class="ds-survey--option ds-survey--option--base ds-survey--closed-option can-delete"
[attr.data-id]="ePreguntaOpcionFinal.id"
>
<div class="radio" *ngIf="ePregunta.tipo === 'SINGLE'">
<!--<input
type="text"
readonly
style="border-radius: 3px"
name="{{ 'radio' + ePregunta.id }}"
id="'radio'"
/>-->
<label>{{
ePreguntaOpcionFinal.nombre + ' / Cantidad de veces seleccionada: ' + ePreguntaOpcionFinal.cantidad
}}</label>
</div>
<div class="checkbox" *ngIf="ePregunta.tipo === 'MULTIPLE'">
<!--<input
type="checkbox"
style="border-radius: 3px"
id="{{ 'checkbox' + ePreguntaOpcionFinal.id }}"
/>-->
<label>{{
ePreguntaOpcionFinal.nombre + ' / Cantidad de veces seleccionada: ' + ePreguntaOpcionFinal.cantidad
}}</label>
</div>
</div>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
<div *ngIf="!ePregunta.tipo">
<div *ngFor="let res of respuestaAbiertaColaboracion">
<!-- <ul>
<li *ngIf="res.epreguntaAbierta?.id == preguntaId"> {{ res.respuesta }}</li>
</ul>-->
<!-- <textarea readonly class="ds-survey&#45;&#45;textarea" cols="33" rows="10" *ngIf="res.epreguntaAbierta?.id == preguntaId" > {{ res.respuesta }} </textarea>-->
<div *ngIf="res.epreguntaAbierta?.id == preguntaId">
<label> {{ '- ' + res.respuesta }}</label> <br />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -13,8 +13,8 @@ import { faListAlt, faUser, faEye, faStar, faCalendarAlt } from '@fortawesome/fr
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';
import { IUsuarioEncuesta } from '../../usuario-encuesta/usuario-encuesta.model';
@Component({
selector: 'jhi-dashboard-user',
@ -22,7 +22,6 @@ import { IEPreguntaAbiertaRespuesta } from '../../e-pregunta-abierta-respuesta/e
styleUrls: ['./dashboard-user.component.scss'],
})
export class DashboardUserComponent implements OnInit {
usuarioEncuestas?: IUsuarioEncuesta[];
user: IUser | null = null;
cantEncuestas: number = 0;
cantPersonas: number = 0;
@ -39,6 +38,8 @@ export class DashboardUserComponent implements OnInit {
reportsGeneral = false;
reportForEncuestas = true;
reportPreguntas = true;
reportColaboraciones = true;
reportColaboracionPreguntas = true;
duracion?: number = 0;
ePreguntas?: any[];
ePreguntasOpciones?: any[];
@ -49,6 +50,13 @@ export class DashboardUserComponent implements OnInit {
account: Account | null = null;
encuesta: IEncuesta | null = null;
preguntaId?: number = 0;
usuarioEncuestas?: IUsuarioEncuesta[];
colaboraciones?: IEncuesta[];
duracionColaboracion?: number = 0;
ePreguntasColaboracion?: any[];
ePreguntasOpcionesColaboracion?: any[];
respuestaAbiertaColaboracion?: IEPreguntaAbiertaRespuesta[];
preguntaIdColaboracion?: number = 0;
constructor(
protected encuestaService: EncuestaService,
@ -67,14 +75,36 @@ export class DashboardUserComponent implements OnInit {
this.reportsGeneral = false;
this.reportForEncuestas = true;
this.reportPreguntas = true;
this.reportColaboraciones = true;
this.reportColaboracionPreguntas = true;
} else if (this.reportForEncuestas) {
this.reportsGeneral = true;
this.reportForEncuestas = false;
this.reportPreguntas = true;
this.reportColaboraciones = true;
this.reportColaboracionPreguntas = true;
} else if (this.reportPreguntas) {
this.reportForEncuestas = false;
this.reportPreguntas = true;
this.reportsGeneral = true;
this.reportColaboraciones = true;
this.reportColaboracionPreguntas = true;
}
}
cambiarVistaColaboracion(cambio: string) {
if (cambio === 'colaboracion') {
this.reportForEncuestas = true;
this.reportPreguntas = true;
this.reportsGeneral = true;
this.reportColaboraciones = false;
this.reportColaboracionPreguntas = true;
} else if (cambio === 'preguntasColaboracion') {
this.reportForEncuestas = true;
this.reportPreguntas = true;
this.reportsGeneral = true;
this.reportColaboraciones = true;
this.reportColaboracionPreguntas = false;
}
}
@ -84,13 +114,17 @@ export class DashboardUserComponent implements OnInit {
this.isLoading = false;
const tmpEncuestas = res.body ?? [];
this.encuestas = tmpEncuestas.filter(e => e.usuarioExtra?.id === this.usuarioExtra?.id);
this.encuestas = tmpEncuestas.filter(e => e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED');
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;
this.cantPublicas = tmpEncuestas.filter(
e => e.acceso === 'PUBLIC' && e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED'
).length;
this.cantPrivadas = tmpEncuestas.filter(
e => e.acceso === 'PRIVATE' && e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED'
).length;
tmpEncuestas.forEach(encuesta => {
const _calificacion = encuesta.calificacion;
@ -103,7 +137,9 @@ export class DashboardUserComponent implements OnInit {
}
});
this.cantPersonas = tmpEncuestas.filter(e => e.calificacion && e.usuarioExtra?.id === this.usuarioExtra?.id).length;
this.cantPersonas = tmpEncuestas.filter(
e => e.calificacion && e.usuarioExtra?.id === this.usuarioExtra?.id && e.estado !== 'DELETED'
).length;
//cantidad de personas que han completado la encuesta
this.loadFirstChart();
@ -125,6 +161,7 @@ export class DashboardUserComponent implements OnInit {
});
this.loadEncuestas();
this.loadAllColaboraciones();
}
loadFirstChart(): void {
@ -220,12 +257,98 @@ export class DashboardUserComponent implements OnInit {
}
});
}
loadAllColaboraciones(): void {
this.usuarioEncuestaService.query().subscribe((res: HttpResponse<IUsuarioEncuesta[]>) => {
const tempUsuarioEncuestas = res.body ?? [];
this.usuarioEncuestas = tempUsuarioEncuestas
.filter(c => c.usuarioExtra?.id === this.usuarioExtra?.id)
.filter(c => c.encuesta?.estado !== 'DELETED');
// Fix calificacion
tempUsuarioEncuestas.forEach(colaboracion => {
if (colaboracion.encuesta) {
const _calificacion = colaboracion.encuesta.calificacion;
colaboracion.encuesta.calificacion = Number(_calificacion?.toString().split('.')[0]);
if (colaboracion.encuesta.fechaFinalizada == null) {
this.duracionColaboracion = -1;
} else {
this.duracionColaboracion = colaboracion.encuesta.fechaPublicacion?.diff(colaboracion.encuesta.fechaFinalizada!, 'days');
}
}
});
});
}
detallesPreguntasColaboracion(encuesta: IEncuesta): void {
if (!this.reportColaboraciones) {
this.reportPreguntas = true;
this.reportForEncuestas = true;
this.reportsGeneral = true;
this.reportColaboraciones = true;
this.reportColaboracionPreguntas = false;
}
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.ePreguntasOpcionesColaboracion = res.body ?? [];
//debugger;
this.getOpenQuestionAnswersColaboracion();
},
() => {
this.isLoading = false;
}
)
)
)
.subscribe(
(res: any) => {
this.isLoading = false;
this.ePreguntasColaboracion = res.body ?? [];
},
() => {
this.isLoading = false;
}
);
}
getOpenQuestionAnswersColaboracion() {
this.ePreguntasColaboracion!.forEach(pregunta => {
debugger;
if (!pregunta.tipo) {
this.resAbierta.query().subscribe(res => {
debugger;
this.preguntaIdColaboracion = pregunta.id;
this.respuestaAbiertaColaboracion = 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.respuestaAbiertaColaboracion);
});
}
});
}
}

View File

@ -79,11 +79,11 @@
</div>
</form>
<div class="ds-survey" id="entities" *ngIf="encuestas?.length === 0">
<div class="ds-survey" id="entitiesEncuestas" *ngIf="encuestas?.length === 0">
<div class="ds-survey--all-question-wrapper">
<ng-container class="">
<p class="ds-title text-center">No posee encuestas</p>
<p class="ds-subtitle text-center">Incie a explorar, colaborar y adquirir datos al crear encuestas mundialmente</p>
<p class="ds-subtitle text-center">Inicie a explorar, colaborar y adquirir datos al crear encuestas mundialmente</p>
</ng-container>
</div>
</div>

View File

@ -43,7 +43,7 @@
</div>
</div>
<div class="table-responsive" id="entities" *ngIf="usuarioEncuestas && usuarioEncuestas.length > 0">
<div class="table-responsive" id="entities2" *ngIf="usuarioEncuestas && usuarioEncuestas.length > 0">
<table class="ds-table table table-striped" aria-describedby="page-heading">
<thead>
<tr>