From 640e73a462ef474c83b113e97f0f728bd6945b57 Mon Sep 17 00:00:00 2001 From: vktrrdk Date: Wed, 19 Apr 2023 11:35:10 +0200 Subject: [PATCH 1/5] fix(Application): Better checking of required comment on critical resource applications --- .../application-formular.component.html | 8 +++++--- .../application-formular.component.ts | 14 ++++++++++++++ .../modification-request.component.html | 7 ++++--- .../modification-request.component.ts | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/app/applications/application-formular/application-formular.component.html b/src/app/applications/application-formular/application-formular.component.html index 607748f4bf..809a70ffff 100644 --- a/src/app/applications/application-formular/application-formular.component.html +++ b/src/app/applications/application-formular/application-formular.component.html @@ -530,8 +530,8 @@
Resources
placeholder="" [(ngModel)]="application.project_application_comment" [ngClass]="{ - 'is-invalid': form.controls.project_application_comment?.invalid, - 'is-valid': form.controls.project_application_comment?.valid + 'is-invalid': form.controls.project_application_comment?.invalid || !checkValidityComment(), + 'is-valid': form.controls.project_application_comment?.valid && checkValidityComment() }" > Additional information you want to share? @@ -1728,7 +1728,9 @@
Platforms
application?.project_application_edam_terms.length === 0 || application?.project_application_edam_terms.length > 10 || (application?.flavors.length === 0 && !application?.project_application_openstack_project) || - (!application?.dissemination?.isPlatformSelected() && application?.project_application_report_allowed) + (!application?.dissemination?.isPlatformSelected() && + application?.project_application_report_allowed) || + !checkValidityComment() " class="btn btn-sm btn-success" type="button" diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index 976d92a63b..808f2ea3d1 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -129,6 +129,20 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent } } + checkValidityComment(): boolean { + if (this.extraResourceCommentRequired) { + if (this.application.project_application_comment?.length < 50) { + return false; + } else { + const regExp = /[a-zA-Z]/g; + + return regExp.test(this.application.project_application_comment); + } + } else { + return true; + } + } + getUserinfo(): void { this.userService.getUserInfo().subscribe((userinfo: Userinfo) => { this.userinfo = userinfo; diff --git a/src/app/projectmanagement/modals/modification-request/modification-request.component.html b/src/app/projectmanagement/modals/modification-request/modification-request.component.html index e184104bee..a3d1736df8 100644 --- a/src/app/projectmanagement/modals/modification-request/modification-request.component.html +++ b/src/app/projectmanagement/modals/modification-request/modification-request.component.html @@ -598,8 +598,9 @@
[required]="extraResourceCommentRequired" [(ngModel)]="temp_project_modification.comment" [ngClass]="{ - 'is-invalid': modificationForm.controls.project_application_renewal_comment?.invalid, - 'is-valid': modificationForm.controls.project_application_renewal_comment?.valid + 'is-invalid': + modificationForm.controls.project_application_renewal_comment?.invalid || !checkValidityComment(), + 'is-valid': modificationForm.controls.project_application_renewal_comment?.valid && checkValidityComment() }" > Additional information you want to share? @@ -698,7 +699,7 @@
id="submit_modification_btn" data-test-id="submit_modification_request_button" (click)="bsModalRef.hide(); showSubmitModal(false)" - [disabled]="modificationForm.invalid || !min_vm" + [disabled]="modificationForm.invalid || !min_vm || !checkValidityComment()" > Submit diff --git a/src/app/projectmanagement/modals/modification-request/modification-request.component.ts b/src/app/projectmanagement/modals/modification-request/modification-request.component.ts index 10a0ab58f8..9e345e03a3 100644 --- a/src/app/projectmanagement/modals/modification-request/modification-request.component.ts +++ b/src/app/projectmanagement/modals/modification-request/modification-request.component.ts @@ -92,6 +92,20 @@ export class ModificationRequestComponent implements OnInit, OnDestroy { ); } + checkValidityComment(): boolean { + if (this.extraResourceCommentRequired) { + if (this.temp_project_modification.comment.length < 50) { + return false; + } else { + const regExp = /[a-zA-Z]/g; + + return regExp.test(this.temp_project_modification.comment); + } + } else { + return true; + } + } + getFlavors(): void { this.subscription.add( this.flavorService @@ -148,7 +162,6 @@ export class ModificationRequestComponent implements OnInit, OnDestroy { flavor.counter = amount; this.temp_project_modification.flavors.push(flavor); } - console.log(this.temp_project_modification.flavors); this.min_vm = this.project.project_application_openstack_project || this.temp_project_modification.flavors.length > 0; this.temp_project_modification.calculateRamCores(); this.getExtraCredits(); From 5072d91a3b1a63df099f4c63403ab6fcb00d226d Mon Sep 17 00:00:00 2001 From: vktrrdk Date: Wed, 19 Apr 2023 11:35:41 +0200 Subject: [PATCH 2/5] fix(Application): Adjustment of unclear information regarding sensitive data --- .../information-detail/information-detail.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 15f8c60ac7..74c4a492ca 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 @@ -110,7 +110,7 @@
- Nonsensitive Data + Personal data [Article 4 (1) GDPR] (e.g. name, e-mail)

Yes

No

From a259d896346c8cc8c50b5e9773542ef8f01e47e4 Mon Sep 17 00:00:00 2001 From: vktrrdk Date: Wed, 19 Apr 2023 13:29:22 +0200 Subject: [PATCH 3/5] added textual information on minimal comment length --- .../application-formular/application-formular.component.html | 3 +++ .../modification-request/modification-request.component.html | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/app/applications/application-formular/application-formular.component.html b/src/app/applications/application-formular/application-formular.component.html index 809a70ffff..149482d3b0 100644 --- a/src/app/applications/application-formular/application-formular.component.html +++ b/src/app/applications/application-formular/application-formular.component.html @@ -534,6 +534,9 @@
Resources
'is-valid': form.controls.project_application_comment?.valid && checkValidityComment() }" > +
+ Please provide a more detailed description. At least 50 characters must be entered. +
Additional information you want to share? diff --git a/src/app/projectmanagement/modals/modification-request/modification-request.component.html b/src/app/projectmanagement/modals/modification-request/modification-request.component.html index a3d1736df8..05f11c5f31 100644 --- a/src/app/projectmanagement/modals/modification-request/modification-request.component.html +++ b/src/app/projectmanagement/modals/modification-request/modification-request.component.html @@ -603,6 +603,9 @@
'is-valid': modificationForm.controls.project_application_renewal_comment?.valid && checkValidityComment() }" > +
+ Please provide a more detailed description. At least 50 characters must be entered. +
Additional information you want to share? From 3bedea6756f973529ba1b0b414c33395adcbd318 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:30:35 +0200 Subject: [PATCH 4/5] fix(Linting):blacked code (#5636) Co-authored-by: vktrrdk --- .../public-key/public-key.component.ts | 209 +++++++++--------- 1 file changed, 104 insertions(+), 105 deletions(-) diff --git a/src/app/shared/shared_modules/public-key/public-key.component.ts b/src/app/shared/shared_modules/public-key/public-key.component.ts index 5f64402d33..604c5c767d 100644 --- a/src/app/shared/shared_modules/public-key/public-key.component.ts +++ b/src/app/shared/shared_modules/public-key/public-key.component.ts @@ -1,128 +1,127 @@ import { - Component, EventEmitter, Input, OnInit, Output, + Component, EventEmitter, Input, OnInit, Output, } from '@angular/core'; -import {ClipboardService} from 'ngx-clipboard'; -import {saveAs} from 'file-saver'; -import {BsModalService} from 'ngx-bootstrap/modal'; -import {KeyService} from '../../../api-connector/key.service'; -import {ApiSettings} from '../../../api-connector/api-settings.service'; -import {Userinfo} from '../../../userinfo/userinfo.model'; -import {IResponseTemplate} from '../../../api-connector/response-template'; -import {AbstractBaseClass} from '../baseClass/abstract-base-class'; -import {WIKI_GENERATE_KEYS} from '../../../../links/links'; -import {NotificationModalComponent} from '../../modal/notification-modal'; -import {BlacklistedResponse} from '../../../api-connector/response-interfaces'; -import {CLOUD_PORTAL_SUPPORT_MAIL} from '../../../../links/links' +import { ClipboardService } from 'ngx-clipboard'; +import { saveAs } from 'file-saver'; +import { BsModalService } from 'ngx-bootstrap/modal'; +import { KeyService } from '../../../api-connector/key.service'; +import { ApiSettings } from '../../../api-connector/api-settings.service'; +import { Userinfo } from '../../../userinfo/userinfo.model'; +import { IResponseTemplate } from '../../../api-connector/response-template'; +import { AbstractBaseClass } from '../baseClass/abstract-base-class'; +import { WIKI_GENERATE_KEYS, CLOUD_PORTAL_SUPPORT_MAIL } from '../../../../links/links'; +import { NotificationModalComponent } from '../../modal/notification-modal'; +import { BlacklistedResponse } from '../../../api-connector/response-interfaces'; /** * Public Key component. */ @Component({ - // eslint-disable-next-line @angular-eslint/component-selector - selector: '[app-public-key]', - templateUrl: './public-key.component.html', - styleUrls: ['./public-key.component.scss'], - providers: [ApiSettings, KeyService], + // eslint-disable-next-line @angular-eslint/component-selector + selector: '[app-public-key]', + templateUrl: './public-key.component.html', + styleUrls: ['./public-key.component.scss'], + providers: [ApiSettings, KeyService], }) export class PublicKeyComponent extends AbstractBaseClass implements OnInit { - WIKI_GENERATE_KEYS: string = WIKI_GENERATE_KEYS; - public_key: string; - validated_key: boolean = false; - blocked_key: boolean = false; - current_key_blocked: boolean = false; - acknowledgement_given: boolean = false; - @Input() userinfo: Userinfo; - @Output() readonly currentKeyBlockedChanged: EventEmitter = new EventEmitter(); - CLOUD_PORTAL_SUPPORT_MAIL: string= CLOUD_PORTAL_SUPPORT_MAIL + WIKI_GENERATE_KEYS: string = WIKI_GENERATE_KEYS; + public_key: string; + validated_key: boolean = false; + blocked_key: boolean = false; + current_key_blocked: boolean = false; + acknowledgement_given: boolean = false; + @Input() userinfo: Userinfo; + @Output() readonly currentKeyBlockedChanged: EventEmitter = new EventEmitter(); + CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL; - constructor( - private keyService: KeyService, - private clipboardService: ClipboardService, - private modalService: BsModalService, - ) { - super(); - } + constructor( + private keyService: KeyService, + private clipboardService: ClipboardService, + private modalService: BsModalService, + ) { + super(); + } - ngOnInit() { - if (this.userinfo?.PublicKey) { - this.isCurrentKeyBlocked(); - } + ngOnInit() { + if (this.userinfo?.PublicKey) { + this.isCurrentKeyBlocked(); } + } - downloadPem(data: string): void { - const blob: Blob = new Blob([data], {type: 'pem'}); - const url: string = window.URL.createObjectURL(blob); - saveAs(url, `${this.userinfo.UserLogin}_ecdsa`); - } + downloadPem(data: string): void { + const blob: Blob = new Blob([data], { type: 'pem' }); + const url: string = window.URL.createObjectURL(blob); + saveAs(url, `${this.userinfo.UserLogin}_ecdsa`); + } - generateKey(): void { - this.keyService.generateKey().subscribe((res: any): void => { - this.getUserPublicKey(); - this.downloadPem(res['private_key']); - }); - } + generateKey(): void { + this.keyService.generateKey().subscribe((res: any): void => { + this.getUserPublicKey(); + this.downloadPem(res['private_key']); + }); + } - isKeyBlocked(): void { - this.keyService.isBlocked(this.public_key.trim()).subscribe((res: BlacklistedResponse) => { - this.blocked_key = res.blacklisted; - }); - } + isKeyBlocked(): void { + this.keyService.isBlocked(this.public_key.trim()).subscribe((res: BlacklistedResponse) => { + this.blocked_key = res.blacklisted; + }); + } - isCurrentKeyBlocked(): void { - this.keyService.isBlocked(this.userinfo.PublicKey).subscribe((res: BlacklistedResponse) => { - this.current_key_blocked = res.blacklisted; - this.currentKeyBlockedChanged.emit(this.current_key_blocked); - }); - } + isCurrentKeyBlocked(): void { + this.keyService.isBlocked(this.userinfo.PublicKey).subscribe((res: BlacklistedResponse) => { + this.current_key_blocked = res.blacklisted; + this.currentKeyBlockedChanged.emit(this.current_key_blocked); + }); + } - validateKey(): void { - this.keyService.validateKey(this.public_key.trim()).subscribe( - (res: any) => { - this.validated_key = res['status'] === 'valid'; - }, - () => { - this.validated_key = false; - }, - ); - } + validateKey(): void { + this.keyService.validateKey(this.public_key.trim()).subscribe( + (res: any) => { + this.validated_key = res['status'] === 'valid'; + }, + () => { + this.validated_key = false; + }, + ); + } - importKey(): void { - const re: RegExp = /\+/gi; + importKey(): void { + const re: RegExp = /\+/gi; - this.keyService.postKey(this.public_key.replace(re, '%2B').trim()).subscribe({ - next: (): void => { - this.getUserPublicKey(); - const initialState = { - notificationModalTitle: 'Success', - notificationModalType: 'info', - notificationModalMessage: 'The new public key got successfully set', - }; - this.modalService.show(NotificationModalComponent, {initialState}); - }, - error: (): any => { - const initialState = { - notificationModalTitle: 'Error', - notificationModalType: 'danger', - notificationModalMessage: - 'We were not able successfully set a new public key. Please enter a valid public key!', - }; - this.modalService.show(NotificationModalComponent, {initialState}); - }, - }); - } + this.keyService.postKey(this.public_key.replace(re, '%2B').trim()).subscribe({ + next: (): void => { + this.getUserPublicKey(); + const initialState = { + notificationModalTitle: 'Success', + notificationModalType: 'info', + notificationModalMessage: 'The new public key got successfully set', + }; + this.modalService.show(NotificationModalComponent, { initialState }); + }, + error: (): any => { + const initialState = { + notificationModalTitle: 'Error', + notificationModalType: 'danger', + notificationModalMessage: + 'We were not able successfully set a new public key. Please enter a valid public key!', + }; + this.modalService.show(NotificationModalComponent, { initialState }); + }, + }); + } - copyToClipboard(text: string): void { - if (this.clipboardService.isSupported) { - this.clipboardService.copy(text); - } else { - super.copyToClipboard(text); - } + copyToClipboard(text: string): void { + if (this.clipboardService.isSupported) { + this.clipboardService.copy(text); + } else { + super.copyToClipboard(text); } + } - getUserPublicKey(): void { - this.keyService.getKey().subscribe((key: IResponseTemplate): void => { - this.userinfo.PublicKey = key.value as string; - this.isKeyBlocked(); - }); - } + getUserPublicKey(): void { + this.keyService.getKey().subscribe((key: IResponseTemplate): void => { + this.userinfo.PublicKey = key.value as string; + this.isKeyBlocked(); + }); + } } From 9f399154407c55fc9b38b08b0da5d996e4c570da Mon Sep 17 00:00:00 2001 From: dweinholz Date: Wed, 19 Apr 2023 14:06:36 +0200 Subject: [PATCH 5/5] Update information-detail.component.html --- .../information-detail/information-detail.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 74c4a492ca..980f5b9cbe 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 @@ -117,7 +117,7 @@
- Sensitive Data + Sensitive Personal data [Articles 4 (13,14,15), 9 GDPR and Recital 51]

Yes

No