<div class="row-fluid">
  <div class="job-link span2">
    <a href="/[[ job.project.name || project.name ]]/[[ job.nojobs ? '' : 'job/' + job._id ]]">
      <i ng-hide="job.nojobs"
         data-toggle="tooltip"
         title="[[ job.status ]]"
         class="fa [[ statusClasses[job.status] ]] fa-2x"></i>
      <span class="job-link-id" ng-show="job.nojobs">No job history</span>
      <span class="job-link-id" data-test="job-id">[[ job._id.substr(0,8) ]]</span>
    </a>
  </div>

  <div class="committer span2">
    <div ng-show="job.trigger.author.image" ng-switch="!!job.trigger.author.url">
      <span ng-switch-when="false">
        <img ng-src="[[ job.trigger.author.image ]]" class="img-circle"/>
        [[ job.trigger.author.name ]]
      </span>

      <a ng-switch-default href="[[ job.trigger.author.url ]]" target="_blank">
        <img ng-src="[[ job.trigger.author.image ]]" class="img-circle"/>
        [[ job.trigger.author.name ]]
      </a>
    </div>
  </div>

  <div class="branch span2">
    <strong>[[ job.ref.branch ]]</strong>
  </div>

  <div class="run-time span2" ng-switch="job.status">
    <time ng-switch-when="running" class="duration" since="[[ job.created ]]" ng-hide="job.nojobs"></time>
    <time ng-switch-when="submitted" class="duration" since="[[ job.started ]]" ng-hide="job.nojobs"></time>
    <time ng-switch-default class="duration" duration="[[ job.duration ]]" ng-hide="job.nojobs"></time>
  </div>

  <div class="finished-at span4" ng-switch="job.status === 'running'">
    <span ng-switch-when="false" class="small-text" ng-hide="job.nojobs || job.status === 'submitted'">
      <time data-toggle="tooltip" data-placement="top" datetime="[[ job.finished ]]" class="timeago summary-text"></time>
    </span>

    <div class="current-build-actions pull-right">
      {% if currentUser %}
        <button type='button' class="button is-danger is-inverted is-outlined" ng-click="cancelJob(job._id)" ng-hide="job.status !== 'running' && job.status !== 'submitted'">
          <span class="icon is-small">
            <i class="fa fa-times text-muted"></i>
          </span>
          <span>Cancel</span>
        </button>
      {% endif %}
      <!--
      <a class='button' ng-click="restartJob(job)" disabled="[[ job.status === 'running' || job.status === 'submitted' ? true : false ]]">
        <span class="icon is-small">
          <i class="fa fa-retweet"></i>
        </span>
        <span>Restart Job</span>
      </a>-->
    </div>
  </div>
</div>

<div class="row-fluid">
  <div class="commit-url span12" ng-switch="!!job.trigger.url">
    <span ng-switch-when="true">
      <a href="[[ job.trigger.url ]]" target="_blank">
        <span class="small-text" title="[[ job.trigger.message ]]">
          <i class="trigger-icon fa fa-[[ triggers[job.trigger.type].icon ]]" data-toggle="tooltip" title="[[ triggers[job.trigger.type].title ]]"></i>
          [[ job.trigger.message ]]
        </span>
      </a>
    </span>

    <span class="small-text" ng-switch-default title="[[ job.trigger.message ]]">
      <i class="trigger-icon fa fa-[[ triggers[job.trigger.type].icon ]]" data-toggle="tooltip" title="[[ triggers[job.trigger.type].title ]]"></i>
      [[ job.trigger.message ]]
    </span>
  </div>
</div>

<div class="row-fluid" ng-if="job.status === 'running'">
  <div class="span12">
    <div class="progress-meter">
      <div class="progress progress-striped active progress-info">
        <div class="bar" style="width:[[ (phases.indexOf(job.phase)+1)/phases.length*100 ]]%; max-width: 100%"></div>
      </div>
    </div>
  </div>
</div>

