Code cleaned up

This commit is contained in:
Piotr Pekala 2019-09-02 05:43:36 -07:00
parent a146dfcb40
commit 4d2d7f6180
5 changed files with 34 additions and 5 deletions

View File

@ -200,6 +200,7 @@ import { InfoDialogComponent } from './components/project-map/info-dialog/info-d
import { InfoService } from './services/info.service';
import { BringToFrontActionComponent } from './components/project-map/context-menu/actions/bring-to-front-action/bring-to-front-action.component';
import { ExportConfigActionComponent } from './components/project-map/context-menu/actions/export-config/export-config-action.component';
import { ImportConfigActionComponent } from './components/project-map/context-menu/actions/import-config/import-config-action.component';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -329,7 +330,8 @@ if (environment.production) {
TopologySummaryComponent,
InfoDialogComponent,
BringToFrontActionComponent,
ExportConfigActionComponent
ExportConfigActionComponent,
ImportConfigActionComponent
],
imports: [
BrowserModule,

View File

@ -23,9 +23,9 @@ export class ExportConfigActionComponent {
private downloadByHtmlTag(config: string) {
const element = document.createElement('a');
const fileType = 'vpc';
const fileType = 'text/plain';
element.setAttribute('href', `data:${fileType};charset=utf-8,${encodeURIComponent(config)}`);
element.setAttribute('download', 'configFile.vpc');
element.setAttribute('download', `${this.node.name}_startup.vpc`);
var event = new MouseEvent("click");
element.dispatchEvent(event);

View File

@ -0,0 +1,4 @@
<button mat-menu-item (click)="importConfig()">
<mat-icon>call_received</mat-icon>
<span>Import config</span>
</button>

View File

@ -0,0 +1,19 @@
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-import-config-action',
templateUrl: './import-config-action.component.html'
})
export class ImportConfigActionComponent {
@Input() server: Server;
@Input() node: Node;
constructor() {}
importConfig() {
//needs implementation
}
}

View File

@ -36,15 +36,19 @@
[link]="links[0]"
[linkNode]="linkNodes[0]"
></app-edit-text-action>
<app-edit-config-action *ngIf="nodes.length===1"
<app-edit-config-action *ngIf="nodes.length===1 && nodes[0].node_type==='vpcs'"
[server]="server"
[project]="project"
[node]="nodes[0]"
></app-edit-config-action>
<app-export-config-action *ngIf="nodes.length===1"
<app-export-config-action *ngIf="nodes.length===1 && nodes[0].node_type==='vpcs'"
[server]="server"
[node]="nodes[0]"
></app-export-config-action>
<!-- <app-import-config-action *ngIf="nodes.length===1"
[server]="server"
[node]="nodes[0]"
></app-import-config-action> -->
<app-move-layer-up-action
*ngIf="!projectService.isReadOnly(project) && (drawings.length || nodes.length) && labels.length===0"
[server]="server"