Chocobozzz/PeerTube

View on GitHub
client/src/app/+my-library/my-video-channel-syncs/my-video-channel-syncs.component.html

Summary

Maintainability
Test Coverage
<my-alert *ngIf="error" type="danger">{{ error }}</my-alert>

<div class="sub-title-container">
  <div class="sub-title">
    <my-global-icon iconName="refresh" aria-hidden="true"></my-global-icon>
    <ng-container i18n>My synchronizations</ng-container>
  </div>
</div>

<div *ngIf="!syncEnabled()">
  <p class="muted" i18n>⚠️ The instance doesn't allow channel synchronization</p>
</div>

<p-table
  *ngIf="syncEnabled()" [value]="channelSyncs" [lazy]="true"
  [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [rowsPerPageOptions]="rowsPerPageOptions"
  [first]="pagination.start" [sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" dataKey="id"
  [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"
  [expandedRowKeys]="expandedRows"
>
  <ng-template pTemplate="caption">
    <div class="caption">
      <div class="left-buttons">
        <a class="peertube-create-button" routerLink="{{ getSyncCreateLink() }}">
          <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
          <ng-container i18n>Add synchronization</ng-container>
        </a>
      </div>
    </div>
  </ng-template>

  <ng-template pTemplate="header">
    <tr>
      <th scope="col" style="width: 10%;">
        <span i18n class="visually-hidden">Actions</span>
      </th>
      <th scope="col" style="width: 25%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="externalChannelUrl">External Channel <p-sortIcon field="externalChannelUrl"></p-sortIcon></th>
      <th scope="col" style="width: 25%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="videoChannel">Channel <p-sortIcon field="videoChannel"></p-sortIcon></th>
      <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="state">State <p-sortIcon field="state"></p-sortIcon></th>
      <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
      <th scope="col" style="width: 10%" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="lastSyncAt">Last synchronization at <p-sortIcon field="lastSyncAt"></p-sortIcon></th>
    </tr>
  </ng-template>

  <ng-template pTemplate="body" let-expanded="expanded" let-videoChannelSync>
    <tr>
      <td class="action-cell">
        <my-action-dropdown
           container="body"
          [actions]="videoChannelSyncActions" [entry]="videoChannelSync"
        ></my-action-dropdown>
      </td>

      <td>
        <a [href]="videoChannelSync.externalChannelUrl" target="_blank" rel="noopener noreferrer">{{ videoChannelSync.externalChannelUrl }}</a>
      </td>

      <td>
        <a [routerLink]="[ '/c', videoChannelSync.channel.name ]" i18n-title title="Channel page">
          <div class="chip two-lines">
            <my-actor-avatar
              [actor]="videoChannelSync.channel" actorType="channel"
              [internalHref]="[ '/c', videoChannelSync.channel.name ]" size="32"
            ></my-actor-avatar>

            <div>
              <span class="fw-semibold">{{ videoChannelSync.channel.displayName }}</span>
              <span class="muted">{{ videoChannelSync.channel.name }}</span>
            </div>
          </div>
        </a>
      </td>

      <td>
        <span [ngClass]="getSyncStateClass(videoChannelSync.state.id)">
          {{ videoChannelSync.state.label }}
        </span>
      </td>

      <td>{{ videoChannelSync.createdAt | date: 'short' }}</td>
      <td>{{ videoChannelSync.lastSyncAt | date: 'short' }}</td>
    </tr>
  </ng-template>
</p-table>