"Fossies" - the Fresh Open Source Software Archive

Member "ganglia-web-3.7.2/templates/default/host_view.tpl" (12 Oct 2015, 9351 Bytes) of package /linux/www/ganglia-web-3.7.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!-- Begin host_view.tpl -->
    2 <script type="text/javascript">
    3 var SEPARATOR = "_|_";
    4 var ALL_GROUPS = "ALLGROUPS";
    5 var NO_GROUPS = "NOGROUPS";
    6 // Map metric group id to name
    7 var g_mgMap = new Object();
    8 
    9 function clearStoredMetricGroups() {
   10   var stored_groups = $('input[name="metric_group"]');
   11   stored_groups.val(NO_GROUPS);
   12 }
   13 
   14 function selectAllMetricGroups() {
   15   var stored_groups = $('input[name="metric_group"]');
   16   stored_groups.val(ALL_GROUPS);
   17 }
   18 
   19 function addMetricGroup(mgName) {
   20   var stored_groups = $('input[name="metric_group"]');
   21 
   22   var open_groups = stored_groups.val();
   23   if (open_groups == ALL_GROUPS)
   24     return; // no exceptions
   25 
   26   var groups = open_groups.split(SEPARATOR);
   27   switch (groups[0]) {
   28     case ALL_GROUPS:
   29       // Remove from except list
   30       for (var i = 1; i < groups.length; i++) {
   31         if (groups[i] == mgName) {
   32           groups.splice(i, 1);
   33           break;
   34         }
   35       }
   36       open_groups = groups.join(SEPARATOR);
   37     break;
   38     case NO_GROUPS:
   39       // Add to list if not already there
   40       var inList = false;
   41       for (var i = 1; i < groups.length; i++) {
   42          if (groups[i] == mgName) {
   43            inList = true;
   44            break;
   45          }
   46       }
   47       if (!inList) {
   48         open_groups += SEPARATOR;
   49         open_groups += mgName;
   50       }
   51     break;
   52     default:
   53       alert("Unrecognized group option - " + groups[0]);
   54   }
   55   stored_groups.val(open_groups);
   56 }
   57 
   58 function removeMetricGroup(mgName) {
   59   var stored_groups = $('input[name="metric_group"]');
   60 
   61   var open_groups = stored_groups.val();
   62   if (open_groups == NO_GROUPS)
   63     return; // no exceptions
   64 
   65   var groups = open_groups.split(SEPARATOR);
   66   switch (groups[0]) {
   67     case ALL_GROUPS:
   68       var inList = false;
   69       for (var i = 1; i < groups.length; i++) {
   70         if (groups[i] == mgName) {
   71           inList = true;
   72           break;
   73         }
   74       }
   75       if (!inList) {
   76         open_groups += SEPARATOR;
   77         open_groups += mgName;
   78       }
   79     break;
   80     case NO_GROUPS:
   81       for (var i = 1; i < groups.length; i++) {
   82         if (groups[i] == mgName) {
   83           groups.splice(i, 1);
   84           break;
   85         }
   86       }
   87       open_groups = groups.join(SEPARATOR);
   88     break;
   89     default:
   90       alert("Unrecognized group option - " + groups[0]);
   91   }
   92   stored_groups.val(open_groups);
   93 }
   94 
   95 function toggleMetricGroup(mgId, mgDiv) {
   96   var mgName = g_mgMap[mgId];
   97   if (mgDiv.is(":visible")) {
   98     // metric group is being closed
   99     removeMetricGroup(mgName);
  100     mgDiv.html("");
  101     mgDiv.hide();
  102   } else {
  103     addMetricGroup(mgName);
  104     var url = 'metric_group_view.php?{$baseGraphArgs}&metric_group=' + mgName;
  105     url += "&event=";
  106     url += ($("#show_all_events").attr("checked") == "checked") ? "show" : "hide";
  107     url += "&ts=";
  108     url += ($("#timeshift_overlay").attr("checked") == "checked") ? "1" : "0";
  109 
  110     $.get(url, 
  111           function(data) {
  112             mgDiv.html(data);
  113 	    mgInitEventBtns(mgDiv);
  114 	    mgInitTimeshiftBtns(mgDiv);
  115             mgDiv.show();
  116           });
  117   }
  118 }
  119 
  120 function jumpToMetricGroup(mgId) {
  121   //alert("jumping to " + mgId);
  122   $.scrollTo($('#' + mgId));
  123 }
  124 
  125 function refreshHostView() {
  126   $.get('host_overview.php?h={$hostname}&c={$cluster}', function(data) {
  127     $('#host_overview_div').html(data);
  128   });
  129 
  130   $("#optional_graphs img").each(function (index) {
  131     var src = $(this).attr("src");
  132     if ((src.indexOf("graph.php") == 0) ||
  133         (src.indexOf("./graph.php") == 0)) {
  134       var d = new Date();
  135       $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
  136     }    
  137   });
  138 
  139   $("#metrics img").each(function (index) {
  140     var src = $(this).attr("src");
  141     if ((src.indexOf("graph.php") == 0)  ||
  142         (src.indexOf("./graph.php") == 0)) {
  143       var d = new Date();
  144       $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
  145     }    
  146   });
  147 }
  148 
  149 function mgInitEventBtns(mgDiv) {
  150   var checked = $("#show_all_events").attr("checked");
  151   mgDiv.find("[id^=" + SHOW_EVENTS_BASE_ID + "]").each(function() {
  152     $(this).button();
  153     if (checked == "checked")
  154       $(this).attr("checked", 'checked');
  155     else
  156       $(this).removeAttr("checked");
  157     $(this).button('refresh');
  158   });
  159 }
  160 
  161 function mgInitTimeshiftBtns(mgDiv) {
  162   var checked = $("#timeshift_overlay").attr("checked");
  163   mgDiv.find("[id^=" + TIME_SHIFT_BASE_ID + "]").each(function() {
  164     $(this).button();
  165     if (checked == "checked")
  166       $(this).attr("checked", 'checked');
  167     else
  168       $(this).removeAttr("checked");
  169     $(this).button('refresh');
  170   });
  171 }
  172 
  173 $(function() {
  174   var stored_groups = $('input[name="metric_group"]');
  175   stored_groups.val("{$g_open_metric_groups}");
  176  
  177   $("#edit_optional_graphs").dialog({ autoOpen: false, minWidth: 550,
  178     beforeClose: function(event, ui) { location.reload(true); } });
  179 
  180   $("#close_edit_optional_graphs_link").button();
  181 
  182   $("#edit_optional_graphs_button").button();
  183   $("#edit_optional_graphs_button").click(function(event) {
  184     $("#edit_optional_graphs").dialog('open');
  185     $('#edit_optional_graphs_content').html('<img src="img/spinner.gif" />');
  186     $.get('edit_optional_graphs.php', "hostname={$hostname}", function(data) {
  187       $('#edit_optional_graphs_content').html(data);
  188     })
  189     return false;
  190   });
  191 
  192   $("#save_optional_graphs_button").button();
  193   $("#save_optional_graphs_button").click(function(event) {
  194     $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
  195       $('#edit_optional_graphs_content').html(data);
  196       $("#save_optional_graphs_button").hide();
  197     });
  198     return false;
  199   });
  200 
  201   $("#expand_all_metric_groups").button();
  202   $("#expand_all_metric_groups").click(function(event) {
  203     selectAllMetricGroups();
  204     document.ganglia_form.submit();
  205     return false;
  206   });
  207 
  208   $("#collapse_all_metric_groups").button();
  209   $("#collapse_all_metric_groups").click(function(event) {
  210     clearStoredMetricGroups();
  211     document.ganglia_form.submit();
  212     return false;
  213   });
  214 
  215   $("#host_overview").button();
  216   $('#host_overview').click(function() {
  217     var options = { to: { width: 200, height: 60 } }; 
  218     $("#host_overview_div").toggle("blind", options, 500);
  219     return false;
  220   });
  221 
  222   $('.metric-group').each(function() {
  223     $(this).button();
  224     $(this).click(function() {
  225       var id = $(this).attr('id');
  226       toggleMetricGroup(id, $("#"+id+"_div"));
  227       return false;
  228     });
  229   });
  230 });
  231 </script>
  232 
  233 <style type="text/css">
  234   .toggler { width: 500px; height: 200px; }
  235   #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
  236   #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
  237 </style>
  238 
  239 <div>
  240 <button id="host_overview" class="button">Host Overview</button>
  241 </div>
  242 
  243 <div style="display: none;" id="host_overview_div">
  244 {include('host_overview.tpl')}
  245 </div>
  246 
  247 <div id="edit_optional_graphs">
  248   <div style="text-align:center">
  249     <button id="save_optional_graphs_button">Save</button>
  250   </div>
  251   <div id="edit_optional_graphs_content" style="padding: .4em 1em .4em 10px;">Empty</div>
  252 </div>
  253 
  254 <div id="optional_graphs" style="padding-top:5px;">
  255 {$optional_reports}
  256 <div style='clear: left'></div>
  257 {if $may_edit_cluster}
  258 <div style="text-align:center"><button id="edit_optional_graphs_button">Edit Optional Graphs</button></div>
  259 {/if}
  260 </div>
  261 
  262 <div id="sort_column_dropdowns" style="padding-top:5px;">
  263 <table border="0" width="100%">
  264 <tr>
  265   <td style="text-align:center;background-color:rgb(238,238,238);">
  266   {$host} <strong>graphs</strong> ({$host_metrics_count})
  267   last <strong>{$range}</strong>
  268   sorted <strong>{$sort}</strong>
  269 {if isset($columns_dropdown)}
  270   <font>
  271     Columns&nbsp;&nbsp;{$metric_cols_menu}
  272     Size&nbsp;&nbsp;{$size_menu}
  273   </font>
  274 {/if}
  275   </td>
  276 </tr>
  277 </table>
  278 
  279 </div>
  280 
  281 <div id=metrics style="padding-top:5px">
  282 <center>
  283 <div style="padding-bottom:5px;">
  284 <button id="expand_all_metric_groups">Expand All Metric Groups</button>
  285 <button id="collapse_all_metric_groups">Collapse All Metric Groups</button>
  286 <input title="Time Shift Overlay - overlays previous period on all graphs" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label for="timeshift_overlay">Timeshift Overlay</label>
  287 <select id="jump_to_metric_group" class="ui-corner-all" onchange="jumpToMetricGroup(this.options[this.selectedIndex].value);">
  288 <option disabled="disabled" selected="selected">Jump To Metric Group...</option>
  289 {foreach $g_metrics_group_data group g_metrics}
  290 {$mgId = "mg_"; $mgId .= regex_replace($group, '/[^a-zA-Z0-9_]/', '_')}
  291 <option value="{$mgId}">{$group}</a>
  292 {/foreach}
  293 </select>
  294 </div>
  295 <table>
  296 <tr>
  297  <td>
  298 
  299 {foreach $g_metrics_group_data group g_metrics}
  300 {$mgId = "mg_"; $mgId .= regex_replace($group, '/[^a-zA-Z0-9_]/', '_')}
  301 <table border="0" width="100%">
  302 <tr>
  303   <td class="metric">
  304   <button id="{$mgId}" class="metric-group" title="Toggle {$group} metrics group on/off">{$group} metrics ({$g_metrics.group_metric_count})</button>
  305 <script type="text/javascript">$(function() {
  306 g_mgMap["{$mgId}"] = "{$group}";
  307 })</script>
  308   </td>
  309 </tr>
  310 </table>
  311 
  312 {if $g_metrics.visible}
  313 <div id="{$mgId}_div">
  314 {else}
  315 <div id="{$mgId}_div" class="ui-helper-hidden">
  316 {/if}
  317 {if $g_metrics.visible}
  318 {include('metric_group_view.tpl')}
  319 {/if}
  320 </div>
  321 {/foreach}
  322  </td>
  323 </tr>
  324 </table>
  325 </center>
  326 </div>
  327 <input type="hidden" name="metric_group" value="">
  328 <!-- End host_view.tpl -->