Add last reset time to server power operations page

 - Timestamp is displayed to inform user of last
   power operation

Signed-off-by: Dixsie Wolmers <dixsie@ibm.com>
Change-Id: I14c23ff56b3a0cf134c0ad2d831290971d93e293
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 0fde253..cc99373 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -540,6 +540,7 @@
     "hostStatus": "Host status",
     "immediateReboot": "Immediate – Server reboots without OS shutting down; may cause data corruption",
     "immediateShutdown": "Immediate - Server shuts down without OS shutting down; may cause data corruption",
+    "lastPowerOperation": "Last power operation",
     "oneTimeBootWarning": "Pending one time boot. Next boot will be performed with the specified one time boot settings. Subsequent boots will be performed with the default settings.",
     "operationInProgress": "There are no options to display while a power operation is in progress. When complete, power operations will be displayed here.",
     "operations": "Operations",
diff --git a/src/store/modules/Control/ControlStore.js b/src/store/modules/Control/ControlStore.js
index f88f2aa..6908769 100644
--- a/src/store/modules/Control/ControlStore.js
+++ b/src/store/modules/Control/ControlStore.js
@@ -31,16 +31,30 @@
 const ControlStore = {
   namespaced: true,
   state: {
-    isOperationInProgress: false
+    isOperationInProgress: false,
+    lastPowerOperationTime: null
   },
   getters: {
-    isOperationInProgress: state => state.isOperationInProgress
+    isOperationInProgress: state => state.isOperationInProgress,
+    lastPowerOperationTime: state => state.lastPowerOperationTime
   },
   mutations: {
     setOperationInProgress: (state, inProgress) =>
-      (state.isOperationInProgress = inProgress)
+      (state.isOperationInProgress = inProgress),
+    setLastPowerOperationTime: (state, lastPowerOperationTime) =>
+      (state.lastPowerOperationTime = lastPowerOperationTime)
   },
   actions: {
+    async getLastPowerOperationTime({ commit }) {
+      return await api
+        .get('/redfish/v1/Systems/system')
+        .then(response => {
+          const lastReset = response.data.LastResetTime;
+          const lastPowerOperationTime = new Date(lastReset);
+          commit('setLastPowerOperationTime', lastPowerOperationTime);
+        })
+        .catch(error => console.log(error));
+    },
     async rebootBmc() {
       const data = { ResetType: 'GracefulRestart' };
       return await api
@@ -81,10 +95,11 @@
       await checkForHostStatus.bind(this, 'off')();
       commit('setOperationInProgress', false);
     },
-    hostPowerChange({ commit }, data) {
+    hostPowerChange({ commit, dispatch }, data) {
       commit('setOperationInProgress', true);
       api
         .post('/redfish/v1/Systems/system/Actions/ComputerSystem.Reset', data)
+        .then(() => dispatch('getLastPowerOperationTime'))
         .catch(error => {
           console.log(error);
           commit('setOperationInProgress', false);
diff --git a/src/views/Control/ServerPowerOperations/BootSettings.vue b/src/views/Control/ServerPowerOperations/BootSettings.vue
index c56bcf5..37de1e7 100644
--- a/src/views/Control/ServerPowerOperations/BootSettings.vue
+++ b/src/views/Control/ServerPowerOperations/BootSettings.vue
@@ -106,7 +106,9 @@
     Promise.all([
       this.$store.dispatch('hostBootSettings/getBootSettings'),
       this.$store.dispatch('hostBootSettings/getTpmPolicy')
-    ]).finally(() => this.endLoader());
+    ]).finally(() =>
+      this.$root.$emit('serverPowerOperations::bootSettings::complete')
+    );
   },
   methods: {
     handleSubmit() {
diff --git a/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue b/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue
index 41d8cf0..0db0129 100644
--- a/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue
+++ b/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue
@@ -6,18 +6,36 @@
         <page-section
           :section-title="$t('pageServerPowerOperations.currentStatus')"
         >
-          <dl>
-            <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
-            <dd v-if="hostStatus === 'on'">
-              {{ $t('global.status.on') }}
-            </dd>
-            <dd v-else-if="hostStatus === 'off'">
-              {{ $t('global.status.off') }}
-            </dd>
-            <dd v-else>
-              {{ $t('global.status.notAvailable') }}
-            </dd>
-          </dl>
+          <b-row>
+            <b-col>
+              <dl>
+                <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
+                <dd v-if="hostStatus === 'on'">
+                  {{ $t('global.status.on') }}
+                </dd>
+                <dd v-else-if="hostStatus === 'off'">
+                  {{ $t('global.status.off') }}
+                </dd>
+                <dd v-else>
+                  {{ $t('global.status.notAvailable') }}
+                </dd>
+              </dl>
+            </b-col>
+          </b-row>
+          <b-row>
+            <b-col>
+              <dl>
+                <dt>
+                  {{ $t('pageServerPowerOperations.lastPowerOperation') }}
+                </dt>
+                <dd v-if="lastPowerOperationTime">
+                  {{ lastPowerOperationTime | formatDate }}
+                  {{ lastPowerOperationTime | formatTime }}
+                </dd>
+                <dd v-else>--</dd>
+              </dl>
+            </b-col>
+          </b-row>
         </page-section>
       </b-col>
     </b-row>
@@ -142,12 +160,24 @@
     isOperationInProgress() {
       return this.$store.getters['controls/isOperationInProgress'];
     },
+    lastPowerOperationTime() {
+      return this.$store.getters['controls/lastPowerOperationTime'];
+    },
     oneTimeBootEnabled() {
       return this.$store.getters['hostBootSettings/overrideEnabled'];
     }
   },
   created() {
     this.startLoader();
+    const bootSettingsPromise = new Promise(resolve => {
+      this.$root.$on('serverPowerOperations::bootSettings::complete', () =>
+        resolve()
+      );
+    });
+    Promise.all([
+      this.$store.dispatch('controls/getLastPowerOperationTime'),
+      bootSettingsPromise
+    ]).finally(() => this.endLoader());
   },
   beforeRouteLeave(to, from, next) {
     this.hideLoader();