fix for alarms seeking charts by name instead of id
Costa Tsaousis (ktsaou) committed
Aug 31, 2016 at 00:14 UTC
ac406caa95779ca0e22e8e253ac130213fd9a291
1 file changed
+33
-13
web/index.html
+33
-13
@@ -2533,10 +2533,20 @@ function alarmsUpdateModal() {
2533
var families_sort = new Array();
2534
for(x in data.alarms) {
2535
var alarm = data.alarms[x];
2536
- var chart = options.data.charts[alarm.chart];
2536
var family = alarm.family;
2537
2539
- if(typeof chart !== 'undefined' && typeof chart.menu !== 'undefined' && typeof chart.submenu !== 'undefined')
2538
+ // find the chart
2539
+ var chart = options.data.charts[alarm.chart];
2540
+ if(typeof chart === 'undefined')
2541
+ chart = options.data.charts_by_name[alarm.chart];
2542
+
2543
+ // not found - this should never happen!
2544
+ if(typeof chart === 'undefined') {
2545
+ console.log('WARNING: alarm ' + x + ' is linked to chart ' + alarm.chart + ', which is not found in the list of chart got from the server.');
2546
+ chart = { priority: 9999999 };
2547
+ }
2548
+ else if(typeof chart.menu !== 'undefined' && typeof chart.submenu !== 'undefined')
2549
+ // the family based on the chart
2550
family = chart.menu + ' - ' + chart.submenu;
2551
2552
if(typeof families[family] === 'undefined') {
@@ -2678,26 +2688,36 @@ function downloadAllCharts(netdata_url) {
2688
2689
NETDATA.pause(function() {
2690
$("#loadOverlay").css("display","none");
2681
- $("#loadOverlay").css("display","none");
2691
2692
NETDATA.alarms.callback = alarmsCallback;
2693
2694
// download all the charts the server knows
2695
NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
2696
2688
- options.data = data;
2689
- options.hostname = data.hostname;
2690
- document.getElementById('hostname').innerHTML = options.hostname;
2691
- document.getElementById('hostname').href = NETDATA.serverDefault;
2692
- document.title = options.hostname + ' netdata dashboard';
2697
+ if(data !== null) {
2698
+ options.hostname = data.hostname;
2699
+ options.data = data;
2700
+
2701
+ // create a chart_by_name index
2702
+ data.charts_by_name = {};
2703
+ var charts = data.charts;
2704
+ var x;
2705
+ for(x in charts) {
2706
+ var chart = charts[x];
2707
+ data.charts_by_name[chart.name] = chart;
2708
+ }
2709
+ console.log(options.data);
2710
2694
- renderChartsAndMenu(data);
2711
+ // update the dashboard hostname
2712
+ document.getElementById('hostname').innerHTML = options.hostname;
2713
+ document.getElementById('hostname').href = NETDATA.serverDefault;
2714
2696
- // prepare our DOM
2697
-// prepareScreen(data);
2715
+ // update the dashboard title
2716
+ document.title = options.hostname + ' netdata dashboard';
2717
2699
- // due to affix issues, prepareScreen() will unpause
2700
- // netdata as needed
2718
+ // render all charts
2719
+ renderChartsAndMenu(data);
2720
+ }
2721
});
2722
});
2723
}