Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

4.9 KB
Raw Blame
<div class="border border-top-0 rounded-bottom p-3">
  @if (!loading() && error()) {
    <div class="alert alert-danger mb-0" role="alert">{{ error() }}</div>
  }
  @if (!loading() && !error() && links().length === 0) {
    <p class="mb-0 text-muted fst-italic" i18n>
      No document share links currently exist.
    </p>
  }
  @if (!loading() && !error() && links().length > 0) {
    <div class="table-responsive">
      <table class="table table-sm align-middle mb-0 bg-body">
        <thead>
          <tr>
            <th scope="col" class="fw-normal" pngxSortable="document__title" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Document</th>
            <th scope="col" class="fw-normal" pngxSortable="created" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Created</th>
            <th scope="col" class="fw-normal" pngxSortable="expiration" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Expires</th>
            <th scope="col" i18n>File version</th>
            <th scope="col" class="text-end" i18n>Actions</th>
          </tr>
        </thead>
        <tbody>
          @for (link of links(); track link.id) {
            <tr>
              <td>
                <a routerLink="/documents/{{ link.document }}">{{ link.document_title | documentTitle }}</a>
                <span class="badge bg-primary text-primary-text-contrast ms-3 small fs-normal cursor-pointer" (click)="copyDocumentID(link.document)">
                  @if (copiedDocumentID() === link.document) {
                    <pngx-bs-icon width="1em" height="1em" name="clipboard-check" class="me-1"></pngx-bs-icon><ng-container i18n>Copied!</ng-container>
                  } @else {
                    ID: {{link.document}}
                  }
                </span>
              </td>
              <td>{{ link.created | date: 'short' }}</td>
              <td>
                @if (link.expiration) {
                  {{ link.expiration | date: 'short' }}
                  @if (isExpired(link.expiration)) {
                    <span class="badge text-bg-danger ms-2" i18n>Expired</span>
                  }
                } @else {
                  <span i18n>Never</span>
                }
              </td>
              <td>{{ fileVersionLabel(link.file_version) }}</td>
              <td class="text-end">
                <div class="d-inline-block position-relative">
                  <span
                    class="badge bg-primary small fade position-absolute top-50 end-100 translate-middle-y me-2 pe-none z-3 text-nowrap"
                    [class.show]="copiedID() === link.id"
                    i18n
                  >Copied!</span>
                  <div class="btn-group btn-group-sm">
                    <button
                      type="button"
                      class="btn btn-outline-primary"
                      (click)="copy(link)"
                      title="Copy share link"
                      i18n-title
                    >
                      @if (copiedID() === link.id) {
                        <pngx-bs-icon name="clipboard-check"></pngx-bs-icon>
                      } @else {
                        <pngx-bs-icon name="clipboard"></pngx-bs-icon>
                      }
                      <span class="visually-hidden" i18n>Copy share link</span>
                    </button>
                    <pngx-confirm-button
                      *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.ShareLink }"
                      buttonClasses="btn btn-sm btn-outline-danger"
                      (confirm)="delete(link)"
                      iconName="trash"
                    >
                      <span class="visually-hidden" i18n>Delete share link</span>
                    </pngx-confirm-button>
                  </div>
                </div>
              </td>
            </tr>
          }
        </tbody>
      </table>
    </div>
    <div class="d-flex flex-wrap justify-content-end align-items-center gap-3 mt-3 ms-auto">
      <div class="d-flex align-items-center">
        <label class="small text-muted me-2" for="shareLinkPageSize" i18n>Show:</label>
        <select id="shareLinkPageSize" class="form-select form-select-sm w-auto" [(ngModel)]="pageSize">
          <option [ngValue]="25">25</option>
          <option [ngValue]="50">50</option>
          <option [ngValue]="100">100</option>
        </select>
        <span class="small text-muted ms-2 d-none d-md-inline" i18n>per page</span>
      </div>
      @if (total() > pageSize) {
        <ngb-pagination
          class="mb-0"
          [pageSize]="pageSize"
          [collectionSize]="total()"
          [page]="page()"
          [maxSize]="5"
          (pageChange)="setPage($event)"
          size="sm"
          aria-label="Share links pagination"
          i18n-aria-label
        ></ngb-pagination>
      }
    </div>
  }
</div>