rajah 6 ماه پیش
والد
کامیت
dfaaff9533

+ 2 - 2
src/app/composants/poll-list/poll-list.component.ts

@@ -78,10 +78,10 @@ export class PollListComponent implements OnInit
 
   fermerVotes() { if (this.logged && (this.role === "ADMIN")) { this.categorieService.cloreScrutins().subscribe(() => { this.goToRefreshListCategorie(); }); } }
 
-  getResultatsPDF() { this.bulletinService.getResultatsPDF().subscribe(response => { this.savePDF(response.body, 'resultats.pdf'); }); }
+  getResultatsPDF() { this.bulletinService.getResultatsPDF().subscribe(response => { this.savePDF(response.body, 'ranks.all.pdf'); }); }
   savePDF(data: any, filename?: string) { const blob = new Blob([data], {type: 'application/pdf'}); saveAs(blob, filename); }
 
-  getDiaporama(id: number, nom: string) { this.bulletinService.getResultatsHTML(id).subscribe(response => { this.saveHTML(response.body, nom + '.html'); }); }
+  getDiaporama(id: number, nom: string) { this.bulletinService.getResultatsHTML(id).subscribe(response => { this.saveHTML(response.body, 'ranks.' + nom + '.html'); }); }
   saveHTML(data: any, filename?: string) { const blob = new Blob([data], {type: 'text/html'}); saveAs(blob, filename); }
 
   publierVotes() { if (this.logged && (this.role === "ADMIN")) { this.categorieService.publierVotes().subscribe(() => { this.goToRefreshListCategorie(); }); } }

+ 24 - 8
src/app/composants/result-list/result-list.component.html

@@ -11,20 +11,36 @@
   	</div>
   	<div class="card-body">
   		<table class="table table-sm">
-  			<thead class="thead-dark">
+        <thead class="thead-dark">
   				<tr>
-            <th class="fs-6 label-nobr"><small><span i18n>Catégorie</span></small></th>
-            <th class="fs-6 label-nobr"><small><span i18n>TODO : tout sur même page</span></small></th>
+            <th class="fs-6 label-nobr"><small><p i18n>Catégorie</p><p>&nbsp;</p></small></th>
+            <th class="fs-6 label-nobr text-sm-end"><small><p i18n>Rang</p><p>&nbsp;</p></small></th>
+            <th class="fs-6 label-nobr"><small><p i18n>Titre</p><p>&nbsp;</p></small></th>
+            <th class="fs-6 label-nobr"><small><p i18n>Auteur(s) / Groupe(s)</p><p>&nbsp;</p></small></th>
+            <th class="fs-6 label-nobr text-sm-end"><small><p i18n>Points</p><p>&nbsp;</p></small></th>
+            <th class="fs-6 label-nobr text-sm-end"><small><p i18n>Nb "First"</p><p>&nbsp;</p></small></th>
   				</tr>
   			</thead>
-  			<tbody>
-  				@for (categorie of categories; track categorie.numeroCategorie) {
+        @for (categorie of categories; track categorie.numeroCategorie; let c = $index) { @if (categories[c].displayable) {
+        <tbody>
+          {{ resetPositions() }} @for (production of productions[c]; track production.numeroProduction; let p = $index;) {  {{ setPositionReelle(c, p) }}
   				<tr>
-            <td class="label-nobr"><a class="link-primary pointeur-souris text-decoration-none">{{ categorie.libelle }}</a>&nbsp;&nbsp;</td>
-  					<td>@if (categorie.displayable) { <i class="fa-solid fa-circle-check text-success"></i> } @else { <i class="fa-solid fa-circle-xmark text-danger"></i> }&nbsp;&nbsp;</td>
+            @if (p == 0) { <td class="fs-5 label-nobr" [attr.rowspan]="$count">{{ categorie.libelle }}&nbsp;&nbsp;&nbsp;</td> }
+            <td class="fs-6 label-nobr text-sm-end"><small>{{ positionReelle }}</small></td>
+            <td class="fs-6">
+              <a (click)="getFile(production.numeroProduction, production.groupes, production.titre)" class="link-primary pointeur-souris text-decoration-none">{{ production.titre }}</a>
+              @if (production.plateforme) { <span class="text-muted">&nbsp;<span i18n>sur</span> {{ production.plateforme }} </span> }</td>
+            <td class="fs-6"><small>{{ production.auteurs }} @if (production.groupes) {  /  {{ production.groupes }} }</small></td>
+            <td class="fs-6 label-nobr text-sm-end"><small>{{ production.nombrePoints }}</small></td>
+            <td class="fs-6 label-nobr text-sm-end"><small>{{ production.nombreFirst }}</small></td>
   				</tr>
-  				}
+          {{ incrementePosition() }} }
+          <tr>
+            <td class="fs-6 label-nobr" colspan="4">&nbsp;</td>
+            <td class="fs-6 label-nobr text-sm-end" colspan="2"><small><p i18n>{{ nombreVotants[c] }} votant(s)</p><p>&nbsp;</p></small></td>
+          </tr>
   			</tbody>
+        } }
   		</table>
   	</div>
   </div>

+ 43 - 2
src/app/composants/result-list/result-list.component.ts

@@ -1,9 +1,13 @@
 import { Component, OnInit } from '@angular/core';
 import { Router, ActivatedRoute } from '@angular/router';
+import { saveAs } from 'file-saver';
 
 import { MenuComponent } from '../menu/menu.component';
 import { Categorie } from '../../interfaces/categorie';
+import { ProductionVote } from '../../interfaces/production';
 import { CategorieService } from '../../services/categorie.service';
