summaryrefslogtreecommitdiff
path: root/src/store/modules/GlobalStore.js
blob: 332c801766c90cd20955e4652f7098ce7cb3b433 (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
import api from "../api";

const GlobalStore = {
  namespaced: true,
  state: {
    hostName: "--",
    hostStatus: null
  },
  getters: {
    hostName(state) {
      return state.hostName;
    },
    hostStatus(state) {
      return state.hostStatus;
    }
  },
  mutations: {
    setHostName(state, hostName) {
      state.hostName = hostName;
    }
  },
  actions: {
    getHostName({ commit }) {
      api
        .get("/xyz/openbmc_project/network/config/attr/HostName")
        .then(response => {
          const hostName = response.data.data;
          commit("setHostName", hostName);
        })
        .catch(error => console.log(error));
    }
  }
};

export default GlobalStore;