gns3-web-ui/src/app/shared/services/project.service.ts

56 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-09-25 13:07:52 +02:00
import { Injectable } from '@angular/core';
import { Project } from '../models/project';
import { Node } from '../../cartography/shared/models/node';
2017-09-25 13:07:52 +02:00
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Link } from "../../cartography/shared/models/link";
2017-09-25 13:07:52 +02:00
import { Server } from "../models/server";
import { HttpServer } from "./http-server.service";
import {Drawing} from "../../cartography/shared/models/drawing";
2017-09-25 13:07:52 +02:00
@Injectable()
export class ProjectService {
constructor(private httpServer: HttpServer) { }
2018-03-20 16:02:41 +01:00
get(server: Server, project_id: string) {
2017-09-25 13:07:52 +02:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.get<Project>(server, `/projects/${project_id}`);
2017-09-25 13:07:52 +02:00
}
2018-03-20 16:02:41 +01:00
open(server: Server, project_id: string) {
2017-09-25 13:07:52 +02:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.post<Project>(server, `/projects/${project_id}/open`, {});
2017-09-25 13:07:52 +02:00
}
2018-03-20 16:02:41 +01:00
list(server: Server) {
2017-09-25 13:07:52 +02:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.get<Project[]>(server, '/projects');
2017-09-25 13:07:52 +02:00
}
2018-03-20 16:02:41 +01:00
nodes(server: Server, project_id: string) {
2017-09-25 13:07:52 +02:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.get<Node[]>(server, `/projects/${project_id}/nodes`);
2017-09-25 13:07:52 +02:00
}
2018-03-20 16:02:41 +01:00
links(server: Server, project_id: string) {
2017-09-25 13:07:52 +02:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.get<Link[]>(server, `/projects/${project_id}/links`);
2017-09-25 13:07:52 +02:00
}
2018-03-20 16:02:41 +01:00
drawings(server: Server, project_id: string) {
2017-11-28 15:06:01 +01:00
return this.httpServer
2018-03-20 16:02:41 +01:00
.get<Drawing[]>(server, `/projects/${project_id}/drawings`);
2017-11-28 15:06:01 +01:00
}
2017-09-28 12:13:35 +02:00
delete(server: Server, project_id: string): Observable<any> {
return this.httpServer
.delete(server, `/projects/${project_id}`);
}
2017-09-25 13:07:52 +02:00
notificationsPath(server: Server, project_id: string): string {
return `ws://${server.ip}:${server.port}/v2/projects/${project_id}/notifications/ws`;
}
}