extends ../layouts/main
block content

  mixin renderHostList (hosts)
    if Array.isArray(hosts) && (hosts.length > 0)
      table.uk-table.uk-table-small.uk-table-divider
        thead
          th Host
          th Status
          th Memory
          th Platform
          th Arch
          th Created
          th Updated
        tbody
          each host in hosts
            tr(data-host-id= host._id)
              td
                a(href=`/admin/host/${host._id}`)= host.hostname
              td= host.status
              td= numeral((host.totalmem - host.freemem) / host.totalmem).format('0.00%')
              td= host.platform
              td= host.arch
              td= moment(host.created).fromNow()
              td= host.updated ? moment(host.updated).fromNow() : 'N/A'
    else
      div The host list is empty
  
  if Array.isArray(activeHosts) && (activeHosts.length > 0)
    h2 Active hosts
    +renderHostList(activeHosts)

  if Array.isArray(crashedHosts) && (crashedHosts.length > 0)
    h2 Crashed hosts
    +renderHostList(crashedHosts)
