Dialog for IOS added

This commit is contained in:
Piotr Pekala 2019-09-17 06:27:34 -07:00
parent 6f92207847
commit 125706dd7b
5 changed files with 126 additions and 3 deletions

View File

@ -225,6 +225,7 @@ import { UdpTunnelsComponent } from './components/preferences/common/udp-tunnels
import { ConfiguratorDialogAtmSwitchComponent } from './components/project-map/node-editors/configurator/atm_switch/configurator-atm-switch.component';
import { ConfiguratorDialogVmwareComponent } from './components/project-map/node-editors/configurator/vmware/configurator-vmware.component';
import { ConfiguratorDialogIouComponent } from './components/project-map/node-editors/configurator/iou/configurator-iou.component';
import { ConfiguratorDialogIosComponent } from './components/project-map/node-editors/configurator/ios/configurator-ios.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -377,7 +378,8 @@ if (environment.production) {
UdpTunnelsComponent,
ConfiguratorDialogAtmSwitchComponent,
ConfiguratorDialogVmwareComponent,
ConfiguratorDialogIouComponent
ConfiguratorDialogIouComponent,
ConfiguratorDialogIosComponent
],
imports: [
BrowserModule,
@ -487,7 +489,8 @@ if (environment.production) {
ConfiguratorDialogCloudComponent,
ConfiguratorDialogAtmSwitchComponent,
ConfiguratorDialogVmwareComponent,
ConfiguratorDialogIouComponent
ConfiguratorDialogIouComponent,
ConfiguratorDialogIosComponent
],
bootstrap: [AppComponent]
})

View File

@ -12,6 +12,7 @@ import { ConfiguratorDialogCloudComponent } from '../../../node-editors/configur
import { ConfiguratorDialogAtmSwitchComponent } from '../../../node-editors/configurator/atm_switch/configurator-atm-switch.component';
import { ConfiguratorDialogVmwareComponent } from '../../../node-editors/configurator/vmware/configurator-vmware.component';
import { ConfiguratorDialogIouComponent } from '../../../node-editors/configurator/iou/configurator-iou.component';
import { ConfiguratorDialogIosComponent } from '../../../node-editors/configurator/ios/configurator-ios.component';
@Component({
@ -39,7 +40,7 @@ export class ConfigActionComponent {
} else if (this.node.node_type === 'cloud') {
this.dialogRef = this.dialog.open(ConfiguratorDialogCloudComponent, this.conf);
} else if (this.node.node_type === 'dynamips') {
this.dialogRef = this.dialog.open(ConfiguratorDialogIosComponent, this.conf);
} else if (this.node.node_type === 'iou') {
this.dialogRef = this.dialog.open(ConfiguratorDialogIouComponent, this.conf);
} else if (this.node.node_type === 'qemu') {

View File

@ -0,0 +1,51 @@
<h1 mat-dialog-title>Configurator for node {{name}}</h1>
<div class="modal-form-container">
<div class="content">
<div class="default-content">
<mat-card class="matCard">
<mat-tab-group *ngIf="name">
<mat-tab label="General settings">
<br/><form [formGroup]="generalSettingsForm">
<mat-form-field class="form-field">
<input matInput type="text" formControlName="name" [(ngModel)]="node.name" placeholder="Name">
</mat-form-field>
</form>
<mat-form-field class="select">
<mat-select placeholder="Console type" [(ngModel)]="node.console_type">
<mat-option *ngFor="let type of consoleTypes" [value]="type">
{{type}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox [(ngModel)]="node.console_auto_start">
Auto start console
</mat-checkbox><br/>
</mat-tab>
<mat-tab label="Memories and disks">
<br/><form [formGroup]="memoryForm">
<mat-form-field class="form-field">
<input matInput type="number" formControlName="ram" [(ngModel)]="node.properties.ram" placeholder="RAM size">
</mat-form-field>
<mat-form-field class="form-field">
<input matInput type="number" formControlName="nvram" [(ngModel)]="node.properties.nvram" placeholder="NVRAM size">
</mat-form-field>
</form>
</mat-tab>
<mat-tab label="Usage">
<mat-form-field class="form-field">
<textarea matInput type="text" [(ngModel)]="node.properties.usage"></textarea>
</mat-form-field>
</mat-tab>
</mat-tab-group>
</mat-card>
</div>
</div>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onCancelClick()" color="accent">Cancel</button>
<button mat-button (click)="onSaveClick()" tabindex="2" mat-raised-button color="primary">Apply</button>
</div>

View File

@ -0,0 +1,67 @@
import { Component, OnInit, Input, ViewChild } from "@angular/core";
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { Node } from '../../../../../cartography/models/node';
import { Server } from '../../../../../models/server';
import { NodeService } from '../../../../../services/node.service';
import { ToasterService } from '../../../../../services/toaster.service';
import { MatDialogRef } from '@angular/material';
import { IosConfigurationService } from '../../../../../services/ios-configuration.service';
@Component({
selector: 'app-configurator-ios',
templateUrl: './configurator-ios.component.html',
styleUrls: ['../configurator.component.scss']
})
export class ConfiguratorDialogIosComponent implements OnInit {
server: Server;
node: Node;
name: string;
generalSettingsForm: FormGroup;
memoryForm: FormGroup;
consoleTypes: string[] = [];
constructor(
public dialogRef: MatDialogRef<ConfiguratorDialogIosComponent>,
public nodeService: NodeService,
private toasterService: ToasterService,
private formBuilder: FormBuilder,
private configurationService: IosConfigurationService
) {
this.generalSettingsForm = this.formBuilder.group({
name: new FormControl('', Validators.required)
});
this.memoryForm = this.formBuilder.group({
ram: new FormControl('', Validators.required),
nvram: new FormControl('', Validators.required)
});
}
ngOnInit() {
this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => {
this.node = node;
this.name = node.name;
this.getConfiguration();
});
}
getConfiguration() {
this.consoleTypes = this.configurationService.getConsoleTypes();
}
onSaveClick() {
if (this.generalSettingsForm.valid && this.memoryForm.valid) {
this.nodeService. updateNode(this.server, this.node).subscribe(() => {
this.toasterService.success(`Node ${this.node.name} updated.`);
this.onCancelClick();
});
} else {
this.toasterService.error(`Fill all required fields.`);
}
}
onCancelClick() {
this.dialogRef.close();
}
}

View File

@ -89,6 +89,7 @@ export class NodeService {
updateNode(server: Server, node: Node): Observable<Node> {
return this.httpServer.put<Node>(server, `/projects/${node.project_id}/nodes/${node.node_id}`, {
console_type: node.console_type,
console_auto_start: node.console_auto_start,
name: node.name,
properties: node.properties
});