mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 21:17:51 +00:00
Duplicate action added
This commit is contained in:
parent
031291612f
commit
c0ef682e9c
@ -40,6 +40,9 @@
|
||||
<button mat-icon-button matTooltip="Delete project" (click)="delete(row)" *ngIf="row.status == 'closed'">
|
||||
<mat-icon aria-label="Delete project">delete</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button matTooltip="Duplicate project" (click)="duplicate(row)">
|
||||
<mat-icon aria-label="Duplicate project">filter_2</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button matTooltip="Open project" (click)="open(row)" *ngIf="row.status == 'closed'">
|
||||
<mat-icon aria-label="Open project">play_arrow</mat-icon>
|
||||
</button>
|
||||
|
@ -107,6 +107,12 @@ export class ProjectsComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
duplicate(project: Project) {
|
||||
this.projectService.duplicate(this.server, project.project_id, project.name).subscribe(() => {
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
addBlankProject() {
|
||||
const dialogRef = this.dialog.open(AddBlankProjectDialogComponent, {
|
||||
width: '400px',
|
||||
|
@ -132,6 +132,13 @@ describe('ProjectService', () => {
|
||||
expect(req.request.method).toEqual('DELETE');
|
||||
});
|
||||
|
||||
it('should duplicate the project', () => {
|
||||
service.duplicate(server, 'projectId', 'projectName').subscribe();
|
||||
|
||||
const req = httpTestingController.expectOne('http://127.0.0.1:3080/v2/projects/projectId/duplicate');
|
||||
expect(req.request.method).toEqual('POST');
|
||||
});
|
||||
|
||||
it('should get notifications path of project', () => {
|
||||
const path = service.notificationsPath(server, 'myproject');
|
||||
expect(path).toEqual('ws://127.0.0.1:3080/v2/projects/myproject/notifications/ws');
|
||||
|
@ -49,6 +49,10 @@ export class ProjectService {
|
||||
return this.httpServer.delete(server, `/projects/${project_id}`);
|
||||
}
|
||||
|
||||
duplicate(server: Server, project_id: string, project_name): Observable<any> {
|
||||
return this.httpServer.post(server, `/projects/${project_id}/duplicate`, { name: project_name });
|
||||
}
|
||||
|
||||
notificationsPath(server: Server, project_id: string): string {
|
||||
return `ws://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user