mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Add node to 0,0 position
This commit is contained in:
parent
632ee71378
commit
abcf6f72de
@ -9,7 +9,7 @@
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
|
||||
<mat-cell *matCellDef="let row;"> <a [routerLink]="['/server', row.id, 'projects']" class="table-link">{{row.name}}</a> </mat-cell>
|
||||
<mat-cell *matCellDef="let row;"> <a (click)="addNode(row)" href='javascript:void(0);' class="table-link">{{row.name}}</a> </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
|
@ -53,12 +53,9 @@ export class ApplianceListDialogComponent implements OnInit {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
//
|
||||
// applyFilter(filterValue: string) {
|
||||
// filterValue = filterValue.trim(); // Remove whitespace
|
||||
// filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches
|
||||
// this.dataSource.filter = filterValue;
|
||||
// }
|
||||
addNode(appliance: Appliance): void {
|
||||
this.dialogRef.close(appliance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {MatDialog} from "@angular/material";
|
||||
import {ApplianceListDialogComponent} from "./appliance-list-dialog/appliance-list-dialog.component";
|
||||
|
||||
@ -11,7 +11,7 @@ import {Server} from "../shared/models/server";
|
||||
})
|
||||
export class ApplianceComponent implements OnInit {
|
||||
@Input() server: Server;
|
||||
|
||||
@Output() onNodeCreation = new EventEmitter<any>();
|
||||
|
||||
constructor(private dialog: MatDialog) { }
|
||||
|
||||
@ -26,8 +26,10 @@ export class ApplianceComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(() => {
|
||||
|
||||
dialogRef.afterClosed().subscribe((appliance: AppendMode) => {
|
||||
if (appliance !== null) {
|
||||
this.onNodeCreation.emit(appliance);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
</mat-toolbar-row>
|
||||
|
||||
<mat-toolbar-row>
|
||||
<app-appliance [server]="server"></app-appliance>
|
||||
<app-appliance [server]="server" (onNodeCreation)="onNodeCreation($event)"></app-appliance>
|
||||
</mat-toolbar-row>
|
||||
|
||||
</mat-toolbar>
|
||||
|
@ -27,6 +27,8 @@ import { ProgressDialogComponent } from "../shared/progress-dialog/progress-dial
|
||||
import { ToastyService } from "ng2-toasty";
|
||||
import { Drawing } from "../cartography/shared/models/drawing.model";
|
||||
import { NodeContextMenuComponent } from "../shared/node-context-menu/node-context-menu.component";
|
||||
import {Appliance} from "../shared/models/appliance";
|
||||
import {NodeService} from "../shared/services/node.service";
|
||||
|
||||
|
||||
@Component({
|
||||
@ -55,6 +57,7 @@ export class ProjectMapComponent implements OnInit {
|
||||
private projectService: ProjectService,
|
||||
private symbolService: SymbolService,
|
||||
private snapshotService: SnapshotService,
|
||||
private nodeService: NodeService,
|
||||
private dialog: MatDialog,
|
||||
private progressDialogService: ProgressDialogService,
|
||||
private toastyService: ToastyService) {
|
||||
@ -176,15 +179,18 @@ export class ProjectMapComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
// setUpNodeActions() {
|
||||
// this.mapChild.nodeContextMenu.clearActions();
|
||||
//
|
||||
// const start_node_action = new StartNodeAction(this.server, this.nodeService);
|
||||
// this.mapChild.nodeContextMenu.registerAction(start_node_action);
|
||||
//
|
||||
// const stop_node_action = new StopNodeAction(this.server, this.nodeService);
|
||||
// this.mapChild.nodeContextMenu.registerAction(stop_node_action);
|
||||
// }
|
||||
onNodeCreation(appliance: Appliance) {
|
||||
this.nodeService
|
||||
.createFromAppliance(this.server, this.project, appliance, 0, 0, 'local')
|
||||
.subscribe(() => {
|
||||
this.projectService
|
||||
.nodes(this.server, this.project.project_id)
|
||||
.subscribe((nodes: Node[]) => {
|
||||
this.nodes = nodes;
|
||||
this.mapChild.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public createSnapshotModal() {
|
||||
const dialogRef = this.dialog.open(CreateSnapshotDialogComponent, {
|
||||
|
@ -7,6 +7,7 @@ import 'rxjs/add/operator/map';
|
||||
import { Server } from "../models/server";
|
||||
import { HttpServer } from "./http-server.service";
|
||||
import {Appliance} from "../models/appliance";
|
||||
import {Response} from "@angular/http";
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -26,10 +27,14 @@ export class NodeService {
|
||||
.map(response => response.json() as Node);
|
||||
}
|
||||
|
||||
createFromAppliance(server: Server, project: Project, appliance: Appliance): Observable<Node> {
|
||||
createFromAppliance(
|
||||
server: Server, project: Project, appliance: Appliance,
|
||||
x: number, y: number, compute_id: string): Observable<Response> {
|
||||
return this.httpServer
|
||||
.post(server, `/projects/${project.project_id}/appliances/${appliance.appliance_id}`, {})
|
||||
.map(response => response.json() as Node);
|
||||
.post(
|
||||
server,
|
||||
`/projects/${project.project_id}/appliances/${appliance.appliance_id}`,
|
||||
{'x': x, 'y': y, 'compute_id': compute_id});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user