Duplicate action added

This commit is contained in:
Piotr Pekala 2019-08-09 06:32:58 -07:00
parent 031291612f
commit c0ef682e9c
4 changed files with 20 additions and 0 deletions

View File

@ -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>

View File

@ -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',

View File

@ -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');

View File

@ -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`;
}