diff --git a/package.json b/package.json index 600e7b1bd..ddef5f62a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@denbi/cloud-portal-webapp", - "version": "4.900.0", + "version": "4.901.0", "description": "de.NBI Cloud Portal", "scripts": { "ng": "ng serve", @@ -20,7 +20,7 @@ "dependencies": { "@angular-eslint/eslint-plugin": "^18.3.0", "@angular/animations": "18.2.8", - "@angular/cdk": "18.2.9", + "@angular/cdk": "19.1.0", "@angular/common": "18.2.8", "@angular/compiler": "18.2.8", "@angular/core": "18.2.8", diff --git a/src/app/api-connector/applications.service.ts b/src/app/api-connector/applications.service.ts index 606a0e9da..80a8ba935 100644 --- a/src/app/api-connector/applications.service.ts +++ b/src/app/api-connector/applications.service.ts @@ -337,16 +337,15 @@ export class ApplicationsService { }) } - checkForTakenShortname(shortname: string,exclude_project_id?:string|number): Observable { - - let params:any={ shortname: shortname } - if (exclude_project_id){ - params={ shortname: shortname ,exclude_project_id:exclude_project_id} + checkForTakenShortname(shortname: string, exclude_project_id?: string | number): Observable { + let params: any = { shortname: shortname } + if (exclude_project_id) { + params = { shortname: shortname, exclude_project_id: exclude_project_id } } + return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/shortname/`, { params: params, withCredentials: true - }); - + }) } } diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index 2fe5d576c..52efb80bb 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -33,8 +33,8 @@ import { UserService } from '../../api-connector/user.service' import { Userinfo } from '../../userinfo/userinfo.model' import { User } from '../application.model/user.model' import { NotificationModalComponent } from '../../shared/modal/notification-modal' -import { Subject } from 'rxjs'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; +import { Subject } from 'rxjs' +import { debounceTime, distinctUntilChanged } from 'rxjs/operators' /** * Application formular component. @@ -53,8 +53,8 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent @Input() application: Application @Input() is_validation: boolean = false @Input() hash: string - DEFAULT_SHORTNAME_MAX_LENGTH:number=15 - shortNameMaxLength:number=15 + DEFAULT_SHORTNAME_MAX_LENGTH: number = 15 + shortNameMaxLength: number = 15 userinfo: Userinfo valid_pi_affiliations @@ -91,9 +91,9 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent WIKI_BACKUP_LINK: string = WIKI_BACKUP_LINK GDPR_LINK: string = GDPR_LINK survey_link_visible: boolean = false - private nameCheckPipe = new Subject(); - shortnameChecking: boolean = false; - shortNameTaken: boolean = false; + private nameCheckPipe = new Subject() + shortnameChecking: boolean = false + shortNameTaken: boolean = false MAX_LIFETIME_DEFAULT: number = 6 max_lifetime: number = this.MAX_LIFETIME_DEFAULT @@ -126,7 +126,9 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent this.getListOfFlavors() this.getListOfTypes() this.is_vo_admin = is_vo - this.nameCheckPipe.pipe(debounceTime(600), distinctUntilChanged()).subscribe(value => {this.checkIfNameIsTaken(value)}); + this.nameCheckPipe.pipe(debounceTime(600), distinctUntilChanged()).subscribe(value => { + this.checkIfNameIsTaken(value) + }) if (this.openstack_project) { this.simple_vm_min_vm = true @@ -146,19 +148,20 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent } } - setDefaulShortnameLength():void{ - this.shortNameMaxLength=this.DEFAULT_SHORTNAME_MAX_LENGTH + setDefaulShortnameLength(): void { + this.shortNameMaxLength = this.DEFAULT_SHORTNAME_MAX_LENGTH } checkIfNameIsTaken(shortname: string): void { - this.shortnameChecking = true; - - this.applicationsService.checkForTakenShortname(shortname,this.application?.project_application_id).subscribe((result: boolean): void => { - let nameExists: boolean = result['exists']; - this.shortnameChecking = false; - this.shortNameTaken = nameExists; - }); - + this.shortnameChecking = true + + this.applicationsService + .checkForTakenShortname(shortname, this.application?.project_application_id) + .subscribe((result: boolean): void => { + const nameExists: boolean = result['exists'] + this.shortnameChecking = false + this.shortNameTaken = nameExists + }) } checkValidityComment(): boolean { @@ -196,8 +199,8 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent if (this.application && !this.initiated_validation && this.is_validation) { this.openstack_project = this.application.project_application_openstack_project - if(this.application.project_application_shortname.length > 15){ - this.shortNameMaxLength=this.application.project_application_shortname.length + if (this.application.project_application_shortname.length > 15) { + this.shortNameMaxLength = this.application.project_application_shortname.length } this.simple_vm_project = !this.openstack_project @@ -266,10 +269,9 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent public checkShortname(shortname: string): void { this.invalid_shortname = !/^[a-zA-Z0-9\s]*$/.test(shortname) if (!this.invalid_shortname) { - this.shortnameChecking = true; - this.nameCheckPipe.next(shortname); + this.shortnameChecking = true + this.nameCheckPipe.next(shortname) } - } public checkLongname(longname: string): void { diff --git a/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.spec.ts b/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.spec.ts index 883f9cbe6..d9c118c28 100644 --- a/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.spec.ts +++ b/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.spec.ts @@ -1,23 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { GeneratePublicKeyModalComponent } from './generate-public-key-modal.component'; +import { GeneratePublicKeyModalComponent } from './generate-public-key-modal.component' describe('GeneratePublicKeyModalComponent', () => { - let component: GeneratePublicKeyModalComponent; - let fixture: ComponentFixture; + let component: GeneratePublicKeyModalComponent + let fixture: ComponentFixture - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [GeneratePublicKeyModalComponent] - }) - .compileComponents(); + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [GeneratePublicKeyModalComponent] + }).compileComponents() - fixture = TestBed.createComponent(GeneratePublicKeyModalComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(GeneratePublicKeyModalComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts b/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts index 0e3c66832..6b7d0353e 100644 --- a/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts +++ b/src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts @@ -1,48 +1,43 @@ -import { Component, EventEmitter, Injectable } from '@angular/core'; -import { KeyService } from 'app/api-connector/key.service'; -import { AbstractBaseModalComponent } from 'app/shared/modal/abstract-base-modal/abstract-base-modal.component'; -import { BsModalService } from 'ngx-bootstrap/modal'; +import { Component, EventEmitter, Injectable } from '@angular/core' +import { KeyService } from 'app/api-connector/key.service' +import { AbstractBaseModalComponent } from 'app/shared/modal/abstract-base-modal/abstract-base-modal.component' +import { BsModalService } from 'ngx-bootstrap/modal' import { saveAs } from 'file-saver' @Injectable({ providedIn: 'root' }) @Component({ - selector: 'app-generate-public-key-modal', - templateUrl: './generate-public-key-modal.component.html', - styleUrl: './generate-public-key-modal.component.scss' + selector: 'app-generate-public-key-modal', + templateUrl: './generate-public-key-modal.component.html', + styleUrl: './generate-public-key-modal.component.scss' }) export class GeneratePublicKeyModalComponent extends AbstractBaseModalComponent { - userlogin:string; - acknowledgement_given:boolean=false + userlogin: string + acknowledgement_given: boolean = false - constructor( + constructor( protected modalService: BsModalService, - private keyService:KeyService - ) { - super(modalService) - - } - showGeneratePublicKeyModal( - userlogin:string - - ): EventEmitter { - const initialState = { - userlogin - } - - return this.showBaseModal(GeneratePublicKeyModalComponent, initialState) + private keyService: KeyService + ) { + super(modalService) + } + showGeneratePublicKeyModal(userlogin: string): EventEmitter { + const initialState = { + userlogin } - downloadPem(data: string): void { - const blob: Blob = new Blob([data], { type: 'pem' }) - const url: string = window.URL.createObjectURL(blob) - saveAs(url, `${this.userlogin}_ecdsa`) - } - - - generateKey(): void { - this.keyService.generateKey().subscribe((res: any): void => { - this.event.emit() - this.downloadPem(res['private_key']) - }) - } + return this.showBaseModal(GeneratePublicKeyModalComponent, initialState) + } + + downloadPem(data: string): void { + const blob: Blob = new Blob([data], { type: 'pem' }) + const url: string = window.URL.createObjectURL(blob) + saveAs(url, `${this.userlogin}_ecdsa`) + } + + generateKey(): void { + this.keyService.generateKey().subscribe((res: any): void => { + this.event.emit() + this.downloadPem(res['private_key']) + }) + } } 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 802931e24..dd6af9d6d 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 @@ -33,8 +33,8 @@ export class PublicKeyComponent extends AbstractBaseClass implements OnInit { constructor( private keyService: KeyService, private clipboardService: ClipboardService, - private generatePublicKeyModal:GeneratePublicKeyModalComponent, - private setPublicKeyModalComponent:SetPublicKeyModalComponent + private generatePublicKeyModal: GeneratePublicKeyModalComponent, + private setPublicKeyModalComponent: SetPublicKeyModalComponent ) { super() } @@ -45,28 +45,24 @@ export class PublicKeyComponent extends AbstractBaseClass implements OnInit { } } - showSetPublicKeyModal():void{ - this.setPublicKeyModalComponent.showSetPublicKeyModal(this.userinfo.PublicKey).subscribe(() =>{ - console.log("event submitted") + showSetPublicKeyModal(): void { + this.setPublicKeyModalComponent.showSetPublicKeyModal(this.userinfo.PublicKey).subscribe(() => { + console.log('event submitted') this.getUserPublicKey() }) - } - showGeneratePublicKeyModal():void{ - this.generatePublicKeyModal.showGeneratePublicKeyModal(this.userinfo.UserLogin).subscribe(() =>{ - console.log("event submitted") + showGeneratePublicKeyModal(): void { + this.generatePublicKeyModal.showGeneratePublicKeyModal(this.userinfo.UserLogin).subscribe(() => { + console.log('event submitted') this.getUserPublicKey() }) } - unsetAcknowledgment():void{ - this.acknowledgement_given=false; + unsetAcknowledgment(): void { + this.acknowledgement_given = false } - - - isKeyBlocked(): void { this.keyService.isBlocked(this.userinfo.PublicKey.trim()).subscribe((res: BlacklistedResponse) => { this.blocked_key = res.blacklisted @@ -80,8 +76,6 @@ export class PublicKeyComponent extends AbstractBaseClass implements OnInit { }) } - - copyToClipboard(text: string): void { if (this.clipboardService.isSupported) { this.clipboardService.copy(text) diff --git a/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.spec.ts b/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.spec.ts index 522215967..a0d03b51c 100644 --- a/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.spec.ts +++ b/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.spec.ts @@ -1,23 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { SetPublicKeyModalComponent } from './set-public-key-modal.component'; +import { SetPublicKeyModalComponent } from './set-public-key-modal.component' describe('SetPublicKeyModalComponent', () => { - let component: SetPublicKeyModalComponent; - let fixture: ComponentFixture; + let component: SetPublicKeyModalComponent + let fixture: ComponentFixture - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [SetPublicKeyModalComponent] - }) - .compileComponents(); + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SetPublicKeyModalComponent] + }).compileComponents() - fixture = TestBed.createComponent(SetPublicKeyModalComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + fixture = TestBed.createComponent(SetPublicKeyModalComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.ts b/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.ts index 416cdc517..9c7e7ff11 100644 --- a/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.ts +++ b/src/app/shared/shared_modules/public-key/set-public-key-modal/set-public-key-modal.component.ts @@ -1,48 +1,43 @@ -import { Component, EventEmitter, Injectable } from '@angular/core'; -import { KeyService } from 'app/api-connector/key.service'; -import { BlacklistedResponse } from 'app/api-connector/response-interfaces'; -import { AbstractBaseModalComponent } from 'app/shared/modal/abstract-base-modal/abstract-base-modal.component'; -import { NotificationModalComponent } from 'app/shared/modal/notification-modal'; -import { BsModalService } from 'ngx-bootstrap/modal'; +import { Component, EventEmitter, Injectable } from '@angular/core' +import { KeyService } from 'app/api-connector/key.service' +import { BlacklistedResponse } from 'app/api-connector/response-interfaces' +import { AbstractBaseModalComponent } from 'app/shared/modal/abstract-base-modal/abstract-base-modal.component' +import { NotificationModalComponent } from 'app/shared/modal/notification-modal' +import { BsModalService } from 'ngx-bootstrap/modal' @Injectable({ providedIn: 'root' }) @Component({ - selector: 'app-set-public-key-modal', - templateUrl: './set-public-key-modal.component.html', - styleUrl: './set-public-key-modal.component.scss' + selector: 'app-set-public-key-modal', + templateUrl: './set-public-key-modal.component.html', + styleUrl: './set-public-key-modal.component.scss' }) -export class SetPublicKeyModalComponent extends AbstractBaseModalComponent { - - acknowledgement_given:boolean=false - public_key:string; +export class SetPublicKeyModalComponent extends AbstractBaseModalComponent { + acknowledgement_given: boolean = false + public_key: string validated_key: boolean = false blocked_key: boolean = false current_key_blocked: boolean = false - constructor( + constructor( protected modalService: BsModalService, - private keyService:KeyService - ) { - super(modalService) - + private keyService: KeyService + ) { + super(modalService) + } + showSetPublicKeyModal(userlogin: string): EventEmitter { + const initialState = { + userlogin } - showSetPublicKeyModal( - userlogin:string - ): EventEmitter { - const initialState = { - userlogin - } - - return this.showBaseModal(SetPublicKeyModalComponent, initialState) - } + return this.showBaseModal(SetPublicKeyModalComponent, initialState) + } isKeyBlocked(): void { this.keyService.isBlocked(this.public_key.trim()).subscribe((res: BlacklistedResponse) => { this.blocked_key = res.blacklisted }) } -validateKey(): void { + validateKey(): void { this.keyService.validateKey(this.public_key.trim()).subscribe( (res: any) => { this.validated_key = res['status'] === 'valid'