Delete a project

This commit is contained in:
ziajka 2017-09-28 12:13:35 +02:00
parent 7968368b81
commit a4525a67f1
3 changed files with 25 additions and 6 deletions

View File

@ -6,13 +6,16 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let project of projects"> <tr *ngFor="let project of projects">
<td><a [routerLink]="['/server', server.id, 'project', project.project_id]">{{ project.name }}</a></td> <td><a [routerLink]="['/server', server.id, 'project', project.project_id]">{{ project.name }}</a></td>
<td><button class="btn btn-outline-danger btn-sm" (click)="delete(project)">Remove</button></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -27,12 +27,23 @@ export class ProjectsComponent implements OnInit {
}) })
.subscribe((server: Server) => { .subscribe((server: Server) => {
this.server = server; this.server = server;
this.reload();
});
}
reload() {
this.projectService this.projectService
.list(server) .list(this.server)
.subscribe((projects: Project[]) => { .subscribe((projects: Project[]) => {
this.projects = projects; this.projects = projects;
}); });
}
delete(project: Project) {
this.projectService.delete(this.server, project.project_id).subscribe(() => {
this.reload();
}); });
} }

View File

@ -45,6 +45,11 @@ export class ProjectService {
.map(response => response.json() as Link[]); .map(response => response.json() as Link[]);
} }
delete(server: Server, project_id: string): Observable<any> {
return this.httpServer
.delete(server, `/projects/${project_id}`);
}
notificationsPath(server: Server, project_id: string): string { notificationsPath(server: Server, project_id: string): string {
return `ws://${server.ip}:${server.port}/v2/projects/${project_id}/notifications/ws`; return `ws://${server.ip}:${server.port}/v2/projects/${project_id}/notifications/ws`;
} }