summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorVitalii Lysak <v.lysak@dunice.net>2022-08-31 14:47:02 +0300
committerVitalii Lysak <v.lysak@dunice.net>2022-08-31 14:47:02 +0300
commit9123716b55d809bf8d1cc4727b3b10c127b405a0 (patch)
tree1aaab637d3c1cd9fd47f5a093c53e62bdb479b62 /src/store
parenta7830e9bfb3e0d3988765301f84945328dc51434 (diff)
downloadwebui-vue-9123716b55d809bf8d1cc4727b3b10c127b405a0.tar.xz
SILABMC-259: add live time from bmc
Diffstat (limited to 'src/store')
-rw-r--r--src/store/modules/GlobalStore.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index 39eb597e..a2b55db6 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -31,6 +31,9 @@ const GlobalStore = {
state: {
assetTag: null,
bmcTime: null,
+ liveBmcTime: null,
+ liveClock: null,
+ clockInterval: null,
modelType: null,
serialNumber: null,
serverStatus: 'unreachable',
@@ -47,6 +50,8 @@ const GlobalStore = {
serialNumber: (state) => state.serialNumber,
serverStatus: (state) => state.serverStatus,
bmcTime: (state) => state.bmcTime,
+ liveBmcTime: (state) => state.liveBmcTime,
+ liveClock: (state) => state.liveClock,
languagePreference: (state) => state.languagePreference,
isUtcDisplay: (state) => state.isUtcDisplay,
username: (state) => state.username,
@@ -58,6 +63,10 @@ const GlobalStore = {
setSerialNumber: (state, serialNumber) =>
(state.serialNumber = serialNumber),
setBmcTime: (state, bmcTime) => (state.bmcTime = bmcTime),
+ setLiveBmcTime: (state, liveBmcTime) => (state.liveBmcTime = liveBmcTime),
+ setLiveClock: (state, liveClock) => (state.liveClock = liveClock),
+ setClockInterval: (state, clockInterval) =>
+ (state.clockInterval = clockInterval),
setServerStatus: (state, serverState) =>
(state.serverStatus = serverStateMapper(serverState)),
setLanguagePreference: (state, language) =>
@@ -72,13 +81,36 @@ const GlobalStore = {
},
},
actions: {
- async getBmcTime({ commit }) {
+ async getBmcTime({ commit, state }) {
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);
})
.catch((error) => console.log(error));
},