diff --git a/src/app/applications/application-card/application-card.component.html b/src/app/applications/application-card/application-card.component.html index 77761eec7b..b3c4b50121 100644 --- a/src/app/applications/application-card/application-card.component.html +++ b/src/app/applications/application-card/application-card.component.html @@ -1,49 +1,49 @@ - - - - {{ application?.project_application_name }} - {{ application?.project_application_shortname }} - {{ application?.project_application_date_submitted }} - - @if (application?.project_application_user?.username) { - {{ application?.project_application_user?.username }} - } @else { - - } - - {{ application?.project_application_institute }} + + + + {{ application?.project_application_name }} + {{ application?.project_application_shortname }} + {{ application?.project_application_date_submitted }} + + @if (application?.project_application_user?.username) { + {{ application?.project_application_user?.username }} + } @else { + + } + + {{ application?.project_application_institute }} - @if (voView) { - - } @else if (facilityView) { - - } + @if (voView) { + + } @else if (facilityView) { + + } - @if (!isCollapsed) { - - } + @if (!isCollapsed) { + + } diff --git a/src/app/applications/application-card/application-card.component.ts b/src/app/applications/application-card/application-card.component.ts index 41d61deec8..f31f4024ae 100644 --- a/src/app/applications/application-card/application-card.component.ts +++ b/src/app/applications/application-card/application-card.component.ts @@ -18,7 +18,6 @@ import { ApplicationDetailComponent } from '../application-detail/application-de styleUrl: './application-card.component.scss', }) export class ApplicationCardComponent extends AbstractBaseClass implements OnInit { - @Input() application: Application; @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; @Input() computeCenters: ComputecenterComponent[] = []; @@ -57,10 +56,7 @@ export class ApplicationCardComponent extends AbstractBaseClass implements OnIni }); } - constructor( - private applicationsService: ApplicationsService, - - ) { + constructor(private applicationsService: ApplicationsService) { super(); } diff --git a/src/app/applications/application-detail/information-detail/information-detail.component.html b/src/app/applications/application-detail/information-detail/information-detail.component.html index 000ec360e6..f8753f8e24 100644 --- a/src/app/applications/application-detail/information-detail/information-detail.component.html +++ b/src/app/applications/application-detail/information-detail/information-detail.component.html @@ -7,7 +7,7 @@
*ngFor="let term of application?.project_application_edam_terms" style="margin-left: 5px" class="badge bg-info" - >{{ term.name }} + >{{ term.term }}
diff --git a/src/app/applications/application-facility-actions/application-facility-actions.component.ts b/src/app/applications/application-facility-actions/application-facility-actions.component.ts index 562c3a7b0e..a3b3ea5f4e 100644 --- a/src/app/applications/application-facility-actions/application-facility-actions.component.ts +++ b/src/app/applications/application-facility-actions/application-facility-actions.component.ts @@ -33,256 +33,255 @@ export class ApplicationFacilityActionsComponent extends AbstractBaseClass { isCollapsed: boolean = true; bsModalRef: BsModalRef; @Output() switchCollapseEvent: EventEmitter = new EventEmitter(); - @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); + @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); - constructor( + constructor( private facilityService: FacilityService, private modalService: BsModalService, private applicationsService: ApplicationsService, - ) { - super(); - } + ) { + super(); + } - switchCollaps() { - this.switchCollapseEvent.emit(); - } + switchCollaps() { + this.switchCollapseEvent.emit(); + } - triggerRemoveApplication() { - this.removeApplicationTrigger.emit(this.application.project_application_id); - } + triggerRemoveApplication() { + this.removeApplicationTrigger.emit(this.application.project_application_id); + } - triggerReloadNumbers() { - this.reloadNumbersTrigger.emit(); - } + triggerReloadNumbers() { + this.reloadNumbersTrigger.emit(); + } - triggerReloadApplication():void { - this.reloadApplicationTrigger.emit(); + triggerReloadApplication(): void { + this.reloadApplicationTrigger.emit(); + } - } + declineApplication(): void { + this.showNotificationModal('Decline Application', 'Waiting..', 'info'); - declineApplication(): void { - this.showNotificationModal('Decline Application', 'Waiting..', 'info'); + this.facilityService + .declineFacilityApplication( + this.application.project_application_compute_center.FacilityId, + this.application.project_application_id, + ) + .subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully declined the application.', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); - this.facilityService - .declineFacilityApplication( - this.application.project_application_compute_center.FacilityId, - this.application.project_application_id, - ) - .subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully declined the application.', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); + }, + (): void => { + this.showNotificationModal('Failed', 'Failed to decline the application.', 'danger'); + }, + ); + } - // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); - }, - (): void => { - this.showNotificationModal('Failed', 'Failed to decline the application.', 'danger'); - }, - ); - } + public approveExtension(): void { + this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully approved extension!', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + }, + (): void => { + this.showNotificationModal('Failed', 'The approval of the extension request has failed.', 'danger'); + }, + ); + } - public approveExtension(): void { - this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully approved extension!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - }, - (): void => { - this.showNotificationModal('Failed', 'The approval of the extension request has failed.', 'danger'); - }, - ); - } - - /** + /** * Decline an extension request. * * @param application_id */ - public declineExtension(): void { - this.applicationsService.declineAdditionalLifetime(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully declined extension!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - }, - (): void => { - this.showNotificationModal('Failed', 'The decline of the extension request has failed.', 'danger'); - }, - ); - } + public declineExtension(): void { + this.applicationsService.declineAdditionalLifetime(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully declined extension!', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + }, + (): void => { + this.showNotificationModal('Failed', 'The decline of the extension request has failed.', 'danger'); + }, + ); + } - showNotificationModal( - notificationModalTitle: string, - notificationModalMessage: string, - notificationModalType: string, - ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; - if (this.bsModalRef) { - this.bsModalRef.hide(); - } + showNotificationModal( + notificationModalTitle: string, + notificationModalMessage: string, + notificationModalType: string, + ) { + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + if (this.bsModalRef) { + this.bsModalRef.hide(); + } - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); - } + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); + this.bsModalRef.setClass('modal-lg'); + } - approveApplication(): void { - this.showNotificationModal('Approving Application', 'Waiting..', 'info'); - this.facilityService - .approveFacilityApplication( - this.application.project_application_compute_center.FacilityId, - this.application.project_application_id, - ) - .subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully approved the application.', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); + approveApplication(): void { + this.showNotificationModal('Approving Application', 'Waiting..', 'info'); + this.facilityService + .approveFacilityApplication( + this.application.project_application_compute_center.FacilityId, + this.application.project_application_id, + ) + .subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully approved the application.', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); - // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); - }, - (): void => { - this.showNotificationModal('Failed', 'Failed to approve the application.', 'danger'); - }, - ); - } + // this.getAllApplicationsHistory(this.selectedFacility['FacilityId']); + }, + (): void => { + this.showNotificationModal('Failed', 'Failed to approve the application.', 'danger'); + }, + ); + } - showConfirmationModal(action: ConfirmationActions): void { - const initialState = { - application: this.application, - action, - }; + showConfirmationModal(action: ConfirmationActions): void { + const initialState = { + application: this.application, + action, + }; - this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); - this.subscribeToBsModalRef(); - } + this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); + this.subscribeToBsModalRef(); + } - approveModification(): void { - this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully approved modification!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - }, - (): void => { - this.showNotificationModal('Failed', 'The approval of the modification request has failed.', 'danger'); - }, - ); - } + approveModification(): void { + this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully approved modification!', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + }, + (): void => { + this.showNotificationModal('Failed', 'The approval of the modification request has failed.', 'danger'); + }, + ); + } - declineModification(): void { - this.applicationsService.declineModificationRequest(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Success', 'Successfully declined modification!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - }, - (): void => { - this.showNotificationModal('Failed', 'The decline of the modification request has failed.', 'danger'); - }, - ); - } + declineModification(): void { + this.applicationsService.declineModificationRequest(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Success', 'Successfully declined modification!', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + }, + (): void => { + this.showNotificationModal('Failed', 'The decline of the modification request has failed.', 'danger'); + }, + ); + } - approveTermination(): void { - this.facilityService - .approveTerminationByFM( - this.application.project_application_perun_id, - this.application.project_application_compute_center.FacilityId, - ) - .subscribe( - (): void => { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - this.showNotificationModal('Success', 'The project was terminated.', 'success'); - }, - (error: any): void => { - if (error['status'] === 409) { - this.showNotificationModal( - 'Failed', - `The project could not be terminated. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, + approveTermination(): void { + this.facilityService + .approveTerminationByFM( + this.application.project_application_perun_id, + this.application.project_application_compute_center.FacilityId, + ) + .subscribe( + (): void => { + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'The project was terminated.', 'success'); + }, + (error: any): void => { + if (error['status'] === 409) { + this.showNotificationModal( + 'Failed', + `The project could not be terminated. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, - 'danger', - ); - } else { - this.showNotificationModal('Failed', 'The project could not be terminated.', 'danger'); - } - }, - ); - } + 'danger', + ); + } else { + this.showNotificationModal('Failed', 'The project could not be terminated.', 'danger'); + } + }, + ); + } - declineTermination(): void { - this.facilityService - .declineTerminationByFM( - this.application.project_application_perun_id, - this.application.project_application_compute_center.FacilityId, - ) - .subscribe( - (): void => { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - this.showNotificationModal('Success', 'The termination of the project was declined.', 'success'); - }, - (error: any): void => { - if (error['status'] === 409) { - this.showNotificationModal( - 'Failed', - `The decline of the project was not successful. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, + declineTermination(): void { + this.facilityService + .declineTerminationByFM( + this.application.project_application_perun_id, + this.application.project_application_compute_center.FacilityId, + ) + .subscribe( + (): void => { + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); + this.showNotificationModal('Success', 'The termination of the project was declined.', 'success'); + }, + (error: any): void => { + if (error['status'] === 409) { + this.showNotificationModal( + 'Failed', + `The decline of the project was not successful. Reason: ${error['error']['reason']} for ${error['error']['openstackid']}`, - 'danger', - ); - } else { - this.showNotificationModal('Failed', 'The decline of the project failed.', 'danger'); - } - }, - ); - } + 'danger', + ); + } else { + this.showNotificationModal('Failed', 'The decline of the project failed.', 'danger'); + } + }, + ); + } - subscribeToBsModalRef(): void { - this.subscription.add( - this.bsModalRef.content.event.subscribe((event: any) => { - const action: ConfirmationActions = event.action; - switch (action) { - case ConfirmationActions.APPROVE_APPLICATION: { - this.approveApplication(); - break; - } - case ConfirmationActions.DECLINE_APPLICATION: { - this.declineApplication(); - break; - } - case ConfirmationActions.DECLINE_EXTENSION: { - this.declineExtension(); - break; - } - case ConfirmationActions.APPROVE_EXTENSION: { - this.approveExtension(); - break; - } - case ConfirmationActions.DECLINE_MODIFICATION: { - this.declineModification(); - break; - } - case ConfirmationActions.APPROVE_MODIFICATION: { - this.approveModification(); - break; - } - case ConfirmationActions.APPROVE_TERMINATION: { - this.approveTermination(); - break; - } - case ConfirmationActions.DECLINE_TERMINATION: { - this.declineTermination(); - break; - } - default: - break; - } - }), - ); - } + subscribeToBsModalRef(): void { + this.subscription.add( + this.bsModalRef.content.event.subscribe((event: any) => { + const action: ConfirmationActions = event.action; + switch (action) { + case ConfirmationActions.APPROVE_APPLICATION: { + this.approveApplication(); + break; + } + case ConfirmationActions.DECLINE_APPLICATION: { + this.declineApplication(); + break; + } + case ConfirmationActions.DECLINE_EXTENSION: { + this.declineExtension(); + break; + } + case ConfirmationActions.APPROVE_EXTENSION: { + this.approveExtension(); + break; + } + case ConfirmationActions.DECLINE_MODIFICATION: { + this.declineModification(); + break; + } + case ConfirmationActions.APPROVE_MODIFICATION: { + this.approveModification(); + break; + } + case ConfirmationActions.APPROVE_TERMINATION: { + this.approveTermination(); + break; + } + case ConfirmationActions.DECLINE_TERMINATION: { + this.declineTermination(); + break; + } + default: + break; + } + }), + ); + } - ngOnInit() {} + ngOnInit() {} - protected readonly Application_States = Application_States; + protected readonly Application_States = Application_States; } diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index cb2601282f..314a352a6d 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -182,7 +182,8 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent this.simple_vm_project = !this.openstack_project; this.application.project_application_pi = new User(); - this.searchTermsInEdamTerms(); + + // this.searchTermsInEdamTerms(); if (this.application.dissemination.someAllowed()) { this.project_application_report_allowed = true; @@ -190,6 +191,9 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent if (this.simple_vm_project) { this.simple_vm_min_vm = this.application.flavors.length > 0; } + if (this.application.project_application_nfdi && this.application.project_application_nfdi.length > 0) { + this.max_lifetime = 12; + } this.initiated_validation = true; } else { this.application = new Application(null); diff --git a/src/app/applications/application-vo-actions/application-vo-actions.component.ts b/src/app/applications/application-vo-actions/application-vo-actions.component.ts index 86ef775905..958abb6c2f 100644 --- a/src/app/applications/application-vo-actions/application-vo-actions.component.ts +++ b/src/app/applications/application-vo-actions/application-vo-actions.component.ts @@ -14,15 +14,9 @@ import { is_vo } from '../../shared/globalvar'; import { ApplicationsService } from '../../api-connector/applications.service'; import { VoService } from '../../api-connector/vo.service'; import { GroupService } from '../../api-connector/group.service'; -import { - AdjustLifetimeRequestComponent, -} from '../../projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component'; -import { - AdjustApplicationComponent, -} from '../../projectmanagement/modals/adjust-application/adjust-application.component'; -import { - ModificationRequestComponent, -} from '../../projectmanagement/modals/modification-request/modification-request.component'; +import { AdjustLifetimeRequestComponent } from '../../projectmanagement/modals/adjust-lifetime/adjust-lifetime-request.component'; +import { AdjustApplicationComponent } from '../../projectmanagement/modals/adjust-application/adjust-application.component'; +import { ModificationRequestComponent } from '../../projectmanagement/modals/modification-request/modification-request.component'; import { ConfirmationModalComponent } from '../../shared/modal/confirmation-modal.component'; import { ClientLimitsComponent } from '../../vo_manager/clients/modals/client-limits..component'; import { NotificationModalComponent } from '../../shared/modal/notification-modal'; @@ -35,386 +29,218 @@ import { NotificationModalComponent } from '../../shared/modal/notification-moda export class ApplicationVoActionsComponent extends AbstractBaseClass implements OnInit { private subscription: Subscription = new Subscription(); - @Input() application: Application; - @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; - @Input() computeCenters: ComputecenterComponent[] = []; - @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); - @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); - @Output() removeApplicationTrigger: EventEmitter = new EventEmitter(); - @Output() switchCollapseEvent: EventEmitter = new EventEmitter(); - - bsModalRef: BsModalRef; - is_vo_admin: boolean = false; - selectedComputeCenter: ComputecenterComponent; - - ngOnInit() { - this.is_vo_admin = is_vo; - } - - constructor( - private applicationsService: ApplicationsService, - private modalService: BsModalService, - private voService: VoService, - private groupService: GroupService, - private adjustLifeTimeExtensionModal: AdjustLifetimeRequestComponent, - private adjustApplicationModal: AdjustApplicationComponent, - ) { - super(); - } - - triggerRemoveApplication() { - this.removeApplicationTrigger.emit(this.application.project_application_id); - } - - showAdjustLifetimeExtensionModal() { - this.adjustLifeTimeExtensionModal - .showAdjustLifetimeExtensionModal(this.application) - .subscribe((eventSuccess: boolean) => { - if (eventSuccess) { - this.triggerReloadApplication(); - this.showNotificationModal( - 'Success', - 'The lifetime of the extension request were adjusted successfully!', - 'success', - ); - } else { - this.showNotificationModal('Failed', 'The adjustment of the lifetime has failed!', 'danger'); - } - }); - } - - triggerReloadApplication(): void { - this.reloadApplicationTrigger.emit(); - - } - - showAdjustApplicationModal() { - this.adjustApplicationModal.showAdjustApplicationModal(this.application).subscribe((changed: boolean) => { - if (changed) { + @Input() application: Application; + @Input() tabState: ApplicationTabStates = ApplicationTabStates.SUBMITTED; + @Input() computeCenters: ComputecenterComponent[] = []; + @Output() reloadNumbersTrigger: EventEmitter = new EventEmitter(); + @Output() reloadApplicationTrigger: EventEmitter = new EventEmitter(); + @Output() removeApplicationTrigger: EventEmitter = new EventEmitter(); + @Output() switchCollapseEvent: EventEmitter = new EventEmitter(); + + bsModalRef: BsModalRef; + is_vo_admin: boolean = false; + selectedComputeCenter: ComputecenterComponent; + + ngOnInit() { + this.is_vo_admin = is_vo; + } + + constructor( + private applicationsService: ApplicationsService, + private modalService: BsModalService, + private voService: VoService, + private groupService: GroupService, + private adjustLifeTimeExtensionModal: AdjustLifetimeRequestComponent, + private adjustApplicationModal: AdjustApplicationComponent, + ) { + super(); + } + + triggerRemoveApplication() { + this.removeApplicationTrigger.emit(this.application.project_application_id); + } + + showAdjustLifetimeExtensionModal() { + this.adjustLifeTimeExtensionModal + .showAdjustLifetimeExtensionModal(this.application) + .subscribe((eventSuccess: boolean) => { + if (eventSuccess) { this.triggerReloadApplication(); - - this.showNotificationModal('Success', 'The resources of the application were adjusted successfully!', 'success'); + this.showNotificationModal( + 'Success', + 'The lifetime of the extension request were adjusted successfully!', + 'success', + ); } else { - this.showNotificationModal('Failed', 'The adjustment of the resources has failed!', 'danger'); + this.showNotificationModal('Failed', 'The adjustment of the lifetime has failed!', 'danger'); } }); - } - - showModificationAdjustmentModal() { - const initialState = { - project: this.application, - adjustment: true, - }; + } - this.bsModalRef = this.modalService.show(ModificationRequestComponent, { - initialState, - class: 'modal-lg', - }); - this.subscribeToBsModalRef(); - // this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION); - } + triggerReloadApplication(): void { + this.reloadApplicationTrigger.emit(); + } - triggerReloadNumbers() { - this.reloadNumbersTrigger.emit(); - } - - setCurrentUserProcessingVoManager(application: Application): void { - if (this.is_vo_admin) { - this.voService.setCurrentUserProcessingVoManager(application.project_application_id).subscribe((res: any) => { - application.processing_vo_initials = res['processing_vo_initials']; - }); - } - } - - showConfirmationModal(action: ConfirmationActions): void { - let initialState = {}; - if (action === ConfirmationActions.APPROVE_APPLICATION) { - const application_center = !this.selectedComputeCenter.FacilityId; - initialState = { application: this.application, action, application_center }; - } else { - initialState = { - application: this.application, - action, - }; - } - this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); - this.subscribeToBsModalRef(); - } - - unsetProcessingVoManager(application: Application): void { - if (this.is_vo_admin) { - this.voService.unsetProcessingVoManager(application.project_application_id).subscribe(() => { - application.processing_vo_initials = null; - }); - } - } - - showClientsLimitsModal(is_modification_request: boolean = false): void { - let initialState = {}; - if (is_modification_request) { - initialState = { - compute_center_id: this.application.project_application_compute_center.FacilityId, - application: this.application, - is_modification_request, - }; - } else { - initialState = { - compute_center_id: this.selectedComputeCenter.FacilityId, - application: this.application, - is_modification_request, - }; - } - - this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }); - this.subscribeToBsModalRef(); - } - - removeApplicationFromFacilityConfirmation(): void { - this.groupService.removeGroupFromResource(this.application.project_application_perun_id.toString()).subscribe( - (): void => { - this.triggerReloadApplication(); - this.showNotificationModal('Success', 'The application was removed from the compute center', 'success'); - }, - (): void => { - this.showNotificationModal('Failed', 'The application was removed from the compute center', 'danger'); - }, - ); - } + showAdjustApplicationModal() { + this.adjustApplicationModal.showAdjustApplicationModal(this.application).subscribe((changed: boolean) => { + if (changed) { + this.triggerReloadApplication(); - assignGroupToFacility(): void { - if (this.selectedComputeCenter) { - this.groupService - .assignGroupToResource(this.application.project_application_perun_id, this.selectedComputeCenter.FacilityId) - .subscribe( - (): void => { - this.triggerReloadApplication(); - - this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); - }, - (error: object): void => { - console.log(error); - this.showNotificationModal('Failed', 'Project could not be created!', 'danger'); - }, - ); + this.showNotificationModal('Success', 'The resources of the application were adjusted successfully!', 'success'); } else { - this.showNotificationModal('Failed', 'You need to select an compute center!', 'danger'); + this.showNotificationModal('Failed', 'The adjustment of the resources has failed!', 'danger'); } - } - - resetApplicationPI(): void { - this.applicationsService.resetPIValidation(this.application).subscribe(() => { - this.triggerReloadApplication(); + }); + } + + showModificationAdjustmentModal() { + const initialState = { + project: this.application, + adjustment: true, + }; + + this.bsModalRef = this.modalService.show(ModificationRequestComponent, { + initialState, + class: 'modal-lg', + }); + this.subscribeToBsModalRef(); + // this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION); + } + + triggerReloadNumbers() { + this.reloadNumbersTrigger.emit(); + } + + setCurrentUserProcessingVoManager(application: Application): void { + if (this.is_vo_admin) { + this.voService.setCurrentUserProcessingVoManager(application.project_application_id).subscribe((res: any) => { + application.processing_vo_initials = res['processing_vo_initials']; }); } - - switchCollaps() { - this.switchCollapseEvent.emit(); + } + + showConfirmationModal(action: ConfirmationActions): void { + let initialState = {}; + if (action === ConfirmationActions.APPROVE_APPLICATION) { + const application_center = !this.selectedComputeCenter.FacilityId; + initialState = { application: this.application, action, application_center }; + } else { + initialState = { + application: this.application, + action, + }; } - - showNotificationModal( - notificationModalTitle: string, - notificationModalMessage: string, - notificationModalType: string, - ) { - const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; - if (this.bsModalRef) { - this.bsModalRef.hide(); - } - - this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); - this.bsModalRef.setClass('modal-lg'); + this.bsModalRef = this.modalService.show(ConfirmationModalComponent, { initialState, class: 'modal-lg' }); + this.subscribeToBsModalRef(); + } + + unsetProcessingVoManager(application: Application): void { + if (this.is_vo_admin) { + this.voService.unsetProcessingVoManager(application.project_application_id).subscribe(() => { + application.processing_vo_initials = null; + }); } - - createSimpleVmProjectGroup(): void { - this.showNotificationModal('Info', 'Creating Project...', 'info'); - - if (this.selectedComputeCenter && this.selectedComputeCenter.FacilityId) { - this.groupService - .createGroupByApplication(this.application.project_application_id, this.selectedComputeCenter.FacilityId) - .subscribe( - (res: any): void => { - if (!res['client_available'] && !res['created']) { - this.showNotificationModal( - 'Failed', - `The client ${res['client_name']} has not the necessary resources left!`, - 'danger', - ); - } else { - this.showNotificationModal('Success', 'The project was created!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); - } - }, - (error: any): void => { - console.log(error); - const errorMessage = error && error.error === 'locked' - ? 'Project is locked and could not be created!' - : 'Project could not be created!'; - - this.showNotificationModal('Failed', errorMessage, 'danger'); - console.log(error); - }, - ); - } + } + + showClientsLimitsModal(is_modification_request: boolean = false): void { + let initialState = {}; + if (is_modification_request) { + initialState = { + compute_center_id: this.application.project_application_compute_center.FacilityId, + application: this.application, + is_modification_request, + }; + } else { + initialState = { + compute_center_id: this.selectedComputeCenter.FacilityId, + application: this.application, + is_modification_request, + }; } - approveModificationRequest(): void { - this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( - (res: Response): void => { - this.showNotificationModal('Success', 'The resource modification request was approved!', 'success'); - if (!this.application.project_application_openstack_project) { - if (res.status === HttpStatusCode.Accepted) { - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.bsModalRef = this.modalService.show(ClientLimitsComponent, { initialState }); + this.subscribeToBsModalRef(); + } - // this.all_applications.splice(this.all_applications.indexOf(application), 1); - } - } else { + removeApplicationFromFacilityConfirmation(): void { + this.groupService.removeGroupFromResource(this.application.project_application_perun_id.toString()).subscribe( + (): void => { + this.triggerReloadApplication(); + this.showNotificationModal('Success', 'The application was removed from the compute center', 'success'); + }, + (): void => { + this.showNotificationModal('Failed', 'The application was removed from the compute center', 'danger'); + }, + ); + } + + assignGroupToFacility(): void { + if (this.selectedComputeCenter) { + this.groupService + .assignGroupToResource(this.application.project_application_perun_id, this.selectedComputeCenter.FacilityId) + .subscribe( + (): void => { this.triggerReloadApplication(); - } - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Approval of resource modification failed!', 'danger'); - }, - ); - } - - declineModificationRequest(): void { - this.applicationsService.deleteModificationRequest(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Declined', 'The resource modification request was declined!', 'success'); - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - - this.triggerReloadApplication(); - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of resource modification failed!', 'danger'); - }, - ); - } - - deleteApplication(): void { - // const idx: number = this.all_applications.indexOf(application); - this.subscription.add( - this.applicationsService.deleteApplication(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Success', 'The application has been successfully removed', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); + this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); }, - (): void => { - this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger'); + (error: object): void => { + console.log(error); + this.showNotificationModal('Failed', 'Project could not be created!', 'danger'); }, - ), - ); - } - - declineLifetimeExtension(): void { - this.applicationsService.deleteAdditionalLifetimeRequests(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Declined', 'The project extension was declined!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of project extension failed!', 'danger'); - }, - ); + ); + } else { + this.showNotificationModal('Failed', 'You need to select an compute center!', 'danger'); } - - declineCreditExtension(): void { - this.applicationsService.deleteAdditionalCreditsRequests(this.application.project_application_id).subscribe( - (): void => { - this.showNotificationModal('Declined', 'The credit extension request was declined!', 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Decline of credit extension failed!', 'danger'); - }, - ); + } + + resetApplicationPI(): void { + this.applicationsService.resetPIValidation(this.application).subscribe(() => { + this.triggerReloadApplication(); + }); + } + + switchCollaps() { + this.switchCollapseEvent.emit(); + } + + showNotificationModal( + notificationModalTitle: string, + notificationModalMessage: string, + notificationModalType: string, + ) { + const initialState = { notificationModalTitle, notificationModalType, notificationModalMessage }; + if (this.bsModalRef) { + this.bsModalRef.hide(); } - declineApplication(): void { - // const idx: number = this.all_applications.indexOf(app); - this.applicationsService.declineApplication(this.application.project_application_id).subscribe( - (): void => { - const message: string = 'The Application was declined.'; + this.bsModalRef = this.modalService.show(NotificationModalComponent, { initialState }); + this.bsModalRef.setClass('modal-lg'); + } - this.showNotificationModal('Success', message, 'success'); - this.triggerRemoveApplication(); - this.triggerReloadNumbers(); - }, - (): void => { - this.showNotificationModal('Failed', 'Application could not be declined!', 'danger'); - }, - ); - } + createSimpleVmProjectGroup(): void { + this.showNotificationModal('Info', 'Creating Project...', 'info'); - approveLifetimeExtension(): void { - this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( - (res: Response): void => { - if (this.application.project_application_openstack_project) { - this.triggerReloadApplication(); - this.showNotificationModal('Success', 'The request has been sent to the facility manager.', 'success'); - } else { - this.showNotificationModal('Success', 'The project has been extended!', 'success'); - } - if (!this.application.project_application_openstack_project) { - if (res.status === HttpStatusCode.Accepted) { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - } - } - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Project lifetime could not be extendend!', 'danger'); - }, - ); - } - - approveCreditExtension(): void { - this.applicationsService.approveAdditionalCreditsRequest(this.application.project_application_id).subscribe( - (res: Response): void => { - this.showNotificationModal('Success', 'The credit extension request was approved!', 'success'); - if (!this.application.project_application_openstack_project) { - if (res.status === HttpStatusCode.Accepted) { - this.triggerReloadNumbers(); - this.triggerRemoveApplication(); - } - } else { - this.triggerReloadApplication(); - } - }, - (err: any): void => { - console.log('error', err.status); - this.showNotificationModal('Failed', 'Approval of credit extension failed!', 'danger'); - }, - ); - } - - createOpenStackProjectGroup(): void { + if (this.selectedComputeCenter && this.selectedComputeCenter.FacilityId) { this.groupService - .createGroupOpenStack(this.application.project_application_id, this.selectedComputeCenter.FacilityId) + .createGroupByApplication(this.application.project_application_id, this.selectedComputeCenter.FacilityId) .subscribe( - (result: { [key: string]: string }): void => { - if (result['Error']) { - this.showNotificationModal('Failed', result['Error'], 'danger'); + (res: any): void => { + if (!res['client_available'] && !res['created']) { + this.showNotificationModal( + 'Failed', + `The client ${res['client_name']} has not the necessary resources left!`, + 'danger', + ); } else { - this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); - this.triggerReloadApplication(); - // this.switchApproveLocked(false); + this.showNotificationModal('Success', 'The project was created!', 'success'); + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); } }, (error: any): void => { - const errorMessage = error && error.error === 'locked' + console.log(error); + const errorMessage = error && error.error === 'locked' ? 'Project is locked and could not be created!' : 'Project could not be created!'; @@ -423,66 +249,233 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements }, ); } + } + + approveModificationRequest(): void { + this.applicationsService.approveModificationRequest(this.application.project_application_id).subscribe( + (res: Response): void => { + this.showNotificationModal('Success', 'The resource modification request was approved!', 'success'); + if (!this.application.project_application_openstack_project) { + if (res.status === HttpStatusCode.Accepted) { + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); - /** - * Function to listen to modal results. - */ - subscribeToBsModalRef(): void { - this.subscription.add( - this.bsModalRef.content.event.subscribe((result: any) => { - let action = null; - if ('action' in result) { - action = result['action']; - } - if ('createSimpleVM' in result) { - this.createSimpleVmProjectGroup(); - } - if (action === ConfirmationActions.APPROVE_MODIFICATION) { - this.approveModificationRequest(); - } - if ('closed' in result) { - // this.switchApproveLocked(false); - } - if (action === ConfirmationActions.DECLINE_MODIFICATION) { - this.declineModificationRequest(); - } - if (action === ConfirmationActions.DELETE_APPLICATION) { - this.deleteApplication(); - } - if (action === ConfirmationActions.DECLINE_EXTENSION) { - this.declineLifetimeExtension(); - } - if (action === ConfirmationActions.DECLINE_CREDITS) { - this.declineCreditExtension(); - } - if (action === ConfirmationActions.DECLINE_APPLICATION) { - this.declineApplication(); + // this.all_applications.splice(this.all_applications.indexOf(application), 1); } + } else { + this.triggerReloadApplication(); + } + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Approval of resource modification failed!', 'danger'); + }, + ); + } + + declineModificationRequest(): void { + this.applicationsService.deleteModificationRequest(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Declined', 'The resource modification request was declined!', 'success'); + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); - if (action === ConfirmationActions.APPROVE_EXTENSION) { - this.approveLifetimeExtension(); - } - if (action === ConfirmationActions.RESET_PI) { - this.resetApplicationPI(); - } - if (action === ConfirmationActions.APPROVE_CREDITS) { - this.approveCreditExtension(); + this.triggerReloadApplication(); + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Decline of resource modification failed!', 'danger'); + }, + ); + } + + deleteApplication(): void { + // const idx: number = this.all_applications.indexOf(application); + + this.subscription.add( + this.applicationsService.deleteApplication(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Success', 'The application has been successfully removed', 'success'); + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); + }, + (): void => { + this.updateNotificationModal('Failed', 'Application could not be removed!', true, 'danger'); + }, + ), + ); + } + + declineLifetimeExtension(): void { + this.applicationsService.deleteAdditionalLifetimeRequests(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Declined', 'The project extension was declined!', 'success'); + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Decline of project extension failed!', 'danger'); + }, + ); + } + + declineCreditExtension(): void { + this.applicationsService.deleteAdditionalCreditsRequests(this.application.project_application_id).subscribe( + (): void => { + this.showNotificationModal('Declined', 'The credit extension request was declined!', 'success'); + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Decline of credit extension failed!', 'danger'); + }, + ); + } + + declineApplication(): void { + // const idx: number = this.all_applications.indexOf(app); + this.applicationsService.declineApplication(this.application.project_application_id).subscribe( + (): void => { + const message: string = 'The Application was declined.'; + + this.showNotificationModal('Success', message, 'success'); + this.triggerRemoveApplication(); + this.triggerReloadNumbers(); + }, + (): void => { + this.showNotificationModal('Failed', 'Application could not be declined!', 'danger'); + }, + ); + } + + approveLifetimeExtension(): void { + this.applicationsService.approveAdditionalLifetime(this.application.project_application_id).subscribe( + (res: Response): void => { + if (this.application.project_application_openstack_project) { + this.triggerReloadApplication(); + this.showNotificationModal('Success', 'The request has been sent to the facility manager.', 'success'); + } else { + this.showNotificationModal('Success', 'The project has been extended!', 'success'); + } + if (!this.application.project_application_openstack_project) { + if (res.status === HttpStatusCode.Accepted) { + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); } - if (action === ConfirmationActions.APPROVE_APPLICATION) { - if (this.application.project_application_openstack_project) { - this.createOpenStackProjectGroup(); - } + } + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Project lifetime could not be extendend!', 'danger'); + }, + ); + } + + approveCreditExtension(): void { + this.applicationsService.approveAdditionalCreditsRequest(this.application.project_application_id).subscribe( + (res: Response): void => { + this.showNotificationModal('Success', 'The credit extension request was approved!', 'success'); + if (!this.application.project_application_openstack_project) { + if (res.status === HttpStatusCode.Accepted) { + this.triggerReloadNumbers(); + this.triggerRemoveApplication(); } - if (action === 'adjustedModificationRequest') { - // this.isLoaded = false; - // this.changeTabState(ApplicationTabStates.MODIFICATION_EXTENSION); + } else { + this.triggerReloadApplication(); + } + }, + (err: any): void => { + console.log('error', err.status); + this.showNotificationModal('Failed', 'Approval of credit extension failed!', 'danger'); + }, + ); + } + + createOpenStackProjectGroup(): void { + this.groupService + .createGroupOpenStack(this.application.project_application_id, this.selectedComputeCenter.FacilityId) + .subscribe( + (result: { [key: string]: string }): void => { + if (result['Error']) { + this.showNotificationModal('Failed', result['Error'], 'danger'); + } else { + this.showNotificationModal('Success', 'The project was assigned to the facility.', 'success'); + this.triggerReloadApplication(); + // this.switchApproveLocked(false); } - }), + }, + (error: any): void => { + const errorMessage = error && error.error === 'locked' + ? 'Project is locked and could not be created!' + : 'Project could not be created!'; + + this.showNotificationModal('Failed', errorMessage, 'danger'); + console.log(error); + }, ); - } + } + + /** + * Function to listen to modal results. + */ + subscribeToBsModalRef(): void { + this.subscription.add( + this.bsModalRef.content.event.subscribe((result: any) => { + let action = null; + if ('action' in result) { + action = result['action']; + } + if ('createSimpleVM' in result) { + this.createSimpleVmProjectGroup(); + } + if (action === ConfirmationActions.APPROVE_MODIFICATION) { + this.approveModificationRequest(); + } + if ('closed' in result) { + // this.switchApproveLocked(false); + } + if (action === ConfirmationActions.DECLINE_MODIFICATION) { + this.declineModificationRequest(); + } + if (action === ConfirmationActions.DELETE_APPLICATION) { + this.deleteApplication(); + } + if (action === ConfirmationActions.DECLINE_EXTENSION) { + this.declineLifetimeExtension(); + } + if (action === ConfirmationActions.DECLINE_CREDITS) { + this.declineCreditExtension(); + } + if (action === ConfirmationActions.DECLINE_APPLICATION) { + this.declineApplication(); + } - isCollapsed: boolean = true; - protected readonly Application_States = Application_States; - protected readonly ConfirmationActions = ConfirmationActions; - protected readonly ApplicationTabStates = ApplicationTabStates; + if (action === ConfirmationActions.APPROVE_EXTENSION) { + this.approveLifetimeExtension(); + } + if (action === ConfirmationActions.RESET_PI) { + this.resetApplicationPI(); + } + if (action === ConfirmationActions.APPROVE_CREDITS) { + this.approveCreditExtension(); + } + if (action === ConfirmationActions.APPROVE_APPLICATION) { + if (this.application.project_application_openstack_project) { + this.createOpenStackProjectGroup(); + } + } + if (action === 'adjustedModificationRequest') { + // this.isLoaded = false; + // this.changeTabState(ApplicationTabStates.MODIFICATION_EXTENSION); + } + }), + ); + } + + isCollapsed: boolean = true; + protected readonly Application_States = Application_States; + protected readonly ConfirmationActions = ConfirmationActions; + protected readonly ApplicationTabStates = ApplicationTabStates; } diff --git a/src/app/applications/application.model/application.model.ts b/src/app/applications/application.model/application.model.ts index 48e46eb3f4..b1b3be3e02 100644 --- a/src/app/applications/application.model/application.model.ts +++ b/src/app/applications/application.model/application.model.ts @@ -117,9 +117,10 @@ export class Application { if (aj.project_application_edam_terms) { this.project_application_edam_terms = aj.project_application_edam_terms.map( - (term: any): EdamOntologyTerm => new EdamOntologyTerm(null, term, null, null), + (term: any): EdamOntologyTerm => new EdamOntologyTerm(null, term, null), ); } + console.log(this.project_application_edam_terms); if (aj.project_lifetime_request) { this.project_lifetime_request = new ApplicationLifetimeExtension(aj.project_lifetime_request); this.totalLifetimeExtensionCredits = this.calcLifetimeExtensionCredits(); diff --git a/src/app/applications/edam-ontology-term.ts b/src/app/applications/edam-ontology-term.ts index 9c766e1d7d..20ecd778cd 100644 --- a/src/app/applications/edam-ontology-term.ts +++ b/src/app/applications/edam-ontology-term.ts @@ -2,39 +2,13 @@ * Edam ontology term class. */ export class EdamOntologyTerm { + public name: string; + public term: string; + public uri: string; - private _name: string; - private _term: string; - private _uri: string; - - constructor(storid: number, name: string, term: string, uri: string) { - this._name = name; - this._term = term; - this._uri = uri; - } - - get name(): string { - return this._name; - } - - set name(value: string) { - this._name = value; - } - - get term(): string { - return this._term; + constructor(name: string, term: string, uri: string) { + this.name = name; + this.term = term; + this.uri = uri; } - - set term(value: string) { - this._term = value; - } - - get uri(): string { - return this._uri; - } - - set uri(value: string) { - this._uri = value; - } - }