summaryrefslogtreecommitdiff
path: root/src
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
parenta7830e9bfb3e0d3988765301f84945328dc51434 (diff)
downloadwebui-vue-9123716b55d809bf8d1cc4727b3b10c127b405a0.tar.xz
SILABMC-259: add live time from bmc
Diffstat (limited to 'src')
-rw-r--r--src/components/_sila/AppHeader/AppHeader.vue12
-rw-r--r--src/store/modules/GlobalStore.js34
-rw-r--r--src/views/_sila/Overview/OverviewQuickLinks.vue11
3 files changed, 46 insertions, 11 deletions
diff --git a/src/components/_sila/AppHeader/AppHeader.vue b/src/components/_sila/AppHeader/AppHeader.vue
index 8d65b894..315136e1 100644
--- a/src/components/_sila/AppHeader/AppHeader.vue
+++ b/src/components/_sila/AppHeader/AppHeader.vue
@@ -50,9 +50,9 @@
</b-navbar-nav>
<!-- Right aligned nav items -->
<b-navbar-nav class="ml-auto helper-menu">
- <!--<span v-if="bmcTime" class="bmcTime">
- {{ bmcTime }}
- </span>-->
+ <span v-if="liveClock" class="liveClock">
+ {{ liveClock }}
+ </span>
<div class="display--flex align-items--center">
<b-nav-item
to="/logs/event-logs"
@@ -259,8 +259,8 @@ export default {
isNavTagPresent() {
return this.assetTag || this.modelType || this.serialNumber;
},
- bmcTime() {
- return this.$store.getters['global/bmcTime']?.toLocaleTimeString();
+ liveClock() {
+ return this.$store.getters['global/liveClock'];
},
assetTag() {
return this.$store.getters['global/assetTag'];
@@ -602,7 +602,7 @@ export default {
display: none;
}
}
-.bmcTime {
+.liveClock {
padding: 0 8px;
color: lightgoldenrodyellow;
}
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));
},
diff --git a/src/views/_sila/Overview/OverviewQuickLinks.vue b/src/views/_sila/Overview/OverviewQuickLinks.vue
index 6f74fd91..ad82ee6f 100644
--- a/src/views/_sila/Overview/OverviewQuickLinks.vue
+++ b/src/views/_sila/Overview/OverviewQuickLinks.vue
@@ -4,8 +4,8 @@
<b-col sm="6" lg="9" class="mb-2 mt-2">
<dl>
<dt>{{ $t('pageOverview.bmcTime') }}</dt>
- <dd v-if="bmcTime" data-test-id="overviewQuickLinks-text-bmcTime">
- {{ bmcTime | formatDate }} {{ bmcTime | formatTime }}
+ <dd v-if="liveBmcTime" data-test-id="overviewQuickLinks-text-bmcTime">
+ {{ liveBmcTime | formatDate }} {{ liveBmcTime | formatTime }}
</dd>
<dd v-else>--</dd>
</dl>
@@ -36,8 +36,11 @@ export default {
},
mixins: [BVToastMixin],
computed: {
- bmcTime() {
- return this.$store.getters['global/bmcTime'];
+ liveBmcTime() {
+ if (!this.$store.getters['global/liveBmcTime']) {
+ return;
+ }
+ return new Date(this.$store.getters['global/liveBmcTime']);
},
},
created() {