diff --git a/src/app/applications/application-list/application-list.component.ts b/src/app/applications/application-list/application-list.component.ts index f761a7873e..097c8c9081 100644 --- a/src/app/applications/application-list/application-list.component.ts +++ b/src/app/applications/application-list/application-list.component.ts @@ -15,72 +15,72 @@ import { is_vo } from '../../shared/globalvar'; styleUrl: './application-list.component.scss', }) export class ApplicationListComponent implements OnInit, OnChanges { - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); + @Output() reloadNumbersTrigger: EventEmitter = 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; } 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..50e8fc8a12 --- /dev/null +++ b/src/app/shared/modal/email/project-csv-templated-email-modal/project-csv-templated-email-modal.component.html @@ -0,0 +1,219 @@ + + + + + + \ No newline at end of file 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..ef8fc3e5db 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 @@ -1,179 +1,136 @@ + + -
-

You can use the following keys as variables:

-
- {{ '{' + template + '}' }} -
-
+
+

You can use the following keys as variables:

+
+ {{ '{' + template + '}' }} +
+
+ +
+ Please consider: In case any dates are part of the sent E-Mails, they will be formatted in the german + TT.MM.YYYY-format. +
-
- Please consider: In case any dates are part of the sent E-Mails, they will be formatted in the german - TT.MM.YYYY-format. -
diff --git a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts index 40c9dce8ef..aa9e6ce5d6 100644 --- a/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts +++ b/src/app/shared/modal/email/project-email-modal/project-email-modal.component.ts @@ -3,11 +3,9 @@ import { } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { Application } from '../../../../applications/application.model/application.model'; -import { VoService } from '../../../../api-connector/vo.service'; -import { IResponseTemplate } from '../../../../api-connector/response-template'; 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-email-modal', @@ -17,24 +15,19 @@ import { CsvMailTemplateModel } from '../../../classes/csvMailTemplate.model'; }) export class ProjectEmailModalComponent implements OnInit, OnDestroy { @Input() selectedProjects: Application[]; - @Input() csvMailTemplate: CsvMailTemplateModel; - @Input() csvFile: File; emailAdminsOnly: boolean; emailSubject: string; emailReply: string; emailText: string; templates: string[]; - validCSVExample = `Project, Key1, Key2 -Proj1, ValK1, ValK2 -Proj2, ValK1, ValK2`; public event: EventEmitter = new EventEmitter(); constructor( public bsModalRef: BsModalRef, - private voService: VoService, private emailService: EmailService, + private notificationModal: NotificationModalComponent, ) { // eslint-disable-next-line no-empty-function } @@ -49,39 +42,18 @@ Proj2, ValK1, ValK2`; }); } - sentProjectsTemplatedMail(): void { - const project_ids = this.selectedProjects.map((pr: Application) => pr.project_application_perun_id); - - this.emailService - .sendCsvTemplatedMail( - this.csvFile, - project_ids, - this.emailSubject, - this.emailText, - this.emailAdminsOnly, - this.emailReply, - ) - .subscribe( - (res: IResponseTemplate) => { - this.event.emit(res.value as boolean); - }, - () => { - this.event.emit(false); - }, - ); - } - sentProjectsMail(): void { const project_ids = this.selectedProjects.map((pr: Application) => pr.project_application_perun_id); + this.notificationModal.showInfoNotificationModal('Info', 'Sending Mails...'); this.emailService .sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply) .subscribe( - (res: IResponseTemplate) => { - this.event.emit(res.value as boolean); + () => { + this.notificationModal.showSuccessFullNotificationModal('Success', 'Mails were successfully sent'); }, () => { - this.event.emit(false); + this.notificationModal.showSuccessFullNotificationModal('Failed', 'Failed to send mails!'); }, ); } diff --git a/src/app/shared/modal/notification-modal.component.html b/src/app/shared/modal/notification-modal.component.html index d1ed6e7157..da03ceaa33 100644 --- a/src/app/shared/modal/notification-modal.component.html +++ b/src/app/shared/modal/notification-modal.component.html @@ -1,25 +1,21 @@