[% USE date %]
[% PROCESS _header.tt %]
[% PROCESS _message.tt %]
[% PROCESS _sounds.tt %]
[% authorized_for_read_only = 0 %][% IF c.check_user_roles('authorized_for_read_only') %][% authorized_for_read_only = 1 %][% END %]

[% PROCESS _status_cmd_pane.tt %]
[% UNLESS minimal %]

  [% IF explore %]
    [% PROCESS _status_explore.tt %]
  [% END %]
  [% IF !explore %]
    [% WRAPPER _status_totals_header.tt %]
      <div class="card overflow-hidden">
        <div class="actionbox less-padding">
          [% IF hostgroup %]
            <div><a href="status.cgi?hostgroup=all&amp;style=detail">View Service Status Detail For All Host Groups</a></div>
            <div><a href="status.cgi?hostgroup=[% hostgroup | uri %]&amp;style=hostdetail">View Host Status Detail For This Host Group</a></div>
            <div><a href="status.cgi?hostgroup=[% hostgroup | uri %]&amp;style=overview">View Status Overview For This Host Group</a></div>
            <div><a href="status.cgi?hostgroup=[% hostgroup | uri %]&amp;style=summary">View Status Summary For This Host Group</a></div>
            <div><a href="status.cgi?hostgroup=[% hostgroup | uri %]&amp;style=grid">View Status Grid For This Host Group</a></div>
          [% ELSIF servicegroup %]
            <div><a href="status.cgi?servicegroup=[% servicegroup | uri %]&amp;style=overview">View Status Overview For This Service Group</a></div>
            <div><a href="status.cgi?servicegroup=[% servicegroup | uri %]&amp;style=summary">View Status Summary For This Service Group</a></div>
            <div><a href="status.cgi?servicegroup=[% servicegroup | uri %]&amp;style=grid">View Service Status Grid For This Service Group</a></div>
            <div><a href="status.cgi?servicegroup=all&amp;style=detail">View Service Status Detail For All Service Groups</a></div>
          [% ELSIF host == 'all' %]
            <div><a href="history.cgi?host=all&amp;nosystem=1">View History For all hosts</a></div>
            <div><a href="notifications.cgi?host=all">View Notifications For All Hosts</a></div>
            <div><a href="status.cgi?hostgroup=all&amp;style=hostdetail">View Host Status Detail For All Hosts</a></div>
          [% ELSIF host != '' %]
            <div><a href="history.cgi?host=[% host | uri %]&amp;nosystem=1[% add_request_backend %]">View History For This Host</a></div>
            <div><a href="notifications.cgi?host=[% host | uri %][% add_request_backend %]">View Notifications For This Host</a></div>
            <div><a href="status.cgi?host=all">View Service Status Detail For All Hosts</a></div>
          [% ELSE %]
            <div><a href="status.cgi?hostgroup=all&amp;style=detail">View Service Status Detail For All Host Groups</a></div>
            <div><a href="status.cgi?hostgroup=all&amp;style=overview">View Status Overview For All Host Groups</a></div>
            <div><a href="status.cgi?hostgroup=all&amp;style=summary">View Status Summary For All Host Groups</a></div>
            <div><a href="status.cgi?hostgroup=all&amp;style=grid">View Status Grid For All Host Groups</a></div>
          [% END %]
        </div>
      </div>
    [% END %]
  [% END %]

  [% IF !explore %]
  <div class="flex flex-row mt-2">
    <div class="basis-1/3">

    </div>
    <div class="basis-1/3">
      <h1>
        [% IF custom_title != '' %][% custom_title %]
        [% ELSIF hostgroup != '' %]Service Status Details For Host Group '[% hostgroup | html %]'
        [% ELSIF servicegroup %] Service Status Details For Service Group '[% servicegroup | html %]'
        [% ELSIF host == 'all' %]Service Status Details For All Hosts
        [% ELSIF host != '' %]Service Status Details For Host '[% host | html %]'
        [% ELSE %]Service Status Details
        [% END %]
      </h1>
    </div>
    <div class="basis-1/3 flex justify-end">
      [% PROCESS _customvar_box.tt %]
    </div>
  </div>
  [% END %]

  <div class="flexrow sm:flex-nowrap my-2 gap-y-1">
    <div class="flex basis-1/3 self-end gap-1">
      [% PROCESS _add_bookmark.tt %]
      [% PROCESS _show_link.tt %]
      [% PROCESS _json_export.tt %]
      [% columns_excel=[ 'Site:0', 'Hostname', 'Hostdisplayname:0', 'IP', 'Host Alias:0', 'Host Parents:0', 'Host Groups:0', 'Host Acknowledged', 'Host Downtime', 'Host Notifications', 'Host Active Checks', 'Host Flapping', 'Service', 'Displayname:0', 'Status', 'Last Check', 'Contacts', 'Duration', 'Attempt', 'Acknowledged', 'Downtime', 'Notifications', 'Active Checks', 'Flapping', 'Status Information', 'Extra Status Information', 'Comments:0' ] %]
      [% PROCESS _excel_export.tt columns=columns_excel with_custom_vars=1 prefix="status_detail_excel_" %]
      [%# Duration requires conditionals which the api cannnot do %]
      [%# Extra Status Information requires conditionals which the api cannnot do %]
      [%# Comment requires looping through a %]
      [% columns_csv=[ 'host_name::1', 'host_display_name::0', 'host_address::0', 'host_alias::0', 'host_parents::0', 'host_groups::0','host_acknowledged::0', 'host_scheduled_downtime_depth::0', 'host_notifications_enabled::0','host_active_checks_enabled::0', 'host_is_flapping::0', 'description::1', 'display_name::0','servicestate(state):servicestate:1', 'utc(last_check):utc(last_check):0', 'current_attempt::0', 'max_check_attempts::0', 'acknowledged::0', 'scheduled_downtime_depth::0', 'notifications_enabled::0', 'active_checks_enabled::0', 'is_flapping::0', 'contacts::0'] %]
      [% PROCESS _csv_export.tt columns=columns_csv with_custom_vars=1 api_endpoint='csv/services' prefix="status_detail_csv_" filter_text=csv_filter_text %]
      [% IF hostgroup != '' && hostgroup != 'all' %]
        <a class="button round small" href="extinfo.cgi?type=5&amp;hostgroup=[% hostgroup | uri %]" title="send hostgroup commands"><i class="uil uil-icons"></i></a>
      [% ELSIF servicegroup != '' && servicegroup != 'all' %]
        <a class="button round small" href="extinfo.cgi?type=8&amp;servicegroup=[% servicegroup | uri %]" title="send servicegroup commands"><i class="uil uil-icons"></i></a>
      [% END %]
    </div>
    <div class="basis-1/3">
      [% UNLESS authorized_for_read_only %]
      <div class="hint flex gap-x-0.5 justify-center">
        <button class="sm:min-w-[100px]" title="Select all Hosts" onclick="selectAllHosts(true,'[% paneprefix %]');return false;">Hosts</button>
        <button class="sm:min-w-[100px]" title="Select all Services" onclick="selectAllServices(true,'[% paneprefix %]');return false;">Services</button>
        <button class="sm:min-w-[100px]" title="Select all Services with Problems" onclick="selectAllHosts(false,'[% paneprefix %]');selectAllServices(false,'[% paneprefix %]');selectServicesByClass(Array('.CRITICAL','.WARNING','.UNKNOWN'));return false;">Problems</button>
        <button class="sm:min-w-[100px]" title="Select all Services in Downtime" onclick="selectAllHosts(false,'[% paneprefix %]');selectAllServices(false,'[% paneprefix %]');selectServicesByClass(Array('.has_downtime'));return false;">In Downtime</button>
        <button class="sm:min-w-[100px]" title="Unselect all Hosts/Services" onclick="selectAllHosts(false,'[% paneprefix %]');selectAllServices(false,'[% paneprefix %]');return false;">Unselect all</button>
      </div>
      [% END %]
    </div>
    <div class="basis-1/3 hidden sm:flex self-end justify-end relative">
      <button class="round small gray text-lg relative" onclick="toggleElement('show_table_info_svc', undefined, true); return false;" title="Toggle help">
        <i class="uil uil-info"></i>
      </button>
      <div class="card shadow-float absolute z-20 top-7" style="visibility: hidden;" id="show_table_info_svc">
        <div class="head justify-between">
          <h3>Info</h3>
          <button class="iconOnly medium" onclick="toggleElement('show_table_info_svc'); return false;"><i class="uil uil-times"></i></button>
        </div>
        <div class="body">
          <div class="whitespace-nowrap">You can select hosts / services with leftclick to send multiple commands.</div>
          <div class="whitespace-nowrap">Select multiple by holding shift + leftclick</div>
        </div>
      </div>
    </div>
  </div>
[% END %]

<div id="statusTableContainer" class="relative">
  <div class="card w-full min-w-[420px]" id="statusTableContent">
    <div class="mainTableHeader">
      <div>
        <div class="flex flex-nowrap gap-x-2 items-center">
          [% PROCESS _status_column_select.tt colprefix="svc" columns_name="service" %]
          [% IF ! explore %]
            [% PROCESS _status_filter.tt %]
          [% END %]
        </div>
      </div>
      <div>
        [% PROCESS _pager.tt %]
      </div>
      <div>
        [% PROCESS _pager_per_page.tt %]
      </div>
    </div>
    <div class="mainTable [% IF main_table_full %]fullsize[% END %]">
      [% PROCESS _status_detail_table.tt %]
    </div>
    <div class="mainTableFooter">
      [% PROCESS _pager_total_items.tt %]
    </div>
  </div>
</div>

[% UNLESS authorized_for_read_only %]
<script>
  var dfl_Hash = [% get_cmd_submit_hash(data, 'svc') %];
  start_hide_activity_icons_timer();
</script>
[% END %]

[% PROCESS _footer.tt %]
