]> arthur.barton.de Git - netdata.git/blob - web/index.html
ui changes
[netdata.git] / web / index.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5     <meta charset="utf-8">
6     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7     <meta name="viewport" content="width=device-width, initial-scale=1">
8     <meta name="apple-mobile-web-app-capable" content="yes">
9     <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
10     <meta name="description" content="">
11     <meta name="author" content="costa@tsaousis.gr">
12  
13         <title>NetData</title>
14
15         <!-- Google AJAX API -->
16         <script type="text/javascript" src="https://www.google.com/jsapi"></script>
17         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
18
19         <!-- Bootstrap -->
20         <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
21         <!-- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> -->
22         <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
23         <link href="/file/theme.css" rel="stylesheet">
24
25         <!-- NetData -->
26         <script type="text/javascript" src="/file/netdata.js"></script>
27         <script type="text/javascript" src="/file/jquery.visible.js"></script>
28         <script type="text/javascript">
29         
30         // Set a callback to run when the Google Visualization API is loaded.
31         google.setOnLoadCallback(initCharts);
32         
33         var TARGET_THUMB_GRAPH_WIDTH = 500; // chart width will range from 0.5 to 1.5 of that
34         var MINIMUM_THUMB_GRAPH_WIDTH = 400; // chart will generally try to be wider than that
35         var TARGET_THUMB_GRAPH_HEIGHT = 220;
36         var MAINCHART_MAX_TIME_TO_SHOW = 1200;
37         var THUMBS_MAX_TIME_TO_SHOW = 600;
38
39         var MODE_THUMBS = 1;
40         var MODE_MAIN = 2;
41         var MODE_GROUP_THUMBS = 3;
42         var mode; // one of the MODE_* values
43
44         var mycharts = new Array();
45         var mainchart;
46
47         // html for the main menu
48         var mainmenu = "";
49
50
51         // ------------------------------------------------------------------------
52         // common HTML generation
53
54         function chartIsLoadingHTML(width, height) { return "<table><tr><td align=\"center\" width=\"" + width + "\" height=\"" + height + "\" style=\"vertical-align:middle\"><h4><span class=\"glyphicon glyphicon-refresh\"></span><br/><br/>loading chart<br/><br/><span class=\"label label-default\">Please wait...</span></h4></td></tr></table>"; }
55
56         function showChartIsLoading(id, width, height) { document.getElementById(id).innerHTML = chartIsLoadingHTML(width, height); }
57
58         function thumbChartActions(i, c, nogroup) {
59                 var refinfo = "the chart is drawing ";
60                 if(c.group == 1) refinfo += "every single point collected.";
61                 else refinfo += ((c.group_method == "average")?"the average":"the max") + " value for every " + (c.group * c.update_every) + " seconds of data";
62
63                 var html = "<div class=\"btn-group btn-group\" data-toggle=\"tooltip\" title=\"" + refinfo + "\">"
64                 +               "<button type=\"button\" class=\"btn btn-default\" onclick=\"javascript: return;\"><span class=\"glyphicon glyphicon-info-sign\"></span></button>"
65                 +       "</div>"
66                 +       "<div class=\"btn-group btn-group\"><button type=\"button\" class=\"btn btn-default disabled\"><small>&nbsp;&nbsp; " + c.name + "</small></button>";
67
68                 if(!nogroup) {
69                         var ingroup = 0;
70                         var ingroup_detail = 0;
71
72                         $.each(mycharts, function(i, d) {
73                                 if(d.group_tag == c.group_tag) {
74                                         ingroup++;
75                                         if(d.isdetail) ingroup_detail++;
76                                 }
77                         });
78
79                         var hidden = "";
80                         if(ingroup_detail) hidden = ", including " + ingroup_detail + " charts not shown now";
81
82                         html += "<button type=\"button\" data-toggle=\"tooltip\" title=\"Show all " + ingroup + " charts in group '" + c.group_tag + "'" + hidden + "\" class=\"btn btn-default\" onclick=\"initGroupGraphs('" + c.group_tag +"');\"><span class=\"glyphicon glyphicon-th-large\"></span></button>";
83                 }
84
85                 html += "<button type=\"button\" data-toggle=\"tooltip\" title=\"show chart '" + c.name + "' in fullscreen\" class=\"btn btn-default\" onclick=\"initMainChartIndex(" + i +");\"><span class=\"glyphicon glyphicon-resize-full\"></span></button>"
86                 +               "<button type=\"button\" data-toggle=\"tooltip\" title=\"set options for chart '" + c.name + "'\" class=\"btn btn-default disabled\" onclick=\"alert('Not implemented yet!');\"><span class=\"glyphicon glyphicon-cog\"></span></button>"
87                 +               "<button type=\"button\" data-toggle=\"tooltip\" title=\"ignore chart '" + c.name + "'\" class=\"btn btn-default\" onclick=\"disableChart(" + i + ");\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
88                 +       "</div>";
89
90                 return html;
91         }
92
93         function disableChart(i) {
94                 var chart = null;
95
96                 if(group_charts) 
97                         chart = group_charts[i];
98                 else
99                         chart = mycharts[i];
100
101                 if(chart) {
102                         chart.enabled = false;
103                         if(chart.chart) chart.chart.clearChart();
104                         chart.chart = null;
105                 }
106                 var div = document.getElementById(chart.div);
107                 if(div) div.innerHTML = "";
108
109                 div = document.getElementById(chart.div + "_parent");
110                 if(div) div.innerHTML = "";
111         }
112
113         function chartssort(a, b) {
114                 if(a.userpriority < b.userpriority) return -1;
115                 return 1;
116         }
117
118
119         // ------------------------------------------------------------------------
120         // MAINGRAPH = fullscreen view of 1 graph
121
122         // copy the chart c to mainchart
123         // switch to main graphs screen
124         function initMainChart(c) {
125                 if(mainchart && mainchart.chart) {
126                         mainchart.chart.clearChart();
127                         mainchart.chart = null;
128                 }
129
130                 mainchart = $.extend(true, {}, c);
131
132                 mainchart.chart = null;
133                 mainchart.chartOptions.width = screenWidth();
134                 mainchart.chartOptions.height = $(window).height() - 150;
135                 if(mainchart.chartOptions.height < 300) mainchart.chartOptions.height = 300;
136                 
137                 mainchart.group = 2;
138                 mainchart.div = 'maingraph';
139                 mainchart.last_updated = 0;
140
141                 if(mainchart.chartOptions.isStacked) mainchart.group = 5;
142                 //mainchart.chartOptions.titlePosition = 'none';
143                 mainchart.chartOptions.explorer = null;
144
145                 // initialize the div
146                 showChartIsLoading(mainchart.div, mainchart.chartOptions.width, mainchart.chartOptions.height);
147
148                 // set the radio buttons
149                 setMainChartGroupMethod(mainchart.group_method, 'no-refresh');
150                 setMainChartMax('normal');
151
152                 $('#group' + mainchart.group).trigger('click');
153
154                 switchToMainGraph();
155         }
156
157         function initMainChartIndex(i) {
158                 if(mode == MODE_GROUP_THUMBS) 
159                         initMainChart(group_charts[i]);
160                 else if(mode == MODE_THUMBS)
161                         initMainChart(mycharts[i]);
162         }
163
164         var last_main_chart_max='normal';
165         function setMainChartMax(m) {
166                 if(!mainchart || mode != MODE_MAIN) return;
167
168                 if(m == 'toggle') {
169                         if(last_main_chart_max == 'maximized') m = 'normal';
170                         else m = 'maximized';
171                 }
172
173                 if(m == "maximized") {
174                         mainchart.chartOptions.theme = 'maximized';
175                         //mainchart.chartOptions.axisTitlesPosition = 'in';
176                         //mainchart.chartOptions.legend = {position: 'none'};
177                         //mainchart.chartOptions.hAxis.title = null;
178                         mainchart.chartOptions.hAxis.viewWindowMode = 'maximized';
179                         mainchart.chartOptions.vAxis.viewWindowMode = 'maximized';
180                 }
181                 else {
182                         mainchart.chartOptions.theme = null;
183                         mainchart.chartOptions.hAxis.viewWindowMode = null;
184                         mainchart.chartOptions.vAxis.viewWindowMode = null;
185                 }
186                 $('.mainchart_max_button').button(m);
187                 last_main_chart_max = m;
188                 mainchart.last_updated = 0;
189         }
190
191         function setMainChartGroup(g) {
192                 if(!mainchart || mode != MODE_MAIN) return;
193
194                 mainchart.group = g;
195                 mainchart.last_updated = 0;
196                 playGraphs();
197         }
198
199         var last_main_chart_avg = null;
200         function setMainChartGroupMethod(g, norefresh) {
201                 if(!mainchart || mode != MODE_MAIN) return;
202
203                 if(g == 'toggle') {
204                         if(last_main_chart_avg == 'max') g = 'average';
205                         else g = 'max';
206                 }
207
208                 mainchart.group_method = g;
209
210                 $('.mainchart_avg_button').button(g);
211
212                 if(!norefresh) {
213                         mainchart.last_updated = 0;
214                         playGraphs();
215                 }
216
217                 last_main_chart_avg = g;
218         }
219
220         function setMainChartPlay(p) {
221                 if(!mainchart) return;
222
223                 if(p == 'toggle') {
224                         if(stop_refreshing) p = 'play';
225                         else p = 'pause';
226                 }
227
228                 if(p == 'play') {
229                         mainchart.chartOptions.explorer = null;
230                         playGraphs();
231                 }
232                 else {
233                         mainchart.chartOptions.explorer = {
234                                 'axis': 'horizontal',
235                                 'maxZoomOut': 1,
236                         };
237                         mainchart.last_updated = 0;
238                         
239                         if(!refreshChart(mainchart, pauseGraphs))
240                                 pauseGraphs();
241                 }
242                 last_main_chart_play = p;
243         }
244
245
246         // ------------------------------------------------------------------------
247         // Chart resizing
248
249         function screenWidth() {
250                 return (($(window).width() * 0.95) - 40);
251         }
252
253         // calculate the proper width for the thumb charts
254         function thumbWidth() {
255                 var cwidth = screenWidth();
256                 var items = Math.round(cwidth / TARGET_THUMB_GRAPH_WIDTH);
257                 if(items < 1) items = 1;
258
259                 if(items > 1 && (cwidth / items) < MINIMUM_THUMB_GRAPH_WIDTH) items--;
260
261                 return Math.round(cwidth / items) - 1;
262         }
263
264         function groupWidth() {
265                 var width = screenWidth() / 2;
266                 if(width < 500) width = screenWidth();
267                 return width;
268         }
269
270         // resize all charts
271         // if the thumb charts need resize in their width, reset them
272         function resizeCharts() {
273                 var width = screenWidth();
274
275                 if(mainchart) {
276                         mainchart.chartOptions.width = width;
277                         mainchart.chartOptions.height = $(window).height() - 200;
278                         mainchart.last_updated = 0;
279                 }
280
281                 width = thumbWidth();
282                 $.each(mycharts, function(i, c) {
283                         if(c.enabled && c.chartOptions.width != width) {
284                                 if(c.chart) c.chart.clearChart();
285                                 c.chart = null;
286                                 c.chartOptions.width = width;
287                                 showChartIsLoading(c.div, c.chartOptions.width, c.chartOptions.height);
288                                 c.last_updated = 0;
289                         }
290                 });
291
292                 width = groupWidth();
293                 if(group_charts) $.each(group_charts, function(i, c) {
294                         if(c.enabled && c.chartOptions.width != width) {
295                                 if(c.chart) c.chart.clearChart();
296                                 c.chart = null;
297                                 c.chartOptions.width = width;
298                                 showChartIsLoading(c.div, c.chartOptions.width, c.chartOptions.height);
299                                 c.last_updated = 0;
300                         }
301                 });
302
303                 playGraphs();
304         }
305
306         window.onresize = function(event) {
307                 resizeCharts();
308         };
309
310
311         // ------------------------------------------------------------------------
312         // Core of the thread refreshing the charts
313
314         var stop_refreshing = 1;
315         var last_refresh = 0;
316         function playGraphs() {
317                 if(!stop_refreshing) {
318                         // check if the thread died due to a javascript error
319                         var now = new Date().getTime();
320                         if((now - last_refresh) > 5000) {
321                                 // it died!
322                                 console.log('It seems the refresh thread died. Restarting it.');
323                                 chartsRefresh();
324                         }
325                         return;
326                 }
327
328                 stop_refreshing = 0;
329                 $('.mainchart_play_button').button('play');
330                 chartsRefresh();
331         }
332
333         function pauseGraphs() {
334                 if(stop_refreshing) return;
335
336                 stop_refreshing = 1;
337                 $('.mainchart_play_button').button('pause');
338         }
339
340         // refresh the proper chart
341         // this is an internal function.
342         // never call it directly, or new javascript threads will be spawn
343         var timeout;
344         function chartsRefresh() {
345                 if(stop_refreshing) return;
346
347                 last_refresh = new Date().getTime();
348
349                      if(mode == MODE_THUMBS)            thumbChartsRefresh();
350                 else if(mode == MODE_GROUP_THUMBS)  groupChartsRefresh();
351                 else if(mode == MODE_MAIN)              mainChartRefresh();
352                 else                                    timeout = setTimeout(triggerRefresh, 500);
353         }
354
355         // callback for refreshing the charts later
356         // this is an internal function.
357         // never call it directly, or new javascript threads will be spawn
358         function triggerRefresh() {
359                 // cleanup has to take place when the charts are not refreshed
360                 // since the refreshing thread is in this function, it means
361                 // nothing is being refreshed.
362                 cleanupCharts();
363
364                      if(mode == MODE_THUMBS)            timeout = setTimeout(chartsRefresh, 200);
365                 else if(mode == MODE_GROUP_THUMBS)      timeout = setTimeout(chartsRefresh, 200);
366                 else if(mode == MODE_MAIN)              timeout = setTimeout(chartsRefresh, 200);
367                 else                                    timeout = setTimeout(triggerRefresh, 500);
368         }
369
370         // refresh the main chart
371         // make sure we don't loose the refreshing thread
372         function mainChartRefresh() {
373                 if(mode != MODE_MAIN || !mainchart) {
374                         triggerRefresh();
375                         return;
376                 }
377
378                 mainchart.points_to_show = Math.round(mainchart.entries / mainchart.group) - 1;
379
380                 if(mainchart.points_to_show * mainchart.group > MAINCHART_MAX_TIME_TO_SHOW)
381                         mainchart.points_to_show = MAINCHART_MAX_TIME_TO_SHOW / mainchart.group;
382
383                 if(!refreshChart(mainchart, triggerRefresh))
384                         triggerRefresh();
385         }
386
387         // refresh the thumb charts
388         // make sure we don't loose the refreshing thread
389         var last_thumb_updated = 0;
390         function thumbChartsRefresh() {
391                 if(mycharts.length == 0 || mode != MODE_THUMBS) {
392                         triggerRefresh();
393                         return;
394                 }
395
396                 if(last_thumb_updated >= mycharts.length) last_thumb_updated = 0;
397
398                 // find a chart to refresh
399                 var orig = last_thumb_updated;
400                 var refreshed = false;
401
402                 last_thumb_updated++;
403                 if(last_thumb_updated >= mycharts.length) last_thumb_updated = 0;
404
405                 while(1) {
406                         refreshed = refreshChart(mycharts[last_thumb_updated], chartsRefresh);
407                         if(refreshed) break;
408
409                         last_thumb_updated++;
410                         if(last_thumb_updated >= mycharts.length) last_thumb_updated = 0;
411                         if(last_thumb_updated == orig) break;
412                 }
413
414                 // no chart refreshed
415                 if(!refreshed) triggerRefresh();
416         }
417
418         // refresh the group charts
419         // make sure we don't loose the refreshing thread
420         var last_group_updated = 0;
421         function groupChartsRefresh() {
422                 if(!group_charts || group_charts.length == 0 || mode != MODE_GROUP_THUMBS) {
423                         triggerRefresh();
424                         return;
425                 }
426
427                 if(last_group_updated >= group_charts.length) last_group_updated = 0;
428
429                 // find a chart to refresh
430                 var orig = last_group_updated;
431                 var refreshed = false;
432
433                 last_group_updated++;
434                 if(last_group_updated >= group_charts.length) last_group_updated = 0;
435
436                 while(1) {
437                         refreshed = refreshChart(group_charts[last_group_updated], chartsRefresh);
438                         if(refreshed) break;
439
440                         last_group_updated++;
441                         if(last_group_updated >= group_charts.length) last_group_updated = 0;
442                         if(last_group_updated == orig) break;
443                 }
444
445                 // no chart refreshed
446                 if(!refreshed) triggerRefresh();
447         }
448
449
450         // ------------------------------------------------------------------------
451         // switch the screen between views
452         // these should be called only from initXXXX()
453
454         // cleanup the previously shown charts
455         function cleanupCharts() {
456                 if(mode != MODE_MAIN && mainchart) {
457                         if(mainchart.chart) {
458                                 mainchart.chart.clearChart();
459                                 mainchart.chart = null;
460                         }
461                         mainchart = null;
462                 }
463
464                 if(mode != MODE_GROUP_THUMBS && group_charts) {
465                         clearGroupGraphs();
466                 }
467
468                 // we never cleanup the thumb charts
469         }
470
471         var thumbsScrollPosition = null;
472         function switchToMainGraph() {
473                 if(!mainchart) return;
474
475                 if(!group_charts) thumbsScrollPosition = window.pageYOffset;
476
477                 document.getElementById('maingraph_container').style.display = 'block';
478                 document.getElementById('thumbgraphs_container').style.display = 'none';
479                 document.getElementById('groupgraphs_container').style.display = 'none';
480
481                 document.getElementById("main_menu_div").innerHTML = "<ul class=\"nav navbar-nav\"><li><a href=\"javascript:switchToThumbGraphs();\">Back to Home</a></li><li class=\"active\"><a href=\"#\">" + mainchart.title + "</a></li></ul>";
482
483                 mode = MODE_MAIN;
484                 playGraphs();
485         }
486
487         function switchToThumbGraphs() {
488                 document.getElementById('maingraph_container').style.display = 'none';
489                 document.getElementById('thumbgraphs_container').style.display = 'block';
490                 document.getElementById('groupgraphs_container').style.display = 'none';
491
492                 document.getElementById("main_menu_div").innerHTML = mainmenu;
493
494                 if(thumbsScrollPosition) window.scrollTo(0, thumbsScrollPosition);
495
496                 // switch mode
497                 mode = MODE_THUMBS;
498                 playGraphs();
499
500                 $('[data-spy="scroll"]').each(function () {
501                         var $spy = $(this).scrollspy('refresh')
502                 })
503         }
504
505         function switchToGroupGraphs() {
506                 if(!group_charts) return;
507
508                 if(!mainchart) thumbsScrollPosition = window.pageYOffset;
509
510                 document.getElementById('maingraph_container').style.display = 'none';
511                 document.getElementById('thumbgraphs_container').style.display = 'none';
512                 document.getElementById('groupgraphs_container').style.display = 'block';
513
514                 document.getElementById("main_menu_div").innerHTML = "<ul class=\"nav navbar-nav\"><li><a href=\"javascript:switchToThumbGraphs();\">Back to Home</a></li><li class=\"active\"><a href=\"#\">" + group_charts[0].group_tag + " charts</a></li></ul>";
515
516                 window.scrollTo(0, 0);
517
518                 mode = MODE_GROUP_THUMBS;
519                 playGraphs();
520         }
521
522
523         // ------------------------------------------------------------------------
524         // Group Charts
525
526         var group_charts = null;
527         function initGroupGraphs(group) {
528                 var width = groupWidth();
529                 var height = (($(window).height() - 130) / 3) - 10;
530                 if(height < TARGET_THUMB_GRAPH_HEIGHT) height = TARGET_THUMB_GRAPH_HEIGHT;
531
532                 var count = 0;
533                 
534                 if(group_charts) clearGroupGraphs();
535                 group_charts = new Array();
536
537                 var groupbody = "";
538                 $.each(mycharts, function(i, c) {
539                         if(c.group_tag == group) {
540                                 group_charts[count] = [];
541                                 group_charts[count] = $.extend(true, {}, c);
542                                 group_charts[count].div += "_group";
543                                 group_charts[count].enabled = true;
544                                 group_charts[count].chart = null;
545                                 group_charts[count].last_updated = 0;
546
547                                 group_charts[count].chartOptions.width = width;
548                                 group_charts[count].chartOptions.height = height;
549                                 count++;
550                         }
551                 });
552                 group_charts.sort(chartssort);
553
554                 var groupbody = "";
555                 $.each(group_charts, function(i, c) {
556                         groupbody += "<div class=\"thumbgraph\" id=\"" + c.div + "_parent\"><table><tr><td><div class=\"thumbgraph\" id=\"" + c.div + "\">" + chartIsLoadingHTML(c.chartOptions.width, c.chartOptions.height) + "</div></td></tr><tr><td align=\"center\">" + thumbChartActions(i, c, 'nogroup') + "</td></tr></table></div>";
557                 });
558                 groupbody += "";
559
560                 document.getElementById("groupgraphs").innerHTML = groupbody;
561                 switchToGroupGraphs();
562         }
563
564         function clearGroupGraphs() {
565                 if(group_charts && group_charts.length) {
566                         $.each(group_charts, function(i, c) {
567                                 if(c.chart) c.chart.clearChart();
568                                 c.chart = null;
569                         });
570
571                         group_charts = null;
572                 }
573
574                 document.getElementById("groupgraphs").innerHTML = "";
575         }
576
577
578         // ------------------------------------------------------------------------
579         // Global entry point
580         // initialize the thumb charts
581
582         // load the charts from the server
583         // generate html for the thumbgraphs to support them
584         function initCharts() {
585                 var width = thumbWidth();
586                 var height = TARGET_THUMB_GRAPH_HEIGHT;
587
588                 loadCharts(null, function(c) {
589                         mycharts = c;
590
591                         if(mycharts == null || mycharts.length == 0) {
592                                 alert("Cannot load data from server.");
593                                 return;
594                         }
595
596                         var thumbsContainer = document.getElementById("thumbgraphs");
597                         if(!thumbsContainer) {
598                                 alert("Cannot find the thumbsContainer");
599                                 return;
600                         }
601
602                         mycharts.sort(chartssort);
603
604                         document.getElementById('hostname_id').innerHTML = mycharts[0].hostname;
605                         document.title = mycharts[0].hostname;
606
607                         // create an array for grouping all same-type graphs together
608                         var categories = new Array();
609                         $.each(mycharts, function(i, c) {
610                                 c.chartOptions.width = width;
611                                 c.chartOptions.height = height;
612
613                                 // calculate how many point to show for each chart
614                                 c.points_to_show = Math.round(c.entries / c.group) - 1;
615
616                                 // show max 10 mins of data
617                                 if(c.points_to_show * c.group > THUMBS_MAX_TIME_TO_SHOW) c.points_to_show = THUMBS_MAX_TIME_TO_SHOW / c.group;
618
619                                 if(c.enabled) {
620                                         var j;
621                                         var h = "<div class=\"thumbgraph\" id=\"" + c.div + "_parent\"><table><tr><td><div class=\"thumbgraph\" id=\"" + c.div + "\">" + chartIsLoadingHTML(c.chartOptions.width, c.chartOptions.height) + "</div></td></tr><tr><td align=\"center\">"
622                                         + thumbChartActions(i, c)
623                                         +       "</td></tr></table></div>";
624
625                                         // find the categories object for this type
626                                         for(j = 0; j < categories.length ;j++) {
627                                                 if(categories[j].name == c.type) {
628                                                         categories[j].html += h;
629                                                         categories[j].count++;
630                                                         break;
631                                                 }
632                                         }
633
634                                         if(j == categories.length) {
635                                                 categories.push({name: c.type, title: c.category, description: '', priority: 0, count: 1, glyphicon: c.glyphicon, html: h});
636                                         }
637                                 }
638                         });
639
640                         $.each(categories, function(i, a) {
641                                      if(a.name == "system") a.priority = 1;
642                                 else if(a.name == "net") a.priority = 2;
643                                 else if(a.name == "tc") a.priority = 3;
644                                 else if(a.name == "conntrack") a.priority = 4;
645                                 else if(a.name == "ipvs") a.priority = 5;
646                                 else if(a.name == "ipv4") a.priority = 6;
647                                 else if(a.name == "cpu") a.priority = 7;
648                                 else if(a.name == "mem") a.priority = 8;
649                                 else if(a.name == "disk") a.priority = 9;
650                                 else a.priority = 99;
651
652                                 a.html = "<tr><td id=\"" + a.name + "\"><ol class=\"breadcrumb graphs\"><li class=\"active\"><span class=\"glyphicon " + a.glyphicon + "\"></span> &nbsp; <a id=\"" + a.name + "\" href=\"#" + a.name + "\"><b>" + a.title + "</b> " + a.description + " </a></li></ol></td></tr><tr><td><div class=\"thumbgraphs\">" + a.html + "</td></tr>";
653                         });
654
655                         function categoriessort(a, b) {
656                                 if(a.priority < b.priority) return -1;
657                                 return 1;
658                         }
659                         categories.sort(categoriessort);
660                         
661                         // combine all the htmls into one
662                         var allcategories = "<table width=\"100%\">";
663                         mainmenu = "<ul class=\"nav navbar-nav\"><li><a href=\"#\">Home</a></li>";
664                         $.each(categories, function(i, a) {
665                                 allcategories += a.html;
666                                 mainmenu += "<li><a href=\"#" + a.name + "\">" + a.title + "</a></li>";
667                         });
668                         allcategories += "</table>";
669                         mainmenu += "</ul>";
670
671                         thumbsContainer.innerHTML = allcategories;
672                         $('[data-toggle="tooltip"]').tooltip({'placement': 'top', 'container': 'body', 'html': true});
673                         switchToThumbGraphs();
674                 });
675         }
676
677         </script>
678 </head>
679
680 <body role="document" data-spy="scroll" data-target="#main_menu_div">
681     <nav id="mynav" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
682       <div class="container">
683         <div class="navbar-header">
684           <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main_menu_div">
685             <span class="sr-only">Toggle navigation</span>
686             <span class="icon-bar"></span>
687             <span class="icon-bar"></span>
688             <span class="icon-bar"></span>
689           </button>
690           <a class="navbar-brand" href="javascript:switchToThumbGraphs();" id="hostname_id">NetData</a>
691         </div>
692         <div class="collapse navbar-collapse" id="main_menu_div">
693           <ul class="nav navbar-nav">
694             <li><a href="#">Home</a></li>
695           </ul>
696         </div><!--/.nav-collapse -->
697       </div>
698     </nav>
699
700     <div class="container graphs" id="maingraph_container" style="display: none">
701                 <table>
702                         <tr><td>
703                         <div class="maingraph">
704                                         <table>
705                                                 <tr><td>
706                                                 <div class="maingraph" id="maingraph"></div>
707                                                 </td></tr>
708                                                 <tr><td align="center">
709                                                         <div class="btn-group">
710                                                                 <form id="mainchartform">
711                                                                         <div class="btn-group btn-group" data-toggle="tooltip" title=" click <span class='glyphicon glyphicon-play'></span> to have the graph auto-refresh, or click <span class='glyphicon glyphicon-pause'></span> to pause the graph. When paused the graph can be zoomed and panned horizontally." >
712                                                                                 <button type="button" class="btn btn-primary mainchart_play_button" data-play-text="<span class='glyphicon glyphicon-pause'></span>" data-pause-text="<span class='glyphicon glyphicon-play'></span>" onClick="setMainChartPlay('toggle');">
713                                                                                         <span class="glyphicon glyphicon-pause"></span>
714                                                                                 </button>
715                                                                         </div>
716                                                                         <div class="btn-group btn-group" data-toggle="tooltip" title="use the maximum ( <span class='glyphicon glyphicon-signal'></span> ) or the average ( <span class='glyphicon glyphicon-align-justify'></span> ) value of grouped points" >
717                                                                                 <button type="button" class="btn btn-primary mainchart_avg_button" data-max-text="<span class='glyphicon glyphicon-signal'></span>" data-average-text="<span class='glyphicon glyphicon-align-justify'></span>" onClick="setMainChartGroupMethod('toggle');">
718                                                                                         <span class="glyphicon glyphicon-signal"></span>
719                                                                                 </button>
720                                                                         </div>
721 <!--                                                                    <div class="btn-group btn-group" data-toggle="buttons">
722                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="show the MAX point among all points grouped">
723                                                                                         <input type="radio" name="groupmethod" id="groupmax" onChange="setMainChartGroupMethod('max');">
724                                                                                         <span class="glyphicon glyphicon-signal"></span>
725                                                                                 </label>
726                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="show the AVERAGE of all points grouped">
727                                                                                         <input type="radio" name="groupmethod" id="groupaverage" onChange="setMainChartGroupMethod('average');">
728                                                                                         <span class="glyphicon glyphicon-align-justify"></span>
729                                                                                 </label>
730                                                                         </div>
731 -->                                                                     <div class="btn-group btn-group" data-toggle="buttons" >
732                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="do not group points, show the raw data">
733                                                                                         <input type="radio" name="group" id="group1" onChange="setMainChartGroup(1);">1
734                                                                                 </label>
735                                                                                 
736                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group in half, show 1 every 2 points of data">
737                                                                                         <input type="radio" name="group" id="group2" onChange="setMainChartGroup(2);">2
738                                                                                 </label>
739
740                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 5 points of data">
741                                                                                         <input type="radio" name="group" id="group5" onChange="setMainChartGroup(5);">5
742                                                                                 </label>
743                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 10 points of data">
744                                                                                         <input type="radio" name="group" id="group10" onChange="setMainChartGroup(10);">10
745                                                                                 </label>
746                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 15 points of data">
747                                                                                         <input type="radio" name="group" id="group15" onChange="setMainChartGroup(15);">15
748                                                                                 </label>
749                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 20 points of data">
750                                                                                         <input type="radio" name="group" id="group20" onChange="setMainChartGroup(20);">20
751                                                                                 </label>
752                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 30 points of data">
753                                                                                         <input type="radio" name="group" id="group30" onChange="setMainChartGroup(30);">30
754                                                                                 </label>
755                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 45 points of data">
756                                                                                         <input type="radio" name="group" id="group45" onChange="setMainChartGroup(45);">45
757                                                                                 </label>
758                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="group every 60 points of data">
759                                                                                         <input type="radio" name="group" id="group60" onChange="setMainChartGroup(60);">60
760                                                                                 </label>
761                                                                         </div>
762                                                                         <div class="btn-group btn-group" data-toggle="tooltip" title="maximized ( <span class='glyphicon glyphicon-fullscreen'></span> ) or normal ( <span class='glyphicon glyphicon-resize-small'></span> ) view of the graph" >
763                                                                                 <button type="button" class="btn btn-primary mainchart_max_button" data-maximized-text="<span class='glyphicon glyphicon-resize-small'></span>" data-normal-text="<span class='glyphicon glyphicon-fullscreen'></span>" onClick="setMainChartMax('toggle');">
764                                                                                         <span class="glyphicon glyphicon-fullscreen"></span>
765                                                                                 </button>
766                                                                         </div>
767 <!--                                                                    <div class="btn-group btn-group" data-toggle="buttons" >
768                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="NORMAL chart size">
769                                                                                         <input type="radio" name="chartmax" id="chartnormal" onChange="setMainChartMax('normal');">
770                                                                                         <span class="glyphicon glyphicon-resize-small"></span>
771                                                                                 </label>
772                                                                                 <label class="btn btn-primary" data-toggle="tooltip" title="MAXIMIZED chart size">
773                                                                                         <input type="radio" name="chartmax" id="chartmax" onChange="setMainChartMax('maximized');">
774                                                                                         <span class="glyphicon glyphicon-fullscreen"></span>
775                                                                                 </label>
776                                                                         </div>
777 -->                                                             </form>
778                                                         </div>
779                                                         </td></tr>
780                                         </table>
781                            </div><!-- /.maingraph -->
782                         </td></tr>
783                 </table>
784         </div>
785
786     <div class="container graphs" id="thumbgraphs_container">
787         <div class="allgraphs" id="thumbgraphs">
788                 <table width="100%">
789                         <tr><td id="splash" align="center" style="vertical-align:middle">
790                                 <h1>
791                                 Welcome to <b>NetData</b>!
792                                 <br/><br/>
793                                 <span class="glyphicon glyphicon-off"></span>
794                                 <br/><br/>
795                                 loading charts
796                                 <br/><br/>
797                                 <span class="label label-default">Please wait...</span>
798                                 </h1>
799                         </td></tr>
800                 </table>
801         </div>
802         </div>
803
804     <div class="container graphs" id="groupgraphs_container">
805         <div class="allgraphs" id="groupgraphs">
806         </div>
807         </div>
808
809         <script type='text/javascript'>
810                 $(document).ready(function(){
811                         document.getElementById('splash').height = $(window).height();
812
813                         $(document).on('click','.navbar-collapse.in',function(e) {
814                                 if( $(e.target).is('a') ) {
815                                         $(this).collapse('hide');
816                                 }
817                         });
818                         
819                         $('body').scrollspy({ target: '#main_menu_div' })
820                 });
821
822         </script>
823 </html>