summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalii Lysak <v.lysak@dunice.net>2022-09-01 10:43:25 +0300
committerVitalii Lysak <v.lysak@dunice.net>2022-09-01 10:43:25 +0300
commit53e003b2502a8b01afdd65ff1c3fd2c485419bd5 (patch)
tree192b2e4e27de0c4f9572754a4ab40d0039fcdb51
parentdfc9ebca8098af82994ca6fc8067cc4f8fad5e18 (diff)
downloadwebui-vue-53e003b2502a8b01afdd65ff1c3fd2c485419bd5.tar.xz
SILABMC-259: upd bmc time if server status change
-rw-r--r--src/store/modules/GlobalStore.js54
-rw-r--r--src/store/plugins/WebSocketPlugin.js2
2 files changed, 31 insertions, 25 deletions
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index a2b55db6..72f1c473 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -81,36 +81,42 @@ const GlobalStore = {
},
},
actions: {
- async getBmcTime({ commit, state }) {
+ changeServerStatus({ commit, dispatch }, status) {
+ commit('setServerStatus', status);
+ dispatch('getBmcTime');
+ },
+ initLiveClock({ commit, state }) {
+ if (state.clockInterval) {
+ clearInterval(state.clockInterval);
+ commit('setClockInterval', null);
+ }
+
+ let clockData = state.bmcTime;
+ let clockInterval = setInterval(() => {
+ clockData.setSeconds(clockData.getSeconds() + 1);
+ commit('setLiveBmcTime', clockData.toString());
+
+ let hours = clockData.getHours();
+ let minutes = clockData.getMinutes();
+ let sec = clockData.getSeconds();
+ if (minutes < 10) {
+ minutes = '0' + minutes;
+ }
+ if (sec < 10) {
+ sec = '0' + sec;
+ }
+ commit('setLiveClock', hours + ':' + minutes + ':' + sec);
+ }, 1000);
+ commit('setClockInterval', clockInterval);
+ },
+ async getBmcTime({ commit, dispatch }) {
return await api
.get('/redfish/v1/Managers/bmc')
.then((response) => {
const bmcDateTime = response.data.DateTime;
const date = new Date(bmcDateTime);
commit('setBmcTime', date);
-
- if (state.clockInterval) {
- clearInterval(state.clockInterval);
- commit('setClockInterval', null);
- }
-
- let clockData = date;
- let clockInterval = setInterval(() => {
- clockData.setSeconds(clockData.getSeconds() + 1);
- commit('setLiveBmcTime', clockData.toString());
-
- let hours = clockData.getHours();
- let minutes = clockData.getMinutes();
- let sec = clockData.getSeconds();
- if (minutes < 10) {
- minutes = '0' + minutes;
- }
- if (sec < 10) {
- sec = '0' + sec;
- }
- commit('setLiveClock', hours + ':' + minutes + ':' + sec);
- }, 1000);
- commit('setClockInterval', clockInterval);
+ dispatch('initLiveClock');
})
.catch((error) => console.log(error));
},
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js
index afad6718..29a98c20 100644
--- a/src/store/plugins/WebSocketPlugin.js
+++ b/src/store/plugins/WebSocketPlugin.js
@@ -39,7 +39,7 @@ const WebSocketPlugin = (store) => {
if (eventInterface === 'xyz.openbmc_project.State.Host') {
const { properties: { CurrentHostState } = {} } = data;
if (CurrentHostState) {
- store.commit('global/setServerStatus', CurrentHostState);
+ store.dispatch('global/changeServerStatus', CurrentHostState);
}
} else if (path === '/xyz/openbmc_project/logging') {
store.dispatch('eventLog/getEventLogData');