Configurator for docker added

This commit is contained in:
Piotr Pekala 2019-09-18 01:07:24 -07:00
parent 125706dd7b
commit c8a2067847
5 changed files with 126 additions and 3 deletions

View File

@ -226,6 +226,7 @@ import { ConfiguratorDialogAtmSwitchComponent } from './components/project-map/n
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';
import { ConfiguratorDialogDockerComponent } from './components/project-map/node-editors/configurator/docker/configurator-docker.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -379,7 +380,8 @@ if (environment.production) {
ConfiguratorDialogAtmSwitchComponent,
ConfiguratorDialogVmwareComponent,
ConfiguratorDialogIouComponent,
ConfiguratorDialogIosComponent
ConfiguratorDialogIosComponent,
ConfiguratorDialogDockerComponent
],
imports: [
BrowserModule,
@ -490,7 +492,8 @@ if (environment.production) {
ConfiguratorDialogAtmSwitchComponent,
ConfiguratorDialogVmwareComponent,
ConfiguratorDialogIouComponent,
ConfiguratorDialogIosComponent
ConfiguratorDialogIosComponent,
ConfiguratorDialogDockerComponent
],
bootstrap: [AppComponent]
})

View File

@ -52,6 +52,8 @@ export class Properties {
platform: string;
process_priority: string;
qemu_path: string;
environment: string;
extra_hosts: string;
}
export class Node {

View File

@ -13,6 +13,7 @@ import { ConfiguratorDialogAtmSwitchComponent } from '../../../node-editors/conf
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';
import { ConfiguratorDialogDockerComponent } from '../../../node-editors/configurator/docker/configurator-docker.component';
@Component({
@ -50,7 +51,7 @@ export class ConfigActionComponent {
} else if (this.node.node_type === 'vmware') {
this.dialogRef = this.dialog.open(ConfiguratorDialogVmwareComponent, this.conf);
} else if (this.node.node_type === 'docker') {
this.dialogRef = this.dialog.open(ConfiguratorDialogDockerComponent, this.conf);
} else if (this.node.node_type === 'nat') {
} else if (this.node.node_type === 'frame_relay_switch') {

View File

@ -0,0 +1,54 @@
<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 formControlName="name" type="text" [(ngModel)]="node.name" placeholder="Name">
</mat-form-field>
<mat-form-field class="form-field">
<input formControlName="adapter" matInput type="number" [(ngModel)]="node.properties.adapters" placeholder="Adapters">
</mat-form-field>
<mat-form-field class="select">
<mat-select [ngModelOptions]="{standalone: true}" 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 [ngModelOptions]="{standalone: true}" [(ngModel)]="node.console_auto_start">
Auto start console
</mat-checkbox>
</form>
<h6>Environment</h6>
<mat-form-field class="form-field">
<textarea matInput type="text" [(ngModel)]="node.properties.environment"></textarea>
</mat-form-field>
</mat-tab>
<mat-tab label="Advanced">
<h6>Extra hosts</h6>
<mat-form-field class="form-field">
<textarea matInput type="text" [(ngModel)]="node.properties.extra_hosts"></textarea>
</mat-form-field>
</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,63 @@
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 { DockerConfigurationService } from '../../../../../services/docker-configuration.service';
@Component({
selector: 'app-configurator-docker',
templateUrl: './configurator-docker.component.html',
styleUrls: ['../configurator.component.scss']
})
export class ConfiguratorDialogDockerComponent implements OnInit {
server: Server;
node: Node;
name: string;
generalSettingsForm: FormGroup;
consoleTypes: string[] = [];
constructor(
public dialogRef: MatDialogRef<ConfiguratorDialogDockerComponent>,
public nodeService: NodeService,
private toasterService: ToasterService,
private formBuilder: FormBuilder,
private dockerConfigurationService: DockerConfigurationService
) {
this.generalSettingsForm = this.formBuilder.group({
name: new FormControl('', Validators.required),
adapter: 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.dockerConfigurationService.getConsoleTypes();
}
onSaveClick() {
if (this.generalSettingsForm.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();
}
}