diff --git a/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.html b/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.html index bdcb38024e..3b2163623f 100644 --- a/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.html +++ b/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.html @@ -1,10 +1,8 @@
- - - {{ securityGroupsLine }} - - - {{ 'COMMON.NONE' | translate }} - + + {{ securityGroupsLine }} + + {{ 'COMMON.NONE' | translate }} +
diff --git a/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.ts b/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.ts index 7934ae8bbc..8201ae90a9 100644 --- a/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.ts +++ b/src/app/vm/vm-creation/components/security-group-rules-manager/security-group-manager-existing-group/security-group-manager-existing-group.component.ts @@ -11,13 +11,9 @@ export class SecurityGroupManagerExistingGroupComponent { @Input() public securityGroups: Array; public get securityGroupsLine(): string { - if (this.securityGroups) { - return this.securityGroups.map(securityGroup => { - return securityGroup.name; - }) - .join(', '); - } else { - return ''; - } + return this.securityGroups.map(securityGroup => { + return securityGroup.name; + }) + .join(', '); } } diff --git a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.html b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.html index 168c1b430b..eea90bca8d 100644 --- a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.html +++ b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.html @@ -1,26 +1,31 @@
-

- {{ sg.name }} -

-

- {{ sg.description }} -

+ + +

+ {{ sg.name }} +

+

+ {{ sg.description }} +

+
+ + [checked]="checkSelectedSG(sg?.id)" + (change)="selectSecurityGroup(sg)">
diff --git a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.scss b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.scss index 6ac5a30283..83190ca073 100644 --- a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.scss +++ b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.scss @@ -12,7 +12,7 @@ mat-list-item .mat-line-secondary { color: rgba(0, 0, 0, 0.54); } -.security-group-radio-list { +.security-group-checkbox-list { display: flex; flex-direction: column; width: 100%; diff --git a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.ts b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.ts index 7b99b4d01c..8f3178833a 100644 --- a/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.ts +++ b/src/app/vm/vm-creation/components/security-group-selector/security-group-selector.component.ts @@ -41,15 +41,17 @@ export class SecurityGroupSelectorComponent implements ControlValueAccessor { } public selectSecurityGroup(securityGroup: SecurityGroup): void { - if (this.checkSelectedSG(securityGroup.id)) { - const index = this.selectedSecurityGroups.findIndex(_ => _.id === securityGroup.id); - this.selectedSecurityGroups.splice(index, 1); - } else { - this.selectedSecurityGroups.push(securityGroup); + if (securityGroup) { + if (this.checkSelectedSG(securityGroup.id)) { + const index = this.selectedSecurityGroups.findIndex(_ => _.id === securityGroup.id); + this.selectedSecurityGroups.splice(index, 1); + } else { + this.selectedSecurityGroups.push(securityGroup); + } } } - public checkSelectedSG(securityGroupId: string) { + public checkSelectedSG(securityGroupId: string): boolean { const isSelectedItem = this.selectedSecurityGroups.find(securityGroup => securityGroup.id === securityGroupId); return !!isSelectedItem; } diff --git a/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.html b/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.html index f8dba9b68e..ff7873d51e 100644 --- a/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.html +++ b/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.html @@ -32,7 +32,10 @@

{{ 'COMMON.CANCEL' | translate }} -

diff --git a/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.ts b/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.ts index f20ce827e0..d8e614c35e 100644 --- a/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.ts +++ b/src/app/vm/vm-creation/components/security-group/vm-creation-security-group.component.ts @@ -6,6 +6,7 @@ import { Rules } from '../../../../shared/components/security-group-builder/rule // tslint:disable-next-line import { VmCreationSecurityGroupData } from '../../security-group/vm-creation-security-group-data'; import { VmCreationSecurityGroupMode } from '../../security-group/vm-creation-security-group-mode'; +import { AuthService } from '../../../../shared/services/auth.service'; @Component({ @@ -16,19 +17,23 @@ import { VmCreationSecurityGroupMode } from '../../security-group/vm-creation-se export class VmCreationSecurityGroupComponent implements OnInit { public sharedGroups: Array; - constructor( - @Inject(MAT_DIALOG_DATA) public savedData: VmCreationSecurityGroupData, - private dialogRef: MatDialogRef, - private securityGroupService: SecurityGroupService - ) { + public get savedData(): VmCreationSecurityGroupData { + return this._savedData; + } + + constructor(@Inject(MAT_DIALOG_DATA) public _savedData: VmCreationSecurityGroupData, + private dialogRef: MatDialogRef, + private securityGroupService: SecurityGroupService, + private authService: AuthService) { } public ngOnInit(): void { + const account = this.authService.user.username; this.securityGroupService.getSharedGroups() .subscribe(groups => { - this.sharedGroups = groups; - if (!this.savedData.securityGroups) { - this.savedData.securityGroups = [this.sharedGroups[0]]; + this.sharedGroups = groups.filter(item => item.account === account); + if (!this._savedData.securityGroups) { + this._savedData.securityGroups = [this.sharedGroups[0]]; } }); } @@ -38,7 +43,7 @@ export class VmCreationSecurityGroupComponent implements OnInit { } public get displayMode(): VmCreationSecurityGroupMode { - return this.savedData.mode; + return this._savedData.mode; } public set displayMode(value: VmCreationSecurityGroupMode) { @@ -47,7 +52,7 @@ export class VmCreationSecurityGroupComponent implements OnInit { 1: VmCreationSecurityGroupMode.Selector }; - this.savedData.mode = map[value]; + this._savedData.mode = map[value]; } public get isModeBuilder(): boolean { @@ -69,8 +74,7 @@ export class VmCreationSecurityGroupComponent implements OnInit { } public onSave(): void { - console.log('SAVED DATA', this.savedData); - this.dialogRef.close(this.savedData); + this.dialogRef.close(this._savedData); } public onCancel(): void { @@ -78,6 +82,6 @@ export class VmCreationSecurityGroupComponent implements OnInit { } public onBuilderGroupChange(rules: Rules): void { - this.savedData.rules = rules; + this._savedData.rules = rules; } } diff --git a/src/app/vm/vm-creation/services/vm-deployment.service.ts b/src/app/vm/vm-creation/services/vm-deployment.service.ts index 1e1be54ba4..faf6a72c07 100644 --- a/src/app/vm/vm-creation/services/vm-deployment.service.ts +++ b/src/app/vm/vm-creation/services/vm-deployment.service.ts @@ -60,7 +60,6 @@ export class VmDeploymentService { public deploy(state: VmCreationState): VmDeployObservables { const deployStatusObservable = new Subject(); - console.log('11111 DEPLOY STATE', state); return { deployStatusObservable, deployObservable: this.deployObservable(deployStatusObservable, state)