Skip to content

Commit 83853a6

Browse files
committed
Extendend options for mapping of external service icons
1 parent 369809f commit 83853a6

File tree

8 files changed

+114
-22
lines changed

8 files changed

+114
-22
lines changed

src/assets/default.png

2.51 KB
Loading

src/assets/http.png

5.54 KB
Loading

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@
3838
.vizceral .vizceral-notice .subtitle {
3939
font-weight: 900;
4040
}
41+
42+
.zoom-button-container {
43+
position: absolute;
44+
top: 0;
45+
right: 1rem;
46+
}

src/graph/GraphGenerator.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import _ from 'lodash';
2+
import {has, find} from 'lodash';
23

34
class GraphGenerator {
45

@@ -26,7 +27,8 @@ class GraphGenerator {
2627
connections: connections,
2728
layoutOptions: {
2829
noRankPromotion: true,
29-
pullUpLeaves: true
30+
pullUpLeaves: true,
31+
adjustWidthToRanks: true
3032
}
3133
};
3234

@@ -69,7 +71,7 @@ class GraphGenerator {
6971
.map(n => n.data.res_time_sum)
7072
.sum(), -1);
7173

72-
if (responseTime >= 0) {
74+
if (this.panelCtrl.panel.sdgSettings.sumTimings && responseTime >= 0) {
7375
responseTime = responseTime / (requestCount + errorCount);
7476
}
7577

@@ -256,17 +258,22 @@ class GraphGenerator {
256258
}
257259

258260
getTypeSymbol(type) {
259-
if (type.toLowerCase() === 'database') {
260-
return this.getAssetUrl('database.png');
261-
}
262-
else if (type.toLowerCase() === 'jms') {
263-
return this.getAssetUrl('message.png');
264-
}
265-
else if (type.toLowerCase() === 'web') {
266-
return this.getAssetUrl('web.png');
267-
}
268-
else {
269-
return '';
261+
const mapping = find(this.panelCtrl.panel.sdgSettings.externalIcons, e => e.type.toLowerCase() === type.toLowerCase());
262+
263+
// debugger;
264+
265+
// const typeLC = type.toLowerCase();
266+
// const iconMap = {
267+
// 'database': 'database.png',
268+
// 'jms': 'message.png',
269+
// 'web': 'web.png',
270+
// 'http': 'http.png'
271+
// };
272+
273+
if (mapping !== undefined) {
274+
return this.getAssetUrl(mapping.icon + '.png');
275+
} else {
276+
return this.getAssetUrl('default.png');
270277
}
271278
}
272279

src/options_ctrl.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,28 @@ export class OptionsCtrl {
1616
this.getColumnNames = this.getColumnNames.bind(this);
1717
this.getPrefixCandidates = this.getPrefixCandidates.bind(this);
1818
this.getColumnNamesExternal = this.getColumnNamesExternal.bind(this);
19+
this.addExternalMapping = this.addExternalMapping.bind(this);
20+
this.removeExternalMapping = this.removeExternalMapping.bind(this);
21+
}
22+
23+
addExternalMapping() {
24+
this.panel.sdgSettings.externalIcons.push({type: 'my-type', icon: 'default'});
25+
this.panelCtrl.render();
26+
}
27+
28+
removeExternalMapping(index) {
29+
this.panel.sdgSettings.externalIcons.splice(index, 1);
30+
this.panelCtrl.render();
1931
}
2032

2133
getLayoutOptions() {
2234
return ['ltrTree', 'ring', 'ringCenter', 'cytoscape'];
2335
}
2436

37+
getExternalIconOptions() {
38+
return ['default', 'message', 'database', 'http', 'web'];
39+
}
40+
2541
getColumnNames() {
2642
if (this.panelCtrl.currentData) {
2743
return _.sortBy(this.panelCtrl.currentData.columns);

src/partials/module.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<div class="clock-panel" ng-style="{height: ctrl.height}">
22

3+
<div class="zoom-button-container">
4+
<button class="btn navbar-button" ng-click="ctrl.zoom(+1)"><i class="fa fa-plus"></i></button>
5+
<button class="btn navbar-button" ng-click="ctrl.zoom(-1)"><i class="fa fa-minus"></i></button>
6+
</div>
7+
38
<div class="vizceral" id="nt-sdg-container" ng-show="ctrl.dataAvailable()" style="width: 100%; height: 100%"></div>
49

510
<div class="noData" ng-show="!ctrl.dataAvailable()">No data to show - the query returned no data.</div>

src/partials/options.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ <h5 class="section-heading">SDG Settings</h5>
8383
<option ng-repeat="variable in editor.getLayoutOptions()" value="{{variable}}">{{variable}}</option>
8484
</select>
8585
</div>
86+
87+
<div class="gf-form-inline">
88+
89+
<label class="gf-form-label width-16">Handle Timings as Sums<info-popover mode="right-normal">If this setting is active, the timings provided by the mapped response time columns are considered as a continually increasing sum of response times. When deactivated, it is considered that the timings provided by columns are the actual average response times.</info-popover></label>
90+
<gf-form-switch class="gf-form" checked="ctrl.panel.sdgSettings.sumTimings" on-change="ctrl.forceRender()"></gf-form-switch>
91+
</div>
8692
</div>
8793

8894
<div class="section gf-form-group">
@@ -100,5 +106,30 @@ <h5 class="section-heading">SDG Style</h5>
100106
</span>
101107
</div>
102108
</div>
109+
110+
<div class="section gf-form-group">
111+
<h5 class="section-heading">External Service Icon Mapping</h5>
112+
113+
<div class="gf-form-inline">
114+
<div class="gf-form">
115+
<label class="gf-form-label width-10">Target Type</label>
116+
<label class="gf-form-label width-10">Icon</label>
117+
</div>
118+
</div>
119+
120+
<div class="gf-form-inline" ng-repeat="(index, mapping) in ctrl.panel.sdgSettings.externalIcons">
121+
<div class="gf-form">
122+
<input type="text" class="input-small gf-form-input width-10" ng-model="ctrl.panel.sdgSettings.externalIcons[index].type" ng-change="ctrl.forceRender()" ng-model-onblur />
123+
124+
<select class="input-small gf-form-input width-10" ng-model="ctrl.panel.sdgSettings.externalIcons[index].icon" ng-change="ctrl.forceRender()">
125+
<option ng-repeat="variable in editor.getExternalIconOptions()" value="{{variable}}">{{variable}}</option>
126+
</select>
127+
128+
<a class="gf-form-label tight-form-func" ng-click="editor.removeExternalMapping(index)"><i class="fa fa-trash"></i></a>
129+
</div>
130+
</div>
131+
132+
<button class="btn navbar-button navbar-button--primary" ng-click="editor.addExternalMapping()">Add External Service Icon Mapping</button>
133+
</div>
103134
</div>
104135
</div>

src/service_dependency_graph_ctrl.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,27 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
2929
dangerColor: 'rgb(184, 36, 36)'
3030
},
3131
sdgSettings: {
32+
sumTimings: false,
3233
showConnectionStats: true,
33-
layout: 'ltrTree'
34+
layout: 'ltrTree',
35+
externalIcons: [
36+
{
37+
type:'web',
38+
icon: 'web'
39+
},
40+
{
41+
type:'jms',
42+
icon: 'message'
43+
},
44+
{
45+
type:'database',
46+
icon: 'database'
47+
},
48+
{
49+
type:'http',
50+
icon: 'http'
51+
}
52+
]
3453
}
3554
};
3655

@@ -40,7 +59,7 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
4059

4160
currentGraphNodes: Array<string> = [];
4261

43-
currentLayout: string;
62+
zoomLevel: number;
4463

4564
/** @ngInject */
4665
constructor($scope, $injector) {
@@ -56,6 +75,17 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
5675
this.events.on('data-snapshot-load', this.onDataReceived.bind(this));
5776
}
5877

78+
zoom(zoom) {
79+
const zoomStep = 0.1 * zoom;
80+
const nextZoomLevel = Math.min(Math.max(this.zoomLevel + zoomStep, 0.1), 2);
81+
82+
if (this.vizceral) {
83+
console.log("Current:", this.zoomLevel, "New:", nextZoomLevel);
84+
this.zoomLevel = nextZoomLevel;
85+
this.vizceral.setZoom(this.zoomLevel);
86+
}
87+
}
88+
5989
dataAvailable() {
6090
return this.currentData != null && _.has(this.currentData, 'data') && this.currentData.data.length > 0;
6191
}
@@ -112,6 +142,9 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
112142

113143
if (vizContainer != null) {
114144

145+
// init variables for vizceral
146+
this.zoomLevel = 1;
147+
115148
var viz = new Vizceral(vizContainer);
116149
viz.setOptions({
117150
allowDraggingOfNodes: true,
@@ -212,13 +245,7 @@ export class ServiceDependencyGraphCtrl extends MetricsPanelCtrl {
212245
this.currentData = [];
213246
}
214247

215-
var layout = this.getTemplateVariable('layout');
216-
if (this.currentLayout === layout) {
217-
this.render();
218-
} else {
219-
this.currentLayout = layout;
220-
this.forceRender();
221-
}
248+
this.render();
222249
}
223250

224251
getTemplateVariable(name) {

0 commit comments

Comments
 (0)