extends ../layouts/main
block content

  include ../../components/pagination-bar
  include components/list-item
  
  .uk-margin
    div(uk-grid).uk-grid-small.uk-flex-middle
      div(class="uk-width-1-1 uk-width-expand@m")
        h1(style="line-height: 1em;") Core Node
      
      .uk-width-auto
        a(href=`mailto:${coreNode.meta.supportEmail}?subject=${encodeURIComponent(`Support request from ${site.name}`)}`)
          span
            i.fas.fa-envelope
          span.uk-margin-small-left Email Support

      .uk-width-auto
        span.uk-label(style="line-height: 1.75em;", class={
          'uk-label-success': coreNode.flags.isConnected,
          'uk-label-warning': !coreNode.flags.isConnected && !coreNode.flags.isBlocked,
          'uk-label-danger': coreNode.flags.isBlocked,
        }).no-select= coreNode.flags.isConnected ? 'Connected' : 'Pending'


  +renderCoreNodeListItem(coreNode)

  .uk-margin
    button(
      type="button",
      data-core={ _id: coreNode._id, name: coreNode.meta.name},
      onclick="return dtp.adminApp.disconnectCore(event);",
    ).uk-button.dtp-button-danger.uk-border-rounded
      span
        i.fas.fa-window-close
      span.uk-margin-small-left Disconnect

  .uk-margin
    table.uk-table.uk-table-small
      thead
        tr
          th Timestamp
          th Method
          th URL
          th Status
          th Result
          th Perf
      tbody
        each request in requestHistory.requests
          tr
            td= moment(request.created).format('YYYY-MM-DD HH:mm:ss.SSS')
            td= request.method
            td= request.url
            td= (request.response && request.response.statusCode) ? request.response.statusCode : '- - -'
            td= (request.response) ? ((request.response.success) ? 'success' : 'fail') : '- - -'
            td= request.response ? `${numeral(request.response.elapsed).format('0,0')}ms` : '- - -'
  
  .uk-margin
    +renderPaginationBar(`/admin/core-node/${coreNode._id}`, requestHistory.totalRequestCount)