Skip to content

Commit

Permalink
adjustments of tests missing + applicationDetailComponent is undefined?
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Jan 10, 2025
1 parent 7d3da47 commit 6ee46aa
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class ApplicationListComponent implements OnInit, OnChanges {
}

setDataTestId(): void {
console.log('set data test id')
switch (this.tabState) {
case ApplicationTabStates.SUBMITTED: {
this.dataTestId = 'submitted_applications_container'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ApplicationVoActionsComponent extends AbstractBaseClass implements

this.bsModalRef = this.modalService.show(ModificationRequestComponent, {
initialState,
class: 'modal-lg'
class: 'modal-xl'
})
this.subscribeToBsModalRef()
// this.subscribeForExtensionResult(this.ExtensionRequestType.MODIFICATION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4>Adjust application for {{ application?.project_application_shortname }}</h4>
Expand Down Expand Up @@ -461,5 +460,3 @@ <h6 class="col-md-8 form-control-label">Project Data</h6>
}
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class AdjustApplicationComponent implements OnInit {
application
}
const bsModalRef: BsModalRef = this.modalService.show(AdjustApplicationComponent, { initialState })
bsModalRef.setClass('modal-lg')
bsModalRef.setClass('modal-xl')
this.modalId = bsModalRef.id

return bsModalRef.content.eventSuccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ <h6 class="col-md-8 form-control-label">
>
</i>
</div>
<div *ngFor="let flavor_name of getFlavorNamesByType(flavorType)" class="form-group row my-3">
<div *ngFor="let flavor_name of getFlavorNamesByType(flavorType)" class="form-group row my-4">

<div class="col-4">
<label class="text-muted" for ="{{flavor_name}}_old">
<strong>{{ flavor_name}}</strong>
<br />
Number of cores: <span id="{{ flavor_name }}_old_cores">{{ REFACTOR_flavors[flavorType.long_name][flavor_name][0].vcpus }}</span>
Number of cores: <span id="{{ flavor_name }}_old_cores">{{ shown_flavors[flavorType.long_name][flavor_name][0].vcpus }}</span>
<br />
RAM: <span id="{{ flavor_name }}_old_ram">{{ REFACTOR_flavors[flavorType.long_name][flavor_name][0].ram_gib }}</span> GB
RAM: <span id="{{ flavor_name }}_old_ram">{{ shown_flavors[flavorType.long_name][flavor_name][0].ram_gib }}</span> GB
<span *ngIf="project?.credits_allowed">
<br />
Credits per hour:
<span id="{{ flavor_name }}_old_cph">{{ REFACTOR_flavors[flavorType.long_name][flavor_name][0].credits_costs_per_hour }}</span> CCs/h
<span id="{{ flavor_name }}_old_cph">{{ shown_flavors[flavorType.long_name][flavor_name][0].credits_costs_per_hour }}</span> CCs/h
</span>
</label>
</div>
<ng-container *ngFor="let flavor_instance of REFACTOR_flavors[flavorType.long_name][flavor_name]; let i = index" >
<ng-container *ngFor="let flavor_instance of shown_flavors[flavorType.long_name][flavor_name]; let i = index" >


<ng-container *ngIf="REFACTOR_flavors[flavorType.long_name][flavor_name].length > 1; else elseFlavorBlock">
<ng-container *ngIf="shown_flavors[flavorType.long_name][flavor_name].length > 1; else elseFlavorBlock">


<ng-container *ngIf="flavor_instance.disabled">
Expand Down Expand Up @@ -103,6 +103,7 @@ <h6 class="col-md-8 form-control-label">
id="{{ flavor_instance.name }}"
type="number"
min="0"
[disabled]="adjustment"
step="1"
attr.data-test-id="{{ flavor_instance.type.shortcut + '_' + i }}"
placeholder="e.g 1"
Expand All @@ -127,6 +128,9 @@ <h6 class="col-md-8 form-control-label">
'is-valid': name?.valid && !adjustment,
}"
/>
<div class="input-group-append">
<span class="input-group-text"> VMs</span>
</div>
</div>
<div id="{{ flavor_instance.name }}_help" class="form-text text-muted" *ngIf="!adjustment">
Number of VMs you would like to run in the future
Expand All @@ -139,7 +143,7 @@ <h6 class="col-md-8 form-control-label">

</ng-container>
<ng-template #elseFlavorBlock>
<div class="col-8">
<div [ngClass]="adjustment ? 'col-4' : 'col-8'">
<div class="input-group">
<input
class="form-control"
Expand All @@ -148,6 +152,7 @@ <h6 class="col-md-8 form-control-label">
type="number"
min="0"
step="1"
[disabled]="adjustment"
attr.data-test-id="{{ flavor_instance.type.shortcut + '_' + i }}"
placeholder="e.g 1"
[ngModel]="
Expand Down Expand Up @@ -180,43 +185,43 @@ <h6 class="col-md-8 form-control-label">
</div>
</div>
</ng-template>

</ng-container>

<!-- this is the adjustment part - this is comming afterwards ###
<div class="col-4" *ngIf="adjustment"></div>
<div class="col-8" *ngIf="adjustment">
<div class="input-group">
<input
class="form-control"
[name]="flavor.name + '_adjusted'"
id="{{ flavor.name }}_adjusted"
type="number"
min="0"
step="1"
attr.data-test-id="adjusted_{{ flavor.type.shortcut + '_' + i }}"
placeholder="e.g 1"
[ngModel]="adjusted_project_modification | flavorCounter: flavor"
#name="ngModel"
(change)="checkFlavorPairsAdjustment(flavor, $event)"
appMinAmount="0"
appInteger
value="{{ adjusted_project_modification | flavorCounter: flavor }}"
aria-describedby="adjust_{{ flavor.name }}_help"
[ngClass]="{
'is-invalid': name?.invalid,
'is-valid': name?.valid,
}"
/>
<div class="input-group-append">
<span class="input-group-text"> VMs</span>
<ng-container *ngIf="adjustment">
<div *ngIf="shown_flavors[flavorType.long_name][flavor_name].length > 1" class="col-4"></div>
<div [ngClass]="shown_flavors[flavorType.long_name][flavor_name].length > 1 ? 'col-8': 'col-4'">
<div class="input-group">
<input
class="form-control"
[name]="flavor_name + '_adjusted'"
id="{{ flavor_name }}_adjusted"
type="number"
min="0"
step="1"
attr.data-test-id="adjusted_{{ flavorType.shortcut + '_' + i }}"
placeholder="e.g 1"
[ngModel]="adjusted_project_modification | flavorCounter: shown_flavors[flavorType.long_name][flavor_name][0]"
#name="ngModel"
(change)="checkFlavorPairsAdjustment(shown_flavors[flavorType.long_name][flavor_name][0], $event)"
appMinAmount="0"
appInteger
value="{{ adjusted_project_modification | flavorCounter: shown_flavors[flavorType.long_name][flavor_name][0] }}"
aria-describedby="adjust_{{ flavor_name }}_help"
[ngClass]="{
'is-invalid': name?.invalid,
'is-valid': name?.valid,
}"
/>

