{% extends 'base.html' %}

{% block head %}
{{ super() }}

<script>
  var jobName = '{{ job.name }}';
  var taskName = '{{ task_name }}';
</script>

<link rel="stylesheet" href="/static/css/task_detail.css"></link>
{% endblock head %}

{% block navbar_current %}
<li><a href='{{ url_for('job_detail', job_id=job.job_id) }}'>Job: {{ job.name }}</a></li>
<li><a href='#'>Task Detail: {{ task_name }}</a></li>
{% endblock navbar_current %}

{% block content %}

<div class='page-header'>
  <h3>Task Detail: {{ task_name }}</h3>
  <h3 id='task-status' class='right'></h3>
</div>

<div class='alert alert-caution'>
  This page is still a work in progress. Information here may not be updated in realtime; refresh the page to make sure you're seeing accurate information.
</div>

<div class='row' id='timeout'>

  <div class='span12'>
    <h3>Task Timeouts (in seconds, 0 to disable)</h3>
  </div>

  <div class='span6'>

    <div id='soft-timeout-alert' class='alert hidden'>
    </div>

    <form id='soft-timeout-form' class='form form-horizontal'>
      <div class='control-group'>
        <label class='control-label' for='soft-timeout'>Soft Timeout (TERM)</label>
        <div class='controls'>
          <input id='soft-timeout' type='text' class='input'
                 value={{ task.soft_timeout }}></input>
        </div>
      </div>
      <div class='control-group'>
        <div class='controls'>
          <button id='save-soft-timeout' class='btn btn-success' onclick='return false;'>Set Soft Timeout</button>
        </div>
      </div>
    </form>
  </div>

  <div class='span6'>

    <div id='hard-timeout-alert' class='alert hidden'>
    </div>

    <form id='hard-timeout-form' class='form form-horizontal'>
      <div class='control-group'>
        <label class='control-label' for='hard-timeout'>Hard Timeout (KILL)</label>
        <div class='controls'>
          <input id='hard-timeout' type='text' class='input'
                 value={{ task.hard_timeout }}></input>
        </div>
      </div>
      <div class='control-group'>
        <div class='controls'>
          <button id='save-hard-timeout' class='btn btn-success' onclick='return false;'>Set Hard Timeout</button>
        </div>
      </div>
    </form>

  </div>

</div>

<div id='logs' class='row'>
  <div class='span12'>

    <h3>Run Logs</h3>

    <div class='log-controls'>
      <button id='head-stdout' class='btn btn-sequence btn-primary'>Head Stdout</button>
      <button id='tail-stdout' class='btn btn-sequence btn-primary'>Tail Stdout</button>
      <button id='head-stderr' class='btn btn-sequence btn-primary'>Head Stderr</button>
      <button id='tail-stderr' class='btn btn-sequence btn-primary'>Tail Stderr</button>

      <span id='log-type' class='right-header'></span>
    </div>

    <textarea id='log-detail' class='hidden'></textarea>

  </div>
</div>

{% endblock content %}

{% block body_scripts %}
  <script src="/static/js/task_detail.js"></script>
{% endblock body_scripts %}
