Initial implementation of topology summary

This commit is contained in:
Piotr Pekala 2019-08-12 08:46:15 -07:00
parent 031291612f
commit 8581753520
6 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Project } from '../../models/project';
import { Server } from '../../models/server';
import { NodesDataSource } from '../../cartography/datasources/nodes-datasource';
import { NodeService } from '../../services/node.service';
import { Node } from '../../cartography/models/node';
import { Subscription } from 'rxjs';
import { ProjectService } from '../../services/project.service';
import { ProjectStatistics } from '../../models/project-statistics';
@Component({
selector: 'app-topology-summary',
templateUrl: './topology-summary.component.html',
styleUrls: ['./topology-summary.component.scss']
})
export class TopologySummaryComponent implements OnInit, OnDestroy {
@Input() project: Project;
@Input() server: Server;
private subscriptions: Subscription[];
projectsStatistics: ProjectStatistics;
nodes: Node[] = [];
//filters to introduce -> should be generic
constructor(
private nodesDataSource: NodesDataSource,
private projectService: ProjectService
) {}
ngOnInit() {
this.subscriptions.push(
this.nodesDataSource.changes.subscribe((nodes: Node[]) => {
this.nodes = nodes;
})
);
this.projectService.getStatistics(this.server, this.project.project_id).subscribe((stats: ProjectStatistics) => {
this.projectsStatistics = stats;
});
}
ngOnDestroy() {
this.subscriptions.forEach((subscription: Subscription) => subscription.unsubscribe());
}
}

View File

@ -0,0 +1,6 @@
export class ProjectStatistics {
drawings: number;
links: number;
nodes: number;
snapshots: number
}

View File

@ -49,6 +49,10 @@ export class ProjectService {
return this.httpServer.delete(server, `/projects/${project_id}`);
}
getStatistics(server: Server, project_id: string) {
return this.httpServer.get(server, `/projects/${project_id}/stats`);
}
notificationsPath(server: Server, project_id: string): string {
return `ws://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
}