<div class="input-group-append">
<span class="input-group-text"> VMs</span>
</div>
</div>
<div id="{{ flavor_name }}_help" class="form-text text-muted">Adjusted Number of VMs</div>
</div>
<div id="{{ flavor.name }}_help" class="form-text text-muted">Adjusted Number of VMs</div>
</div>
-->
</ng-container>

</div>
<!-- <div *ngFor="let flavor of shown_flavors[flavorType.long_name]; let i = index"> -->
</accordion-group>
</ng-container>
</accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export class ModificationRequestComponent implements OnInit, OnDestroy {

expected_total_credits: number = 0
flavorTypes: FlavorType[] = []
shown_flavors: { [name: string]: Flavor[] } = {}
REFACTOR_flavors: ShownFlavors = {};
shown_flavors: ShownFlavors = {};
min_vm: boolean = true

min_vm_adjusted: boolean = true
Expand Down Expand Up @@ -66,10 +65,7 @@ export class ModificationRequestComponent implements OnInit, OnDestroy {
this.flavorService.getListOfTypesAvailable().subscribe((result: FlavorType[]) => {
this.flavorTypes = result
for (const flavorType of this.flavorTypes) {
this.shown_flavors[flavorType.long_name] = []
}
for (const flavorType of this.flavorTypes) {
this.REFACTOR_flavors[flavorType.long_name] = {};
this.shown_flavors[flavorType.long_name] = {};

}
this.getFlavors()
Expand Down Expand Up @@ -120,11 +116,11 @@ export class ModificationRequestComponent implements OnInit, OnDestroy {
for (const flavor of flavors) {

if (this.project.project_application_openstack_project || flavor.simple_vm) {
if (flavor.name in this.REFACTOR_flavors[flavor.type.long_name])
if (flavor.name in this.shown_flavors[flavor.type.long_name])
{
this.REFACTOR_flavors[flavor.type.long_name][flavor.name].push(flavor)
this.shown_flavors[flavor.type.long_name][flavor.name].push(flavor)
} else {
this.REFACTOR_flavors[flavor.type.long_name][flavor.name] = [flavor];
this.shown_flavors[flavor.type.long_name][flavor.name] = [flavor];
}
}

Expand All @@ -137,34 +133,31 @@ export class ModificationRequestComponent implements OnInit, OnDestroy {
}

getFlavorNamesByType(type: FlavorType): string[] {
let names: string[] = Object.keys(this.REFACTOR_flavors[type.long_name]);
let names: string[] = Object.keys(this.shown_flavors[type.long_name]);

return names;
}

checkFlavorDifferences(): void {
for (const flavor of this.project.flavors) {
const idx: number = this.REFACTOR_flavors[flavor.type.long_name][flavor.name].findIndex(
const idx: number = this.shown_flavors[flavor.type.long_name][flavor.name].findIndex(
(fl: Flavor): boolean => fl.name === flavor.name
)
// not in shown_flavors, so flavor only for project
if (idx < 0) {
const disabled_flavor: Flavor = new Flavor(flavor)
disabled_flavor.setDisabled(true)
const mod_flavor: Flavor = new Flavor(flavor)
this.REFACTOR_flavors[mod_flavor.type.long_name][mod_flavor.name].push(mod_flavor);
this.REFACTOR_flavors[disabled_flavor.type.long_name][disabled_flavor.name].push(disabled_flavor)
this.shown_flavors[mod_flavor.type.long_name][mod_flavor.name].push(mod_flavor);
this.shown_flavors[disabled_flavor.type.long_name][disabled_flavor.name].push(disabled_flavor)
this.temp_project_modification.flavors.push(mod_flavor)
} else {
// else in shown_flavors, may be different than old one
this.REFACTOR_flavors[flavor.type.long_name][flavor.name][idx].counter = flavor.counter;
const mod_flavor: Flavor = new Flavor(this.shown_flavors[flavor.type.long_name][idx])
this.shown_flavors[flavor.type.long_name][flavor.name][idx].counter = flavor.counter;
const mod_flavor: Flavor = new Flavor(this.shown_flavors[flavor.type.long_name][flavor.name][idx])
this.temp_project_modification.flavors.push(mod_flavor)
this.REFACTOR_flavors[mod_flavor.type.long_name][mod_flavor.name].splice(idx, 0, mod_flavor)
this.REFACTOR_flavors[mod_flavor.type.long_name][mod_flavor.name][idx].setDisabled(true);
this.shown_flavors[flavor.type.long_name].splice(idx, 0, flavor)
this.shown_flavors[flavor.type.long_name][idx].setDisabled(true)
console.log(this.REFACTOR_flavors);
this.shown_flavors[mod_flavor.type.long_name][mod_flavor.name].splice(idx, 0, mod_flavor)
this.shown_flavors[mod_flavor.type.long_name][mod_flavor.name][idx].setDisabled(true);
}
}
this.temp_project_modification.calculateRamCores()
Expand Down

0 comments on commit 6ee46aa

Please sign in to comment.