<clr-datagrid (clrDgRefresh)="refresh($event)">
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="{hidden: true}">
      ID
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'user.name'" *ngIf="listType === 'app'">
    <ng-container *clrDgHideableColumn="showState['user_name']">
      {{'USER.NAME' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'app.name'" *ngIf="listType === 'user'">
    <ng-container *clrDgHideableColumn="showState['app_name']">
      {{'USER.APP_NAME' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['group']">
      {{'USER.GROUP' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['create_time']">
      {{'TITLE.CREATE_TIME' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column
    *ngIf="
      authService.currentNamespacePermission.appUser.update ||
      authService.currentAppPermission.appUser.update ||
      authService.currentNamespacePermission.appUser.delete ||
      authService.currentAppPermission.appUser.delete ||
      authService.currentUser.admin"
  >
    <ng-container *clrDgHideableColumn="showState['action']">
      {{'TITLE.ACTION' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-row *ngFor="let appUser of appUsers" [clrDgItem]="appUser">
    <clr-dg-cell>{{appUser.id}}</clr-dg-cell>
    <clr-dg-cell *ngIf="listType === 'app'" class="copy">{{appUser.user.name}}</clr-dg-cell>
    <clr-dg-cell *ngIf="listType === 'user'" class="copy">{{appUser.app.name}}</clr-dg-cell>
    <clr-dg-cell>{{appUser.groupsName}}</clr-dg-cell>
    <clr-dg-cell>{{appUser.createTime | date:'yyyy-MM-dd HH:mm'}}</clr-dg-cell>
    <clr-dg-cell
      *ngIf="
      authService.currentNamespacePermission.appUser.update ||
      authService.currentAppPermission.appUser.update ||
      authService.currentNamespacePermission.appUser.delete ||
      authService.currentAppPermission.appUser.delete ||
      authService.currentUser.admin"
    >
      <button class="wayne-button text"
              *ngIf="
        authService.currentNamespacePermission.appUser.update ||
        authService.currentAppPermission.appUser.update ||
        authService.currentUser.admin"
              (click)="editAppUser(appUser)">
        {{'BUTTON.EDIT' | translate}}
      </button>
      <button class="wayne-button text"
              *ngIf="
        authService.currentNamespacePermission.appUser.delete ||
        authService.currentAppPermission.appUser.delete ||
        authService.currentUser.admin"
              (click)="deleteAppUser(appUser)">
        {{'BUTTON.DELETE' | translate}}</button>
    </clr-dg-cell>
  </clr-dg-row>

  <clr-dg-footer>
    <wayne-paginate
      [(currentPage)]="currentPage"
      [total]="page.totalCount"
      [pageSizes]="[10, 20, 50]"
      (sizeChange)="pageSizeChange($event)"
    >
    </wayne-paginate>
  </clr-dg-footer>
</clr-datagrid>
