Add host status plugin

- Create WebSocket and get host state changes from server
- Changed webpack devServer to https to allow for
  secure WebSocket creation (wss)
- Updates to AppHeader to visually indicate changes
  in host state
- Cleaned up api.js file
- Check if user is logged in when creating WebSocket
- Adds check if user is already authenticated so WebSocket
  is created when browser refreshed.
- Add appliation header styles
- Add sass loader config changes to allow sass variables to
  be used in single file components

URL must use https protocol when running locally or the page
will not load.

Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Signed-off-by: Derick Montague <derick.montague@ibm.com>
Change-Id: I35e89bdc09e1aa35a6215ef952409a8ed16dd9e1
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index 8cf2e8e..80d9c1a 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -1,10 +1,31 @@
 import api from '../api';
 
+const HOST_STATE = {
+  on: 'xyz.openbmc_project.State.Host.HostState.Running',
+  off: 'xyz.openbmc_project.State.Host.HostState.Off',
+  error: 'xyz.openbmc_project.State.Host.HostState.Quiesced',
+  diagnosticMode: 'xyz.openbmc_project.State.Host.HostState.DiagnosticMode'
+};
+
+const hostStateMapper = hostState => {
+  switch (hostState) {
+    case HOST_STATE.on:
+      return 'on';
+    case HOST_STATE.off:
+      return 'off';
+    case HOST_STATE.error:
+      return 'error';
+    // TODO: Add mapping for DiagnosticMode
+    default:
+      return 'unreachable';
+  }
+};
+
 const GlobalStore = {
   namespaced: true,
   state: {
     hostName: '--',
-    hostStatus: null
+    hostStatus: 'unreachable'
   },
   getters: {
     hostName(state) {
@@ -17,6 +38,9 @@
   mutations: {
     setHostName(state, hostName) {
       state.hostName = hostName;
+    },
+    setHostStatus(state, hostState) {
+      state.hostStatus = hostStateMapper(hostState);
     }
   },
   actions: {
@@ -28,6 +52,15 @@
           commit('setHostName', hostName);
         })
         .catch(error => console.log(error));
+    },
+    getHostStatus({ commit }) {
+      api
+        .get('/xyz/openbmc_project/state/host0/attr/CurrentHostState')
+        .then(response => {
+          const hostState = response.data.data;
+          commit('setHostStatus', hostState);
+        })
+        .catch(error => console.log(error));
     }
   }
 };