diff --git a/src/app/facility_manager/facilityprojectsoverview.component.html b/src/app/facility_manager/facilityprojectsoverview.component.html index cd9cc581dd..d7feed64bd 100644 --- a/src/app/facility_manager/facilityprojectsoverview.component.html +++ b/src/app/facility_manager/facilityprojectsoverview.component.html @@ -45,8 +45,7 @@
- -
diff --git a/src/app/facility_manager/facilityprojectsoverview.component.ts b/src/app/facility_manager/facilityprojectsoverview.component.ts index 4bbf018218..b722a8d618 100644 --- a/src/app/facility_manager/facilityprojectsoverview.component.ts +++ b/src/app/facility_manager/facilityprojectsoverview.component.ts @@ -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'; @@ -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. @@ -43,9 +43,7 @@ export class FacilityProjectsOverviewComponent extends AbstractBaseClass impleme public memberFilter: string = ''; filteredMembers: object[] = []; selectedMember: object[] = []; - facility_members: object[] = []; - filterChanged: Subject = new Subject(); isLoaded: boolean = false; projects: Application[] = []; projectsCopy: Application[] = []; @@ -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 => { @@ -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(); @@ -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 { diff --git a/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts b/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts index ff6ca1edcf..bd8eef3a06 100644 --- a/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts +++ b/src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts @@ -39,6 +39,8 @@ export class WithdrawModalComponent { this.event.emit(true); }); break; + default: + this.event.emit(false); } } diff --git a/src/app/projectmanagement/projectmanagement.module.ts b/src/app/projectmanagement/projectmanagement.module.ts index 2b53063b0a..96bd65b697 100644 --- a/src/app/projectmanagement/projectmanagement.module.ts +++ b/src/app/projectmanagement/projectmanagement.module.ts @@ -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. @@ -59,6 +60,7 @@ import { AdjustApplicationComponent } from './modals/adjust-application/adjust-a ExtensionEntryComponent, AdjustLifetimeRequestComponent, AdjustApplicationComponent, + WithdrawModalComponent, ], exports: [ProjectOsDetailsComponent, ExtensionEntryComponent], }) diff --git a/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.html b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.html new file mode 100644 index 0000000000..adb3016ba2 --- /dev/null +++ b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.html @@ -0,0 +1,194 @@ + + + + + diff --git a/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts new file mode 100644 index 0000000000..aa5c04b137 --- /dev/null +++ b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.ts @@ -0,0 +1,94 @@ +import { + Component, EventEmitter, OnDestroy, OnInit, +} from '@angular/core'; +import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Application } from '../../../../applications/application.model/application.model'; +import { EmailService } from '../../../../api-connector/email.service'; +import { STATUS_LINK } from '../../../../../links/links'; +import { CsvMailTemplateModel } from '../../../classes/csvMailTemplate.model'; +import { NotificationModalComponent } from '../../notification-modal'; + +@Component({ + selector: 'app-project-csv-templated-email-modal', + templateUrl: './project-csv-templated-email-modal.component.html', + styleUrls: ['./project-csv-templated-email.scss'], + providers: [EmailService], +}) +export class ProjectCsvTemplatedEmailModalComponent implements OnInit, OnDestroy { + csvMailTemplate: CsvMailTemplateModel; + csvFile: File; + + emailAdminsOnly: boolean; + emailSubject: string; + emailReply: string; + emailText: string; + templates: string[]; + validCSVExample = `Project, VM, LOCATION +Proj1, VM_1, Bielefeld +Proj2, VM_2, Giessen`; + + public event: EventEmitter = new EventEmitter(); + + constructor( + public bsModalRef: BsModalRef, + private emailService: EmailService, + private notificationModal: NotificationModalComponent, + ) { + // eslint-disable-next-line no-empty-function + } + + ngOnInit() { + this.getMailTemplates(); + } + + onCsvFileSelected(event): void { + const inputElement = event.target as HTMLInputElement; + this.csvFile = inputElement.files[0]; + if (this.csvFile) { + this.emailService.sendCsvTemplate(this.csvFile).subscribe( + (csvTemplate: CsvMailTemplateModel) => { + this.csvMailTemplate = csvTemplate; + }, + (error: CsvMailTemplateModel) => { + this.csvMailTemplate = error; + console.log(error['error']); + }, + ); + } + } + + getMailTemplates(): void { + this.emailService.getMailTemplates().subscribe((res: string[]) => { + this.templates = res; + }); + } + + sentProjectsTemplatedMail(): void { + const project_ids = this.csvMailTemplate.valid_projects.map((pr: Application) => pr.project_application_perun_id); + this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...'); + + this.emailService + .sendCsvTemplatedMail( + this.csvFile, + project_ids, + this.emailSubject, + this.emailText, + this.emailAdminsOnly, + this.emailReply, + ) + .subscribe( + () => { + this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent!'); + }, + () => { + this.notificationModal.showDangerNotificationModal('Failed', 'Failed to send mails!'); + }, + ); + } + + ngOnDestroy(): void { + this.bsModalRef.hide(); + } + + protected readonly STATUS_LINK = STATUS_LINK; +} diff --git a/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email.scss b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email.scss new file mode 100644 index 0000000000..a86e9ffc41 --- /dev/null +++ b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email.scss @@ -0,0 +1,25 @@ +.templates-container { + border: 1px solid #ccc; + padding: 10px; + background-color: #f9f9f9; +} + +.templates-list { + margin: 10px 0; + font-family: monospace; +} + +.valid-example { + border: 1px solid #ccc; + padding: 10px; + background-color: #f9f9f9; + margin-top: 10px; +} + +.valid-example-heading { + margin-bottom: 5px; +} + +.valid-example-content { + font-family: monospace; +} \ No newline at end of file diff --git a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.html b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.html index 5584431736..1b9623c3e8 100644 --- a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.html +++ b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.html @@ -16,31 +16,6 @@