<clr-datagrid (clrDgRefresh)="refresh($event)">
  <clr-dg-column>
    <ng-container>
      ID
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'name'">
    <ng-container *clrDgHideableColumn="showState['name']">
      {{'TITLE.NAME' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['url']">
      URL
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['start_status']">
      {{'TITLE.START_STATUS' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'user'">
    <ng-container *clrDgHideableColumn="showState['create_user']">
      {{'TITLE.CREATE_USER' | 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.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
  >
    <ng-container *clrDgHideableColumn="showState['action']">
      {{'TITLE.ACTION' | translate}}
    </ng-container>
  </clr-dg-column>
  <clr-dg-row *ngFor="let webHook of webHooks; let i = index" [clrDgItem]="webHook">
    <clr-dg-cell>{{webHook.id}}</clr-dg-cell>
    <clr-dg-cell class="copy">{{webHook.name}}</clr-dg-cell>
    <clr-dg-cell>{{webHook.url}}</clr-dg-cell>
    <clr-dg-cell>
      <div class="toggle-switch">
        <input
          type="checkbox"
          id="webhook-toggle-{{i}}"
          (change)="toggleWebhook(webHook)"
          [checked]="webHook.enabled"
        >
        <label for="webhook-toggle-{{i}}"></label>
      </div>
    </clr-dg-cell>
    <clr-dg-cell>{{webHook.user}}</clr-dg-cell>
    <clr-dg-cell>{{webHook.createTime | date:"yyyy-MM-dd HH:mm"}}</clr-dg-cell>
    <clr-dg-cell
      *ngIf="
      authService.currentNamespacePermission.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
    >
      <button class="wayne-button text"
              *ngIf="authService.currentNamespacePermission.webHook.update ||
        authService.currentAppPermission.webHook.update ||
        authService.currentUser.admin"
              (click)="editWebhook(webHook)">
        {{'BUTTON.EDIT' | translate}}
      </button>
      <button class="wayne-button text"
              *ngIf="authService.currentNamespacePermission.webHook.delete ||
          authService.currentAppPermission.webHook.delete ||
          authService.currentUser.admin"
              (click)="deleteWebhook(webHook)">
        {{'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>
