Yoshie Muranaka | b8b6f79 | 2019-12-03 14:47:32 -0800 | [diff] [blame^] | 1 | import api from "../api"; |
| 2 | |
| 3 | const GlobalStore = { |
| 4 | namespaced: true, |
| 5 | state: { |
| 6 | hostName: "--", |
| 7 | hostStatus: null |
| 8 | }, |
| 9 | getters: { |
| 10 | hostName(state) { |
| 11 | return state.hostName; |
| 12 | }, |
| 13 | hostStatus(state) { |
| 14 | return state.hostStatus; |
| 15 | } |
| 16 | }, |
| 17 | mutations: { |
| 18 | setHostName(state, hostName) { |
| 19 | state.hostName = hostName; |
| 20 | } |
| 21 | }, |
| 22 | actions: { |
| 23 | getHostName({ commit }) { |
| 24 | api |
| 25 | .get("/xyz/openbmc_project/network/config/attr/HostName") |
| 26 | .then(response => { |
| 27 | const hostName = response.data.data; |
| 28 | commit("setHostName", hostName); |
| 29 | }) |
| 30 | .catch(error => console.log(error)); |
| 31 | } |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | export default GlobalStore; |