[% PROCESS _blocks.tt %]

<div class="overflow-auto">
[% orig_perfdata = perfdata %]
[% tmp = split_perfdata(perfdata) %]
[% IF tmp.size > 0 && tmp.0.size > 0 %]
  [% splited = tmp.0; has_parents = tmp.1; has_warn = tmp.2; has_crit = tmp.3; has_min = tmp.4; has_max = tmp.5; %]
  [% show_perf_column = 0 %]
  [% FOREACH p = splited %]
    [% IF p.warn || p.crit || p.min || p.max %][% show_perf_column = 1; LAST; %][% END %]
  [% END %]
  [% last_parent = '' %]
  <div class="w-min">
  <table id="perfdata_human" class="cellborder cellspacing rowhover">
    <tr>
      [% IF has_parents %]<th></th>[% END %]
      <th>Name</th>
      <th>Value</th>
      [% IF has_warn %]<th>Warning</th>[% END %]
      [% IF has_crit %]<th>Critical</th>[% END %]
      [% IF has_min  %]<th>Minimum</th>[% END %]
      [% IF has_max  %]<th>Maximum</th>[% END %]
      <th class="js-perf-bar-header[% IF !show_perf_column %] hidden[% END %]"></th>
    </tr>
    [% FOREACH p = splited %]
    <tr[% IF splited.size >= 10 && loop.index >= 5 %] class="js-perfdata-table-row hidden "[% END %]>
      [% IF !has_parents || last_parent != p.parent %]
      [% END %]
      [% IF has_parents %]
      <td class="text-right">[% IF last_parent != p.parent %][% p.parent %][% last_parent = p.parent %][% ELSE %][% END %]</td>
      [% END %]
      <td class="text-left">[% p.name | html %]</td>
      <td class="text-right">[% format_perf_number(p.value, p.unit, 1) %]</td>
      [% IF has_warn %]<td>[% format_perf_number(p.warn, p.unit) %]</td>[% END %]
      [% IF has_crit %]<td>[% format_perf_number(p.crit, p.unit) %]</td>[% END %]
      [% IF has_min  %]<td>[% format_perf_number(p.min, p.unit) %]</td>[% END %]
      [% IF has_max  %]<td>[% format_perf_number(p.max, p.unit) %]</td>[% END %]
      <td class="py-0 js-perf-bar-container[% IF !show_perf_column %] hidden[% END %]">
        [% show_placeholder = 0 %]
        [% IF p.warn || p.crit || p.min || p.max %][% show_placeholder = 1 %][% END %]
        [% PROCESS _perfdata_table add_link="1" perfdata=p.orig state=4 show_placeholder=show_placeholder %]
      </td>
    </tr>
    [% END %]
    [% IF splited.size >= 10 %]
      <tr>
        <td colspan="[% IF has_parents %]7[% ELSE %]6[% END %]" class="text-center">
          <div id="perf_show_more" class="link hoverable rounded clickable font-normal" onclick="jQuery('.js-perfdata-table-row').removeClass('hidden'); jQuery('#perf_show_more').addClass('hidden'); jQuery('#perf_show_less').removeClass('hidden');"> show more...</div>
          <div id="perf_show_less" class="link hoverable rounded clickable font-normal hidden" onclick="jQuery('.js-perfdata-table-row').addClass('hidden'); jQuery('#perf_show_more').removeClass('hidden'); jQuery('#perf_show_less').addClass('hidden'); scrollToEl('perfdata_human');"> show less...</div>
        </td>
      </tr>
    [% END %]
  </table>
  </div>
  <div id="perfdata_raw" style="display:none;">
    [% perfdata = orig_perfdata %]
    [% orig_perfdata | html %]
  </div>
[% ELSE %]
  <script>
  <!--
    hideElement('raw_perf_switch');
  -->
  </script>
  [% orig_perfdata | html %]
[% END %]
</div>
