<template>
  <b-table
    responsive="md"
    show-empty
    no-border-collapse
    :items="accelerators"
    :fields="fields"
  >
    <template #cell(expandRow)="">
      <b-button
        variant="link"
        data-test-id="hardwareStatus-button-expandAccelerators"
        :title="expandRowLabel"
      >
        <icon-chevron />
        <span class="sr-only">{{ expandRowLabel }}</span>
      </b-button>
    </template>
    <template #cell(status)="{ value }">
      <div v-if="value" class="fans-table-col-first__cell">
        <img class="status__img" src="@/assets/images/status/on.svg" />
        <span>
          {{ $t('global.status.inWork') }}
        </span>
      </div>
      <div v-else class="fans-table-col-first__cell">
        <img class="status__img" src="@/assets/images/_sila/status/off.svg" />
        <span>
          {{ $t('global.status.outWorking') }}
        </span>
      </div>
    </template>
  </b-table>
</template>

<script>
import TableRowExpandMixin, {
  expandRowLabel,
} from '@/components/Mixins/TableRowExpandMixin';
import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';

import { Accelerators } from './helpers';
export default {
  components: { IconChevron },
  mixins: [BVToastMixin, TableRowExpandMixin, DataFormatterMixin],
  data() {
    return {
      isBusy: true,
      isAddersСolon: false,
      accelerators: Accelerators,
      fields: [
        {
          key: 'expandRow',
          label: '',
          thStyle: { width: '3%' },
          sortable: false,
        },
        {
          key: 'status',
          label: 'Статус',
          formatter: this.dataFormatter,
          thStyle: { width: '15%' },
        },
        {
          key: 'name',
          label: 'Имя',
          formatter: this.dataFormatter,
          thStyle: { width: '10%' },
        },
        {
          key: 'slot_number',
          label: '№ Слота',
          formatter: this.dataFormatter,
          thStyle: { width: '8%' },
        },
        {
          key: 'board_number',
          label: '№ Платы',
          formatter: this.dataFormatter,
          thStyle: { width: '8%' },
        },
        {
          key: 'serial_number',
          label: 'Серийный номер',
          formatter: this.dataFormatter,
          thStyle: { width: '15%' },
        },
        {
          key: 'frequency',
          label: '№ Детали',
          formatter: this.dataFormatter,
          thStyle: { width: '8%' },
        },
        {
          key: 'cores',
          label: 'Версия прошивки',
          formatter: this.dataFormatter,
          thStyle: { width: '10%' },
        },
      ],
      expandRowLabel: expandRowLabel,
    };
  },
};
</script>
<style lang="scss" scoped>
.row {
  margin: 0px;
  flex-wrap: nowrap;
}
.fans-table-col-first__cell {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: flex-start;
}

.status__img {
  margin-right: 7px;
}

.bold-16px {
  margin: 24px 0 0 2rem;
}

.bold-12px__caps {
  color: $text-secondary;
}

.attrib-names {
  border-bottom: 1px solid $faint-secondary-primary-10;
  color: $text-secondary !important;
  font-weight: 600;
}

.custom-switch {
  margin: 0;
}

.btn-link {
  width: 30px !important;
  height: 20px !important;
}
</style>
