<div class="row" ng-controller="Kubernetes.PipelinesController">
  <script type="text/ng-template" id="hostLinkTemplate.html">
    <div class="ngCellText">
    </div>
  </script>
  <div class="row filter-header">
    <div class="col-md-12">
      <span>
        <hawtio-filter ng-show="pipelines.length"
                       ng-model="filterText"
                       css-class="input-xxlarge"
                       placeholder="Filter builds..."></hawtio-filter>
      </span>
      <a class="btn btn-default pull-right"
         title="Create a new project"
         ng-show="forgeEnabled"
         href="/workspaces/{{namespace}}/forge/createProject"><i class="fa fa-plus"></i> Create Project</a>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div ng-hide="fetched">
        <div class="align-center">
          <i class="fa fa-spinner fa-spin"></i>
        </div>
      </div>
      <div ng-show="fetched">
        <div ng-hide="pipelines.length" class="align-center">
          <p class="alert alert-info">There are no build pipelines available.</p>
          <a class="btn btn-primary" href="{{baseUri}}/kubernetes/buildConfig">Create Build Configuration</a>
        </div>
      </div>
    </div>
  </div>
  <div ng-show="fetched && pipelines.length">
    <div ng-repeat="pipeline in pipelines | filter:filterText">
      <div class="row">

        <div class="pipeline-row">
          <div ng-repeat="step in pipeline.triggersSteps">
            <div ng-switch="step.buildConfig.kind">
              <div ng-switch-default="">
                <div class="col-md-1" ng-hide="$first">
                  <div class="pipeline-arrow">
                    <i class="fa fa-long-arrow-right"></i>
                  </div>
                </div>

                <div class="col-md-2 pipeline-build" title="Build configuration">
                  <span class="pipeline-build-details">
                    <a title="View details for this build configuration"
                       href="{{baseUri}}/kubernetes/buildConfigs/{{step.buildConfig.metadata.name}}">
                      <i class="fa fa-cog"></i>
                      {{step.buildConfig.metadata.name}}
                    </a>
                  </span>
                  &nbsp;&nbsp;&nbsp;
                  <span class="pipeline-last-build" ng-show="step.buildConfig.$lastBuild">
                    <a href="{{step.buildConfig.$lastBuild.$viewLink}}" title="view this build">
                      <i class="fa fa-info"></i>
                      build
                    </a>
                  </span>

                  <div class="ngCellText" class="pipeline-last-build-time"
                       title="last build was at: {{step.buildConfig.$lastBuild.$creationDate | date : 'h:mm:ss a, EEE MMM yyyy'}}">
                    <div ng-switch="step.buildConfig.$lastBuild.status">
                        <span ng-switch-when="New" class="text-primary">
                          <i class="fa fa-spin fa-spinner"></i> new: {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                        <span ng-switch-when="Pending" class="text-primary">
                          <i class="fa fa-spin fa-spinner"></i> pending: {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                        <span ng-switch-when="Running" class="text-primary">
                          <i class="fa fa-spin fa-spinner"></i> running {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                        <span ng-switch-when="Complete" class="text-success">
                          <i class="fa fa-check-circle"></i> completed {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                        <span ng-switch-when="Failed" class="text-danger">
                          <i class="fa fa-exclamation-circle"></i> failed {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                        <span ng-switch-default class="text-warning">
                          <i class="fa fa-exclamation-triangle"></i> {{step.buildConfig.$lastBuild.status}}: {{step.buildConfig.$lastBuild.$creationDate.relative()}}
                        </span>
                    </div>
                  </div>
                  <div class="pipeline-last-build-logs">
                    <a href="{{step.buildConfig.$lastBuild.$logsLink}}" title="view the logs of this build">
                      <i class="fa fa-file-text-o"></i>
                      logs
                    </a>
                  </div>
                </div>
              </div>
              <div ng-switch-when="DeploymentConfig">
                <div class="col-md-1">
                  <div class="pipeline-arrow">
                    <i class="fa fa-long-arrow-right"></i>
                  </div>
                </div>

                <div class="col-md-2 pipeline-deploy" title="Deployment Configuration">
                  <div class="pipeline-build-details">
                    <a title="View details for this deployment configuration"
                       href="{{baseUri}}/kubernetes/deploymentConfigs/{{step.buildConfig.metadata.name}}">
                      <i class="fa fa-cogs"></i>
                      {{step.buildConfig.metadata.name}}
                    </a>
                  </div>
                  <div class="pipeline-deploy-pods">
                    <div class="pipeline-pod-counts" ng-show="step.$podCounters">pods:
                      <a ng-show="step.$podCounters.podsLink" target="pods" href="{{step.$podCounters.podsLink}}"
                         title="View pods for this deployment">
                        <span class="badge badge-success">{{step.$podCounters.ready}}</span>
                        <span class="badge badge-info">{{step.$podCounters.valid}}</span>
                        <span ng-show="step.$podCounters.waiting" class="badge">{{step.$podCounters.waiting}}</span>
                        <span ng-show="step.$podCounters.error"
                              class="badge badge-warning">{{step.$podCounters.error}}</span>
                      </a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
