Skip to content

Commit bb238dc

Browse files
authored
Adding statistics for the selected node element in the sidebar (#12)
1 parent 4599914 commit bb238dc

File tree

5 files changed

+65
-20
lines changed

5 files changed

+65
-20
lines changed

src/canvas/particle_engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class ParticleEngine {
1111
minSpawnPropability: number = 0.01;
1212

1313
spawnInterval: number | null;
14-
14+
1515
constructor(canvasDrawer: CanvasDrawer) {
1616
this.drawer = canvasDrawer;
1717
}

src/css/novatec-service-dependency-graph-panel.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
padding-left: 0.5%;
4444
}
4545

46-
.header--selection{
46+
.header--selection {
4747
font-size: 1.25em;
4848
text-align: center;
4949
border-bottom: 2px solid #161719;
@@ -59,8 +59,7 @@
5959
}
6060

6161
.no-data--selection{
62-
font-size: 1.2em;
63-
display: block;
62+
color: #888888;
6463
text-align: center;
6564
}
6665

@@ -87,6 +86,10 @@
8786
width: 5.5rem;
8887
}
8988

89+
.table--th--selectionMedium {
90+
width: 8rem;
91+
}
92+
9093
.table--selection--head {
9194
background-color: #28282a;
9295
border-top: 2px solid #161719;

src/partials/module.html

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,41 @@
1212
<button class="btn navbar-button" ng-click="ctrl.zoom(-1)"><i class="fa fa-minus"></i></button>
1313
</div>
1414
</div>
15-
16-
1715
<div ng-class="{statistics: true, 'show': ctrl.showStatistics}">
16+
1817
<div class="header--selection">{{ctrl.selectionId}}
1918
<a target="_blank" ng-href="{{ctrl.resolvedDrillDownLink}}"
2019
ng-show="ctrl.resolvedDrillDownLink && ctrl.resolvedDrillDownLink.length > 0 && ctrl.currentType === 'INTERNAL'">
2120
<i class="fa fa-paper-plane-o"></i>
2221
</a>
2322
</div>
24-
<div class="secondHeader--selection">Receiving</div>
25-
<div class="no-data--selection" ng-show="ctrl.receiving.length == 0">No receiving Data</div>
23+
24+
<div class="secondHeader--selection">Statistics</div>
25+
<table class="table--selection">
26+
<tr class="table--selection--head">
27+
<th>Name</th>
28+
<th class="table--th--selectionMedium">Value</th>
29+
</tr>
30+
<tr ng-show="ctrl.selectionStatistics.requests">
31+
<td class="table--td--selection">Request</td>
32+
<td class="table--td--selection">{{ctrl.selectionStatistics.requests}}</td>
33+
</tr>
34+
<tr ng-show="ctrl.selectionStatistics.errors">
35+
<td class="table--td--selection">Errors</td>
36+
<td class="table--td--selection">{{ctrl.selectionStatistics.errors}}</td>
37+
</tr>
38+
<tr ng-show="ctrl.selectionStatistics.requests && ctrl.selectionStatistics.errors">
39+
<td class="table--td--selection">Error Rate</td>
40+
<td class="table--td--selection">{{ (100 / ctrl.selectionStatistics.requests * ctrl.selectionStatistics.errors) | number:1 }}%</td>
41+
</tr>
42+
<tr ng-show="ctrl.selectionStatistics.responseTime">
43+
<td class="table--td--selection">Avg. Response Time</td>
44+
<td class="table--td--selection">{{ctrl.selectionStatistics.responseTime}}ms</td>
45+
</tr>
46+
</table>
47+
48+
<div class="secondHeader--selection">Incoming Statistics</div>
49+
<div class="no-data--selection" ng-show="ctrl.receiving.length == 0">No incoming statistics available.</div>
2650
<table class="table--selection" ng-show="ctrl.receiving.length > 0">
2751
<tr class="table--selection--head">
2852
<th>Name</th>
@@ -38,8 +62,8 @@
3862
</tr>
3963
</table>
4064

41-
<div class="secondHeader--selection">Sending</div>
42-
<div class="no-data--selection" ng-show="ctrl.sending.length == 0">No sending Data</div>
65+
<div class="secondHeader--selection">Outgoing Statistics</div>
66+
<div class="no-data--selection" ng-show="ctrl.sending.length == 0">No outgoing statistics available.</div>
4367
<table class="table--selection" ng-show="ctrl.sending.length>0">
4468
<tr class="table--selection--head">
4569
<th>Name</th>

src/service_dependency_graph_ctrl.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import cola from 'cytoscape-cola';
1212
import cyCanvas from 'cytoscape-canvas';
1313

1414
import layoutOptions from './layout_options';
15-
import { DataMapping, IGraph, IGraphNode, IGraphEdge, CyData, PanelSettings, CurrentData, QueryResponse, TableContent, IGraphMetrics } from './types';
15+
import { DataMapping, IGraph, IGraphNode, IGraphEdge, CyData, PanelSettings, CurrentData, QueryResponse, TableContent, IGraphMetrics, ISelectionStatistics } from './types';
1616

1717
import dummyGraph from './dummy_graph';
1818

@@ -101,6 +101,8 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
101101

102102
currentType: string;
103103

104+
selectionStatistics: ISelectionStatistics;
105+
104106
/** @ngInject */
105107
constructor($scope, $injector) {
106108
super($scope, $injector);
@@ -312,12 +314,24 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
312314
const currentNode: NodeSingular = selection[0];
313315
this.selectionId = currentNode.id();
314316
this.currentType = currentNode.data('type');
315-
console.log(this.currentType);
316-
console.log(currentNode.data('type'));
317317
const receiving: TableContent[] = [];
318318
const sending: TableContent[] = [];
319319
const edges: EdgeCollection = selection.connectedEdges();
320320

321+
const metrics = selection.nodes()[0].data('metrics');
322+
323+
this.selectionStatistics = {};
324+
325+
if (metrics.rate != undefined) {
326+
this.selectionStatistics.requests = Math.floor(metrics.rate);
327+
}
328+
if (metrics.error_rate != undefined) {
329+
this.selectionStatistics.errors = Math.floor(metrics.error_rate);
330+
}
331+
if (metrics.response_time != undefined) {
332+
this.selectionStatistics.responseTime = Math.floor(metrics.response_time);
333+
}
334+
321335
for (let i = 0; i < edges.length; i++) {
322336

323337
const actualEdge: EdgeSingular = edges[i];
@@ -362,17 +376,15 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
362376

363377
this.generateDrillDownLink();
364378
}
365-
366379
}
367380

368381
onMount() {
369-
console.log("mount");
382+
// console.log("mount");
370383
this.render();
371384
}
372385

373386
onRender(payload) {
374-
console.log("render");
375-
387+
// console.log("render");
376388

377389
if (!this.cy) {
378390
this._initCytoscape();

src/types.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ export interface CyCanvas {
139139
export interface TableContent {
140140
name: string;
141141
responseTime: string;
142-
rate: string;
143-
error: string;
144-
}
142+
rate: string;
143+
error: string;
144+
};
145+
146+
export interface ISelectionStatistics {
147+
requests?: number;
148+
errors?: number;
149+
responseTime?: number;
150+
};

0 commit comments

Comments
 (0)