Skip to content

Commit

Permalink
Merge pull request #6110 from deNBI/refactor/templated_mail
Browse files Browse the repository at this point in the history
Refactor/templated mail
  • Loading branch information
dweinholz authored Jul 9, 2024
2 parents 2fd7cf7 + 5084277 commit 165e0e7
Show file tree
Hide file tree
Showing 16 changed files with 622 additions and 338 deletions.
112 changes: 56 additions & 56 deletions src/app/applications/application-list/application-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,72 @@ import { is_vo } from '../../shared/globalvar';
styleUrl: './application-list.component.scss',
})
export class ApplicationListComponent implements OnInit, OnChanges {
@Output() reloadNumbersTrigger: EventEmitter<void> = new EventEmitter();
@Output() reloadNumbersTrigger: EventEmitter<void> = new EventEmitter();

@Input() applications: Application[] = [];
@Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED;
@Input() computeCenters: ComputecenterComponent[] = [];
@Input() facilityView: boolean = false;
@Input() voView: boolean = false;
dataTestId: string = '';
@Input() applications: Application[] = [];
@Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED;
@Input() computeCenters: ComputecenterComponent[] = [];
@Input() facilityView: boolean = false;
@Input() voView: boolean = false;
dataTestId: string = '';

is_vo_admin: boolean = false;
is_vo_admin: boolean = false;

ngOnInit() {
this.is_vo_admin = is_vo;
this.setDataTestId();
}

ngOnChanges(changes: SimpleChanges) {
this.setDataTestId();
ngOnInit() {
this.is_vo_admin = is_vo;
this.setDataTestId();
}

}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ngOnChanges(changes: SimpleChanges) {
this.setDataTestId();
}

setDataTestId(): void {
console.log('set data test id');
switch (this.tabState) {
case ApplicationTabStates.SUBMITTED: {
this.dataTestId = 'submitted_applications_container';
break;
}
case ApplicationTabStates.CREDITS_EXTENSION: {
this.dataTestId = 'credits_requests_applications_container';
break;
}
case ApplicationTabStates.LIFETIME_EXTENSION: {
this.dataTestId = 'lifetime_requests_applications_container';
break;
}
case ApplicationTabStates.MODIFICATION_EXTENSION: {
this.dataTestId = 'modification_requests_applications_container';
break;
}
case ApplicationTabStates.TERMINATION_REQUEST: {
this.dataTestId = 'termination_requests_applications_container';
break;
}
default: {
break;
}
setDataTestId(): void {
console.log('set data test id');
switch (this.tabState) {
case ApplicationTabStates.SUBMITTED: {
this.dataTestId = 'submitted_applications_container';
break;
}
case ApplicationTabStates.CREDITS_EXTENSION: {
this.dataTestId = 'credits_requests_applications_container';
break;
}
case ApplicationTabStates.LIFETIME_EXTENSION: {
this.dataTestId = 'lifetime_requests_applications_container';
break;
}
case ApplicationTabStates.MODIFICATION_EXTENSION: {
this.dataTestId = 'modification_requests_applications_container';
break;
}
case ApplicationTabStates.TERMINATION_REQUEST: {
this.dataTestId = 'termination_requests_applications_container';
break;
}
default: {
break;
}
console.log(this.dataTestId);
}
console.log(this.dataTestId);
}

triggerReloadNumbers() {
console.log('trigger reload 2');
this.reloadNumbersTrigger.emit();
}
triggerReloadNumbers() {
console.log('trigger reload 2');
this.reloadNumbersTrigger.emit();
}

removeApplicationFromList(application_id: string | number) {
const idx: number = this.applications.findIndex(
(application: Application) => application.project_application_id === application_id,
);
removeApplicationFromList(application_id: string | number) {
const idx: number = this.applications.findIndex(
(application: Application) => application.project_application_id === application_id,
);

if (idx !== -1) {
console.log('remove index');
this.applications.splice(idx, 1);
}
if (idx !== -1) {
console.log('remove index');
this.applications.splice(idx, 1);
}
}

protected readonly Application_States = Application_States;
protected readonly Application_States = Application_States;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
</button>
</div>
<div class="col-md-2">
<input type="file" accept=".csv" style="display: none" #fileInput (change)="onCsvFileSelected($event)" />
<button type="button " class="btn btn-outline-primary" (click)="fileInput.click()">
<button type="button " class="btn btn-outline-primary" (click)="openProjectCSVMailModal()">
Send CSV Templated Email
</button>
</div>
Expand Down
32 changes: 6 additions & 26 deletions src/app/facility_manager/facilityprojectsoverview.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Component, Input, OnInit, QueryList, ViewChildren, inject,
} from '@angular/core';
import { Observable, Subject, take } from 'rxjs';
import { Observable, take } from 'rxjs';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { MatomoTracker } from 'ngx-matomo-client';
import { ProjectMember } from '../projectmanagement/project_member.model';
Expand All @@ -19,10 +19,10 @@ import {
import { ProjectSortService } from '../shared/shared_modules/services/project-sort.service';
import { AbstractBaseClass } from '../shared/shared_modules/baseClass/abstract-base-class';
import { ProjectEmailModalComponent } from '../shared/modal/email/project-email-modal/project-email-modal.component';
import { NotificationModalComponent } from '../shared/modal/notification-modal';
import { MembersListModalComponent } from '../shared/modal/members/members-list-modal.component';
import { EmailService } from '../api-connector/email.service';
import { CsvMailTemplateModel } from '../shared/classes/csvMailTemplate.model';
import { ProjectCsvTemplatedEmailModalComponent } from '../shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component';

/**
* Facility Project overview component.
Expand All @@ -43,9 +43,7 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme
public memberFilter: string = '';
filteredMembers: object[] = [];
selectedMember: object[] = [];
facility_members: object[] = [];

filterChanged: Subject<string> = new Subject<string>();
isLoaded: boolean = false;
projects: Application[] = [];
projectsCopy: Application[] = [];
Expand Down Expand Up @@ -183,7 +181,11 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme
);
}
}
openProjectCSVMailModal(): void {
console.log('show');

this.bsModalRef = this.modalService.show(ProjectCsvTemplatedEmailModalComponent, { class: 'modal-lg' });
}
onSort({ column, direction }: SortEvent) {
// resetting other headers
this.headers.forEach(header => {
Expand All @@ -196,10 +198,6 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme
this.sortProjectService.sortDirection = direction;
}

searchForUserInFacility(searchString: string): void {
this.facilityService.getFilteredMembersOfFacility(searchString);
}

filterMembers(bare_searchString: string): void {
this.filteredMembers = [];
const searchString: string = bare_searchString.toLowerCase();
Expand Down Expand Up @@ -516,24 +514,6 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme
initialState = { selectedProjects: this.selectedEmailProjects };
}
this.bsModalRef = this.modalService.show(ProjectEmailModalComponent, { initialState, class: 'modal-lg' });
this.bsModalRef.content.event.subscribe((sent_successfully: boolean) => {
if (sent_successfully) {
const initialStateNotification = {
notificationModalTitle: 'Success',
notificationModalType: 'success',
notificationModalMessage: 'Mails were successfully sent',
};

this.modalService.show(NotificationModalComponent, { initialState: initialStateNotification });
} else {
const initialStateNotification = {
notificationModalTitle: 'Failed',
notificationModalType: 'danger',
notificationModalMessage: 'Failed to send mails!',
};
this.modalService.show(NotificationModalComponent, { initialState: initialStateNotification });
}
});
}

setFacilitySupportMails(supportMails: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class WithdrawModalComponent {
this.event.emit(true);
});
break;
default:
this.event.emit(false);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/app/projectmanagement/projectmanagement.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ResultComponent } from './modals/result/result.component';
import { SharedModuleModule } from '../shared/shared_modules/shared-module.module';
import { AdjustLifetimeRequestComponent } from './modals/adjust-lifetime/adjust-lifetime-request.component';
import { AdjustApplicationComponent } from './modals/adjust-application/adjust-application.component';
import { WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component';

/**
* Projectmanagment module.
Expand Down Expand Up @@ -59,6 +60,7 @@ import { AdjustApplicationComponent } from './modals/adjust-application/adjust-a
ExtensionEntryComponent,
AdjustLifetimeRequestComponent,
AdjustApplicationComponent,
WithdrawModalComponent,
],
exports: [ProjectOsDetailsComponent, ExtensionEntryComponent],
})
Expand Down
Loading

0 comments on commit 165e0e7

Please sign in to comment.