import { Component, OnInit, ViewChild } from '@angular/core'; import { UserProfileService } from 'src/app/shared/services/user.profile.service'; import { EmailAuditFilter, EmailAudit } from 'tournee.businesslogic'; import { AuthService } from 'src/app/shared/services/auth.service'; import { FeedbackPanelComponent } from 'src/app/shared/components/feedback-panel/feedback-panel.component'; @Component({ selector: 'app-user-selectable-listing-user-email', templateUrl: './user-selectable-listing-user-email.component.html', styleUrls: ['./user-selectable-listing-user-email.component.css'], providers: [ UserProfileService ] }) export class UserSelectableListingUserEmailComponent implements OnInit { isWorking: boolean = false; @ViewChild('FeedbackPanel') FeedbackPanel:FeedbackPanelComponent; Filter: EmailAuditFilter = EmailAuditFilter.create().set('user_id', this._auth.User.id); Results: Array = []; constructor(private _profile: UserProfileService, private _auth: AuthService) { } ngOnInit() { this.load(); } load() { this.isWorking = true; this._profile.my_emails(this.Filter) .then((result) => { this.Results = result.result.map((ea) => { return new EmailAudit(ea); }); this.isWorking = false; }) .catch((err) => { this.isWorking = false; this.FeedbackPanel.triggerError(err); }); } get_icon(audit: EmailAudit) : string { switch (audit.audit_type) { case 'privacypreferences': return 'fas fa-user-secret'; case 'system': return 'fas fa-comment' case 'transactional': return 'fas fa-shopping-cart'; case 'marketing': return 'fas fa-mail-bulk'; default: break; } } ToggleSystem() { this.Filter.include_system = !this.Filter.include_system; this.load(); } ToggleTransactional() { this.Filter.include_transactional = !this.Filter.include_transactional; this.load(); } ToggleMarketing() { this.Filter.include_marketing = !this.Filter.include_marketing; this.load(); } button_class(property) { if (this.Filter[property]) { return 'btn-success'; } return 'btn-border-dark'; } }