extends ../layouts/main
block content

  .uk-margin
    .uk-card.uk-card-secondary.uk-card-small
      .uk-card-header
        h1.uk-card-title #{job.name} id: #{job.id}

      .uk-card-body
        .uk-margin
          progress(value= job.progress, max= 100).uk-progress
        .uk-margin
          div(uk-grid)
            .uk-width-auto attempt: #{job.attemptsMade}
            .uk-width-auto attempts: #{job.opts.attempts}
            .uk-width-auto ts: #{moment(job.timestamp).format('YYYY-MM-DD hh:mm:ss a')}
            .uk-width-auto proc: #{moment(job.processedOn).format('YYYY-MM-DD hh:mm:ss a')}

            if job.finishedOn
              .uk-width-auto fin: #{job.finishedOn}

            if job.delay > 0
              .uk-width-auto delay: #{job.delay}

            if job.opts.removeOnComplete
              .uk-width-auto.uk-text-success remove on complete

            if job.opts.removeOnFail
              .uk-width-auto.uk-text-danger remove on fail

        if job.data
          h4 Job data
          pre= JSON.stringify(job.data, null, 2)      

        if job.failedReason
          h4.uk-text-danger Failed reason
          div= job.failedReason
        
        if Array.isArray(jobLogs) && (jobLogs.length > 0)
          h4 Log
          each log in jobLogs
            div= log

        if Array.isArray(job.stacktrace) && (job.stacktrace.length > 0)
          h4 Stacktrace
          each trace in job.stacktrace
            pre= trace

      .uk-card-footer
        div(uk-grid)
          .uk-width-expand
            div(uk-grid)
              .uk-width-auto
                button(
                  type="button",
                  data-job-queue= queue.name,
                  data-job-id= job.id,
                  data-job-action= 'remove',
                  onclick="return dtp.adminApp.jobQueueAction(event);",
                ).uk-button.dtp-button-danger Remove
              .uk-width-auto
                button(
                  type="button",
                  data-job-queue= queue.name,
                  data-job-id= job.id,
                  data-job-action= 'discard',
                  onclick="return dtp.adminApp.jobQueueAction(event);",
                ).uk-button.dtp-button-danger Discard
          .uk-width-auto
            button(
              type="button",
              data-job-queue= queue.name,
              data-job-id= job.id,
              data-job-action= 'retry',
              onclick="return dtp.adminApp.jobQueueAction(event);",
            ).uk-button.dtp-button-primary Retry