diff --git a/src/app/course/course-wizard/course-wizard.component.html b/src/app/course/course-wizard/course-wizard.component.html index 03ed2746..0fbd2d34 100644 --- a/src/app/course/course-wizard/course-wizard.component.html +++ b/src/app/course/course-wizard/course-wizard.component.html @@ -27,11 +27,52 @@ + Virtual Machine + + Virtual Machines Finalize

Confirm the following details before finishing

Course

+ @@ -467,52 +528,56 @@

Course

-

VM Information

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +

VM Information

+
VM NameVM Template
{{ q.key }}{{ q.value }}{{ q.key }}{{ q.value }}{{ q.value }}
{{ q.key }}{{ q.value }}
+ + + + - - -
VM NameVM Template
+ + + + + + + {{ q.key }} + + + {{ q.value }} + + + + {{ q.key }} + {{ q.value }} + + + + {{ q.value }} + + + + + + + + {{ q.key }} + {{ q.value }} + + + + + +
0; + } + + courseHasValidVMCConfiguration(): boolean { + console.log(this.editVirtualMachines); + if (this.editVirtualMachines.length > 0) { + const validVMSets = this.editVirtualMachines.filter( + (virtualmachine, i) => { + if (Object.keys(virtualmachine).length > 0) { + return true; + } + return false; + } + ); + if (validVMSets.length == this.editVirtualMachines.length) { + return true; + } } + return false; } + openEditCourse(course: Course) { this.wizard.reset(); this.selectedCourse = course; this.editCourse(course); - this.VMSAllow(); this.wizard.open(); this.wizard.navService.goTo(this.wizard.pages.last, true); this.wizard.pages.first.makeCurrent(); @@ -202,20 +215,19 @@ export class CourseWizardComponent implements OnChanges, OnInit { course.categories = this.editCategories; } newCourseWizard() { - this.setCourseValues(this.course) + this.setCourseValues(this.course); } updateCourseWizard() { - this.setCourseValues(this.selectedCourse) - } - updateFinalPageWizard() { - if (this.wizardCourse == 'edit'){ - this.setCourseValues(this.editSelectedCourse) + this.setCourseValues(this.selectedCourse); } + updateFinalPageWizard() { + if (this.wizardCourse == 'edit') { + this.setCourseValues(this.editSelectedCourse); + } } setVM(vms: {}[]) { this.editVirtualMachines = vms; - this.VMSAllow(); this.setModified(); } setModified() { @@ -304,9 +316,8 @@ export class CourseWizardComponent implements OnChanges, OnInit { } whenFinish() { - if (this.wizardCourse == 'create') this.createCourse(); - if (this.wizardCourse == 'edit') { + if (this.wizardCourse == 'edit') { this.updateCourseWizard(); this.updateCourse(); } @@ -348,32 +359,45 @@ export class CourseWizardComponent implements OnChanges, OnInit { this.isAlert = true; } ); - } + } - getSelectedCourseVM(index: any, vmname: any) { - const selectedCourseVMs = this.showVM( this.selectedCourse.virtualmachines[index]) - return selectedCourseVMs.has(vmname) ? selectedCourseVMs.get(vmname) : 0; + getSelectedCourseVM(index: any, vmname: any) { + const selectedCourseVMs = this.showVM( + this.selectedCourse.virtualmachines[index] + ); + return selectedCourseVMs.has(vmname) ? selectedCourseVMs.get(vmname) : 0; } - getEditSelectedCourseVM(index: any, vmname: any) { - const editSelectedCourseVMs = this.showVM( this.editSelectedCourse.virtualmachines[index]) - return editSelectedCourseVMs.has(vmname) ? editSelectedCourseVMs.get(vmname) : 0; + getEditSelectedCourseVM(index: any, vmname: any) { + const editSelectedCourseVMs = this.showVM( + this.editSelectedCourse.virtualmachines[index] + ); + return editSelectedCourseVMs.has(vmname) + ? editSelectedCourseVMs.get(vmname) + : 0; } - showVM(vms: any) { - return new Map(Object.entries(JSON.parse(JSON.stringify(vms) ))) + showVM(vms: any) { + if(!vms){ + return new Map(); + } + return new Map(Object.entries(JSON.parse(JSON.stringify(vms)))); } - isScenarioInList(scenario: Scenario, list?: Scenario[]): boolean { - return list.some(item => item.name === scenario.name); + isScenarioInList(scenario: Scenario, list?: Scenario[]): boolean { + return list.some((item) => item.name === scenario.name); } - + isEditedVM(index: any, vmname: string, templateName: any): boolean { // This function determines if the currently selected VM is either beeing edited throug the following condition: - const isEdited = this.getSelectedCourseVM(index, vmname) != templateName && this.getSelectedCourseVM(index, vmname) != 0 + const isEdited = + this.getSelectedCourseVM(index, vmname) != templateName && + this.getSelectedCourseVM(index, vmname) != 0; // ... or if it was deleted and created again with the same vm name through the following condition: - const deletedAndCreatedWithSameName = this.getSelectedCourseVM(index, vmname) === 0 && this.getEditSelectedCourseVM(index, vmname) != templateName + const deletedAndCreatedWithSameName = + this.getSelectedCourseVM(index, vmname) === 0 && + this.getEditSelectedCourseVM(index, vmname) != templateName; // this.getSelectedCourseVM(index, vmname) != templateName && this.getSelectedCourseVM(index, vmname) != 0 - return isEdited || deletedAndCreatedWithSameName + return isEdited || deletedAndCreatedWithSameName; } } diff --git a/src/app/event/new-scheduled-event/new-scheduled-event.component.html b/src/app/event/new-scheduled-event/new-scheduled-event.component.html index ef457723..a9eafc39 100644 --- a/src/app/event/new-scheduled-event/new-scheduled-event.component.html +++ b/src/app/event/new-scheduled-event/new-scheduled-event.component.html @@ -372,13 +372,21 @@ Select Environment(s) Please wait... - + + VirtualMachines are not needed. Only scenarios/courses without + Machines were selected. + + No suitable environments found. @@ -439,139 +447,147 @@ (clrWizardPageOnLoad)="setupVMSelection()" (clrWizardPageNext)="copyVMCounts()" [clrWizardPageNextDisabled]=" - (!vmCounts.valid && !simpleMode) || - (!simpleModeVmCounts.valid && simpleMode) + (!vmCounts.valid && !simpleMode && !noVirtualMachinesNeeded) || + (!simpleModeVmCounts.valid && simpleMode && !noVirtualMachinesNeeded) " > Select Virtual Machines - - - - - - In simple mode, define the number of users per environment. Virtual - machines are calculated for you. - - - - - - - - - + + VirtualMachines are not needed. Only scenarios/courses without Machines + were selected. + + + + + + + + In simple mode, define the number of users per environment. Virtual + machines are calculated for you. +
EnvironmentUsers
+ - - + + - - - - - - -
- {{ - getEnvironmentName(selectedEnvironments[it]?.environment) - }} - - - - User count higher than max - - (max - {{ maxUserCounts[selectedEnvironments[it]?.environment] }}) - EnvironmentUsers
- Total - {{ simpleUserTotal() }} users
-
- - The following environments are incompatible with simple mode: - - -

Simple Mode Compatibility

-

- An environment must be able to support the creation of all types - of required VMs, as well as have enough capacity for at least - one user (and all their associated VMs). -

-
-
-
    -
  • {{ s }}
  • -
-
-
- - In advanced mode, define the number of virtual machines per - environment. Remember to account for the number of expected users, - thus number_of_users * number_of_required_vms. - -

- The following VMs are required per user: - -

  • {{ item.key }}: {{ item.value }}
  • -
    -

    - - - - - - - - - - - + + + - - - + + + + + + +
    EnvironmentVM TemplateCount
    {{ getEnvironmentName(groupName) }}{{ getVirtualMachineTemplateName(controlName) }} + + {{ + getEnvironmentName(selectedEnvironments[it]?.environment) + }} + VM count higher than maxUser count higher than max + (max + {{ maxUserCounts[selectedEnvironments[it]?.environment] }})
    + Total + {{ simpleUserTotal() }} users
    +
    + + The following environments are incompatible with simple mode: + + + +

    Simple Mode Compatibility

    +

    + An environment must be able to support the creation of all + types of required VMs, as well as have enough capacity for at + least one user (and all their associated VMs). +

    +
    +
    +
      +
    • {{ s }}
    • +
    +
    +
    + + In advanced mode, define the number of virtual machines per + environment. Remember to account for the number of expected users, + thus number_of_users * number_of_required_vms. + +

    + The following VMs are required per user: + +

  • {{ item.key }}: {{ item.value }}
  • - - +

    + + + + + + + + + + + + + + + + + + + +
    EnvironmentVM TemplateCount
    {{ getEnvironmentName(groupName) }}{{ getVirtualMachineTemplateName(controlName) }} + + + VM count higher than max + +
    +
    @@ -634,7 +650,10 @@

    Basic Information

    VM Information

    - + + VirtualMachines are not needed for this ScheduledEvent. + +
    @@ -824,7 +843,10 @@

    Basic Information

    VM Information

    -
    Environment
    + + VirtualMachines are not needed for this ScheduledEvent. + +
    diff --git a/src/app/event/new-scheduled-event/new-scheduled-event.component.ts b/src/app/event/new-scheduled-event/new-scheduled-event.component.ts index 80bd7b29..2ce0c1e6 100644 --- a/src/app/event/new-scheduled-event/new-scheduled-event.component.ts +++ b/src/app/event/new-scheduled-event/new-scheduled-event.component.ts @@ -96,6 +96,7 @@ export class NewScheduledEventComponent public availableEnvironments: EnvironmentAvailability[] = []; public checkingEnvironments: boolean = true; public noEnvironmentsAvailable: boolean = false; + public noVirtualMachinesNeeded: boolean = false; public unavailableVMTs: string[] = []; public environments: Environment[] = []; public keyedEnvironments: Map = new Map(); @@ -756,6 +757,17 @@ export class NewScheduledEventComponent }); }); + //If there are no templates needed, we do not need virtual machines and have content only scenarios / courses + this.noVirtualMachinesNeeded = templates.size == 0; + + if (this.noVirtualMachinesNeeded) { + this.noEnvironmentsAvailable = true; + this.unavailableVMTs = []; + this.availableEnvironments = []; + this.checkingEnvironments = false; + return; + } + this.es .list() .pipe( @@ -995,15 +1007,22 @@ export class NewScheduledEventComponent return true; } - //no environment selected - if (this.selectedEnvironments.length == 0) { + //no environment selected but VMs are required + if ( + this.selectedEnvironments.length == 0 && + !this.noVirtualMachinesNeeded + ) { return true; } //vm count is valid if ( - (!this.simpleMode && !this.vmCounts.valid) || - (this.simpleMode && !this.simpleModeVmCounts.valid) + (!this.simpleMode && + !this.vmCounts.valid && + !this.noVirtualMachinesNeeded) || + (this.simpleMode && + !this.simpleModeVmCounts.valid && + !this.noVirtualMachinesNeeded) ) { return true; } diff --git a/src/app/scenario/scenario-wizard/scenario-wizard.component.html b/src/app/scenario/scenario-wizard/scenario-wizard.component.html index 571b36d2..8c4e004d 100644 --- a/src/app/scenario/scenario-wizard/scenario-wizard.component.html +++ b/src/app/scenario/scenario-wizard/scenario-wizard.component.html @@ -139,15 +139,32 @@ - + Virtual Machine + @@ -358,6 +375,26 @@ Finalize

    Confirm the following details before finishing

    Scenario

    +
    Environment
    @@ -382,8 +419,8 @@

    Scenario

    - - + + @@ -399,9 +436,9 @@

    Scenario

    diff --git a/src/app/scenario/scenario-wizard/scenario-wizard.component.ts b/src/app/scenario/scenario-wizard/scenario-wizard.component.ts index ebd22db8..56066e8f 100644 --- a/src/app/scenario/scenario-wizard/scenario-wizard.component.ts +++ b/src/app/scenario/scenario-wizard/scenario-wizard.component.ts @@ -206,6 +206,10 @@ export class ScenarioWizardComponent implements OnInit { } saveUpdatedScenario() { + if(!this.selectedScenarioHasVM()){ + this.selectedscenario.virtualmachines = []; + } + this.scenarioService .update(this.selectedscenario) .subscribe((s: ServerResponse) => { @@ -277,11 +281,16 @@ export class ScenarioWizardComponent implements OnInit { if (element == tag) this.selectedscenario.tags.splice(index, 1); }); } + + selectedScenarioHasVMSet(): boolean { + return this.selectedscenario.virtualmachines.length > 0 + } + selectedScenarioHasVM(): boolean { - if (this.selectedscenario.virtualmachines.length != 0) { + if (this.selectedscenario.virtualmachines.length > 0) { const validVMSet = this.selectedscenario.virtualmachines.filter( (virtualmachine, i) => { - if (Object.keys(virtualmachine).length != 0) { + if (Object.keys(virtualmachine).length > 0) { return true; } return false; @@ -293,11 +302,12 @@ export class ScenarioWizardComponent implements OnInit { } return false; } + addVMSet() { this.selectedscenario.virtualmachines.push({}); } + addVM() { - this.selectedScenarioHasVM(); this.selectedscenario.virtualmachines[this.newvmindex][ this.vmform.controls.vm_name.value ] = this.vmform.controls.vm_template.value; @@ -312,10 +322,12 @@ export class ScenarioWizardComponent implements OnInit { public deleteVM(setIndex: number, key: string) { delete this.selectedscenario.virtualmachines[setIndex][key]; } + doDeleteVMSet() { this.selectedscenario.virtualmachines.splice(this.deletingVMSetIndex, 1); this.deleteVMSetModal.close(); } + public openCreateVM(i: number) { this.vmform.reset(); this.newvmindex = i;
    Pause Duration {{ selectedscenario.pause_duration }}
    Virtual Machine
    Virtual Machines {{ selectedscenario.virtualmachines.length }}
    - {{ categorie }}