From 7427957e9c28f18df4fce17f88f8d51ae59886e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Tue, 16 Feb 2021 10:55:45 +0100 Subject: [PATCH] =?UTF-8?q?Affichage=20de=20la=20liste=20des=20notes=20pri?= =?UTF-8?q?ses=20par=20l'utilisateur=20connect=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/notes/notes.component.html | 57 ++++++++++++++++++- src/app/notes/notes.component.ts | 57 ++++++++++++++++--- src/app/notes/notes.module.ts | 3 +- .../shared/api-swagger/api/notes.service.ts | 2 +- 4 files changed, 109 insertions(+), 10 deletions(-) diff --git a/src/app/notes/notes.component.html b/src/app/notes/notes.component.html index 712194f..31766c1 100644 --- a/src/app/notes/notes.component.html +++ b/src/app/notes/notes.component.html @@ -1,2 +1,57 @@ -

Liste de vos notes

\ No newline at end of file +

Liste de vos notes

+ + + + + + + + + Rechercher un collaborateur + + + close + + + + +

Vous n'avez aucune note à afficher

+
+ + + + + + + Collaborateur + {{ row.collaborateur }} + + + + Titre + {{ row.titre }} + + + + Dernière mise à jour + {{ row.dateMiseAJour | date : 'dd/MM/yyyy'}} + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/app/notes/notes.component.ts b/src/app/notes/notes.component.ts index 3b9a69c..9c32ada 100644 --- a/src/app/notes/notes.component.ts +++ b/src/app/notes/notes.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from "@angular/core"; -import { CollaborateurDTO, NotesService } from "@shared/api-swagger"; +import { MatTableDataSource } from "@angular/material/table"; +import { AffichageNoteDTO, CollaborateurDTO, NotesService } from "@shared/api-swagger"; import { cles } from "@shared/utils/cles"; import { Subscription } from "rxjs"; @@ -9,24 +10,44 @@ import { Subscription } from "rxjs"; }) export class NotesComponent implements OnInit { + + displayedColumns : string[] = ["collaborateur", "titre", "datemiseajour"]; + chargement: boolean = true; + asc: boolean = true; numPage: number = 1; - parPage: number= 15; - - texte: string = ""; + parPage: number = 15; tri: string = ""; + search: string = ""; - notesSubscriber: Subscription; + taille: number = 0; + notesSubscriber: Subscription; + notesCountSubscriber: Subscription; id: string; + + dataSource: MatTableDataSource; + + pageOption = [ 5, 15, 20, 30, 50]; + constructor(private notesService: NotesService) { } + setSearch() { + this.numPage = 1; + this.updateDataSource(); + } + + resetSearch() { + this.search = ""; + this.setSearch(); + } + ngOnInit() { this.recupererId(); } @@ -38,15 +59,37 @@ export class NotesComponent implements OnInit { else { const collaborateurConnecte : CollaborateurDTO = JSON.parse(sessionStorage.getItem(cles.sessionKeyConnectee)); this.id = collaborateurConnecte.id; + this.chargement = false; this.updateDataSource(); } } updateDataSource() { - this.notesSubscriber = this.notesService.getNotesAuteur(this.id, this.asc, this.numPage, this.parPage, this.texte, this.tri).subscribe( - notes => { console.log(notes)}, + this.notesSubscriber = this.notesService.getNotesAuteur(this.id, this.asc, this.numPage, this.parPage, this.search, this.tri).subscribe( + notes => { console.log(notes); this.dataSource = new MatTableDataSource(notes);}, + err => console.log(err) + ); + + this.notesCountSubscriber = this.notesService.getNotesAuteurCount(this.id, this.asc, this.numPage, this.parPage, this.search, this.tri).subscribe( + count => this.taille = count, err => console.log(err) ); } + + updatePageInfo(event){ + this.parPage = event.pageSize; + this.numPage = event.pageIndex+1; + this.updateDataSource(); + } + + + ngOnDestroy() { + if(this.notesSubscriber != undefined) { + this.notesSubscriber.unsubscribe(); + } + if(this.notesCountSubscriber != undefined) { + this.notesCountSubscriber.unsubscribe(); + } + } } \ No newline at end of file diff --git a/src/app/notes/notes.module.ts b/src/app/notes/notes.module.ts index d3662b9..fb9c805 100644 --- a/src/app/notes/notes.module.ts +++ b/src/app/notes/notes.module.ts @@ -6,6 +6,7 @@ import { MaterialModule } from "@shared/angular-material/angular-material.module import {NavMenuModule} from '@shared/nav-menu/nav-menu.module'; import { NotesComponent } from "./notes.component"; +import { FormsModule } from "@angular/forms"; @NgModule({ declarations: [ @@ -17,7 +18,7 @@ import { NotesComponent } from "./notes.component"; NavMenuModule, RouterModule, NotesRoutingModule, - + FormsModule ], }) export class NotesModule {} \ No newline at end of file diff --git a/src/app/shared/api-swagger/api/notes.service.ts b/src/app/shared/api-swagger/api/notes.service.ts index 71b798e..911e58a 100644 --- a/src/app/shared/api-swagger/api/notes.service.ts +++ b/src/app/shared/api-swagger/api/notes.service.ts @@ -348,7 +348,7 @@ export class NotesService { const consumes: string[] = [ ]; - return this.httpClient.request('get',`${this.basePath}/notes/${encodeURIComponent(String(idAuteur))}/count`, + return this.httpClient.request('get',`${this.basePath}/notes/auteur/${encodeURIComponent(String(idAuteur))}/count`, { params: queryParameters, withCredentials: this.configuration.withCredentials,