From 5f94bca890d5f05a0deac0fb2f0d272122ca7ead Mon Sep 17 00:00:00 2001 From: ekatchko Date: Mon, 19 Apr 2021 14:57:15 +0200 Subject: [PATCH] fix(application, vm): std flavours first, show flavors if > 0 --- .editorconfig | 2 +- package-lock.json | 2 - .../application-formular.component.ts | 31 +-- .../application-base-class.component.ts | 214 +++++++++--------- .../flavordetail.component.html | 2 +- 5 files changed, 113 insertions(+), 138 deletions(-) diff --git a/.editorconfig b/.editorconfig index f3526162d6..d7bd5ec8f5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root = true [*] charset = utf-8 -indent_style = space +indent_style = tab indent_size = 2 end_of_line = lf insert_final_newline = true diff --git a/package-lock.json b/package-lock.json index aaffae522b..3802499574 100644 --- a/package-lock.json +++ b/package-lock.json @@ -346,7 +346,6 @@ "dev": true } } - }, "caniuse-lite": { "version": "1.0.30001208", @@ -7540,7 +7539,6 @@ "node-releases": "^1.1.71" } }, - "caniuse-lite": { "version": "1.0.30001208", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001208.tgz", diff --git a/src/app/applications/application-formular/application-formular.component.ts b/src/app/applications/application-formular/application-formular.component.ts index 0ec27d540a..06ba6ea44f 100644 --- a/src/app/applications/application-formular/application-formular.component.ts +++ b/src/app/applications/application-formular/application-formular.component.ts @@ -59,14 +59,10 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent @ViewChild('edam_ontology', { static: true }) edam_ontology: AutocompleteComponent; @ViewChild(NgForm, { static: true }) application_form: NgForm; - /** - * List of flavor types. - */ - public typeList: FlavorType[] = []; - /** - * List of all collapse booleans. - */ - public collapseList: boolean[]; + // /** + // * List of flavor types. + // */ + // public typeList: FlavorType[] = []; constructor(private creditsService: CreditsService, private flavorService: FlavorService, private fullLayout: FullLayoutComponent, @@ -197,25 +193,6 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent }); } - /** - * Uses the param types to safe the available FlavorTypes to the array typeList. - * Also it fills the array collapseList with booleans of value 'false' so all flavor-categories are shown in the application form. - * - * @param types array of all available FlavorTypes - */ - setListOfTypes(types: FlavorType[]): void { - this.typeList = types; - this.collapseList = new Array(types.length) as boolean[]; - for (const type of types) { - - this.collapseList.push(false); // AS FIX - if (type.long_name === 'Standart Flavor') { - this.collapseList[this.typeList.indexOf(type)] = true; - } - } - - } - checkIfMinVmIsSelected(): void { this.simple_vm_min_vm = this.application.flavors.length > 0; diff --git a/src/app/shared/shared_modules/baseClass/application-base-class.component.ts b/src/app/shared/shared_modules/baseClass/application-base-class.component.ts index f989a8e3e2..5e0fe2a35d 100644 --- a/src/app/shared/shared_modules/baseClass/application-base-class.component.ts +++ b/src/app/shared/shared_modules/baseClass/application-base-class.component.ts @@ -42,10 +42,6 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * List of flavor types. */ typeList: FlavorType[]; - /** - * List of all collapse booleans. - */ - collapseList: boolean[]; /** * Total number of cores. @@ -115,7 +111,7 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { constructor(protected userService: UserService, protected applicationsService: ApplicationsService, protected facilityService: FacilityService) { - super(); + super(); } @@ -123,37 +119,37 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * Gets all available compute centers and saves them in the computeCenters attribute. */ getComputeCenters(): void { - this.facilityService.getComputeCenters().subscribe((result: [{ [key: string]: string }]): void => { - for (const cc of result) { - const compute_center: ComputecenterComponent = new ComputecenterComponent( - cc['compute_center_facility_id'], - cc['compute_center_name'], - cc['compute_center_login'], - cc['compute_center_support_mail'], - ); - this.computeCenters.push(compute_center); - } - - }); + this.facilityService.getComputeCenters().subscribe((result: [{ [key: string]: string }]): void => { + for (const cc of result) { + const compute_center: ComputecenterComponent = new ComputecenterComponent( + cc['compute_center_facility_id'], + cc['compute_center_name'], + cc['compute_center_login'], + cc['compute_center_support_mail'], + ); + this.computeCenters.push(compute_center); + } + + }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars valuesChanged(flavor: Flavor, counter: number, lifetime?: string): void { - this.newFlavors[flavor.name] = { counter, flavor }; - this.calculateRamCores(); + this.newFlavors[flavor.name] = { counter, flavor }; + this.calculateRamCores(); } calculateRamCores(): void { - this.totalNumberOfCores = 0; - this.totalRAM = 0; - this.totalGPU = 0; - // tslint:disable-next-line:forin - for (const extensionFlavorsKey in this.newFlavors) { - const fl: any = this.newFlavors[extensionFlavorsKey]; - this.totalRAM += fl.flavor.ram * fl.counter; - this.totalNumberOfCores += fl.flavor.vcpus * fl.counter; - this.totalGPU += fl.flavor.gpu * fl.counter; - } + this.totalNumberOfCores = 0; + this.totalRAM = 0; + this.totalGPU = 0; + // tslint:disable-next-line:forin + for (const extensionFlavorsKey in this.newFlavors) { + const fl: any = this.newFlavors[extensionFlavorsKey]; + this.totalRAM += fl.flavor.ram * fl.counter; + this.totalNumberOfCores += fl.flavor.vcpus * fl.counter; + this.totalGPU += fl.flavor.gpu * fl.counter; + } } /** @@ -163,20 +159,20 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param collapse_id */ public getMemberDetailsByElixirIdIfCollapsed(application: Application, collapse_id: string): void { - if (!this.getCollapseStatus(collapse_id)) { - this.getMemberDetailsByElixirId(application); - } + if (!this.getCollapseStatus(collapse_id)) { + this.getMemberDetailsByElixirId(application); + } } public getMemberDetailsByElixirId(application: Application): void { - this.userService.getMemberDetailsByElixirId(application.project_application_user.elixir_id).subscribe( - (result: { [key: string]: string }): void => { + this.userService.getMemberDetailsByElixirId(application.project_application_user.elixir_id).subscribe( + (result: { [key: string]: string }): void => { - application.project_application_user.username = `${result['firstName']} ${result['lastName']}`; + application.project_application_user.username = `${result['firstName']} ${result['lastName']}`; - application.project_application_user.email = result['email']; - }, - ); + application.project_application_user.email = result['email']; + }, + ); } /** @@ -186,12 +182,12 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @returns */ public getStatusById(id: number): string { - const dummy: string = 'Unknown'; - if (Application_States_Strings[Application_States[id]]) { - return Application_States_Strings[Application_States[id]]; - } + const dummy: string = 'Unknown'; + if (Application_States_Strings[Application_States[id]]) { + return Application_States_Strings[Application_States[id]]; + } - return dummy; + return dummy; } /** @@ -200,7 +196,7 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param application */ setSelectedApplication(application: Application): void { - this.selectedApplication = application; + this.selectedApplication = application; } /** @@ -210,16 +206,20 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param types array of all available FlavorTypes */ setListOfTypes(types: FlavorType[]): void { - this.typeList = types; - this.collapseList = new Array(types.length) as boolean[]; - for (const type of types) { - - this.collapseList.push(false); // AS FIX - if (type.long_name === 'Standart Flavor') { - this.collapseList[this.typeList.indexOf(type)] = true; + let index: number = -1; + for (let i: number = 0; i < types.length; i += 1) { + if (types[i].shortcut === 'std') { + index = i; + break; } } + if (index !== -1) { + const spliced: FlavorType[] = types.splice(index, 1); + types.unshift(spliced[0]); + } + + this.typeList = types; } /** @@ -228,43 +228,43 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @param shortname */ public checkShortname(shortname: string): void { - this.wronginput = !/^[a-zA-Z0-9\s]*$/.test(shortname); + this.wronginput = !/^[a-zA-Z0-9\s]*$/.test(shortname); } /** * Fills the array constantStrings with values dependent of keys which are used to indicate inputs from the application-form */ generateConstants(): void { - this.constantStrings = []; - this.constantStrings['project_application_shortname'] = 'Shortname: '; - this.constantStrings['project_application_description'] = 'Description: '; - this.constantStrings['project_application_comment'] = 'Comment: '; - this.constantStrings['project_application_pi_email'] = 'Principal Investigator Email: '; - this.constantStrings['project_application_bmbf_project'] = 'BMBF Project: '; - - this.constantStrings['project_application_lifetime'] = 'Lifetime of your project: '; - this.constantStrings['project_application_volume_counter'] = 'Number of volumes for additional storage: '; - this.constantStrings['project_application_object_storage'] = 'Object storage: '; - this.constantStrings['project_application_volume_limit'] = 'Volume Storage space for your VMs: '; - this.constantStrings['project_application_comment'] = 'Comment: '; - this.constantStrings['project_application_renewal_comment'] = 'Comment: '; - - this.constantStrings['project_application_renewal_lifetime'] = 'Lifetime of your project: '; - this.constantStrings['project_application_renewal_volume_counter'] = 'Number of volumes for additional storage: '; - this.constantStrings['project_application_renewal_object_storage'] = 'Object storage: '; - this.constantStrings['project_application_renewal_volume_limit'] = 'Volume Storage space for your VMs: '; - this.constantStrings['project_application_institute'] = 'Your institute: '; - this.constantStrings['project_application_workgroup'] = 'Your Workgroup: '; - this.constantStrings['project_application_horizon2020'] = 'Horizon2020: '; - this.constantStrings['project_application_elixir_project'] = 'Elixir Project: '; - - this.constantStrings['project_application_report_allowed'] = 'Dissemination allowed: '; - - for (const key in this.flavorList) { - if (key in this.flavorList) { - this.constantStrings[`project_application_${this.flavorList[key].name}`] = `Number of VMs of type ${this.flavorList[key].name}: `; - } - } + this.constantStrings = []; + this.constantStrings['project_application_shortname'] = 'Shortname: '; + this.constantStrings['project_application_description'] = 'Description: '; + this.constantStrings['project_application_comment'] = 'Comment: '; + this.constantStrings['project_application_pi_email'] = 'Principal Investigator Email: '; + this.constantStrings['project_application_bmbf_project'] = 'BMBF Project: '; + + this.constantStrings['project_application_lifetime'] = 'Lifetime of your project: '; + this.constantStrings['project_application_volume_counter'] = 'Number of volumes for additional storage: '; + this.constantStrings['project_application_object_storage'] = 'Object storage: '; + this.constantStrings['project_application_volume_limit'] = 'Volume Storage space for your VMs: '; + this.constantStrings['project_application_comment'] = 'Comment: '; + this.constantStrings['project_application_renewal_comment'] = 'Comment: '; + + this.constantStrings['project_application_renewal_lifetime'] = 'Lifetime of your project: '; + this.constantStrings['project_application_renewal_volume_counter'] = 'Number of volumes for additional storage: '; + this.constantStrings['project_application_renewal_object_storage'] = 'Object storage: '; + this.constantStrings['project_application_renewal_volume_limit'] = 'Volume Storage space for your VMs: '; + this.constantStrings['project_application_institute'] = 'Your institute: '; + this.constantStrings['project_application_workgroup'] = 'Your Workgroup: '; + this.constantStrings['project_application_horizon2020'] = 'Horizon2020: '; + this.constantStrings['project_application_elixir_project'] = 'Elixir Project: '; + + this.constantStrings['project_application_report_allowed'] = 'Dissemination allowed: '; + + for (const key in this.flavorList) { + if (key in this.flavorList) { + this.constantStrings[`project_application_${this.flavorList[key].name}`] = `Number of VMs of type ${this.flavorList[key].name}: `; + } + } } /** @@ -276,31 +276,31 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass { * @returns the concatenated string for the confirmation-modal */ matchString(key: string, val: string): string { - if (key in this.constantStrings) { - switch (key) { - case 'project_application_lifetime': { - return (`${this.constantStrings[key]}${val} months`); - } - case ('project_application_volume_limit'): { - return (`${this.constantStrings[key]}${val} GB`); - } - case 'project_application_object_storage': { - return (`${this.constantStrings[key]}${val} GB`); - } - case 'project_application_report_allowed': { - if (val) { - return (`${this.constantStrings[key]} Yes`); - } else { - return (`${this.constantStrings[key]} No`); - } - } - default: { - return (`${this.constantStrings[key]}${val}`); - } - } - } else { - return null; - } + if (key in this.constantStrings) { + switch (key) { + case 'project_application_lifetime': { + return (`${this.constantStrings[key]}${val} months`); + } + case ('project_application_volume_limit'): { + return (`${this.constantStrings[key]}${val} GB`); + } + case 'project_application_object_storage': { + return (`${this.constantStrings[key]}${val} GB`); + } + case 'project_application_report_allowed': { + if (val) { + return (`${this.constantStrings[key]} Yes`); + } else { + return (`${this.constantStrings[key]} No`); + } + } + default: { + return (`${this.constantStrings[key]}${val}`); + } + } + } else { + return null; + } } } diff --git a/src/app/virtualmachines/flavordetail.component.html b/src/app/virtualmachines/flavordetail.component.html index d677e8f3bc..a591ca3b66 100644 --- a/src/app/virtualmachines/flavordetail.component.html +++ b/src/app/virtualmachines/flavordetail.component.html @@ -53,7 +53,7 @@ - +