Skip to content
Snippets Groups Projects
Commit 443d8d88 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'feat/US175-mailchimp' into 'V2.0'

US175: remove newsletter from admin panel

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!326
parents b0a43385 9ba85251
No related branches found
No related tags found
4 merge requests!418V2.1.0,!400V2.0,!326US175: remove newsletter from admin panel,!230V2.0
......@@ -4,7 +4,6 @@ import { PanelComponent } from './components/panel/panel.component';
import { ClaimStructureComponent } from './components/claim-structure/claim-structure.component';
import { ManageUsersComponent } from './components/manage-users/manage-users.component';
import { SharedModule } from '../shared/shared.module';
import { NewsletterUsersComponent } from './components/newsletter-users/newsletter-users.component';
import { AdminStructuresListComponent } from './components/structures-list/admin-structures-list.component';
import { ManageLockdownInfoComponent } from './components/lockdown-info/manage-lockdown-info.component';
import { AdminRoutingModule } from './admin-routing.module';
......@@ -26,7 +25,6 @@ import { JobPersonalOffer } from './components/manage-jobs/jobPersonalOffer/job-
declarations: [
PanelComponent,
ClaimStructureComponent,
NewsletterUsersComponent,
AdminStructuresListComponent,
ManageLockdownInfoComponent,
ManageUsersComponent,
......@@ -41,13 +39,13 @@ import { JobPersonalOffer } from './components/manage-jobs/jobPersonalOffer/job-
AdministredStructuresComponent,
AttachedUsersComponent,
ManageJobsComponent,
ManageEmployersComponent,
ManageEmployersComponent
],
imports: [
CommonModule,
AdminRoutingModule,
SharedModule,
AgGridModule.withComponents([DeleteUserComponent, AdministredStructuresComponent]),
],
AgGridModule.withComponents([DeleteUserComponent, AdministredStructuresComponent])
]
})
export class AdminModule {}
<div fxLayout="column" fxLayoutGap="5px" fxLayoutAlign="center center" class="userBlock">
<h2>Gestion abonnement newsletter</h2>
<div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center center">
<button (click)="copySubscription()">Copier les adresses dans le presse papier</button>
<button (click)="searchSubscribedEmail('')">Afficher tous les inscrits</button>
</div>
<div fxLayout="row">Il y a actuellement {{ subscriptionsCount }} abonnés à la newsletter.</div>
<div fxLayout="row">
<input #searchstring (keyup)="(0)" />
<button (click)="searchSubscribedEmail(searchstring.value)">Rechercher</button>
</div>
<div class="userList">
<tr *ngFor="let subscription of subscriptions">
<td>{{ subscription.email }}</td>
<td>
<button (click)="toggleUnsubscribeModal(subscription.email)">Désabonner</button>
</td>
</tr>
<app-modal-confirmation
*ngIf="emailToUnsubscribe"
[openned]="deleteModalOpenned"
[content]="'Voulez-vous vraiment supprimer ' + emailToUnsubscribe + ' de la newsletter &nbsp;?'"
(closed)="unsubscribeEmail(emailToUnsubscribe, $event)"
></app-modal-confirmation>
<div *ngIf="subscriptions && subscriptions.length == 0">Aucun résultat</div>
</div>
</div>
import { HttpClientModule } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NewsletterUsersComponent } from './newsletter-users.component';
describe('DeleteUserComponent', () => {
let component: NewsletterUsersComponent;
let fixture: ComponentFixture<NewsletterUsersComponent>;
let USERS;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HttpClientModule],
declarations: [NewsletterUsersComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NewsletterUsersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
import { NewsletterSubscription } from '../../../models/subscription-model';
import { AdminService } from '../../services/admin.service';
@Component({
selector: 'app-admin-newsletter-users',
templateUrl: './newsletter-users.component.html',
})
export class NewsletterUsersComponent {
public subscriptions: NewsletterSubscription[];
public deleteModalOpenned = false;
public emailToUnsubscribe: string = null;
public subscriptionsCount: number = 0;
constructor(private adminService: AdminService) {}
ngOnInit(): void {
this.adminService.countNewsletterSubscriptions().subscribe((count) => {
this.subscriptionsCount = count;
});
}
public toggleUnsubscribeModal(emailToUnsubscribe: string): void {
this.emailToUnsubscribe = emailToUnsubscribe;
this.deleteModalOpenned = !this.deleteModalOpenned;
}
public searchSubscribedEmail(searchString: string): void {
this.adminService.searchNewsletterSubscriptions(searchString).subscribe((emails) => {
this.subscriptions = emails;
});
}
public unsubscribeEmail(email: string, shouldUnsubscribe: boolean): void {
this.toggleUnsubscribeModal(email);
if (shouldUnsubscribe) {
this.adminService.unsubscribeEmail(email).subscribe((_data) => {
this.subscriptions = this.subscriptions.filter((obj) => obj.email !== email);
this.subscriptionsCount = this.subscriptions.length;
});
}
}
public copySubscription(): void {
this.adminService.searchNewsletterSubscriptions('').subscribe((emails) => {
let emailsToBeCopied = emails.map((e) => e.email).join(';');
let copyElement = document.createElement('textarea');
copyElement.textContent = decodeURI(emailsToBeCopied);
let body = document.getElementsByTagName('body')[0];
body.appendChild(copyElement);
copyElement.select();
document.execCommand('copy');
body.removeChild(copyElement);
});
}
}
......@@ -5,7 +5,6 @@
<button (click)="changeActiveFeature(features.structuresList)">Liste structures</button>
<button (click)="changeActiveFeature(features.manageUsers)">Gestion des utilisateurs</button>
<button (click)="changeActiveFeature(features.lockdownInfo)">Gestion des infos covid</button>
<button (click)="changeActiveFeature(features.newsletterUsers)">Newsletter</button>
<button (click)="changeActiveFeature(features.jobsList)">Fonctions</button>
<button (click)="changeActiveFeature(features.employersList)">Employeurs</button>
<a target="_blank" class="custom-link" rel="noopener noreferrer" [href]="ghostLink">Ghost</a>
......@@ -22,9 +21,6 @@
<div *ngIf="selectedFeature === features.lockdownInfo">
<app-admin-manage-lockdown-info></app-admin-manage-lockdown-info>
</div>
<div *ngIf="selectedFeature === features.newsletterUsers">
<app-admin-newsletter-users></app-admin-newsletter-users>
</div>
<div *ngIf="selectedFeature === features.jobsList">
<app-admin-manage-jobs></app-admin-manage-jobs>
</div>
......
......@@ -6,7 +6,7 @@ import { PanelRouteService } from '../../services/panel-route.service';
@Component({
selector: 'app-admin-panel',
templateUrl: './panel.component.html',
providers: [PanelRouteService],
providers: [PanelRouteService]
})
export class PanelComponent implements OnInit {
public features = AdminPannelEnum;
......
export enum AdminPannelEnum {
manageUsers,
pendingStructures,
newsletterUsers,
structuresList,
jobsList,
employersList,
lockdownInfo,
lockdownInfo
}
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