diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2019-12-04 01:47:32 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2020-01-23 01:32:22 +0300 |
commit | b8b6f7914f9371fc386fd5b4ea2e4b7a89892730 (patch) | |
tree | b65092ebc2155ff62929a78bb7070cfea528c3c0 /src/store/modules | |
parent | 013964e3da0fd260cff551e4281a202602ea518a (diff) | |
download | webui-vue-b8b6f7914f9371fc386fd5b4ea2e4b7a89892730.tar.xz |
Add GlobalStore module
Create a GlobalStore to store global variables,
including data in app header.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Signed-off-by: Derick Montague <derick.montague@ibm.com>
Change-Id: Id498dec3925feec9a7e31ede91328f89ae591a0b
Diffstat (limited to 'src/store/modules')
-rw-r--r-- | src/store/modules/GlobalStore.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js new file mode 100644 index 00000000..332c8017 --- /dev/null +++ b/src/store/modules/GlobalStore.js @@ -0,0 +1,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; |