From 17c33f963c4c1d93e43edd7669b8c06a745974bb Mon Sep 17 00:00:00 2001 From: dweinholz Date: Fri, 11 Feb 2022 12:59:09 +0100 Subject: [PATCH] test precommit --- .prettierrc | 3 +- package.json | 4 +- src/app/virtualmachines/addvm.component.ts | 154 +++++++++++---------- 3 files changed, 87 insertions(+), 74 deletions(-) diff --git a/.prettierrc b/.prettierrc index 9cf2737a17..1047d0b91e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,8 +4,7 @@ "proseWrap": "preserve", "semi": false, "singleQuote": true, - "useTabs": false, - "tabWidth": 2, + "useTabs": true, "arrowParens": "avoid", "trailingComma": "es5" } diff --git a/package.json b/package.json index 23e716094a..0f9a2e5bb3 100644 --- a/package.json +++ b/package.json @@ -138,12 +138,12 @@ "lint-staged": { "*.{js,jsx,ts}": [ "prettier --write", - "ng lint --fix" + "eslint --fix" ], "*.{html,css,less,ejs}": [ "prettier --write" ], - "*.js": "ng lint --fix", + "*.js": "eslint --cache --fix", "*.{js,css,md}": "prettier --write" } } diff --git a/src/app/virtualmachines/addvm.component.ts b/src/app/virtualmachines/addvm.component.ts index 364a9149c4..859938748e 100644 --- a/src/app/virtualmachines/addvm.component.ts +++ b/src/app/virtualmachines/addvm.component.ts @@ -41,12 +41,20 @@ import { ApplicationsService } from '../api-connector/applications.service'; @Component({ selector: 'app-new-vm', templateUrl: 'addvm.component.html', - providers: [GroupService, ImageService, KeyService, FlavorService, VirtualmachineService, - ApiSettings, UserService, ApplicationsService], + providers: [ + GroupService, + ImageService, + KeyService, + FlavorService, + VirtualmachineService, + ApiSettings, + UserService, + ApplicationsService, + ], }) export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { - SIXTY_SIX_PERCENT: number = 66; + SEVENTY_FIVE: number = 75; ACTIVE: string = 'ACTIVE'; DELETED: string = 'DELETED'; @@ -284,11 +292,11 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { getDetachedVolumesByProject(): void { this.subscription.add( - this.virtualmachineservice.getDetachedVolumesByProject(this.selectedProject[1]).subscribe( - (detached_volumes: Volume[]): void => { + this.virtualmachineservice + .getDetachedVolumesByProject(this.selectedProject[1]) + .subscribe((detached_volumes: Volume[]): void => { this.detached_project_volumes = detached_volumes; - }, - ), + }), ); } @@ -337,7 +345,12 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { if (!(this.volumeStorage > 0)) { return false; // eslint-disable-next-line max-len - } else return (this.selectedProjectRessources.used_volume_storage + this.getStorageInList() + this.volumeStorage) <= this.selectedProjectRessources.max_volume_storage; + } else { + return ( + this.selectedProjectRessources.used_volume_storage + this.getStorageInList() + this.volumeStorage + <= this.selectedProjectRessources.max_volume_storage + ); + } } // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -350,10 +363,12 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { * A new volume can only be added to the list, if this function returns true. */ checkVolumeValidity(): boolean { - return (this.checkStorageNumber() + return ( + this.checkStorageNumber() && this.checkIfMountPathIsUsable(this.volumeMountPath) && this.checkInputVolumeString(this.volumeMountPath) - && this.checkInputVolumeString(this.volumeName)); + && this.checkInputVolumeString(this.volumeName) + ); } /** @@ -374,7 +389,7 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { addAttachVolume(vol: Volume): void { this.selected_detached_vol = this.undefined_detached_vol; this.volumesToAttach.push(vol); - this.detached_project_volumes = this.detached_project_volumes.filter((volume: Volume): any => (vol !== volume)); + this.detached_project_volumes = this.detached_project_volumes.filter((volume: Volume): any => vol !== volume); if (this.detached_project_volumes.length === 0) { this.toggleShowAttachVol(); } @@ -473,57 +488,55 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { if (!this.mosh_mode_available) { this.udp_allowed = false; } - this.delay(500).then((): any => { - this.progress_bar_width = 50; - }).catch((): any => { - }); + this.delay(500) + .then((): any => { + this.progress_bar_width = 50; + }) + .catch((): any => {}); const additional_elixir_ids: string[] = this.members_to_add.map((mem: ProjectMember): string => mem.elixirId); this.subscription.add( - this.virtualmachineservice.startVM( - flavor_fixed, - this.selectedImage, - servername, - project, - projectid.toString(), - this.http_allowed, - this.https_allowed, - this.udp_allowed, - this.volumesToMount, - this.volumesToAttach, - play_information, - additional_elixir_ids, - ) - .subscribe((newVm: VirtualMachine): void => { - this.error_starting_machine = false; - this.newVm = newVm; - this.started_machine = false; - - if (newVm.status) { - this.progress_bar_width = 75; - setTimeout( - (): void => { + this.virtualmachineservice + .startVM( + flavor_fixed, + this.selectedImage, + servername, + project, + projectid.toString(), + this.http_allowed, + this.https_allowed, + this.udp_allowed, + this.volumesToMount, + this.volumesToAttach, + play_information, + additional_elixir_ids, + ) + .subscribe( + (newVm: VirtualMachine): void => { + this.error_starting_machine = false; + this.newVm = newVm; + this.started_machine = false; + + if (newVm.status) { + this.progress_bar_width = 75; + setTimeout((): void => { void this.router.navigate(['/virtualmachines/vmOverview']).then().catch(); - }, - 2000, - ); - - } else { - this.loadProjectData(); - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - this.create_error = newVm; - } - - }, (error): void => { - console.log(error); - this.error_starting_machine = true; - }), + }, 2000); + } else { + this.loadProjectData(); + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + this.create_error = (newVm); + } + }, + (error): void => { + console.log(error); + this.error_starting_machine = true; + }, + ), ); } else { this.progress_bar_status = this.CREATING_STATUS; this.newVm = null; - } - } async delay(ms: number): Promise { @@ -545,9 +558,14 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.timeout += this.biocondaComponent.getTimeout(); } - if (this.resEnvComponent && this.resEnvComponent.selectedTemplate.template_name !== 'undefined' - && this.resEnvComponent.user_key_url.errors === null) { - playbook_info[this.resEnvComponent.selectedTemplate.template_name] = { create_only_backend: `${this.resEnvComponent.getCreateOnlyBackend()}` }; + if ( + this.resEnvComponent + && this.resEnvComponent.selectedTemplate.template_name !== 'undefined' + && this.resEnvComponent.user_key_url.errors === null + ) { + playbook_info[this.resEnvComponent.selectedTemplate.template_name] = { + create_only_backend: `${this.resEnvComponent.getCreateOnlyBackend()}`, + }; playbook_info['user_key_url'] = { user_key_url: this.resEnvComponent.getUserKeyUrl() }; } @@ -589,11 +607,11 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { } else { this.client_available = false; this.client_checked = true; - } this.selectedProjectClient = client; this.subscription.add( - this.imageService.getBlockedImageTagsResenv(Number(this.selectedProjectClient.id), 'true') + this.imageService + .getBlockedImageTagsResenv(Number(this.selectedProjectClient.id), 'true') .subscribe((tags: BlockedImageTagResenv[]): void => { this.blockedImageTagsResenv = tags; }), @@ -675,16 +693,17 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.selectedFlavor = undefined; this.getDetachedVolumesByProject(); this.subscription.add( - this.groupService.getGroupResources(this.selectedProject[1].toString()).subscribe((res: ApplicationRessourceUsage): void => { - this.selectedProjectRessources = new ApplicationRessourceUsage(res); - this.data_loaded = true; - this.checkProjectDataLoaded(); - }), + this.groupService + .getGroupResources(this.selectedProject[1].toString()) + .subscribe((res: ApplicationRessourceUsage): void => { + this.selectedProjectRessources = new ApplicationRessourceUsage(res); + this.data_loaded = true; + this.checkProjectDataLoaded(); + }), ); this.getImages(this.selectedProject[1]); this.getFlavors(this.selectedProject[1]); - } generateRandomName(): void { @@ -696,7 +715,6 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { this.selectedImage = image; this.isMoshModeAvailable(); this.hasImageResenv(); - } checkImageAgain(): void { @@ -718,7 +736,6 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { } } this.mosh_mode_available = false; - } hasImageResenv(): void { @@ -734,13 +751,11 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { return; } } - } this.resenvSelected = false; if (this.resEnvComponent) { this.resEnvComponent.unsetOnlyNamespace(); } - } setSelectedFlavor(flavor: Flavor): void { @@ -828,5 +843,4 @@ export class VirtualMachineComponent implements OnInit, DoCheck, OnDestroy { return storageInList; } } - }