Skip to content
Snippets Groups Projects
Commit d8a36d45 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/admin-pannel-structure' into 'dev'

Feat/admin pannel structure

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!147
parents 40fd4db1 20fa1b02
No related branches found
No related tags found
3 merge requests!178release V1.10.0,!154Dev,!147Feat/admin pannel structure
Showing
with 218 additions and 22 deletions
.selector {
margin-bottom: 20px;
.option {
margin-right: 30px;
}
}
.results-tab {
margin-bottom: 20px;
}
.results-column {
width: 30%;
}
...@@ -5,10 +5,11 @@ import { ClaimStructureComponent } from './components/claim-structure/claim-stru ...@@ -5,10 +5,11 @@ import { ClaimStructureComponent } from './components/claim-structure/claim-stru
import { DeleteUserComponent } from './components/delete-user/delete-user.component'; import { DeleteUserComponent } from './components/delete-user/delete-user.component';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
import { NewsletterUsersComponent } from './components/newsletter-users/newsletter-users.component'; import { NewsletterUsersComponent } from './components/newsletter-users/newsletter-users.component';
import { AdminStructuresListComponent } from './components/structures-list/admin-structures-list.component';
import { AdminRoutingModule } from './admin-routing.module'; import { AdminRoutingModule } from './admin-routing.module';
@NgModule({ @NgModule({
declarations: [PanelComponent, ClaimStructureComponent, DeleteUserComponent, NewsletterUsersComponent], declarations: [PanelComponent, ClaimStructureComponent, DeleteUserComponent, NewsletterUsersComponent, AdminStructuresListComponent],
imports: [CommonModule, AdminRoutingModule, SharedModule], imports: [CommonModule, AdminRoutingModule, SharedModule],
}) })
export class AdminModule {} export class AdminModule {}
<div fxLayout="row" fxLayoutAlign="center center"> <div fxLayout="column" fxLayoutAlign="center center">
<table *ngIf="demandsAttachment" aria-describedby="demands attachment results"> <table *ngIf="isClaimedStructure" aria-describedby="demands attachment results" class="results-tab">
<thead> <thead>
<th scope="col">Utilisateur</th> <th scope="col">Utilisateur</th>
<th scope="col">Structure</th> <th scope="col">Structure</th>
<th scope="col">Options</th> <th scope="col">Options</th>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let demand of demandsAttachment"> <tr *ngFor="let structure of demandsAttachment">
<td>{{ demand.userEmail }}</td> <td>{{ structure.userEmail }}</td>
<td>{{ demand.structureName }}</td> <td>{{ structure.structureName }}</td>
<td> <td>
<button (click)="acceptDemand(demand)">Valider</button><button (click)="refuseDemand(demand)">Refuser</button> <button (click)="acceptDemand(structure)">Valider</button
><button (click)="refuseDemand(structure)">Refuser</button>
</td> </td>
</tr> </tr>
<tr *ngIf="!demandsAttachment.length"> <tr *ngIf="!demandsAttachment?.length">
<td colspan="3">Aucune demande en attente</td> <td colspan="3">Aucune demande en attente</td>
</tr> </tr>
</tbody> </tbody>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { DemandAttachment } from '../../models/demandAttachment.model'; import { StructureAdminInfo } from '../../models/demandAttachment.model';
import { AdminService } from '../../services/admin.service'; import { AdminService } from '../../services/admin.service';
@Component({ @Component({
selector: 'app-admin-claim-structure', selector: 'app-admin-claim-structure',
templateUrl: './claim-structure.component.html', templateUrl: './claim-structure.component.html',
styleUrls: ['../../admin-pannel.scss'],
}) })
export class ClaimStructureComponent implements OnInit { export class ClaimStructureComponent implements OnInit {
public demandsAttachment: DemandAttachment[]; public demandsAttachment: StructureAdminInfo[];
public structuresUnclaimed: StructureAdminInfo[];
public isClaimedStructure: boolean = true;
public isUnclaimedStructure: boolean = false;
constructor(private adminService: AdminService) {} constructor(private adminService: AdminService) {}
ngOnInit(): void { ngOnInit(): void {
...@@ -16,7 +20,7 @@ export class ClaimStructureComponent implements OnInit { ...@@ -16,7 +20,7 @@ export class ClaimStructureComponent implements OnInit {
}); });
} }
public acceptDemand(demand: DemandAttachment): void { public acceptDemand(demand: StructureAdminInfo): void {
this.adminService this.adminService
.acceptStructureClaim(demand.userEmail, demand.structureId, demand.structureName) .acceptStructureClaim(demand.userEmail, demand.structureId, demand.structureName)
.subscribe((data) => { .subscribe((data) => {
...@@ -24,11 +28,15 @@ export class ClaimStructureComponent implements OnInit { ...@@ -24,11 +28,15 @@ export class ClaimStructureComponent implements OnInit {
}); });
} }
public refuseDemand(demand: DemandAttachment): void { public refuseDemand(demand: StructureAdminInfo): void {
this.adminService this.adminService
.refuseStructureClaim(demand.userEmail, demand.structureId, demand.structureName) .refuseStructureClaim(demand.userEmail, demand.structureId, demand.structureName)
.subscribe((data) => { .subscribe((data) => {
this.demandsAttachment = data; this.demandsAttachment = data;
}); });
} }
public claimedStructure(event: boolean): void {
this.isClaimedStructure = !this.isClaimedStructure;
}
} }
<div fxLayout="column" fxLayoutGap="20px" class="content-container full-screen"> <div fxLayout="column" fxLayoutGap="20px" class="content-container full-screen">
<div fxLayout="row" fxLayoutAlign="center center"><h1>Administration</h1></div> <div fxLayout="row" fxLayoutAlign="center center"><h1>Administration</h1></div>
<div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center center"> <div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center center">
<button (click)="changeActiveFeature(features.pendingStructures)">Gestion structure</button> <button (click)="changeActiveFeature(features.pendingStructures)">Revendication structure</button>
<button (click)="changeActiveFeature(features.structuresList)">Liste structures</button>
<button (click)="changeActiveFeature(features.deleteUsers)">Suppression d'utilisateurs</button> <button (click)="changeActiveFeature(features.deleteUsers)">Suppression d'utilisateurs</button>
<button (click)="changeActiveFeature(features.newsletterUsers)">Newsletter</button> <button (click)="changeActiveFeature(features.newsletterUsers)">Newsletter</button>
<a target="_blank" class="custom-link" rel="noopener noreferrer" [href]="ghostLink">Ghost</a> <a target="_blank" class="custom-link" rel="noopener noreferrer" [href]="ghostLink">Ghost</a>
</div> </div>
<div *ngIf="selectedFeature === features.structuresList">
<app-admin-structures-list></app-admin-structures-list>
</div>
<div *ngIf="selectedFeature === features.deleteUsers"> <div *ngIf="selectedFeature === features.deleteUsers">
<app-admin-delete-user></app-admin-delete-user> <app-admin-delete-user></app-admin-delete-user>
</div> </div>
......
<div fxLayout="column" fxLayoutAlign="center center">
<div fxLayout="row" class="selector">
<div fxLayout="row" class="checkbox no-width">
<div class="checkboxItem">
<label>
<input type="checkbox" [checked]="isInClaimStructure" (change)="inClaimStructure($event)" />
<span class="customCheck"></span>
<div class="label pass option">En revendication</div>
</label>
</div>
<div class="checkboxItem">
<label>
<input type="checkbox" [checked]="isClaimedStructure" (change)="claimedStructure($event)" />
<span class="customCheck"></span>
<div class="label pass option">Revendiquées</div>
</label>
</div>
<div class="checkboxItem">
<label>
<input type="checkbox" [checked]="isToClaimStructure" (change)="toClaimStructure($event)" />
<span class="customCheck"></span>
<div class="label pass option">Non revendiquées</div>
</label>
</div>
<div class="checkboxItem">
<label>
<input type="checkbox" [checked]="isAll" (change)="allStructure($event)" />
<span class="customCheck"></span>
<div class="label pass option">Toutes</div>
</label>
</div>
</div>
</div>
<div *ngIf="!isInClaimStructure && !isToClaimStructure && !isClaimedStructure">
Choisir un filtre pour afficher la liste des structures
</div>
<table *ngIf="isInClaimStructure" aria-describedby="demands attachment results" class="results-tab results-column">
<thead>
<th scope="col">Structures en cours de revendication ({{ structuresInClaim.length }})</th>
</thead>
<tbody>
<tr *ngFor="let structure of structuresInClaim">
<td>
<a href="/acteurs?id={{ structure.structureId }}" target="_blank"> {{ structure.structureName }}</a>
</td>
</tr>
<tr *ngIf="!structuresInClaim?.length">
<td colspan="3">Aucune structure</td>
</tr>
</tbody>
</table>
<table *ngIf="isToClaimStructure" aria-describedby="demands attachment results" class="results-tab results-column">
<thead>
<th scope="col">Structures à revendiquer ({{ structuresToClaim.length }})</th>
</thead>
<tbody>
<tr *ngFor="let structure of structuresToClaim">
<td>
<a href="/acteurs?id={{ structure.structureId }}" target="_blank"> {{ structure.structureName }}</a>
</td>
</tr>
<tr *ngIf="!structuresToClaim?.length">
<td colspan="3">Aucune structure</td>
</tr>
</tbody>
</table>
<table *ngIf="isClaimedStructure" aria-describedby="demands attachment results" class="results-tab results-column">
<thead>
<th scope="col">Structures revendiquées ({{ structuresClaimed.length }})</th>
</thead>
<tbody>
<tr *ngFor="let structure of structuresClaimed">
<td>
<a href="/acteurs?id={{ structure.structureId }}" target="_blank"> {{ structure.structureName }}</a>
</td>
</tr>
<tr *ngIf="!structuresInClaim?.length">
<td colspan="3">Aucune structure</td>
</tr>
</tbody>
</table>
</div>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminStructuresListComponent } from './admin-structures-list.component';
describe('AdminStructuresListComponent', () => {
let component: AdminStructuresListComponent;
let fixture: ComponentFixture<AdminStructuresListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AdminStructuresListComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AdminStructuresListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { StructureAdminInfo } from '../../models/demandAttachment.model';
import { AdminService } from '../../services/admin.service';
@Component({
selector: 'app-admin-structures-list',
templateUrl: './admin-structures-list.component.html',
styleUrls: ['../../admin-pannel.scss'],
})
export class AdminStructuresListComponent implements OnInit {
public structuresInClaim: StructureAdminInfo[];
public structuresToClaim: StructureAdminInfo[];
public structuresClaimed: StructureAdminInfo[];
public isClaimedStructure: boolean = false;
public isToClaimStructure: boolean = false;
public isInClaimStructure: boolean = true;
public isAll: boolean = false;
constructor(private adminService: AdminService) {}
ngOnInit(): void {
this.adminService.getAllStructureAdmin().subscribe((structures) => {
this.structuresClaimed = structures.claimed;
this.structuresInClaim = structures.inClaim;
this.structuresToClaim = structures.toClaim;
});
}
public claimedStructure(event: boolean): void {
this.isClaimedStructure = !this.isClaimedStructure;
}
public toClaimStructure(event: boolean): void {
this.isToClaimStructure = !this.isToClaimStructure;
}
public inClaimStructure(event: boolean): void {
this.isInClaimStructure = !this.isInClaimStructure;
}
public allStructure(event: boolean): void {
if (!this.isAll) {
this.isAll = !this.isAll;
this.isInClaimStructure = true;
this.isToClaimStructure = true;
this.isClaimedStructure = true;
} else {
this.isAll = !this.isAll;
this.isInClaimStructure = false;
this.isToClaimStructure = false;
this.isClaimedStructure = false;
}
}
}
export class DemandAttachment { export class StructureAdminInfo {
userEmail: string; userEmail: string;
structureId: number; structureId: number;
structureName: string; structureName: string;
......
...@@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; ...@@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { NewsletterSubscription } from '../../models/subscription-model'; import { NewsletterSubscription } from '../../models/subscription-model';
import { User } from '../../models/user.model'; import { User } from '../../models/user.model';
import { DemandAttachment } from '../models/demandAttachment.model'; import { StructureAdminInfo } from '../models/demandAttachment.model';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
...@@ -13,8 +13,16 @@ export class AdminService { ...@@ -13,8 +13,16 @@ export class AdminService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
// Return pendingAttachments of all profiles. // Return pendingAttachments of all profiles.
public getPendingStructure(): Observable<DemandAttachment[]> { public getPendingStructure(): Observable<StructureAdminInfo[]> {
return this.http.get<DemandAttachment[]>(`${this.baseUrl}/pendingStructures`); return this.http.get<StructureAdminInfo[]>(`${this.baseUrl}/pendingStructures`);
}
public getToClaimStructure(): Observable<StructureAdminInfo[]> {
return this.http.get<StructureAdminInfo[]>(`${this.baseUrl}/unclaimedStructures`);
}
public getAllStructureAdmin(): Observable<any> {
return this.http.get<StructureAdminInfo[]>(`${this.baseUrl}/adminStructuresList`);
} }
public getUsers(): Observable<User[]> { public getUsers(): Observable<User[]> {
...@@ -45,8 +53,8 @@ export class AdminService { ...@@ -45,8 +53,8 @@ export class AdminService {
userEmail: string, userEmail: string,
structureId: number, structureId: number,
structureName: string structureName: string
): Observable<DemandAttachment[]> { ): Observable<StructureAdminInfo[]> {
return this.http.post<DemandAttachment[]>(`${this.baseUrl}/validatePendingStructure`, { return this.http.post<StructureAdminInfo[]>(`${this.baseUrl}/validatePendingStructure`, {
userEmail, userEmail,
structureId, structureId,
structureName, structureName,
...@@ -57,8 +65,8 @@ export class AdminService { ...@@ -57,8 +65,8 @@ export class AdminService {
userEmail: string, userEmail: string,
structureId: number, structureId: number,
structureName: string structureName: string
): Observable<DemandAttachment[]> { ): Observable<StructureAdminInfo[]> {
return this.http.post<DemandAttachment[]>(`${this.baseUrl}/rejectPendingStructure`, { return this.http.post<StructureAdminInfo[]>(`${this.baseUrl}/rejectPendingStructure`, {
userEmail, userEmail,
structureId, structureId,
structureName, structureName,
......
export enum AdminPannelEnum { export enum AdminPannelEnum {
deleteUsers, deleteUsers,
pendingStructures, pendingStructures,
newsletterUsers newsletterUsers,
structuresList,
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment