mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-18 06:48:09 +00:00
Support for editing config files - IOU & routers
This commit is contained in:
@ -1,4 +1,6 @@
|
|||||||
<button mat-menu-item (click)="editConfig()">
|
<button mat-menu-item
|
||||||
|
*ngIf="node.node_type==='vpcs' || node.node_type==='iou' || node.node_type==='dynamips'"
|
||||||
|
(click)="editConfig()">
|
||||||
<mat-icon>settings</mat-icon>
|
<mat-icon>settings</mat-icon>
|
||||||
<span>Edit config</span>
|
<span>Edit config</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<button mat-menu-item (click)="exportConfig()">
|
<button mat-menu-item
|
||||||
|
*ngIf="node.node_type==='vpcs' || node.node_type==='dynamips' || node.node_type==='iou'"
|
||||||
|
(click)="exportConfig()">
|
||||||
<mat-icon>call_made</mat-icon>
|
<mat-icon>call_made</mat-icon>
|
||||||
<span>Export config</span>
|
<span>Export config</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -16,7 +16,7 @@ export class ExportConfigActionComponent {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
exportConfig() {
|
exportConfig() {
|
||||||
this.nodeService.getConfiguration(this.server, this.node).subscribe((config: any) => {
|
this.nodeService.getStartupConfiguration(this.server, this.node).subscribe((config: any) => {
|
||||||
this.downloadByHtmlTag(config);
|
this.downloadByHtmlTag(config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
<h1 mat-dialog-title>Configuration for node {{node.name}}</h1>
|
<h1 mat-dialog-title>Configuration for node {{node.name}}</h1>
|
||||||
|
|
||||||
<div class="modal-form-container">
|
<div *ngIf="node.node_type==='vpcs'" class="modal-form-container">
|
||||||
<textarea #textArea id="textArea" class="textArea" [(ngModel)]="config"></textarea>
|
<textarea #textArea id="textArea" class="textArea" [(ngModel)]="config"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<mat-tab-group *ngIf="node.node_type==='iou' || node.node_type==='dynamips'">
|
||||||
|
<mat-tab label="Startup config">
|
||||||
|
<textarea #textArea id="textArea" class="textAreaTab" [(ngModel)]="config"></textarea>
|
||||||
|
</mat-tab>
|
||||||
|
<mat-tab label="Private config">
|
||||||
|
<textarea #textArea id="textArea" class="textAreaTab" [(ngModel)]="privateConfig"></textarea>
|
||||||
|
</mat-tab>
|
||||||
|
</mat-tab-group>
|
||||||
|
|
||||||
<div mat-dialog-actions>
|
<div mat-dialog-actions>
|
||||||
<button mat-button (click)="onCancelClick()" color="accent">Cancel</button>
|
<button mat-button (click)="onCancelClick()" color="accent">Cancel</button>
|
||||||
<button mat-button (click)="onSaveClick()" tabindex="2" mat-raised-button color="primary">Apply</button>
|
<button mat-button (click)="onSaveClick()" tabindex="2" mat-raised-button color="primary">Apply</button>
|
||||||
|
@ -2,3 +2,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 350px;
|
height: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.textAreaTab {
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ export class ConfigEditorDialogComponent implements OnInit {
|
|||||||
node: Node;
|
node: Node;
|
||||||
|
|
||||||
config: any;
|
config: any;
|
||||||
|
privateConfig: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<ConfigEditorDialogComponent>,
|
public dialogRef: MatDialogRef<ConfigEditorDialogComponent>,
|
||||||
@ -25,15 +26,28 @@ export class ConfigEditorDialogComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.nodeService.getConfiguration(this.server, this.node).subscribe((config: any) => {
|
this.nodeService.getStartupConfiguration(this.server, this.node).subscribe((config: any) => {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.node.node_type === 'iou' || this.node.node_type === 'dynamips') {
|
||||||
|
this.nodeService.getPrivateConfiguration(this.server, this.node).subscribe((privateConfig: any) => {
|
||||||
|
this.privateConfig = privateConfig;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSaveClick() {
|
onSaveClick() {
|
||||||
this.nodeService.saveConfiguration(this.server, this.node, this.config).subscribe((response) => {
|
this.nodeService.saveConfiguration(this.server, this.node, this.config).subscribe((response) => {
|
||||||
this.dialogRef.close();
|
if (this.node.node_type === 'iou' || this.node.node_type === 'dynamips') {
|
||||||
this.toasterService.success(`Configuration for node ${this.node.name} saved.`);
|
this.nodeService.savePrivateConfiguration(this.server, this.node, this.privateConfig).subscribe((resp) => {
|
||||||
|
this.dialogRef.close();
|
||||||
|
this.toasterService.success(`Configuration for node ${this.node.name} saved.`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.dialogRef.close();
|
||||||
|
this.toasterService.success(`Configuration for node ${this.node.name} saved.`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +127,30 @@ export class NodeService {
|
|||||||
return `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
return `putty.exe -telnet \%h \%p -wt \"\%d\" -gns3 5 -skin 4`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfiguration(server: Server, node: Node) {
|
getStartupConfiguration(server: Server, node: Node) {
|
||||||
let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`
|
let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`;
|
||||||
|
|
||||||
if (node.node_type === 'vpcs') {
|
if (node.node_type === 'vpcs') {
|
||||||
urlPath += '/files/startup.vpc';
|
urlPath += '/files/startup.vpc';
|
||||||
return this.httpServer.get(server, urlPath, { responseType: 'text' as 'json'});
|
} else if (node.node_type === 'iou') {
|
||||||
|
urlPath += '/files/startup-config.cfg';
|
||||||
|
} else if (node.node_type === 'dynamips') {
|
||||||
|
urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.httpServer.get(server, urlPath, { responseType: 'text' as 'json'});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPrivateConfiguration(server: Server, node: Node) {
|
||||||
|
let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`;
|
||||||
|
|
||||||
|
if (node.node_type === 'iou') {
|
||||||
|
urlPath += '/files/private-config.cfg';
|
||||||
|
} else if (node.node_type === 'dynamips') {
|
||||||
|
urlPath += `/files/configs/i${node.node_id}_private-config.cfg`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.httpServer.get(server, urlPath, { responseType: 'text' as 'json'});
|
||||||
}
|
}
|
||||||
|
|
||||||
saveConfiguration(server: Server, node: Node, configuration: string) {
|
saveConfiguration(server: Server, node: Node, configuration: string) {
|
||||||
@ -141,7 +158,24 @@ export class NodeService {
|
|||||||
|
|
||||||
if (node.node_type === 'vpcs') {
|
if (node.node_type === 'vpcs') {
|
||||||
urlPath += '/files/startup.vpc';
|
urlPath += '/files/startup.vpc';
|
||||||
return this.httpServer.post(server, urlPath, configuration);
|
} else if (node.node_type === 'iou') {
|
||||||
|
urlPath += '/files/startup-config.cfg';
|
||||||
|
} else if (node.node_type === 'dynamips') {
|
||||||
|
urlPath += `/files/configs/i${node.node_id}_startup-config.cfg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.httpServer.post(server, urlPath, configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
savePrivateConfiguration(server: Server, node: Node, configuration: string) {
|
||||||
|
let urlPath: string = `/projects/${node.project_id}/nodes/${node.node_id}`
|
||||||
|
|
||||||
|
if (node.node_type === 'iou') {
|
||||||
|
urlPath += '/files/private-config.cfg';
|
||||||
|
} else if (node.node_type === 'dynamips') {
|
||||||
|
urlPath += `/files/configs/i${node.node_id}_private-config.cfg`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.httpServer.post(server, urlPath, configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user