<template>
  <b-container fluid="xl">
    <page-title :description="$t('appPageTitle.dynamicInformation')" />

    <chart
      type="motherboard"
      :data="filteredSensors"
      :warning="temperatureWarning"
      :non-normal="temperatureNonNormal"
      :critical-start="temperatureCriticalStart"
    ></chart>
  </b-container>
</template>

<script>
import PageTitle from '@/components/_sila/Global/PageTitle';
import Chart from '@/components/_sila/Global/Chart';

import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin';
import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin';

export default {
  components: { PageTitle, Chart },
  mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin],
  data() {
    return {
      activeFilters: [],
      temperatureWarning: 72,
      temperatureNonNormal: 44,
      temperatureCriticalStart: 55,
    };
  },

  computed: {
    allSensors() {
      let sensors = this.$store.getters['motherboard/motherboard'];
      return sensors;
    },

    filteredSensors() {
      return this.getFilteredTableData(this.allSensors, this.activeFilters);
    },
  },

  created() {
    this.startLoader();
    this.$store.dispatch('motherboard/getMotherboardDynamic').finally(() => {
      this.endLoader();
    });
  },
};
</script>
