summaryrefslogtreecommitdiff
path: root/src/views/_sila/Power/Dynamic/PowerDynamicPage.vue
blob: 6a3c3433b774046e969a73565fe1b0ec696b9b10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
  <b-container fluid="xl">
    <page-title :description="$t('appPageTitle.dynamicInformation')" />
    <table-date-picker
      :class="{ disabledDiv: loading }"
      :time-scale="timeScale"
      @changePeriod="onChangePeriod"
    />
    <power-temp :time-scale="timeScale"></power-temp>
    <volt-input :time-scale="timeScale"></volt-input>
    <volt-output :time-scale="timeScale"></volt-output>
    <power-input :time-scale="timeScale"></power-input>
    <power-output :time-scale="timeScale"></power-output>
    <current-input :time-scale="timeScale"></current-input>
    <current-output :time-scale="timeScale"></current-output>
  </b-container>
</template>
<script>
import PageTitle from '@/components/_sila/Global/PageTitle';

import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
import TableDatePicker from '@/components/_sila/Global/TableDatePicker';
import LoadingBarMixin, {
  loading,
} from '@/components/_sila/Mixins/LoadingBarMixin';
import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin';

import PowerTemp from './PowerTemp';
import VoltInput from './VoltInput';
import VoltOutput from './VoltOutput';
import PowerInput from './PowerInput';
import PowerOutput from './PowerOutput';
import CurrentInput from './CurrentInput';
import CurrentOutput from './CurrentOutput';

export default {
  components: {
    PowerTemp,
    VoltInput,
    VoltOutput,
    PowerInput,
    PowerOutput,
    CurrentInput,
    CurrentOutput,
    PageTitle,
    TableDatePicker,
  },
  mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin],
  data() {
    return {
      loading,
      timeScale: 'hour',
    };
  },

  created() {
    this.startProgress();
  },
  methods: {
    resetZoom() {
      const resetButton = document.querySelector('.highcharts-reset-zoom');
      if (!resetButton) {
        return;
      }

      resetButton.dispatchEvent(new Event('click'));
    },

    onChangePeriod(period) {
      this.timeScale = period;
      this.startProgress();
      this.resetZoom();
    },
    startProgress() {
      this.startLoader();
      this.$root.$on('psu-temp', (loading) => this.onLoading(loading));
      this.$root.$on('psu-volt-input', (loading) => this.onLoading(loading));
      this.$root.$on('psu-volt-output', (loading) => this.onLoading(loading));
      this.$root.$on('psu-power-input', (loading) => this.onLoading(loading));
      this.$root.$on('psu-power-output', (loading) => this.onLoading(loading));
      this.$root.$on('psu-current-input', (loading) => this.onLoading(loading));
      this.$root.$on('psu-current-output', (loading) =>
        this.onLoading(loading)
      );
    },
    onLoading(loading) {
      loading ? this.startLoader() : this.endLoader();
    },
  },
};
</script>