Chocobozzz/PeerTube

View on GitHub
client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.html

Summary

Maintainability
Test Coverage
<div class="sub-title-container">
  <div class="sub-title">
    <my-global-icon iconName="videos" aria-hidden="true"></my-global-icon>
    <h1 i18n>Videos redundancies</h1>
  </div>
</div>

<div class="admin-sub-header">
  <div class="select-filter-block">
    <label for="displayType" i18n>Display</label>

    <div class="peertube-select-container">
      <select id="displayType" name="displayType" [(ngModel)]="displayType" (ngModelChange)="onDisplayTypeChanged()" class="form-control">
        <option value="my-videos" i18n>My videos duplicated by remote instances</option>
        <option value="remote-videos" i18n>Remote videos duplicated by my instance</option>
      </select>
    </div>
  </div>
</div>

<p-table
  [value]="videoRedundancies" [lazy]="true" [paginator]="totalRecords > 0" [totalRecords]="totalRecords"
  [rows]="rowsPerPage"  [first]="pagination.start" [rowsPerPageOptions]="rowsPerPageOptions"
  [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"
  [expandedRowKeys]="expandedRows"
>
  <ng-template pTemplate="header">
    <tr>
      <th scope="col" style="width: 40px;">
        <span i18n class="visually-hidden">More information</span>
      </th>
      <th scope="col" style="width: 150px;" i18n>Action</th>
      <th scope="col" style="width: 160px;" i18n *ngIf="isDisplayingRemoteVideos()">Strategy</th>
      <th scope="col" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="name">Video <p-sortIcon field="name"></p-sortIcon></th >
      <th scope="col" style="width: 100px;" i18n *ngIf="isDisplayingRemoteVideos()">Total size</th>
    </tr>
  </ng-template>

  <ng-template pTemplate="body" let-expanded="expanded" let-redundancy>
    <tr>
      <td class="expand-cell">
        <my-table-expander-icon [pRowToggler]="redundancy" [expanded]="expanded" i18n-tooltip tooltip="List redundancies"></my-table-expander-icon>
      </td>

      <td class="action-cell">
        <my-delete-button label (click)="removeRedundancy(redundancy)"></my-delete-button>
      </td>

      <td *ngIf="isDisplayingRemoteVideos()">{{ getRedundancyStrategy(redundancy) }}</td>

      <td>
        <a [href]="redundancy.url" i18n-title title="Open video in a new tab" target="_blank" rel="noopener noreferrer">
          {{ redundancy.name }}
          <my-global-icon iconName="external-link"></my-global-icon>
        </a>
      </td>

      <td *ngIf="isDisplayingRemoteVideos()">{{ getTotalSize(redundancy) | bytes: 1 }}</td>
    </tr>
  </ng-template>

  <ng-template pTemplate="rowexpansion" let-redundancy>
    <tr *ngIf="redundancy.redundancies.files.length !== 0">
      <td class="expand-cell" myAutoColspan>
        <div *ngFor="let file of redundancy.redundancies.files" class="expansion-block">
          <my-video-redundancy-information [redundancyElement]="file"></my-video-redundancy-information>
        </div>
      </td>
    </tr>

    <tr *ngIf="redundancy.redundancies.streamingPlaylists.length !== 0">
      <td class="expand-cell" myAutoColspan>
        <div *ngFor="let playlist of redundancy.redundancies.streamingPlaylists">
          <my-video-redundancy-information [redundancyElement]="playlist"></my-video-redundancy-information>
        </div>
      </td>
    </tr>
  </ng-template>

  <ng-template pTemplate="emptymessage">
    <tr>
      <td myAutoColspan>
        <div class="no-results">
          <ng-container *ngIf="isDisplayingRemoteVideos()" i18n>Your instance doesn't mirror any video.</ng-container>
          <ng-container *ngIf="!isDisplayingRemoteVideos()" i18n>Your instance has no mirrored videos.</ng-container>
        </div>
      </td>
    </tr>
  </ng-template>
</p-table>


<div class="redundancies-charts" *ngIf="isDisplayingRemoteVideos() && dataLoaded">
  <h6 i18n>Enabled strategies stats</h6>

  <div class="chart-blocks">

    <div *ngIf="noRedundancies" i18n class="no-results">
      No redundancy strategy is enabled on your instance.
    </div>

    <div class="chart-block" *ngFor="let r of redundanciesGraphsData">
      <p-chart [ariaLabel]="r.ariaLabel" type="pie" [data]="r.graphData" [options]="r.options" width="300px" height="300px"></p-chart>
    </div>

  </div>
</div>