Skip to content

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

8.0 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()) {
    @if (bundles().length === 0) {
      <p class="mb-0 text-muted fst-italic" i18n>No share link bundles currently exist.</p>
    }
    @if (bundles().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="created" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Created</th>
              <th scope="col" class="fw-normal" pngxSortable="status" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Status</th>
              <th scope="col" i18n>Size</th>
              <th scope="col" class="fw-normal" pngxSortable="expiration" [currentSortField]="sortField()" [currentSortReverse]="sortReverse()" (sort)="onSort($event)" i18n>Expires</th>
              <th scope="col" i18n>Documents</th>
              <th scope="col" i18n>File version</th>
              <th scope="col" class="text-end" i18n>Actions</th>
            </tr>
          </thead>
          <tbody>
            @for (bundle of bundles(); track bundle.id) {
              <tr>
                <td>
                  <div>{{ bundle.created | date: 'short' }}</div>
                  @if (bundle.built_at) {
                    <div class="small text-muted">
                      <ng-container i18n>Built:</ng-container> {{ bundle.built_at | date: 'short' }}
                    </div>
                  }
                </td>
                <td>
                  <div class="d-flex align-items-center gap-2">
                    @if (bundle.status === statuses.Failed && bundle.last_error) {
                      <button
                        type="button"
                        class="btn btn-link p-0 text-danger"
                        [ngbPopover]="errorDetail"
                        popoverClass="popover-sm"
                        triggers="mouseover:mouseleave"
                        placement="auto"
                        aria-label="View error details"
                        i18n-aria-label
                      >
                        <span class="badge text-bg-warning text-uppercase me-2">{{ statusLabel(bundle.status) }}</span>
                        <pngx-bs-icon name="exclamation-triangle-fill" class="text-warning"></pngx-bs-icon>
                      </button>
                      <ng-template #errorDetail>
                        @if (bundle.last_error.timestamp) {
                          <div class="text-muted small mb-1">
                            {{ bundle.last_error.timestamp | date: 'short' }}
                          </div>
                        }
                        <h6>{{ bundle.last_error.exception_type || ($localize`Unknown error`) }}</h6>
                        @if (bundle.last_error.message) {
                          <pre class="text-muted small"><code>{{ bundle.last_error.message }}</code></pre>
                        }
                      </ng-template>
                    }
                    @if (bundle.status === statuses.Processing || bundle.status === statuses.Pending) {
                      <span class="spinner-border spinner-border-sm" role="status"></span>
                    }
                    @if (bundle.status !== statuses.Failed) {
                      <span class="badge text-bg-secondary text-uppercase">{{ statusLabel(bundle.status) }}</span>
                    }
                  </div>
                </td>
                <td>
                  @if (bundle.size_bytes !== undefined && bundle.size_bytes !== null) {
                    {{ bundle.size_bytes | fileSize }}
                  }
                  @if (bundle.size_bytes === undefined || bundle.size_bytes === null) {
                    <span class="text-muted">&mdash;</span>
                  }
                </td>
                <td>
                  @if (bundle.expiration) {
                    {{ bundle.expiration | date: 'short' }}
                    @if (isExpired(bundle.expiration)) {
                      <span class="badge text-bg-danger ms-2" i18n>Expired</span>
                    }
                  }
                  @if (!bundle.expiration) {
                    <span i18n>Never</span>
                  }
                </td>
                <td>{{ bundle.document_count }}</td>
                <td>{{ fileVersionLabel(bundle.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]="copiedSlug() === bundle.slug"
                      i18n
                    >Copied!</span>
                    <div class="btn-group btn-group-sm">
                      <button
                        type="button"
                        class="btn btn-outline-primary"
                        [disabled]="bundle.status !== statuses.Ready"
                        (click)="copy(bundle)"
                        title="Copy share link"
                        i18n-title
                      >
                        @if (copiedSlug() === bundle.slug) {
                          <pngx-bs-icon name="clipboard-check"></pngx-bs-icon>
                        }
                        @if (copiedSlug() !== bundle.slug) {
                          <pngx-bs-icon name="clipboard"></pngx-bs-icon>
                        }
                        <span class="visually-hidden" i18n>Copy share link</span>
                      </button>
                      @if (bundle.status === statuses.Failed) {
                        <button
                          type="button"
                          class="btn btn-outline-warning"
                          [disabled]="loading()"
                          (click)="retry(bundle)"
                        >
                          <pngx-bs-icon name="arrow-clockwise"></pngx-bs-icon>
                          <span class="visually-hidden" i18n>Retry</span>
                        </button>
                      }
                      <pngx-confirm-button
                        buttonClasses="btn btn-sm btn-outline-danger"
                        [disabled]="loading()"
                        (confirm)="delete(bundle)"
                        iconName="trash"
                      >
                        <span class="visually-hidden" i18n>Delete share link bundle</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 flex-wrap justify-content-end align-items-center gap-3">
          <div class="d-flex align-items-center">
            <label class="small text-muted me-2" for="shareLinkBundlePageSize" i18n>Show:</label>
            <select id="shareLinkBundlePageSize" 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 link bundles pagination"
              i18n-aria-label
            ></ngb-pagination>
          }
        </div>
      </div>
    }
  }
</div>