diff --git a/src/app/api-connector/group.service.ts b/src/app/api-connector/group.service.ts index 81c34a6c35..860e12fe6d 100644 --- a/src/app/api-connector/group.service.ts +++ b/src/app/api-connector/group.service.ts @@ -195,6 +195,8 @@ export class GroupService { } getGroupApplications(group: number | string): Observable { + console.log(group); + return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${group}/applications/`, { withCredentials: true, }); diff --git a/src/app/applications/application.model/application.model.ts b/src/app/applications/application.model/application.model.ts index 1cc01acc0f..9a7cb89900 100644 --- a/src/app/applications/application.model/application.model.ts +++ b/src/app/applications/application.model/application.model.ts @@ -192,6 +192,10 @@ export class Application { } else return 0; } + public isApproved(): boolean { + return this.project_application_statuses.includes(Application_States.APPROVED); + } + public setFlavorInFlavors(flavor_param: Flavor, counter: number): void { const idx: number = this.flavors.findIndex((fl: Flavor): boolean => fl.name === flavor_param.name); if (idx !== -1) { diff --git a/src/app/projectmanagement/overview.component.ts b/src/app/projectmanagement/overview.component.ts index df1e7afd39..55398445c5 100644 --- a/src/app/projectmanagement/overview.component.ts +++ b/src/app/projectmanagement/overview.component.ts @@ -684,32 +684,36 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements * Get all user applications for a project. */ getUserProjectApplications(): void { - this.memberApplicationsLoaded = false; - this.subscription.add( - this.groupService - .getGroupApplications(this.project_application.project_application_perun_id) - .subscribe((applications: any): void => { - const newProjectApplications: ProjectMemberApplication[] = []; - if (applications.length === 0) { - this.project_application.project_application_member_applications = []; + if (this.project_application.isApproved() && this.project_application.project_application_perun_id) { + this.memberApplicationsLoaded = false; + this.subscription.add( + this.groupService + .getGroupApplications(this.project_application.project_application_perun_id) + .subscribe((applications: any): void => { + const newProjectApplications: ProjectMemberApplication[] = []; + if (applications.length === 0) { + this.project_application.project_application_member_applications = []; - this.memberApplicationsLoaded = true; - } - for (const application of applications) { - const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS'); - const membername: string = application['displayName']; - - const newMemberApplication: ProjectMemberApplication = new ProjectMemberApplication( - application['id'], - membername, - `${dateApplicationCreated.date()}.${dateApplicationCreated.month() + 1}.${dateApplicationCreated.year()}`, - ); - newProjectApplications.push(newMemberApplication); - this.project_application.project_application_member_applications = newProjectApplications; - this.memberApplicationsLoaded = true; - } - }), - ); + this.memberApplicationsLoaded = true; + } + for (const application of applications) { + const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS'); + const membername: string = application['displayName']; + + const newMemberApplication: ProjectMemberApplication = new ProjectMemberApplication( + application['id'], + membername, + `${dateApplicationCreated.date()}.${ + dateApplicationCreated.month() + 1 + }.${dateApplicationCreated.year()}`, + ); + newProjectApplications.push(newMemberApplication); + this.project_application.project_application_member_applications = newProjectApplications; + this.memberApplicationsLoaded = true; + } + }), + ); + } } setSupportMails(project: Application): void { 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 37309e435b..20454cc2c5 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 @@ -11,7 +11,7 @@ import { IResponseTemplate } from '../../../../api-connector/response-template'; templateUrl: './project-email-modal.component.html', styleUrls: ['./projext-email-modal.component.scss'], }) -export class ProjectEmailModalComponent implements OnDestroy, OnInit { +export class ProjectEmailModalComponent implements OnInit, OnDestroy { // currently only for vo @Input() selectedProjects: Application[]; emailAdminsOnly: boolean; @@ -20,6 +20,7 @@ export class ProjectEmailModalComponent implements OnDestroy, OnInit { emailText: string; templates: string[]; + public event: EventEmitter = new EventEmitter(); constructor(public bsModalRef: BsModalRef, private voService: VoService) { @@ -43,6 +44,7 @@ export class ProjectEmailModalComponent implements OnDestroy, OnInit { .sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply) .subscribe( (res: IResponseTemplate) => { + this.event.emit(res.value as boolean); }, () => {