mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-06 17:21:34 +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">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
|
<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>
|
</ng-container>
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
|
@ -53,12 +53,9 @@ export class ApplianceListDialogComponent implements OnInit {
|
|||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
addNode(appliance: Appliance): void {
|
||||||
// applyFilter(filterValue: string) {
|
this.dialogRef.close(appliance);
|
||||||
// filterValue = filterValue.trim(); // Remove whitespace
|
}
|
||||||
// filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches
|
|
||||||
// this.dataSource.filter = filterValue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {MatDialog} from "@angular/material";
|
||||||
import {ApplianceListDialogComponent} from "./appliance-list-dialog/appliance-list-dialog.component";
|
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 {
|
export class ApplianceComponent implements OnInit {
|
||||||
@Input() server: Server;
|
@Input() server: Server;
|
||||||
|
@Output() onNodeCreation = new EventEmitter<any>();
|
||||||
|
|
||||||
constructor(private dialog: MatDialog) { }
|
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>
|
||||||
|
|
||||||
<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-row>
|
||||||
|
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
|
@ -27,6 +27,8 @@ import { ProgressDialogComponent } from "../shared/progress-dialog/progress-dial
|
|||||||
import { ToastyService } from "ng2-toasty";
|
import { ToastyService } from "ng2-toasty";
|
||||||
import { Drawing } from "../cartography/shared/models/drawing.model";
|
import { Drawing } from "../cartography/shared/models/drawing.model";
|
||||||
import { NodeContextMenuComponent } from "../shared/node-context-menu/node-context-menu.component";
|
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({
|
@Component({
|
||||||
@ -55,6 +57,7 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private symbolService: SymbolService,
|
private symbolService: SymbolService,
|
||||||
private snapshotService: SnapshotService,
|
private snapshotService: SnapshotService,
|
||||||
|
private nodeService: NodeService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private progressDialogService: ProgressDialogService,
|
private progressDialogService: ProgressDialogService,
|
||||||
private toastyService: ToastyService) {
|
private toastyService: ToastyService) {
|
||||||
@ -176,15 +179,18 @@ export class ProjectMapComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// setUpNodeActions() {
|
onNodeCreation(appliance: Appliance) {
|
||||||
// this.mapChild.nodeContextMenu.clearActions();
|
this.nodeService
|
||||||
//
|
.createFromAppliance(this.server, this.project, appliance, 0, 0, 'local')
|
||||||
// const start_node_action = new StartNodeAction(this.server, this.nodeService);
|
.subscribe(() => {
|
||||||
// this.mapChild.nodeContextMenu.registerAction(start_node_action);
|
this.projectService
|
||||||
//
|
.nodes(this.server, this.project.project_id)
|
||||||
// const stop_node_action = new StopNodeAction(this.server, this.nodeService);
|
.subscribe((nodes: Node[]) => {
|
||||||
// this.mapChild.nodeContextMenu.registerAction(stop_node_action);
|
this.nodes = nodes;
|
||||||
// }
|
this.mapChild.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public createSnapshotModal() {
|
public createSnapshotModal() {
|
||||||
const dialogRef = this.dialog.open(CreateSnapshotDialogComponent, {
|
const dialogRef = this.dialog.open(CreateSnapshotDialogComponent, {
|
||||||
|
@ -7,6 +7,7 @@ import 'rxjs/add/operator/map';
|
|||||||
import { Server } from "../models/server";
|
import { Server } from "../models/server";
|
||||||
import { HttpServer } from "./http-server.service";
|
import { HttpServer } from "./http-server.service";
|
||||||
import {Appliance} from "../models/appliance";
|
import {Appliance} from "../models/appliance";
|
||||||
|
import {Response} from "@angular/http";
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -26,10 +27,14 @@ export class NodeService {
|
|||||||
.map(response => response.json() as Node);
|
.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
|
return this.httpServer
|
||||||
.post(server, `/projects/${project.project_id}/appliances/${appliance.appliance_id}`, {})
|
.post(
|
||||||
.map(response => response.json() as Node);
|
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