mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-15 13:28:10 +00:00
Export config added
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
<button mat-menu-item (click)="exportConfig()">
|
||||
<mat-icon>call_made</mat-icon>
|
||||
<span>Export config</span>
|
||||
</button>
|
@ -0,0 +1,33 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { Server } from '../../../../../models/server';
|
||||
|
||||
@Component({
|
||||
selector: 'app-export-config-action',
|
||||
templateUrl: './export-config-action.component.html'
|
||||
})
|
||||
export class ExportConfigActionComponent {
|
||||
@Input() server: Server;
|
||||
@Input() node: Node;
|
||||
|
||||
constructor(
|
||||
private nodeService: NodeService
|
||||
) {}
|
||||
|
||||
exportConfig() {
|
||||
this.nodeService.getConfiguration(this.server, this.node).subscribe((config: any) => {
|
||||
this.downloadByHtmlTag(config);
|
||||
});
|
||||
}
|
||||
|
||||
private downloadByHtmlTag(config: string) {
|
||||
const element = document.createElement('a');
|
||||
const fileType = 'vpc';
|
||||
element.setAttribute('href', `data:${fileType};charset=utf-8,${encodeURIComponent(config)}`);
|
||||
element.setAttribute('download', 'configFile.vpc');
|
||||
|
||||
var event = new MouseEvent("click");
|
||||
element.dispatchEvent(event);
|
||||
}
|
||||
}
|
@ -36,11 +36,15 @@
|
||||
[link]="links[0]"
|
||||
[linkNode]="linkNodes[0]"
|
||||
></app-edit-text-action>
|
||||
<app-edit-config-action *ngIf="nodes.length === 1"
|
||||
[server]="server"
|
||||
[project]="project"
|
||||
[node]="nodes[0]"
|
||||
<app-edit-config-action *ngIf="nodes.length===1"
|
||||
[server]="server"
|
||||
[project]="project"
|
||||
[node]="nodes[0]"
|
||||
></app-edit-config-action>
|
||||
<app-export-config-action *ngIf="nodes.length===1"
|
||||
[server]="server"
|
||||
[node]="nodes[0]"
|
||||
></app-export-config-action>
|
||||
<app-move-layer-up-action
|
||||
*ngIf="!projectService.isReadOnly(project) && (drawings.length || nodes.length) && labels.length===0"
|
||||
[server]="server"
|
||||
|
Reference in New Issue
Block a user