[% WRAPPER layout.tt title="Machine status" %]
[% PROCESS common.tt %]

<table class="table table-condensed table-striped">
  [% FOREACH m IN machines %]
    <thead>
      <tr>
        <th colspan="5">
          [% IF m.value.maxJobs > 0 %]
            Running
          [% ELSE %]
            Stopped
          [% END %] <tt>[% m.key %]</tt> (<tt>[% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END; system; END %])</tt>
        </th>
      </tr>
    </thead>
    <tbody>
      [% idle = 1 %]
      [% FOREACH step IN steps %]
        [% IF step.machine.match('@(.*)').0 == m.key %]
          [% idle = 0 %]
          <tr>
            <td><tt>[% INCLUDE renderFullJobName project = step.build.project.name jobset = step.build.jobset.name job = step.build.job.name %]</tt></td>
            <td><tt>[% step.system %]</tt></td>
            <td><a href="[% c.uri_for('/build' step.build.id) %]">[% step.build.id %]</a></td>
            <td><tt>[% step.drvpath.match('-(.*)').0 %]</tt></td>
            <td class='right'>[% INCLUDE renderDuration duration = curTime - step.starttime %] </td>
          </tr>
        [% END %]
      [% END %]
      [% IF idle == 1 %]
        [% IF m.value.idle %] 
          <tr><td colspan="5">Idle since [% INCLUDE renderDuration duration = curTime - m.value.idle %]</td></tr>
        [% ELSE %]
          <tr><td colspan="5">Never built</td></tr>
        [% END %]
      [% END %]
    </tbody>
  [% END %]
</table>



[% END %]
