Skip to content

Commit

Permalink
Merge branch 'dev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Jan 24, 2024
2 parents 41d2151 + 7c569a7 commit cc82e58
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 99 deletions.
11 changes: 9 additions & 2 deletions src/app/api-connector/flavor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ export class FlavorService {
);
}

getListOfFlavorsAvailable(project_id: string = '', specific: boolean = false): Observable<Flavor[]> {
const params: HttpParams = new HttpParams().set('project_id', project_id).set('specific', JSON.stringify(specific));
getListOfFlavorsAvailable(
project_id: string = '',
specific: boolean = false,
custom: boolean = false,
): Observable<Flavor[]> {
const params: HttpParams = new HttpParams()
.set('project_id', project_id)
.set('specific', JSON.stringify(specific))
.set('custom', custom);

return this.http
.get<Flavor[]>(`${ApiSettings.getApiBaseURL()}project_applications/flavors/`, {
Expand Down
9 changes: 7 additions & 2 deletions src/app/applications/applications.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,10 @@ <h6 class="col-md-8 form-control-label">
<accordion>
<ng-container *ngFor="let t of typeList; first as isFirst">
<accordion-group
*ngIf="selectedApplication?.project_application_openstack_project || checkIfTypeGotSimpleVmFlavor(t)"
*ngIf="
selectedApplication?.project_application_openstack_project ||
checkIfTypeGotSimpleVMFlavorOrIsCustom(t)
"
[isOpen]="isFirst"
#groupval
>
Expand All @@ -1129,7 +1132,9 @@ <h6 class="col-md-8 form-control-label">
<div
*ngIf="
fl.type.shortcut === t.shortcut &&
(fl.simple_vm || selectedApplication?.project_application_openstack_project)
(fl.simple_vm ||
selectedApplication?.project_application_openstack_project ||
fl.type.shortcut === FlavorTypeShortcuts.CUSTOM_FLAVOR)
"
class="form-group row"
>
Expand Down
16 changes: 15 additions & 1 deletion src/app/applications/applications.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { Subscription } from 'rxjs';
import { HttpStatusCode } from '@angular/common/http';
import { FlavorTypeShortcuts } from 'app/shared/shared_modules/baseClass/flavor-type-shortcuts';
import { ApplicationsService } from '../api-connector/applications.service';
import { ApiSettings } from '../api-connector/api-settings.service';
import { Application } from './application.model/application.model';
Expand Down Expand Up @@ -136,7 +137,7 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme
this.getSubmittedApplicationsAdmin();
this.getApplicationHistory();
this.getComputeCenters();
this.flavorService.getListOfFlavorsAvailable().subscribe((flavList: Flavor[]): void => {
this.flavorService.getListOfFlavorsAvailable(undefined, undefined, true).subscribe((flavList: Flavor[]): void => {
this.flavorList = flavList;
});
this.flavorService.getListOfTypesAvailable().subscribe((availableTypes: FlavorType[]): void => {
Expand Down Expand Up @@ -263,6 +264,19 @@ export class ApplicationsComponent extends ApplicationBaseClassComponent impleme
return false;
}

checkIfTypeGotSimpleVMFlavorOrIsCustom(type: FlavorType): boolean {
for (const flav of this.flavorList) {
if (
(flav.type.shortcut === type.shortcut && flav.simple_vm)
|| type.shortcut === FlavorTypeShortcuts.CUSTOM_FLAVOR
) {
return true;
}
}

return false;
}

/**
* Checks if the key given represents a flavor and if so returns the respective Flavor
*
Expand Down
3 changes: 3 additions & 0 deletions src/app/pipe-module/pipe-module.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HasStatusNotInListPipe } from './pipes/has-status-not-in-list.pipe';
import { SignificancePipe } from '../shared/shared_modules/components/maintenance-notification/significance-pipe/significance.pipe';
import { SocialConsentGivenPipe } from './pipes/social-consent-given.pipe';
import { IsMigratedProjectPipe } from './pipes/isMigratedProject';
import { HasFlavorTypeOrIsNotCustomPipe } from './pipes/has-flavor-type.pipe';

/**
* Pipemodule
Expand All @@ -43,6 +44,7 @@ import { IsMigratedProjectPipe } from './pipes/isMigratedProject';
SignificancePipe,
SocialConsentGivenPipe,
IsMigratedProjectPipe,
HasFlavorTypeOrIsNotCustomPipe,
],
exports: [
FlavorCounterPipe,
Expand All @@ -65,6 +67,7 @@ import { IsMigratedProjectPipe } from './pipes/isMigratedProject';
SignificancePipe,
SocialConsentGivenPipe,
IsMigratedProjectPipe,
HasFlavorTypeOrIsNotCustomPipe,
],
imports: [CommonModule],
providers: [],
Expand Down
33 changes: 33 additions & 0 deletions src/app/pipe-module/pipes/has-flavor-type.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// eslint-disable-next-line max-classes-per-file
import { Pipe, PipeTransform } from '@angular/core';
import { Application } from 'app/applications/application.model/application.model';
import { FlavorTypeShortcuts } from 'app/shared/shared_modules/baseClass/flavor-type-shortcuts';
import { Flavor } from 'app/virtualmachines/virtualmachinemodels/flavor';
import { FlavorType } from 'app/virtualmachines/virtualmachinemodels/flavorType';

/**
* Pipe which compares status.
*/
@Pipe({
name: 'hasFlavorTypeOrIsNotCustom',
})
export class HasFlavorTypeOrIsNotCustomPipe implements PipeTransform {
transform(project: Application, flavorType: FlavorType): boolean {
const hasFlavorTypeFlavor: boolean = project.flavors.some(
(flavor: Flavor): boolean => flavor.type.shortcut === flavorType.shortcut,
);

return hasFlavorTypeFlavor || flavorType.shortcut !== FlavorTypeShortcuts.CUSTOM_FLAVOR;
}
}
/**
* Pipe which checks if status is in a list.
*/
@Pipe({
name: 'statusInList',
})
export class StatusInListPipe implements PipeTransform {
transform(status: string, status_list_to_compare: string[]): boolean {
return status_list_to_compare.indexOf(status) !== -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ <h6 class="col-md-8 form-control-label">
<accordion>
<ng-container *ngFor="let flavorType of flavorTypes; first as isFirst">
<accordion-group
*ngIf="project?.project_application_openstack_project || shown_flavors[flavorType.long_name]"
*ngIf="
(project?.project_application_openstack_project || shown_flavors[flavorType.long_name]) &&
(project | hasFlavorTypeOrIsNotCustom: flavorType)
"
[isOpen]="isFirst"
#groupval
>
Expand Down Expand Up @@ -63,7 +66,7 @@ <h6 class="col-md-8 form-control-label">
name="flavor.name + '_old'"
id="{{ flavor.name }}_old"
type="text"
value="{{ project | flavorCounter : flavor }}"
value="{{ project | flavorCounter: flavor }}"
placeholder="0"
[disabled]="flavor.disabled || adjustment"
aria-describedby="{{ flavor.name }}_old_help"
Expand Down Expand Up @@ -103,17 +106,17 @@ <h6 class="col-md-8 form-control-label">
placeholder="e.g 1"
[ngModel]="
adjustment
? (project.project_modification_request | flavorCounter : flavor)
: (temp_project_modification | flavorCounter : flavor)
? (project.project_modification_request | flavorCounter: flavor)
: (temp_project_modification | flavorCounter: flavor)
"
#name="ngModel"
(change)="checkFlavorPairs(flavor, $event)"
[attr.appMinAmount]="adjustment ? null : 0"
[attr.appInteger]="adjustment ? null : true"
value="{{
adjustment
? (project.project_modification_request | flavorCounter : flavor)
: (temp_project_modification | flavorCounter : flavor)
? (project.project_modification_request | flavorCounter: flavor)
: (temp_project_modification | flavorCounter: flavor)
}}"
[attr.readonly]="flavor.disabled || adjustment ? true : null"
aria-describedby="{{ flavor.name }}_help"
Expand Down Expand Up @@ -144,12 +147,12 @@ <h6 class="col-md-8 form-control-label">
step="1"
attr.data-test-id="adjusted_{{ flavor.type.shortcut + '_' + i }}"
placeholder="e.g 1"
[ngModel]="adjusted_project_modification | flavorCounter : flavor"
[ngModel]="adjusted_project_modification | flavorCounter: flavor"
#name="ngModel"
(change)="checkFlavorPairsAdjustment(flavor, $event)"
appMinAmount="0"
appInteger
value="{{ adjusted_project_modification | flavorCounter : flavor }}"
value="{{ adjusted_project_modification | flavorCounter: flavor }}"
aria-describedby="adjust_{{ flavor.name }}_help"
[ngClass]="{
'is-invalid': name?.invalid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
} from '@angular/core';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { Subscription } from 'rxjs';
import { HasFlavorTypeOrIsNotCustomPipe } from 'app/pipe-module/pipes/has-flavor-type.pipe';
import { ApplicationModification } from '../../../applications/application_modification.model';
import { ResultComponent } from '../result/result.component';
import { Application } from '../../../applications/application.model/application.model';
Expand All @@ -16,7 +17,7 @@ import { CreditsService } from '../../../api-connector/credits.service';
selector: 'app-modification-request',
templateUrl: './modification-request.component.html',
styleUrls: ['./modification-request.component.scss'],
providers: [FlavorService, CreditsService],
providers: [FlavorService, CreditsService, HasFlavorTypeOrIsNotCustomPipe],
})
export class ModificationRequestComponent implements OnInit, OnDestroy {
CLOUD_PORTAL_SUPPORT_MAIL: string = CLOUD_PORTAL_SUPPORT_MAIL;
Expand Down Expand Up @@ -116,6 +117,7 @@ export class ModificationRequestComponent implements OnInit, OnDestroy {
this.shown_flavors[flavor.type.long_name].push(flavor);
}
}

this.checkFlavorDifferences();
}),
);
Expand Down
Loading

0 comments on commit cc82e58

Please sign in to comment.