properly populate submenu titles
Costa Tsaousis committed
Feb 8, 2016 at 23:13 UTC
e1a61c75e2a31eed659619e65a893b45d6f07b07
1 file changed
+17
-17
web/index.html
+17
-17
@@ -692,7 +692,7 @@ if(document.location.hostname === demo_hostname) {
692
693
var options = {
694
sparklines_registry: {},
695
- interfaces_registry: {},
695
+ submenu_names: {},
696
data: null,
697
hostname: 'netdata_server', // will be overwritten by the netdata server
698
categories: new Array(),
@@ -1153,30 +1153,18 @@ function enrichChartData(chart) {
1153
var tmp = chart.type.split('_')[0];
1154
1155
switch(tmp) {
1156
- case 'disk':
1157
- chart.menu = tmp;
1158
- break;
1159
-
1156
case 'ap':
1157
case 'net':
1158
+ case 'disk':
1159
chart.menu = tmp;
1163
-
1164
- // set the family using the name
1165
- if(typeof options.interfaces_registry[chart.family] !== 'undefined' && options.interfaces_registry[chart.family] !== chart.family)
1166
- chart.family += ' (' + options.interfaces_registry[chart.family] + ')';
1167
-
1160
break;
1161
1162
case 'tc':
1163
chart.menu = tmp;
1164
1165
// find the interface name from the name
1174
- if(typeof options.interfaces_registry[chart.family] === 'undefined' || options.interfaces_registry[chart.family] === chart.family)
1175
- options.interfaces_registry[chart.family] = chart.name.split('.')[1].split('_')[0];
1176
-
1177
- // set the family using the name
1178
- if(typeof options.interfaces_registry[chart.family] !== 'undefined' && options.interfaces_registry[chart.family] !== chart.family)
1179
- chart.family += ' (' + options.interfaces_registry[chart.family] + ')';
1166
+ if(typeof options.submenu_names[chart.family] === 'undefined' || options.submenu_names[chart.family] === chart.family)
1167
+ options.submenu_names[chart.family] = chart.name.split('.')[1].split('_')[0];
1168
1169
// increase the priority of IFB devices
1170
if(chart.id.match(/.*-ifb$/))
@@ -1426,7 +1414,7 @@ function renderChartsAndMenu(data) {
1414
menus[charts[c].menu].submenus[charts[c].submenu] = {
1415
priority: charts[c].priority,
1416
charts: new Array(),
1429
- title: submenuTitle(charts[c].menu, charts[c].submenu),
1417
+ title: null,
1418
info: submenuInfo(charts[c].menu, charts[c].submenu),
1419
height: submenuHeight(charts[c].menu, charts[c].submenu, menus[charts[c].menu].height)
1420
};
@@ -1439,6 +1427,18 @@ function renderChartsAndMenu(data) {
1427
menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
1428
}
1429
1430
+ for(var m in menus) {
1431
+ for(var s in menus[m].submenus) {
1432
+ // set the family using a name
1433
+ if(typeof options.submenu_names[s] !== 'undefined') {
1434
+ menus[m].submenus[s].title = s + ' (' + options.submenu_names[s] + ')';
1435
+ }
1436
+ else {
1437
+ menus[m].submenus[s].title = submenuTitle(m, s);
1438
+ }
1439
+ }
1440
+ }
1441
+
1442
renderPage(menus, data);
1443
}
1444