summaryrefslogtreecommitdiff
path: root/src/store/plugins/WebSocketPlugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/plugins/WebSocketPlugin.js')
-rw-r--r--src/store/plugins/WebSocketPlugin.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js
index 3e2139dd..409b1686 100644
--- a/src/store/plugins/WebSocketPlugin.js
+++ b/src/store/plugins/WebSocketPlugin.js
@@ -2,16 +2,19 @@
* WebSocketPlugin will allow us to get new data from the server
* without having to poll for changes on the frontend.
*
- * This plugin is subscribed to host state property changes, which
- * is indicated in the app header Power status.
+ * This plugin is subscribed to host state property and logging
+ * changes, indicated in the app header Health and Power status.
*
* https://github.com/openbmc/docs/blob/b41aff0fabe137cdb0cfff584b5fe4a41c0c8e77/rest-api.md#event-subscription-protocol
*/
const WebSocketPlugin = store => {
let ws;
const data = {
- paths: ['/xyz/openbmc_project/state/host0'],
- interfaces: ['xyz.openbmc_project.State.Host']
+ paths: ['/xyz/openbmc_project/state/host0', '/xyz/openbmc_project/logging'],
+ interfaces: [
+ 'xyz.openbmc_project.State.Host',
+ 'xyz.openbmc_project.Logging.Entry'
+ ]
};
const initWebSocket = () => {
@@ -23,11 +26,21 @@ const WebSocketPlugin = store => {
console.error(event);
};
ws.onmessage = event => {
- const {
- properties: { CurrentHostState, RequestedHostTransition } = {}
- } = JSON.parse(event.data);
- const hostState = CurrentHostState || RequestedHostTransition;
- store.commit('global/setHostStatus', hostState);
+ const data = JSON.parse(event.data);
+ const eventInterface = data.interface;
+
+ if (eventInterface === 'xyz.openbmc_project.State.Host') {
+ const { properties: { CurrentHostState } = {} } = data;
+ store.commit('global/setHostStatus', CurrentHostState);
+ } else {
+ const { interfaces, event } = data;
+ if (event === 'InterfacesAdded' && interfaces) {
+ // Checking for 'InterfacesAdded' events
+ // since they have all properties needed to
+ // change health status
+ store.dispatch('eventLog/checkHealth', interfaces);
+ }
+ }
};
};