Skip to content

Commit

Permalink
fix(application, vm): std flavours first, show flavors if > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
eKatchko committed Apr 19, 2021
1 parent fcf0526 commit 5f94bca
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -115,45 +111,45 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass {
constructor(protected userService: UserService,
protected applicationsService: ApplicationsService,
protected facilityService: FacilityService) {
super();
super();

}

/**
* 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;
}
}

/**
Expand All @@ -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'];
},
);
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -200,7 +196,7 @@ export class ApplicationBaseClassComponent extends AbstractBaseClass {
* @param application
*/
setSelectedApplication(application: Application): void {
this.selectedApplication = application;
this.selectedApplication = application;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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}: `;
}
}
}

/**
Expand All @@ -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;
}
}

}
2 changes: 1 addition & 1 deletion src/app/virtualmachines/flavordetail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

</div>

<ng-container *ngIf="flavors.length > 0 && !selectedFlavor || flavors.length>1 &&selectedFlavor">
<ng-container *ngIf="(flavors.length > 0 && !selectedFlavor) || (flavors.length > 0 && selectedFlavor)">
<div *ngFor=" let flavor of flavors" style="cursor: pointer;" class="col-12 "
[ngClass]="{'col-xl-4':(window_size >= carousel_window_min_xl_9)
|| (window_size <carousel_window_min_xl_9 && window_size>=carousel_window_min_xl_8),
Expand Down

0 comments on commit 5f94bca

Please sign in to comment.