aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/overview/users/user-list/user-list.component.html
blob: e37ad2a3ea5a1dda1ada5a0725d55b99662d4fc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<h1>
  <my-global-icon iconName="user" aria-hidden="true"></my-global-icon>
  <ng-container i18n>Users</ng-container>
</h1>

<p-table
  [value]="users" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"
  [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"
  [(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"
  [showCurrentPageReport]="true" i18n-currentPageReportTemplate
  currentPageReportTemplate="Showing {{'{first}'}} to {{'{last}'}} of {{'{totalRecords}'}} users"
  [expandedRowKeys]="expandedRows"
>
  <ng-template pTemplate="caption">
    <div class="caption">
      <div class="left-buttons">
        <my-action-dropdown
          *ngIf="isInSelectionMode()" i18n-label label="Batch actions" theme="orange"
          [actions]="bulkActions" [entry]="selectedRows"
        >
        </my-action-dropdown>

        <a *ngIf="!isInSelectionMode()" class="peertube-create-button" routerLink="/admin/users/create">
          <my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>
          <ng-container i18n>Create user</ng-container>
        </a>
      </div>

      <div class="ms-auto">
        <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>
      </div>

    </div>
  </ng-template>

  <ng-template pTemplate="header">
    <tr>
      <th style="width: 40px">
        <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
      </th>
      <th style="width: 40px"></th>
      <th style="width: 70px;">
        <div class="c-hand column-toggle" ngbDropdown placement="bottom-left auto" container="body" autoClose="outside">
          <my-global-icon iconName="columns" ngbDropdownToggle></my-global-icon>

          <div role="menu" class="dropdown-menu" ngbDropdownMenu>
            <div class="dropdown-header" i18n>Table parameters</div>
            <div ngbDropdownItem class="dropdown-item">
              <my-select-checkbox
                name="columns"
                [availableItems]="columns"
                [selectableGroup]="false" [(ngModel)]="selectedColumns"
                i18n-placeholder placeholder="Select columns"
              >
              </my-select-checkbox>
            </div>
            <div ngbDropdownItem class="dropdown-item">
              <my-peertube-checkbox inputName="highlightBannedUsers" [(ngModel)]="highlightBannedUsers"
                i18n-labelText labelText="Highlight banned users"></my-peertube-checkbox>
            </div>
          </div>
        </div>
      </th>
      <th *ngIf="isSelected('username')" pResizableColumn  pSortableColumn="username">{{ getColumn('username').label }} <p-sortIcon field="username"></p-sortIcon></th>
      <th *ngIf="isSelected('role')" style="width: 120px;"  pSortableColumn="role">{{ getColumn('role').label }} <p-sortIcon field="role"></p-sortIcon></th>
      <th *ngIf="isSelected('email')">{{ getColumn('email').label }}</th>
      <th *ngIf="isSelected('quota')" style="width: 160px;"  pSortableColumn="videoQuotaUsed">{{ getColumn('quota').label }} <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>
      <th *ngIf="isSelected('quotaDaily')" style="width: 160px;">{{ getColumn('quotaDaily').label }}</th>
      <th *ngIf="isSelected('pluginAuth')" style="width: 140px;" pResizableColumn >{{ getColumn('pluginAuth').label }}</th>
      <th *ngIf="isSelected('createdAt')" style="width: 150px;"  pSortableColumn="createdAt">{{ getColumn('createdAt').label }} <p-sortIcon field="createdAt"></p-sortIcon></th>
      <th *ngIf="isSelected('lastLoginDate')" style="width: 150px;"  pSortableColumn="lastLoginDate">{{ getColumn('lastLoginDate').label }} <p-sortIcon field="lastLoginDate"></p-sortIcon></th>
    </tr>
  </ng-template>

  <ng-template pTemplate="body" let-expanded="expanded" let-user>

    <tr [pSelectableRow]="user" [ngClass]="{ banned: highlightBannedUsers && user.blocked }">
      <td class="checkbox-cell">
        <p-tableCheckbox [value]="user" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>
      </td>

      <td class="expand-cell" [ngClass]="{ 'empty-cell': !user.blockedReason }" [pRowToggler]="user">
        <my-table-expander-icon *ngIf="user.blockedReason" [expanded]="expanded"></my-table-expander-icon>
      </td>

      <td class="action-cell">
        <my-user-moderation-dropdown
          *ngIf="!isInSelectionMode()" [user]="user" [account]="user.accountMutedStatus" [displayOptions]="userModerationDisplayOptions"
          container="body" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()">
        </my-user-moderation-dropdown>
      </td>

      <td *ngIf="isSelected('username')" class="cell-username">
        <a i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer" [routerLink]="[ '/a/' + user.username ]">
          <div class="chip two-lines">
            <my-actor-avatar [actor]="user?.account" actorType="account" size="32"></my-actor-avatar>
            <div>
              <span>{{ user.account.displayName }}</span>
              <span class="muted">{{ user.username }}</span>
            </div>
          </div>
        </a>

        <div *ngIf="user.accountMutedStatus.mutedByInstance" class="pt-badge badge-red" i18n>Muted</div>
        <div *ngIf="user.blocked" class="pt-badge badge-red" i18n>Banned</div>
      </td>

      <td *ngIf="isSelected('role')">
        <span *ngIf="user.blocked" class="pt-badge badge-banned" i18n-title title="The user was banned">{{ user.role.label }}</span>
        <span *ngIf="!user.blocked" class="pt-badge" [ngClass]="getRoleClass(user.role.id)">{{ user.role.label }}</span>
      </td>

      <td *ngIf="isSelected('email')">
        <my-user-email-info [entry]="user" [requiresEmailVerification]="requiresEmailVerification"></my-user-email-info>
      </td>

      <td *ngIf="isSelected('quota')">
        <div class="progress" i18n-title title="Total video quota">
          <div class="progress-bar" role="progressbar" [style]="{ width: getUserVideoQuotaPercentage(user) + '%' }"
               [attr.aria-valuenow]="user.rawVideoQuotaUsed" aria-valuemin="0" [attr.aria-valuemax]="user.rawVideoQuota">
          </div>
          <span>{{ user.videoQuotaUsed }}</span>
          <span>{{ user.videoQuota }}</span>
        </div>
      </td>

      <td *ngIf="isSelected('quotaDaily')">
        <div class="progress" i18n-title title="Total daily video quota">
          <div class="progress-bar" role="progressbar" [style]="{ width: getUserVideoQuotaDailyPercentage(user) + '%' }"
               [attr.aria-valuenow]="user.rawVideoQuotaUsedDaily" aria-valuemin="0" [attr.aria-valuemax]="user.rawVideoQuotaDaily">
          </div>
          <span>{{ user.videoQuotaUsedDaily }}</span>
          <span>{{ user.videoQuotaDaily }}</span>
        </div>
      </td>

      <td *ngIf="isSelected('pluginAuth')">
        <span *ngIf="user.pluginAuth" [ngbTooltip]="user.pluginAuth">{{ user.pluginAuth }}</span>
      </td>

      <td *ngIf="isSelected('createdAt')" [title]="user.createdAt">{{ user.createdAt | date: 'short' }}</td>

      <td *ngIf="isSelected('lastLoginDate')" [title]="user.lastLoginDate">{{ user.lastLoginDate | date: 'short' }}</td>
    </tr>
  </ng-template>

  <ng-template pTemplate="rowexpansion" let-user>
    <tr class="user-blocked-reason">
      <td myAutoColspan>
        <span i18n class="ban-reason-label">Ban reason:</span>
        {{ user.blockedReason }}
      </td>
    </tr>
  </ng-template>
</p-table>

<my-user-ban-modal #userBanModal (userBanned)="onUserChanged()"></my-user-ban-modal>