summaryrefslogtreecommitdiff
path: root/src/store/modules/HardwareStatus/MotherboardStore.js
blob: 09f2449818faba0792f5d5eb78e2de2764b811ff (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
import api from '@/store/api';

const MotherboardStore = {
  namespaced: true,
  state: {
    motherboard: [],
    motherboardLastHour: [],
  },
  getters: {
    motherboard: (state) => state.motherboard,
    motherboardLastHour: (state) => state.motherboardLastHour,
  },
  mutations: {
    setMotherboardDynamic: (state, data) => {
      state.motherboard = data;
    },
    setMotherboardDynamicLastHour: (state, data) => {
      state.motherboardLastHour = data;
    },
  },
  actions: {
    async getMotherboardDynamic({ commit }, { lastHour }) {
      let url = null;
      if (lastHour) {
        url =
          '/redfish/v1/TelemetryService/MetricReports/other_temp&period=last_hour';
      } else {
        url = '/redfish/v1/TelemetryService/MetricReports/other_temp';
      }
      return await api
        .get(url)
        .then(({ data: { MetricValues = [] } }) => {
          if (lastHour) {
            commit('setMotherboardDynamicLastHour', MetricValues);
          } else {
            commit('setMotherboardDynamic', MetricValues);
          }
        })
        .catch((error) => console.log(error));
    },
  },
};

export default MotherboardStore;