mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-23 14:52:22 +00:00
Initial implementation added
This commit is contained in:
parent
ed9ca9ed03
commit
01d2fc2d43
@ -1,4 +1,10 @@
|
||||
<button mat-menu-item (click)="importConfig()">
|
||||
<input
|
||||
type="file"
|
||||
accept=".txt, .vpc"
|
||||
class="non-visible"
|
||||
#file
|
||||
(change)="importConfig($event)"/>
|
||||
<button mat-menu-item (click)="file.click()">
|
||||
<mat-icon>call_received</mat-icon>
|
||||
<span>Import config</span>
|
||||
</button>
|
||||
|
@ -0,0 +1,3 @@
|
||||
.non-visible {
|
||||
display: none;
|
||||
}
|
@ -2,18 +2,34 @@ import { Component, Input } from '@angular/core';
|
||||
import { Node } from '../../../../../cartography/models/node';
|
||||
import { NodeService } from '../../../../../services/node.service';
|
||||
import { Server } from '../../../../../models/server';
|
||||
import { ToasterService } from '../../../../../services/toaster.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-import-config-action',
|
||||
templateUrl: './import-config-action.component.html'
|
||||
templateUrl: './import-config-action.component.html',
|
||||
styleUrls: ['./import-config-action.component.scss']
|
||||
})
|
||||
export class ImportConfigActionComponent {
|
||||
@Input() server: Server;
|
||||
@Input() node: Node;
|
||||
|
||||
constructor() {}
|
||||
constructor(
|
||||
private nodeService: NodeService,
|
||||
private toasterService: ToasterService
|
||||
) {}
|
||||
|
||||
importConfig() {
|
||||
//needs implementation
|
||||
importConfig(event) {
|
||||
let file: File = event.target.files[0];
|
||||
let fileReader: FileReader = new FileReader();
|
||||
fileReader.onload = (e) => {
|
||||
let content: string | ArrayBuffer = fileReader.result;
|
||||
if (typeof content !== 'string'){
|
||||
content = content.toString();
|
||||
}
|
||||
this.nodeService.saveConfiguration(this.server, this.node, content).subscribe(() => {
|
||||
this.toasterService.success(`Configuration for node ${this.node.name} imported.`);
|
||||
});
|
||||
};
|
||||
fileReader.readAsText(file);
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,14 @@
|
||||
[project]="project"
|
||||
[node]="nodes[0]"
|
||||
></app-edit-config-action>
|
||||
<app-export-config-action *ngIf="nodes.length===1 && nodes[0].node_type==='vpcs'"
|
||||
<app-export-config-action *ngIf="nodes.length===1 && (nodes[0].node_type==='vpcs' || nodes[0].node_type==='iou' || nodes[0].node_type==='dynamips')"
|
||||
[server]="server"
|
||||
[node]="nodes[0]"
|
||||
></app-export-config-action>
|
||||
<!-- <app-import-config-action *ngIf="nodes.length===1"
|
||||
<app-import-config-action *ngIf="nodes.length===1 && (nodes[0].node_type==='vpcs' || nodes[0].node_type==='iou' || nodes[0].node_type==='dynamips')"
|
||||
[server]="server"
|
||||
[node]="nodes[0]"
|
||||
></app-import-config-action> -->
|
||||
></app-import-config-action>
|
||||
<app-move-layer-up-action
|
||||
*ngIf="!projectService.isReadOnly(project) && (drawings.length || nodes.length)"
|
||||
[server]="server"
|
||||
|
Loading…
Reference in New Issue
Block a user