2017-09-25 13:07:52 +02:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Project } from '../models/project';
|
2018-03-20 08:18:36 +01:00
|
|
|
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';
|
2018-03-20 08:18:36 +01:00
|
|
|
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";
|
2018-03-20 08:18:36 +01:00
|
|
|
import {Drawing} from "../../cartography/shared/models/drawing";
|
2017-09-25 13:07:52 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ProjectService {
|
|
|
|
|
|
|
|
constructor(private httpServer: HttpServer) { }
|
|
|
|
|
|
|
|
get(server: Server, project_id: string): Observable<Project> {
|
|
|
|
return this.httpServer
|
|
|
|
.get(server, `/projects/${project_id}`)
|
|
|
|
.map(response => response.json() as Project);
|
|
|
|
}
|
|
|
|
|
|
|
|
open(server: Server, project_id: string): Observable<Project> {
|
|
|
|
return this.httpServer
|
|
|
|
.post(server, `/projects/${project_id}/open`, {})
|
|
|
|
.map(response => response.json() as Project);
|
|
|
|
}
|
|
|
|
|
|
|
|
list(server: Server): Observable<Project[]> {
|
|
|
|
return this.httpServer
|
|
|
|
.get(server, '/projects')
|
|
|
|
.map(response => response.json() as Project[]);
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes(server: Server, project_id: string): Observable<Node[]> {
|
|
|
|
return this.httpServer
|
|
|
|
.get(server, `/projects/${project_id}/nodes`)
|
|
|
|
.map(response => response.json() as Node[]);
|
|
|
|
}
|
|
|
|
|
|
|
|
links(server: Server, project_id: string): Observable<Link[]> {
|
|
|
|
return this.httpServer
|
|
|
|
.get(server, `/projects/${project_id}/links`)
|
|
|
|
.map(response => response.json() as Link[]);
|
|
|
|
}
|
|
|
|
|
2017-11-28 15:06:01 +01:00
|
|
|
drawings(server: Server, project_id: string): Observable<Drawing[]> {
|
|
|
|
return this.httpServer
|
|
|
|
.get(server, `/projects/${project_id}/drawings`)
|
|
|
|
.map(response => response.json() as Drawing[]);
|
|
|
|
}
|
|
|
|
|
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`;
|
|
|
|
}
|
|
|
|
}
|