<div>
  <div class="row">
    <div class="col-xs-12 col-md-offset-2 col-md-8">
      <h2>{{ package_name }}</h2>
    </div>
  </div>

  <div class="row" style="margin-top: 10px; margin-bottom: 10px">
    <div class="col-xs-12 col-md-offset-2 col-md-5">
      <div class="input-group">
        <span class="input-group-addon"><i class="fa fa-search"></i></span>
        <input class="form-control" ng-model="searchText" ng-change="currentPage = 0" type="text" placeholder="Search">
      </div>
    </div>
    <div class="col-xs-12 col-md-3 hidden-xs hidden-sm">
      <div ng-show="USER && can_write">
        <button class="btn btn-sm btn-default pull-right" ng-init="uploadCollapsed = true" ng-click="uploadCollapsed = !uploadCollapsed">
          {{ uploadCollapsed ? 'Upload' : 'Cancel' }}
          <i class="fa fa-caret-up" ng-hide="uploadCollapsed"></i>
        </button>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-xs-12 col-md-offset-2 col-md-6">
      <input type="checkbox" ng-model="showPreRelease"> Show pre-release versions
    </div>
  </div>

  <div class="row" style="margin-bottom: 10px">
    <div ng-include="PARTIAL + 'upload.html'"></div>
  </div>

  <div ng-hide="packages !== null" class="text-center">
    <i class="fa fa-spinner fa-spin fa-4x"></i>
  </div>
  <div class="row" ng-if="packages" style="margin-top: 10px">
    <div class="col-xs-12 col-md-offset-2 col-md-8">
      <table class="table table-striped table-bordered" ng-class="can_write ? 'table-hover' : ''">
        <thead>
          <tr>
            <th>Package</th>
            <th>Version</th>
            <th>Uploaded</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="package in filtered = (packages | filter:filterPreRelease | filter:searchText) | startFrom:(currentPage - 1)*pageSize | limitTo:pageSize"
           ng-mouseenter="showDelete = true" ng-mouseleave="showDelete = false">
            <td>
              <a ng-href="{{ package.url }}">{{ package.filename }}</a>
            </td>
            <td>
              {{ package.version }}
            </td>
            <td>
              {{ package.last_modified * 1000 | date:'yyyy-MM-dd HH:mm' }}
              <button ng-click="deletePackage(package)" visible="ALLOW_DELETE && can_write && (showDelete || package.deleting)" class="btn btn-danger btn-xs pull-right" ng-disabled="package.deleting">
                <i class="fa fa-refresh fa-spin" ng-show="package.deleting"></i>
                Delete
              </button>
            </td>
          </tr>
        </tbody>
      </table>
      <div class="text-center">
        <pagination direction-links="true" total-items="filtered.length" rotate="false" max-size="maxSize" items-per-page="pageSize" page="currentPage"></pagination>
      </div>
    </div>
  </div>
</div>
