<nz-divider></nz-divider>
<nz-breadcrumb>
  <nz-breadcrumb-item>
    <a [routerLink]="['/']">
      <i nz-icon nzType="home"></i>
      <span>仪表盘</span>
    </a>
  </nz-breadcrumb-item>
  <nz-breadcrumb-item>
    <i nz-icon nzType="alert"></i>
    <span>告警中心</span>
  </nz-breadcrumb-item>
</nz-breadcrumb>
<nz-divider></nz-divider>

<div>
  <button nz-button nzType="primary" (click)="onDeleteAlerts()">
    <i nz-icon nzType="delete" nzTheme="outline"></i>
    删除告警
  </button>
  <button nz-button nzType="primary" (click)="onMarkReadAlerts()">
    <i nz-icon nzType="down-circle" nzTheme="outline"></i>
    标记已处理
  </button>
  <button nz-button nzType="primary" (click)="onMarkUnReadAlerts()">
    <i nz-icon nzType="up-circle" nzTheme="outline"></i>
    标记未处理
  </button>
  <button nz-button nzType="primary" (click)="sync()" nz-tooltip nzTooltipTitle="刷新">
    <i nz-icon nzType="sync" nzTheme="outline"></i>
  </button>

  <button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchAlerts()"> 搜索 </button>
  <input
    style="margin-right: 5px; float: right; width: 150px; border-radius: 9px; text-align: center"
    nz-input
    type="text"
    placeholder="搜索告警内容"
    nzSize="default"
    [(ngModel)]="filterContent"
  />
  <nz-select
    style="margin-right: 10px; float: right; width: 120px"
    nzAllowClear
    [nzPlaceHolder]="'告警状态过滤'"
    [(ngModel)]="filterStatus"
  >
    <nz-option nzLabel="全部状态" nzValue="9"></nz-option>
    <nz-option nzLabel="未处理" nzValue="0"></nz-option>
    <nz-option nzLabel="已处理" nzValue="3"></nz-option>
  </nz-select>
  <nz-select
    style="margin-right: 10px; float: right; width: 120px"
    nzAllowClear
    [nzPlaceHolder]="'告警级别过滤'"
    [(ngModel)]="filterPriority"
  >
    <nz-option nzLabel="全部级别" nzValue="9"></nz-option>
    <nz-option nzLabel="警告级别" nzValue="2"></nz-option>
    <nz-option nzLabel="严重级别" nzValue="1"></nz-option>
    <nz-option nzLabel="紧急级别" nzValue="0"></nz-option>
  </nz-select>
</div>

<nz-table
  #fixedTable
  [nzData]="alerts"
  [nzPageIndex]="pageIndex"
  [nzPageSize]="pageSize"
  [nzTotal]="total"
  nzFrontPagination="false"
  [nzLoading]="tableLoading"
  nzShowSizeChanger
  [nzShowTotal]="rangeTemplate"
  [nzPageSizeOptions]="[8, 15, 25]"
  (nzQueryParams)="onTablePageChange($event)"
  nzShowPagination="true"
  [nzScroll]="{ x: '1150px', y: '1240px' }"
>
  <thead>
    <tr>
      <th nzAlign="center" nzLeft nzWidth="4%" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
      <th nzAlign="center" nzLeft>告警指标</th>
      <th nzAlign="center">所属监控</th>
      <th nzAlign="center">级别</th>
      <th nzAlign="center">告警内容</th>
      <th nzAlign="center">状态</th>
      <th nzAlign="center">告警时间</th>
      <th nzAlign="center">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of fixedTable.data" [ngStyle]="{ 'background-color': data.status === 0 ? '#E1E7A89B' : 'inherit' }">
      <td nzAlign="center" nzLeft [nzChecked]="checkedAlertIds.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td>
      <td nzAlign="center" nzLeft>{{ data.target }}</td>
      <td nzAlign="center">
        <a [routerLink]="['/monitors/' + data.monitorId]">
          <span>{{ data.monitorName }}</span>
        </a>
      </td>
      <td nzAlign="center">
        <nz-tag *ngIf="data.priority == 0" nzColor="red">
          <i nz-icon nzType="bell" nzTheme="outline"></i>
          <span>紧急告警</span>
        </nz-tag>
        <nz-tag *ngIf="data.priority == 1" nzColor="orange">
          <i nz-icon nzType="bell" nzTheme="outline"></i>
          <span>严重告警</span>
        </nz-tag>
        <nz-tag *ngIf="data.priority == 2" nzColor="yellow">
          <i nz-icon nzType="bell" nzTheme="outline"></i>
          <span>警告告警</span>
        </nz-tag>
      </td>
      <td nzAlign="center">{{ data.content }}</td>
      <td nzAlign="center">
        {{ data.status === 0 ? '未处理' : '已处理' }}
      </td>
      <td nzAlign="center">{{ data.gmtCreate }}</td>
      <td nzAlign="center">
        <button nz-button nzType="primary" (click)="onDeleteOneAlert(data.id)" nz-tooltip nzTooltipTitle="删除告警">
          <i nz-icon nzType="delete" nzTheme="outline"></i>
        </button>
        <button nz-button nzType="primary" (click)="onMarkReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记已处理">
          <i nz-icon nzType="down-circle" nzTheme="outline"></i>
        </button>
        <button nz-button nzType="primary" (click)="onMarkUnReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记未处理">
          <i nz-icon nzType="up-circle" nzTheme="outline"></i>
        </button>
      </td>
    </tr>
  </tbody>
</nz-table>

<ng-template #rangeTemplate> 总量 {{ total }} </ng-template>
