<!DOCTYPE html>
<html lang="en">

<head>
  <link rel="stylesheet" href="https://cdn.gitcdn.link/cdn/angular/bower-material/v1.0.7/angular-material.min.css" type="text/css">
  <link rel="stylesheet" href="md-data-table.min.css" type="text/css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:300,400,500,700,400italic" type="text/css">
  <link rel="stylesheet" href="style.css" type="text/css">
  <link rel="shortcut icon" href="https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png">
  <meta name="viewport" content="initial-scale=1">

  <title>Kubernetes Submit Queue</title>
</head>

<body ng-app="SubmitQueueModule" ng-controller="SQCntl as cntl">
  <!-- Indent the whole thing -->
  <md-content class="md-padding" layout="column">
    <!-- Display the white border around the indented portion -->
    <md-content class="md-whiteframe-z2">
      <md-toolbar layout="row" layout-align="space-around center">
        <h1 class="md-display-2">Submit Queue Status</h1>
        <a ng-href="https://k8s.io"><img src="https://raw.githubusercontent.com/kubernetes/kubernetes/master/logo/logo.png" class="titleLogo"></a>
      </md-toolbar>
      <md-toolbar class="md-warn" ng-show="cntl.failedBuild">
        <h2 class="md-toolbar-tools">E2E Tests Failing. Entire Submit Queue Blocked.</h2>
      </md-toolbar>
      <md-content class="md-padding">
        <md-tabs md-selected="cntl.selected" md-dynamic-height md-border-bottom>

          <md-tab label="PR's" md-on-select="cntl.selectTab('prs')">
            <md-content class="md-whiteframe-z2">
              <md-toolbar>
                <h2 class="md-toolbar-tools">Pull Requests</h2>
              </md-toolbar>
              <form ng-submit="$event.preventDefault()">
                <md-autocomplete md-selected-item="cntl.prSelectedItem" md-search-text="cntl.prDisplayValue" md-items="item in cntl.prQuerySearch(cntl.prDisplayValue)" md-item-text="item.display" md-min-length="0" placeholder="Enter username or PR number">
                  <md-item-template>
                    <span md-highlight-text="cntl.prDisplayValue" md-highlight-flags="^i">{{item.display}}</span>
                  </md-item-template>
                  <md-not-found>
                    No matches found for "{{cntl.prDisplayValue}}".
                  </md-not-found>
                </md-autocomplete>
              </form>
            </md-content>
            <md-list>
              <md-list-item class="md-3-line" ng-repeat="pr in cntl.prs | loginOrPR:cntl.prDisplayValue | orderBy:'Number' track by pr.Number">
                <a class="md-avatar" ng-href="https://github.com/kubernetes/kubernetes/pulls/{{pr.Login}}">
                  <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                </a>
                <md-content class="md-list-item-text" layout="column">
                  <h3 class="md-body-1">
                    <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a>
                  </h3>
                  <h4 class="md-body-2">{{pr.Reason}}</h4>
                  <p>{{pr.Time | date:'medium'}} (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)</p>
                </md-content>
                <md-divider md-inset ng-if="!$last"></md-divider>
              </md-list-item>
            </md-list>
          </md-tab>

          <md-tab label="Queue" md-on-select="cntl.selectTab('queue')">
            <md-toolbar class="md-whiteframe-z2">
              <h2 class="md-toolbar-tools">Queued For Retest And Merge<span id="queue-len" ng-show="cntl.e2equeue.length > 0"></span></h2>
            </md-toolbar>
            <section>
              <md-subheader class="md-primary">CURRENTLY RUNNING</md-subheader>
              <md-list layout-padding>
                <md-list-item class="md-2-line" ng-repeat="pr in cntl.e2erunning track by pr.Number">
                  <a class="md-avatar" ng-href="https://github.com/kubernetes/kubernetes/pulls/{{pr.Login}}">
                    <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                  </a>
                  <md-content class="md-list-item-text" layout="column">
                    <h3 class="md-body-1">
                      <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a> (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)
                    </h3>
                    <h4 class="md-body2">
                      {{pr.ExtraInfo}}
                    </h4>
                  </md-content>
                </md-list-item>
              </md-list>
            </section>
            <section>
              <md-subheader class="md-primary">QUEUE</md-subheader>
              <md-list layout-padding>
                <md-list-item class="md-2-line" ng-repeat="pr in cntl.e2equeue track by pr.Number">
                  <a class="md-avatar" ng-href="https://github.com/kubernetes/kubernetes/pulls/{{pr.Login}}">
                    <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                  </a>
                  <md-content class="md-list-item-text" layout="column">
                    <h3 class="md-body-1">
                      <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a> (<span style="color: green">+{{pr.Additions}}</span>/<span style="color: red">-{{pr.Deletions}}</span>)
                    </h3>
                    <h4 class="md-body2">
                      {{pr.ExtraInfo}}
                    </h4>
                  </md-content>
                  <md-divider md-inset ng-if="!$last"></md-divider>
                </md-list-item>
              </md-list>
            </section>
          </md-tab>

          <md-tab label="History" md-on-select="cntl.selectTab('history')">
            <md-content class="md-whiteframe-z2">
              <md-toolbar>
                <h2 class="md-toolbar-tools">Historic Merge Bot Decisions</h2>
                <form ng-submit="$event.preventDefault()">
                  <md-autocomplete md-selected-item="cntl.historySelectedItem" md-search-text="cntl.historyDisplayValue" md-items="item in cntl.historyQuerySearch(cntl.historyDisplayValue)" md-item-text="item.display" md-min-length="0" placeholder="Enter username or PR number">
                    <md-item-template>
                      <span md-highlight-text="cntl.historyDisplayValue" md-highlight-flags="^i">{{item.display}}</span>
                    </md-item-template>
                    <md-not-found>
                      No matches found for "{{cntl.historyDisplayValue}}".
                    </md-not-found>
                  </md-autocomplete>
                </form>
              </md-toolbar>
            </md-content>
            <md-list>
              <md-list-item class="md-3-line" ng-repeat="pr in cntl.historyPRs | loginOrPR:cntl.historyDisplayValue | orderBy: '-Time' track by pr.Time">
                <a class="md-avatar" ng-href="https://github.com/kubernetes/kubernetes/pulls/{{pr.Login}}">
                  <img ng-src="{{pr.AvatarURL}}" alt="{{pr.Login}}">
                </a>
                <md-content class="md-list-item-text" layout="column">
                  <h3 class="md-body-1">
                    <a ng-href="{{pr.URL}}">#{{pr.Number}}: {{pr.Title}}</a>
                  </h3>
                  <h4 class="md-body-2">{{pr.Reason}}</h4>
                  <p class="md-body-3">{{pr.Time | date:'medium'}}</p>
                </md-content>
                <md-divider md-inset ng-if="!$last"></md-divider>
              </md-list-item>
            </md-list>
          </md-tab>

          <md-tab md-on-select="cntl.selectTab('e2e')">
            <md-tab-label>
              <span ng-class="{'redTab':cntl.failedBuild}">Google Internal E2E</span>
            </md-tab-label>
            <md-tab-body>
              <md-toolbar class="md-whiteframe-z2">
                <h2 class="md-toolbar-tools">Google End-to-End Results</h2>
              </md-toolbar>
              <md-chips ng-model="cntl.builds" readonly="true">
                <md-chip-template title="{{$chip.msg}}">
                  <span style="color: {{$chip.color}}">{{$chip.state}}</span> <a ng-href="https://console.cloud.google.com/storage/kubernetes-jenkins/logs/{{$chip.name}}/{{$chip.id}}/">{{$chip.name}}</a>
                  <span style="color: {{$chip.color}}">{{$chip.msg}}</span> <span title="Job stability">{{$chip.stability}}</span>
                </md-chip-template>
              </md-chips>
              <br>
              <h2 class="md-title" ng-show="cntl.OverallHealth.length > 0">Overall Health: {{ cntl.OverallHealth }}</h2>
              <p>Health percents are the fraction of the time that a given job is stable since the submit queue restarted<span ng-show="cntl.StartTime.length > 0"> ({{ cntl.StartTime }})</span>.</p>
            </md-tab-body>
          </md-tab>

          <md-tab label="Info" md-on-select="cntl.selectTab('info')">
	    <md-content class="md-padding">
	      <md-tabs md-dynamic-height md-border-bottom>

                <md-tab label="Queue Order">
                  <md-content class="md-whiteframe-z2">
                    <md-toolbar>
                      <h2 class="md-toolbar-tools">How PRs get ordered in the queue</h2>
                    </md-toolbar>
                  </md-content>
	          <md-content class="md-padding">
	            <span id="priority-info"></span>
	          </md-content>
	        </md-tab>

                <md-tab label="Merge Requirements">
                  <md-content class="md-whiteframe-z2">
                    <md-toolbar>
                      <h2 class="md-toolbar-tools">Requirements for a PR to get automatically merged </h2>
                    </md-toolbar>
                  </md-content>
	          <md-content class="md-padding">
	            <span id="merge-info"></span>
	          </md-content>
	        </md-tab>

                <md-tab label="Users">
                  <md-toolbar class="md-whiteframe-z2">
                    <h2 class="md-toolbar-tools">Users</h2>
                  </md-toolbar>
                  <md-list>
                    <md-list-item class="md-2-line" ng-repeat="user in cntl.users track by user.Login" ng-click="cntl.goToPerson(user.Login)">
                      <img ng-src="{{user.AvatarURL}}" class="md-avatar" alt="{{user.Login}}">
                      <md-content class="md-list-item-text" layout="column">
                        <h3 class="md-body-1">{{user.Login}}</h3>
                        <h4 class="md-body-2">On list because: {{user.Access}}</h4>
                      </md-content>
                    </md-list-item>
                  </md-list>
                </md-tab>

                <md-tab label="Bot Stats">
                  <md-content class="md-whiteframe-z2">
                    <md-toolbar>
                      <h2 class="md-toolbar-tools">Statistics About the Bot</h2>
                    </md-toolbar>
                  </md-content>
                  <br>
                  <h3 class=md-title>Next Run Loop: <span id="next-run-time"></span></h3>
                  <h3 class=md-title>API Calls Per Second: <span id="api-calls-per-sec"></span></h3>
                  <h3 class=md-title>Github Rate Limit Count: <span id="github-api-limit-count"></span></h3>
                  <h3 class=md-title>Github Rate Limit Next Reset: <span id="github-api-limit-reset"></span></h3>
                  <md-content class="md-whiteframe-z2">
                    <md-data-table-container>
                      <md-data-table-toolbar>
                        <h2 class="md-title">API Calls During Last Loop</h2>
                      </md-data-table-toolbar>
                      <table md-data-table class="md-primary">
                        <thead md-order="cntl.StatOrder">
                          <tr>
                            <th order-by="$key" name="Call"></th>
                            <th order-by="Count" name="Count ({{ cntl.APICount }})" numeric descend-first></th>
                            <th order-by="CachedCount" name="Cached Count ({{ cntl.CachedAPICount }})" numeric descend-first></th>
                          </tr>
                        </thead>
                        <tbody>
                          <tr ng-repeat="stat in cntl.botStats | toArray | orderBy: cntl.StatOrder track by stat.$key">
                            <td>{{stat.$key}}</td>
                            <td>{{stat.Count}}</td>
                            <td>{{stat.CachedCount}}</td>
                          </tr>
                        </tbody>
                      </table>
                    </md-data-table-container>
                  </md-content>
                </md-tab>
	      </md-tabs>
	    </md-content>
	  </md-tab>

        </md-tabs>
      </md-content>
    </md-content>
  </md-content>
  <!-- Angular Material Dependencies -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js" type="text/javascript"></script>
  <script src="https://cdn.gitcdn.link/cdn/angular/bower-material/v1.0.7/angular-material.min.js" type="text/javascript"></script>
  <script src="md-data-table.min.js" type="text/javascript"></script>
  <script src="toArrayFilter.js" type="text/javascript"></script>
  <script src="script.js" type="text/javascript"></script>
</body>

</html>
