From 5ec9e0134add1630472f7615cd11c707ce9b8935 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Wed, 18 Sep 2019 03:00:53 -0700 Subject: [PATCH] Configurator for traceng added --- src/app/app.module.ts | 7 ++- .../config-action/config-action.component.ts | 3 +- .../nat/configurator-nat.component.ts | 1 - .../configurator-traceng.component.html | 24 +++++++++ .../traceng/configurator-traceng.component.ts | 53 +++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.html create mode 100644 src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 666b1326..8aca20e1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -228,6 +228,7 @@ import { ConfiguratorDialogIouComponent } from './components/project-map/node-ed 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'; import { ConfiguratorDialogNatComponent } from './components/project-map/node-editors/configurator/nat/configurator-nat.component'; +import { ConfiguratorDialogTracengComponent } from './components/project-map/node-editors/configurator/traceng/configurator-traceng.component'; if (environment.production) { Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', { @@ -383,7 +384,8 @@ if (environment.production) { ConfiguratorDialogIouComponent, ConfiguratorDialogIosComponent, ConfiguratorDialogDockerComponent, - ConfiguratorDialogNatComponent + ConfiguratorDialogNatComponent, + ConfiguratorDialogTracengComponent ], imports: [ BrowserModule, @@ -496,7 +498,8 @@ if (environment.production) { ConfiguratorDialogIouComponent, ConfiguratorDialogIosComponent, ConfiguratorDialogDockerComponent, - ConfiguratorDialogNatComponent + ConfiguratorDialogNatComponent, + ConfiguratorDialogTracengComponent ], bootstrap: [AppComponent] }) diff --git a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts index faf6f7dc..f732f445 100644 --- a/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts +++ b/src/app/components/project-map/context-menu/actions/config-action/config-action.component.ts @@ -15,6 +15,7 @@ import { ConfiguratorDialogIouComponent } from '../../../node-editors/configurat import { ConfiguratorDialogIosComponent } from '../../../node-editors/configurator/ios/configurator-ios.component'; import { ConfiguratorDialogDockerComponent } from '../../../node-editors/configurator/docker/configurator-docker.component'; import { ConfiguratorDialogNatComponent } from '../../../node-editors/configurator/nat/configurator-nat.component'; +import { ConfiguratorDialogTracengComponent } from '../../../node-editors/configurator/traceng/configurator-traceng.component'; @Component({ @@ -60,7 +61,7 @@ export class ConfigActionComponent { } else if (this.node.node_type === 'atm_switch') { this.dialogRef = this.dialog.open(ConfiguratorDialogAtmSwitchComponent, this.conf); } else if (this.node.node_type === 'traceng') { - + this.dialogRef = this.dialog.open(ConfiguratorDialogTracengComponent, this.conf); } let instance = this.dialogRef.componentInstance; diff --git a/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts b/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts index 55918146..ea7b2ed7 100644 --- a/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts +++ b/src/app/components/project-map/node-editors/configurator/nat/configurator-nat.component.ts @@ -17,7 +17,6 @@ export class ConfiguratorDialogNatComponent implements OnInit { node: Node; name: string; generalSettingsForm: FormGroup; - consoleTypes: string[] = []; constructor( public dialogRef: MatDialogRef, diff --git a/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.html b/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.html new file mode 100644 index 00000000..ff1164d0 --- /dev/null +++ b/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.html @@ -0,0 +1,24 @@ +

Configurator for node {{name}}

+ + + +
+ + +
diff --git a/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.ts b/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.ts new file mode 100644 index 00000000..47811847 --- /dev/null +++ b/src/app/components/project-map/node-editors/configurator/traceng/configurator-traceng.component.ts @@ -0,0 +1,53 @@ +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'; + + +@Component({ + selector: 'app-configurator-traceng', + templateUrl: './configurator-traceng.component.html', + styleUrls: ['../configurator.component.scss'] +}) +export class ConfiguratorDialogTracengComponent implements OnInit { + server: Server; + node: Node; + name: string; + generalSettingsForm: FormGroup; + + constructor( + public dialogRef: MatDialogRef, + public nodeService: NodeService, + private toasterService: ToasterService, + private formBuilder: FormBuilder + ) { + this.generalSettingsForm = this.formBuilder.group({ + name: new FormControl('', Validators.required) + }); + } + + ngOnInit() { + this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { + this.node = node; + this.name = node.name; + }) + } + + 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(); + } +}