[% IF ! modal %]
  [% PROCESS _header.tt %]
  [% PROCESS _message.tt %]

  [% PROCESS _infobox.tt %]
[% END %]

<div class="card w-fit h-auto [% IF modal %] shadow-float[% END %]">
  <div class="head justify-between">
    <h3>OMD Status: [% s.host_name | html %] ([% s.omd_site | html %])</h3>
    [% IF modal %]
    <button class="iconOnly medium" onClick="closeModalWindow(); return false;"><i class="uil uil-times"></i></button>
    [% END %]
  </div>
  <div class="body">
    <form action="node_control.cgi" method="POST">
      <input type="hidden" name="CSRFtoken" value="[% get_user_token(c) %]">
      <input type="hidden" name="json" value="1">
      <table class="w-fit mx-auto innercellborder">
        <tr id="omd_status_[% s.peer_key | html %]_ALL">
          [% status = s.omd_status.OVERALL %]
          <td class="border-b-2 border-b-[var(--border-dark)] js-omd-status-[% s.peer_key | html %]-ALL"><div class="badge w-full h-7 leading-7 [% IF status == 0 %]OK[% ELSIF status == 2 %]WARNING[% ELSIF status == 3 %]UNKNOWN[% ELSE %]CRITICAL[% END %]">All Services</div></td>
          <td class="border-b-2 border-b-[var(--border-dark)]"><button onclick="nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: 'ALL', action: 'omd_start'}); return false;" [% IF status == 0 %]disabled[% END %]><i class="fa-solid fa-play text-sm"></i> start</button></td>
          <td class="border-b-2 border-b-[var(--border-dark)]"><button onclick="confirm('be careful when stopping the hole site, you need to start it manually again.') && nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: 'ALL', action: 'omd_stop'}); return false;" [% IF status == 1 %]disabled[% ELSE %]class="hover-red"[% END %]><i class="fa-solid fa-power-off text-sm"></i> stop</button></td>
          <td class="border-b-2 border-b-[var(--border-dark)]"><button onclick="nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: 'ALL', action: 'omd_restart'}); return false;"><i class="fa-solid fa-rotate-right text-sm"></i> restart</button></td>
        </tr>
        [% FOREACH service IN s.omd_status.keys.sort %]
          [% IF service == "OVERALL"; NEXT; END %]
          [% status = s.omd_status.$service %]
          <tr id="omd_status_[% s.peer_key | html %]_[% service | html %]">
            <td class="[%IF loop.first %]pt-3[% END %] js-omd-status-[% s.peer_key | html %]-[% service | html %]"><div class="badge w-full h-7 leading-7 [% IF status == 0 %]OK[% ELSIF status == 3 %]UNKNOWN[% ELSE %]CRITICAL[% END %]">[% service | html %]</div></td>
            <td class="[%IF loop.first %]pt-3[% END %]"><button onclick="nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: '[% service | html %]', action: 'omd_start'}); return false;" [% IF status == 0 %]disabled[% END %]><i class="fa-solid fa-play text-sm"></i> start</button></td>
            <td class="[%IF loop.first %]pt-3[% END %]"><button onclick="[% IF service == "apache" %]confirm('be careful when stopping the apache, you need to start it manually again.') && [% END %]nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: '[% service | html %]', action: 'omd_stop'}); return false;" [% IF status != 0 %]disabled[% ELSE %]class="hover-red"[% END %]><i class="fa-solid fa-power-off text-sm"></i> stop</button></td>
            <td class="[%IF loop.first %]pt-3[% END %]"><button onclick="nc_omd_service(this, {peer: '[% s.peer_key | html %]', service: '[% service | html %]', action: 'omd_restart'}); return false;"><i class="fa-solid fa-rotate-right text-sm"></i> restart</button></td>
          </tr>
        [% END %]
      </table>
    </form>
  </div>
  [% IF modal %]
    <div class="footer justify-center">
      <button class="w-20" onclick="closeModalWindow()">OK</button>
    </div>
  [% END %]
</div>

[% IF ! modal %]
  [% PROCESS _footer.tt %]
[% END %]
