mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-31 22:40:43 +00:00
Initial implementation of topology summary
This commit is contained in:
parent
031291612f
commit
8581753520
@ -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());
|
||||||
|
}
|
||||||
|
}
|
6
src/app/models/project-statistics.ts
Normal file
6
src/app/models/project-statistics.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export class ProjectStatistics {
|
||||||
|
drawings: number;
|
||||||
|
links: number;
|
||||||
|
nodes: number;
|
||||||
|
snapshots: number
|
||||||
|
}
|
@ -49,6 +49,10 @@ export class ProjectService {
|
|||||||
return this.httpServer.delete(server, `/projects/${project_id}`);
|
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 {
|
notificationsPath(server: Server, project_id: string): string {
|
||||||
return `ws://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
|
return `ws://${server.host}:${server.port}/v2/projects/${project_id}/notifications/ws`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user