+import { BulletinService } from '../../services/bulletin.service';
+import { ProductionService } from '../../services/production.service';
 
 @Component({ selector: 'app-result-list', imports: [MenuComponent], templateUrl: './result-list.component.html', styleUrl: './result-list.component.css' })
 
@@ -11,17 +15,54 @@ export class ResultListComponent implements OnInit
 {
 
   categories: Categorie[] = [];
+  nombreVotants: number[] = [];
+  productions: ProductionVote[][] = [[]];
 
   constructor(
     private categorieService: CategorieService,
     private router: Router,
-    private route: ActivatedRoute
+    private route: ActivatedRoute,
+    private bulletinService: BulletinService,
+    private productionService: ProductionService
   ) { }
 
   ngOnInit() { this.goToRefreshListCategorie(); }
 
-  private retreiveDatas() { this.categorieService.getListCategorie(false).subscribe(data => { this.categories = data; }); }
+  private retreiveDatas()
+  {
+    this.categorieService.getListCategorie(false).subscribe(datac => {
+      this.categories = datac;
+      if (this.categories)
+      {
+        if (this.categories.length > 0)
+        {
+          for (let i = 0; i < this.categories.length; i++)
+          {
+            this.bulletinService.getResultats(this.categories[i].numeroCategorie).subscribe(datap => { this.productions[i] = datap; });
+            this.bulletinService.getNombreVotants(this.categories[i].numeroCategorie).subscribe(datav => { this.nombreVotants[i] = Number('' + datav); });
+          }
+        }
+      }
+    });
+  }
+
+  positionReelle: number = 1;
+  positionCachee: number = 1;
+  resetPositions() { this.positionReelle = 1; this.positionCachee = 1; }
+  setPositionReelle(c: number, p: number)
+  {
+    if (p > 0)
+    {
+      if ((this.productions[c][p].nombrePoints == this.productions[c][p - 1].nombrePoints) && (this.productions[c][p].nombreFirst == this.productions[c][p - 1].nombreFirst)) { }
+      else { this.positionReelle = this.positionCachee; }
+    }
+    else { this.positionReelle = this.positionCachee; }
+  }
+  incrementePosition() { this.positionCachee++; }
 
   goToRefreshListCategorie() { this.retreiveDatas(); }
 
+  getFile(id: number, groupe: string, titre: string) { this.productionService.getProductionFile(id).subscribe(response => { this.saveFile(response.body, 'prod.' + groupe + ' - ' + titre + '.zip'); }); }
+  saveFile(data: any, filename?: string) { const blob = new Blob([data], {type: 'application/zip'}); saveAs(blob, filename); }
+
 }

+ 2 - 2
src/app/composants/show-list/show-list.component.ts

@@ -49,10 +49,10 @@ export class ShowListComponent implements OnInit
   lierProductions(id: number) { this.router.navigate(['/show-links', id]); }
   formPresentation(id: number) { this.router.navigate(['/show-upload', id]); }
 
-  getVersionPDF() { this.presentationService.getPresentationPDF().subscribe(response => { this.savePDF(response.body, 'presentations.pdf'); }); }
+  getVersionPDF() { this.presentationService.getPresentationPDF().subscribe(response => { this.savePDF(response.body, 'shows.all.pdf'); }); }
   savePDF(data: any, filename?: string) { const blob = new Blob([data], {type: 'application/pdf'}); saveAs(blob, filename); }
 
-  getDiaporama(id: number, nom: string) { this.presentationService.getPresentationHTML(id).subscribe(response => { this.saveHTML(response.body, nom + '.html'); }); }
+  getDiaporama(id: number, nom: string) { this.presentationService.getPresentationHTML(id).subscribe(response => { this.saveHTML(response.body, 'shows.' + nom + '.html'); }); }
   saveHTML(data: any, filename?: string) { const blob = new Blob([data], {type: 'text/html'}); saveAs(blob, filename); }
 
   getFile(id: number, nom: string) { this.productionService.getProductionFile(id).subscribe(response => { this.saveFile(response.body, nom); }); }

+ 14 - 0
src/app/interfaces/production.ts

@@ -83,6 +83,20 @@ export class ProductionChoice
   vignette!: string | any;
 }
 
+export class ProductionVote
+{
+  numeroProduction: number = 0;
+  type: string = "AUTRE";
+  titre: string = "";
+  auteurs: string = "";
+  groupes: string = "";
+  plateforme: string = "";
+  informationsPrivees: string = "";
+  nomGestionnaire: string = "";
+  nombrePoints: number = 0;
+  nombreFirst: number = 0;
+}
+
 export class PresentationFile
 {
   numeroProduction: number = 0;

+ 4 - 1
src/app/services/bulletin.service.ts

@@ -3,7 +3,7 @@ import { HttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/comm
 import { Observable } from 'rxjs';
 
 import { Environnement } from '../env';
-import { ProductionChoice } from '../interfaces/production';
+import { ProductionChoice, ProductionVote } from '../interfaces/production';
 import { Message } from '../interfaces/divers';
 
 @Injectable({ providedIn: 'root' })
@@ -80,4 +80,7 @@ export class BulletinService
     return this.httpClient.get(`${this.baseURL}/diapos/${id}`, { headers: headers, observe: 'response', responseType: 'blob' });
   }
 
+  getResultats(id: number): Observable<ProductionVote[]> { return this.httpClient.get<ProductionVote[]>(`${this.baseURL}/results/${id}`); }
+  getNombreVotants(id: number): Observable<Object> { return this.httpClient.get<Object>(`${this.baseURL}/count-voters/${id}`); }
+
 }