<template>
  <page-section class="bootstrap-table__section">
    <b-table
      responsive="md"
      show-empty
      class="bootstrap-rounded-table"
      :items="systems"
      :fields="fields"
      :empty-text="$t('global.table.emptyMessage')"
    >
    </b-table>
  </page-section>
</template>

<script>
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import PageSection from '@/components/Global/PageSection';

import TableRowExpandMixin, {
  expandRowLabel,
} from '@/components/Mixins/TableRowExpandMixin';

export default {
  components: { PageSection },
  mixins: [BVToastMixin, TableRowExpandMixin],
  data() {
    return {
      fields: [
        {
          key: 'param',
          label: 'Параметр',
          formatter: this.dataFormatter,
          thClass: 'semi-bold-12px__caps bootstrap-rounded-table__head_bg',
          class: `bootstrap-rounded-table__column-first
            bootstrap-rounded-table__column-first___system-table`,
          tdClass: 'regular-12px bootstrap-rounded-table__td',
        },
        {
          key: 'value',
          label: 'Значение',
          formatter: this.dataFormatter,
          thClass: 'semi-bold-12px__caps bootstrap-rounded-table__head_bg',
          class: 'bootstrap-rounded-table__column-last',
          tdClass: 'regular-12px bootstrap-rounded-table__td',
        },
      ],
      expandRowLabel: expandRowLabel,
      systems: [
        {
          param: 'UUID сервера',
          value: '17583',
        },
        { param: 'Модель', value: '1.214.248 beta' },
        { param: 'Производитель', value: 'Asus' },
        { param: 'Операционная система', value: 'Linux' },
        { param: 'Серийный номер', value: '741852963335' },
        {
          param: 'Свободное место на Flash-накопителе',
          value: '1 024 000 Мб',
        },
      ],
    };
  },
  created() {
    this.$store.dispatch('system/getSystem').finally(() => {
      // Emit initial data fetch complete to parent component
      this.$root.$emit('hardware-status-system-complete');
      this.isBusy = false;
    });
  },
  methods: {
    toggleIdentifyLedSwitch(state) {
      this.$store
        .dispatch('system/changeIdentifyLedState', state)
        .catch(({ message }) => this.errorToast(message));
    },
  },
};
</script>
<style lang="scss">
.bootstrap-rounded-table__column-first___system-table {
  width: 50%;
}
</style>
