Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

6.9 KB
Raw Blame
<div class="overflow-x-auto">
  <table
    class="gf-table w-100"
    mat-table
    matSort
    [class.simple]="mode() === 'simple'"
    [dataSource]="dataSource"
    [matSortActive]="sortActive()"
    [matSortDirection]="sortDirection()"
  >
    <ng-container matColumnDef="icon" [sticky]="mode() === 'default'">
      <th *matHeaderCellDef class="px-1" mat-header-cell></th>
      <td
        *matCellDef="let element"
        class="px-1 text-center"
        mat-cell
        [class.text-nowrap]="mode() === 'simple'"
      >
        <gf-entity-logo
          [countryCode]="getCountryCodeForCashPosition(element)"
          [dataSource]="element.assetProfile.dataSource"
          [symbol]="element.assetProfile.symbol"
          [tooltip]="getHoldingName(element.assetProfile)"
        />
      </td>
    </ng-container>

    <ng-container matColumnDef="nameWithSymbol">
      <th
        *matHeaderCellDef
        class="px-1"
        mat-header-cell
        mat-sort-header="assetProfile.name"
      >
        <ng-container i18n>Name</ng-container>
      </th>
      <td
        *matCellDef="let element"
        class="lh-normal px-1"
        mat-cell
        [class.w-100]="mode() === 'simple'"
      >
        @let holdingName = getHoldingName(element.assetProfile);

        <div class="text-truncate" [title]="holdingName">
          {{ holdingName }}
          @if (
            !isCashPosition(element.assetProfile) &&
            element.assetProfile.name === element.assetProfile.symbol
          ) {
            <span>({{ element.assetProfile.assetSubClassLabel }})</span>
          }
        </div>
        @if (mode() === 'default') {
          <div>
            <small class="text-body-secondary">{{
              element.assetProfile.symbol
            }}</small>
          </div>
        }
      </td>
    </ng-container>

    <ng-container matColumnDef="dateOfFirstActivity">
      <th
        *matHeaderCellDef
        class="d-none d-lg-table-cell justify-content-end px-1"
        mat-header-cell
        mat-sort-header
      >
        <ng-container i18n>First Activity</ng-container>
      </th>
      <td
        *matCellDef="let element"
        class="d-none d-lg-table-cell px-1"
        mat-cell
      >
        <div class="d-flex justify-content-end">
          <gf-value
            [isDate]="element.dateOfFirstActivity ? true : false"
            [locale]="locale()"
            [value]="element.dateOfFirstActivity ?? ''"
          />
        </div>
      </td>
    </ng-container>

    <ng-container matColumnDef="quantity">
      <th
        *matHeaderCellDef
        class="d-none d-lg-table-cell justify-content-end px-1"
        mat-header-cell
        mat-sort-header
      >
        <ng-container i18n>Quantity</ng-container>
      </th>
      <td
        *matCellDef="let element"
        class="d-none d-lg-table-cell px-1"
        mat-cell
      >
        <div class="d-flex justify-content-end">
          <gf-value
            [isCurrency]="true"
            [isLoading]="isLoading()"
            [locale]="locale()"
            [value]="element.quantity"
          />
        </div>
      </td>
    </ng-container>

    <ng-container matColumnDef="valueInBaseCurrency">
      <th
        *matHeaderCellDef
        class="d-none d-lg-table-cell justify-content-end px-1"
        mat-header-cell
        mat-sort-header
      >
        <ng-container i18n>Value</ng-container>
      </th>
      <td
        *matCellDef="let element"
        class="d-none d-lg-table-cell px-1"
        mat-cell
      >
        <div class="d-flex justify-content-end">
          <gf-value
            [isCurrency]="true"
            [isLoading]="isLoading()"
            [locale]="locale()"
            [value]="element.valueInBaseCurrency"
          />
        </div>
      </td>
    </ng-container>

    <ng-container matColumnDef="allocationInPercentage">
      <th
        *matHeaderCellDef
        class="justify-content-end px-1"
        mat-header-cell
        mat-sort-header
      >
        <span class="d-none d-sm-block" i18n>Allocation</span>
        <span class="d-block d-sm-none" i18n-title title="Allocation">%</span>
      </th>
      <td *matCellDef="let element" class="px-1" mat-cell>
        <div class="d-flex justify-content-end">
          <gf-value
            [isLoading]="isLoading()"
            [isPercent]="true"
            [locale]="locale()"
            [value]="element.allocationInPercentage"
          />
        </div>
      </td>
    </ng-container>

    <ng-container matColumnDef="performance">
      <th
        *matHeaderCellDef
        class="justify-content-end px-1"
        mat-header-cell
        mat-sort-header="netPerformanceWithCurrencyEffect"
      >
        <ng-container i18n>Change</ng-container>
      </th>
      <td *matCellDef="let element" class="px-1" mat-cell>
        <div class="d-flex justify-content-end">
          <gf-value
            [colorizeSign]="true"
            [isCurrency]="true"
            [isLoading]="isLoading()"
            [locale]="locale()"
            [value]="element.netPerformanceWithCurrencyEffect"
          />
        </div>
      </td>
    </ng-container>

    <ng-container
      matColumnDef="performanceInPercentage"
      [stickyEnd]="mode() === 'default'"
    >
      <th
        *matHeaderCellDef
        class="justify-content-end px-1"
        mat-header-cell
        mat-sort-header="netPerformancePercentWithCurrencyEffect"
      >
        <span class="d-none d-sm-block" i18n>Performance</span>
        <span class="d-block d-sm-none" i18n-title title="Performance">±</span>
      </th>
      <td
        *matCellDef="let element"
        class="px-1"
        mat-cell
        [class.text-nowrap]="mode() === 'simple'"
      >
        <div class="d-flex justify-content-end">
          <gf-value
            [colorizeSign]="true"
            [isLoading]="isLoading()"
            [isPercent]="true"
            [locale]="locale()"
            [value]="element.netPerformancePercentWithCurrencyEffect"
          />
        </div>
      </td>
    </ng-container>

    <tr
      *matHeaderRowDef="displayedColumns()"
      mat-header-row
      [class.d-none]="mode() === 'simple'"
    ></tr>
    <tr
      *matRowDef="let row; columns: displayedColumns()"
      mat-row
      [class.cursor-pointer]="canShowDetails(row)"
      (click)="
        canShowDetails(row) &&
          onOpenHoldingDialog({
            dataSource: row.assetProfile.dataSource,
            symbol: row.assetProfile.symbol
          })
      "
    ></tr>
  </table>
</div>

<mat-paginator class="d-none" [hidePageSize]="true" [pageSize]="pageSize()" />

@if (isLoading()) {
  <ngx-skeleton-loader
    animation="pulse"
    [class.px-4]="mode() === 'default'"
    [class.py-3]="mode() === 'default'"
    [theme]="{
      height: '1.5rem',
      width: '100%'
    }"
  />
}

@if (dataSource.data.length > pageSize() && !isLoading()) {
  <div class="my-3 text-center">
    <button mat-stroked-button (click)="onShowAllHoldings()">
      <ng-container i18n>Show all</ng-container>
    </button>
  </div>
}