<div class="header">
  <div class="peertube-select-container">
    <select [(ngModel)]="logType" (ngModelChange)="refresh()" class="form-control">
      <option *ngFor="let logTypeChoice of logTypeChoices" [value]="logTypeChoice.id">{{ logTypeChoice.label }}</option>
    </select>
  </div>

  <ng-select
    [(ngModel)]="startDate"
    (ngModelChange)="refresh()"
    [clearable]="false"
    [searchable]="false"
  >
    <ng-option *ngFor="let time of timeChoices" [value]="time.id">
      {{ time.label }} ({{ time.id | date: time.dateFormat }} - <span i18n>now</span>)
    </ng-option>
  </ng-select>

  <ng-select
    [(ngModel)]="level"
    (ngModelChange)="refresh()"
    [clearable]="false"
    [searchable]="false"
    *ngIf="!isAuditLog()"
  >
    <ng-option *ngFor="let levelChoice of levelChoices" [value]="levelChoice.id">
      <span class="level-choice" [ngClass]="levelChoice.id">&#11044;</span> {{ levelChoice.label }}
    </ng-option>
  </ng-select>

  <my-select-tags *ngIf="!isAuditLog()" i18n-placeholder placeholder="Filter logs by tags" [(ngModel)]="tagsOneOf" (ngModelChange)="refresh()"></my-select-tags>

  <my-button i18n-label label="Refresh" icon="refresh" (click)="refresh()"></my-button>
</div>

<div class="logs">
  <div *ngIf="loading" i18n>Loading...</div>

  <div #logsElement>
    <div *ngIf="!loading && logs.length === 0" i18n>No log.</div>

    <div *ngFor="let log of logs" class="log-row" [ngClass]="{ error: log.level === 'error', warn: log.level === 'warn' }">
      <span class="log-level">{{ log.level }}</span>

      <span class="log-date">[{{ log.localeDate }}]</span>

      <strong class="log-by" *ngIf="log.by" i18n>By {{ log.by }} -></strong>
      <strong class="log-domain-action" *ngIf="log.domain">{{ log.domain }} -> {{ log.action }}</strong>

      {{ log.message }}

      <pre>{{ log.meta }}</pre>
    </div>
  </div>
</div>
