<clr-datagrid (clrDgRefresh)="refresh($event)" [(clrDgSelected)]="selectedTemplate" class="wayne-clr-datagrid">
  <clr-dg-placeholder>暂无数据！</clr-dg-placeholder>
  <clr-dg-column class="col-id" [clrDgSortBy]="'id'">
    <ng-container>
      #
    </ng-container>
  </clr-dg-column>
  <clr-dg-column class="col-time" [clrDgSortBy]="'createTime'">
    <ng-container *clrDgHideableColumn="showState['创建时间']">
      创建时间
    </ng-container>
  </clr-dg-column>
  <clr-dg-column class="col-cluster">
    <ng-container *clrDgHideableColumn="showState['上线机房']">
      上线机房
    </ng-container>
  </clr-dg-column>
  <clr-dg-column class="col-description">
    <ng-container *clrDgHideableColumn="showState['发布说明']">
      发布说明
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['创建者']">
      创建者
    </ng-container>
  </clr-dg-column>
  <clr-dg-column class="col-operate">
    <ng-container *clrDgHideableColumn="showState['操作']">
      操作
    </ng-container>
  </clr-dg-column>
  <clr-dg-row *ngFor="let template of templates" [clrDgItem]="template">
    <clr-dg-cell class="col-id">{{template.id}}</clr-dg-cell>
    <clr-dg-cell class="col-time">{{template.createTime | date:'yyyy-MM-dd HH:mm:ss'}}</clr-dg-cell>
    <clr-dg-cell class="col-cluster" >
      <div class="form-group" style="padding-bottom: 2px"
           *ngFor="let status of template.status">
        <a href="javascript:void(0)" (click)="showResourceState(status,template)" title="查看 ingress 状态" class="label"
           [class.clickable]="status.state!=2"
           [class.label-success]="status.state==0"
           [class.label-warning]="status.state==1">
          {{status.cluster}}
        </a>
      </div>
    </clr-dg-cell>
    <clr-dg-cell class="col-description">{{template.description}}</clr-dg-cell>
    <clr-dg-cell class="col-user">{{template.user}}</clr-dg-cell>
    <clr-dg-cell class="col-operate">
      <button class="wayne-button text"
              (click)="onPublishResourceTemplate(template)"
              *ngIf="authService.currentAppPermission.ingress.deploy || authService.currentUser.admin">
        发布</button>
      <button class="wayne-button text"
              (click)="onViewTemplate(template)"
              *ngIf="authService.currentAppPermission.ingress.read || authService.currentUser.admin">
        详情</button>
      <button class="wayne-button text"
              (click)="oncloneTemplate(template)"
              *ngIf="authService.currentAppPermission.ingress.create || authService.currentUser.admin">
        克隆</button>
      <button class="wayne-button text"
              *ngIf="!template.status && (authService.currentAppPermission.ingress.delete || authService.currentUser.admin)"
              (click)="onDeleteTemplate('删除 Ingress 模版确认', '你确认删除 Ingress 模版', template)">
        删除</button>
      <button class="wayne-button text"
              (click)="onOfflineResourceTemplate(template)"
              *ngIf="template.status && (authService.currentAppPermission.ingress.offline || authService.currentUser.admin)">
        下线</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>
<wayne-ace-editor></wayne-ace-editor>
<publish-tpl [appId]="appId" (published)="onPublishEvent($event)"></publish-tpl>
<status></status>

