Skip to content

Commit

Permalink
feat(Application):added option to withdraw modification/extension req…
Browse files Browse the repository at this point in the history
…uests
  • Loading branch information
dweinholz committed Apr 15, 2024
1 parent 675ca5c commit 46ea9fb
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/app/api-connector/applications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,26 @@ export class ApplicationsService {
);
}

withdrawExtensionRequest(request_id: number | string): Observable<any> {
return this.http.post(
`${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${request_id}/withdraw/`,
null,
{
withCredentials: true,
},
);
}

withdrawModificationRequest(request_id: number | string): Observable<any> {
return this.http.post(
`${ApiSettings.getApiBaseURL()}project_applications/modifications/${request_id}/withdraw/`,
null,
{
withCredentials: true,
},
);
}

declineAdditionalLifetime(request_id: number | string): Observable<any> {
return this.http.post(
`${ApiSettings.getApiBaseURL()}project_applications/lifetime/extensions/${request_id}/decline/`,
Expand Down
2 changes: 2 additions & 0 deletions src/app/applications/application.model/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class Application {
project_application_compute_center: ComputecenterComponent;
project_application_openstack_project: boolean;
project_application_total_gpu: number = 0;
lifetime_extension_request_id: number | string;
modification_extension_request_id: number | string;

pi_approval_notification_send: boolean;
pi_approval_notification_expired: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div>
<div class="modal-header">
<h4 class="modal-title">
Withdraw
@if (type === WITHDRAWAL_TYPES.MODIFICATION) {
Modification
} @else if (type === WITHDRAWAL_TYPES.EXTENSION) {
Extension
}
Request
</h4>
<button
type="button"
class="btn-close"
style="cursor: pointer"
(click)="bsModalRef.hide()"
data-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<div class="col-md-auto mx-auto">
<div class="alert alert-warning" role="alert">
<p>
Are you sure you want to withdraw this
@if (type === WITHDRAWAL_TYPES.MODIFICATION) {
Modification
} @else if (type === WITHDRAWAL_TYPES.EXTENSION) {
Extension
}
Request?
</p>
<p>You can always create a new request if needed.</p>
</div>
</div>
</div>
<div class="modal-footer">
<div class="row" style="margin: auto">
<div class="col-md-auto mx-auto">
<button
id="withdraw_btn"
class="btn btn-danger"
type="reset"
data-test-id="withdraw_btn"
(click)="withdrawTarget()"
>
Withdraw
</button>
</div>
<div class="col-md-auto mx-auto">
<button
id="close_withdrawal_button"
class="btn btn-primary"
type="reset"
data-test-id="close_withdrawal_button"
(click)="bsModalRef.hide()"
>
Cancel
</button>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, EventEmitter } from '@angular/core';
import { BsModalRef } from 'ngx-bootstrap/modal';

import { ApplicationsService } from '../../../api-connector/applications.service';

export enum WITHDRAWAL_TYPES {
MODIFICATION,
EXTENSION,
}

@Component({
selector: 'app-withdrawl-modal',
templateUrl: './withdraw-modal.component.html',
providers: [ApplicationsService],
})
export class WithdrawModalComponent {
target_id: string | number;
type: WITHDRAWAL_TYPES;
event: EventEmitter<boolean> = new EventEmitter();

constructor(
public bsModalRef: BsModalRef,
private projectService: ApplicationsService,
) {
// eslint-disable-next-line no-empty-function
}

withdrawTarget() {
switch (this.type) {

Check warning on line 29 in src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

Expected a default case

Check warning on line 29 in src/app/projectmanagement/modals/withdraw/withdraw-modal.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

Expected a default case
case WITHDRAWAL_TYPES.EXTENSION:
this.projectService.withdrawExtensionRequest(this.target_id).subscribe(() => {
this.bsModalRef.hide();
this.event.emit(true);
});
break;
case WITHDRAWAL_TYPES.MODIFICATION:
this.projectService.withdrawModificationRequest(this.target_id).subscribe(() => {
this.bsModalRef.hide();
this.event.emit(true);
});
break;
}
}

protected readonly WITHDRAWAL_TYPES = WITHDRAWAL_TYPES;
}
33 changes: 29 additions & 4 deletions src/app/projectmanagement/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ <h3>
<button class="btn btn-outline-primary" disabled>Request extension</button>
</span>
</ng-container>
<button
(click)="showWithDrawExtensionModal()"
*ngIf="
project_application.user_is_admin &&
(project_application | hasstatusinlist: Application_States.LIFETIME_EXTENSION_REQUESTED)
"
class="btn btn-outline-warning"
data-test-id="open_modification_request_button"
id="show_lifetime_extension_withdraw_button"
>
Withdraw extension request
</button>
<button
(click)="showExtensionInformationModal()"
*ngIf="
Expand Down Expand Up @@ -403,7 +415,7 @@ <h3>
<div class="row">
<div class="col-6">
<div
*ngIf="this.resourceDataLoaded"
*ngIf="resourceDataLoaded"
class="callout"
[ngClass]="(project_application | isMigratedProject) ? 'callout-warning' : 'callout-info'"
style="border-top-width: 0; border-bottom-width: 0; border-right-width: 0"
Expand Down Expand Up @@ -511,6 +523,18 @@ <h3>
>
Request resource modification
</button>
<button
(click)="showWithDrawModificationModal()"
*ngIf="
project_application.user_is_admin &&
(project_application | hasstatusinlist: Application_States.MODIFICATION_REQUESTED)
"
class="btn btn-outline-warning"
data-test-id="open_modification_request_button"
id="show_modification_extension_withdraw_button"
>
Withdraw resource modification
</button>
<button
*ngIf="
(project_application | hasstatusinlist: Application_States.MODIFICATION_REQUESTED) ||
Expand Down Expand Up @@ -1202,16 +1226,17 @@ <h5 class="card-title">
<div class="alert alert-info">
<p>
If you are unsure whether a DOI has already been entered (for example, in a previous or expired project):
<strong>Duplicate entries are recognized by our system and do not pose a problem.</strong> In addition to
the public page, a
<strong>Duplicate entries are recognized by our system and do not pose a problem.</strong>
In addition to the public page, a
<a href="{{ PUBLIC_DOI_ENDPOINT }}" rel="noopener noreferrer" class="alert-link" target="_blank"
>public endpoint</a
>
is accessible, which returns all registered DOIs and the associated information.
</p>
<hr />
<p>
Please note that <strong>the publications entered on this page are listed publicly</strong> on
Please note that <strong>the publications entered on this page are listed publicly</strong>
on
<a href="{{ PUBLICATIONS_LINK }}" rel="noopener noreferrer" class="alert-link" target="_blank"
>this page on our website</a
>. We kindly ask you to list your publications which have been created during your work in the de.NBI
Expand Down
28 changes: 27 additions & 1 deletion src/app/projectmanagement/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import {
CREDITS_WIKI,
NEW_SVM_PORTAL_LINK,
OPENSTACK_LINK,
PUBLIC_DOI_ENDPOINT,
PUBLICATIONS_LINK,
SIMPLE_VM_LINK,
STATUS_LINK,
WIKI_MEMBER_MANAGEMENT,
WIKI_PUBLICATIONS,
PUBLIC_DOI_ENDPOINT,
} from '../../links/links';
import { Doi } from '../applications/doi/doi';
import { ApiSettings } from '../api-connector/api-settings.service';
Expand All @@ -49,6 +49,7 @@ import { ModificationRequestComponent } from './modals/modification-request/modi
import { LifetimeRequestComponent } from './modals/lifetime-request/lifetime-request.component';
import { CreditsRequestComponent } from './modals/credits-request/credits-request.component';
import { ExtensionEntryComponent } from './modals/testimonial/extension-entry.component';
import { WITHDRAWAL_TYPES, WithdrawModalComponent } from './modals/withdraw/withdraw-modal.component';

/**
* Projectoverview component.
Expand Down Expand Up @@ -229,6 +230,8 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements

return;
}
this.modificationRequestDisabled = false;
this.lifetimeExtensionDisabled = false;

this.project_application = aj;

Expand Down Expand Up @@ -333,6 +336,29 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements
this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION);
}

showWithDrawExtensionModal(): void {
this.showWithdrawModal(this.project_application.lifetime_extension_request_id, WITHDRAWAL_TYPES.EXTENSION);
}

showWithDrawModificationModal(): void {
this.showWithdrawModal(this.project_application.modification_extension_request_id, WITHDRAWAL_TYPES.MODIFICATION);
}

showWithdrawModal(target_id: string | number, type: WITHDRAWAL_TYPES): void {
const initialState = {
target_id,
type,
};
this.bsModalRef = this.modalService.show(WithdrawModalComponent, { initialState, class: 'modal-lg' });
this.subscription.add(
this.bsModalRef.content.event.subscribe((event: boolean): void => {
if (event) {
this.getApplication();
}
}),
);
}

showExtensionInformationModal(): void {
const initialState = {
dois: this.dois,
Expand Down

0 comments on commit 46ea9fb

Please sign in to comment.