Add BMC table missing properties

- Added the following properties: Name, Spare part number,
Manufacturer type, Manager type, BMC date and time, Last reset time,
Identify led

Signed-off-by: Sandeepa Singh <sandeepa.singh@ibm.com>
Change-Id: I6d84f867f3c272f3989f76c86f054f143b8b1bbd
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 33048f6..8ec50e9 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -375,6 +375,7 @@
     "system": "System",
     "table": {
       "assetTag": "Asset tag",
+      "bmcDateTime": "BMC date and time",
       "chassisType": "Chassis type",
       "connectTypesSupported": "Connect types supported",
       "description": "Description",
@@ -388,9 +389,10 @@
       "id": "ID",
       "identifyLed": "Identify LED",
       "indicatorLed": "Indicator LED",
-      "locationNumber": "Location number",
       "instructionSet": "Instruction set",
+      "lastResetTime": "Last reset time",
       "locationNumber": "Location number",
+      "managerType": "Manager type",
       "manufacturer": "Manufacturer",
       "maxConcurrentSessions": "Max concurrent sessions",
       "maxSpeedMHz": "Max speed MHz",
@@ -398,6 +400,7 @@
       "model": "Model",
       "name": "Name",
       "partNumber": "Part number",
+      "power": "Power",
       "powerInputWatts": "Power input watts",
       "powerState": "Power state",
       "processorArchitecture": "Processor architecture",
diff --git a/src/store/modules/Health/BmcStore.js b/src/store/modules/Health/BmcStore.js
index 73df10b..bbe157e 100644
--- a/src/store/modules/Health/BmcStore.js
+++ b/src/store/modules/Health/BmcStore.js
@@ -1,6 +1,7 @@
 import api from '@/store/api';
+import i18n from '@/i18n';
 
-const ChassisStore = {
+const BmcStore = {
   namespaced: true,
   state: {
     bmc: null,
@@ -11,6 +12,7 @@
   mutations: {
     setBmcInfo: (state, data) => {
       const bmc = {};
+      bmc.dateTime = new Date(data.DateTime);
       bmc.description = data.Description;
       bmc.firmwareVersion = data.FirmwareVersion;
       bmc.graphicalConsoleConnectTypes =
@@ -21,7 +23,13 @@
       bmc.health = data.Status.Health;
       bmc.healthRollup = data.Status.HealthRollup;
       bmc.id = data.Id;
+      bmc.lastResetTime = new Date(data.LastResetTime);
+      bmc.identifyLed = data.LocationIndicatorActive;
+      bmc.locationNumber = data.LocationNumber;
+      bmc.manufacturer = data.manufacturer;
+      bmc.managerType = data.ManagerType;
       bmc.model = data.Model;
+      bmc.name = data.Name;
       bmc.partNumber = data.PartNumber;
       bmc.powerState = data.PowerState;
       bmc.serialConsoleConnectTypes = data.SerialConsole.ConnectTypesSupported;
@@ -29,8 +37,10 @@
       bmc.serialConsoleMaxSessions = data.SerialConsole.MaxConcurrentSessions;
       bmc.serialNumber = data.SerialNumber;
       bmc.serviceEntryPointUuid = data.ServiceEntryPointUUID;
+      bmc.sparePartNumber = data.SparePartNumber;
       bmc.statusState = data.Status.State;
       bmc.uuid = data.UUID;
+      bmc.uri = data['@odata.id'];
       state.bmc = bmc;
     },
   },
@@ -41,7 +51,29 @@
         .then(({ data }) => commit('setBmcInfo', data))
         .catch((error) => console.log(error));
     },
+    async updateIdentifyLedValue({ dispatch }, led) {
+      const uri = led.uri;
+      const updatedIdentifyLedValue = {
+        LocationIndicatorActive: led.identifyLed,
+      };
+      return await api
+        .patch(uri, updatedIdentifyLedValue)
+        .then(() => dispatch('getBmcInfo'))
+        .catch((error) => {
+          dispatch('getBmcInfo');
+          console.log('error', error);
+          if (led.identifyLed) {
+            throw new Error(
+              i18n.t('pageHardwareStatus.toast.errorEnableIdentifyLed')
+            );
+          } else {
+            throw new Error(
+              i18n.t('pageHardwareStatus.toast.errorDisableIdentifyLed')
+            );
+          }
+        });
+    },
   },
 };
 
-export default ChassisStore;
+export default BmcStore;
diff --git a/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue b/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue
index 2feced8..9673673 100644
--- a/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue
+++ b/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue
@@ -28,63 +28,101 @@
         {{ value }}
       </template>
 
+      <!-- Toggle identify LED -->
+      <template #cell(identifyLed)="row">
+        <b-form-checkbox
+          v-if="hasIdentifyLed(row.item.identifyLed)"
+          v-model="row.item.identifyLed"
+          name="switch"
+          switch
+          @change="toggleIdentifyLedValue(row.item)"
+        >
+          <span v-if="row.item.identifyLed">
+            {{ $t('global.status.on') }}
+          </span>
+          <span v-else> {{ $t('global.status.off') }} </span>
+        </b-form-checkbox>
+        <div v-else>--</div>
+      </template>
+
       <template #row-details="{ item }">
         <b-container fluid>
           <b-row>
-            <b-col sm="6">
+            <b-col class="mt-2" sm="6" xl="6">
               <dl>
-                <!-- Description -->
-                <dt class="float-none">
-                  {{ $t('pageHardwareStatus.table.description') }}:
-                </dt>
-                <dd class="mb-4">
-                  {{ tableFormatter(item.description) }}
-                </dd>
-                <!-- Firmware version -->
-                <dt class="float-none">
-                  {{ $t('pageHardwareStatus.table.firmwareVersion') }}:
-                </dt>
-                <dd class="mb-4">
-                  {{ tableFormatter(item.firmwareVersion) }}
-                </dd>
-                <!-- Service entry point UUID -->
-                <dt class="float-none">
-                  {{ $t('pageHardwareStatus.table.serviceEntryPointUuid') }}:
-                </dt>
-                <dd class="mb-4">
-                  {{ tableFormatter(item.serviceEntryPointUuid) }}
-                </dd>
-                <!-- UUID -->
-                <dt class="float-none">
-                  {{ $t('pageHardwareStatus.table.uuid') }}:
-                </dt>
-                <dd class="mb-4">
-                  {{ tableFormatter(item.uuid) }}
-                </dd>
-              </dl>
-            </b-col>
-            <b-col sm="6">
-              <dl>
-                <!-- Power state -->
-                <dt>{{ $t('pageHardwareStatus.table.powerState') }}:</dt>
-                <dd>{{ tableFormatter(item.powerState) }}</dd>
-
+                <!-- Name -->
+                <dt>{{ $t('pageHardwareStatus.table.name') }}:</dt>
+                <dd>{{ tableFormatter(item.name) }}</dd>
+                <!-- Part number -->
+                <dt>{{ $t('pageHardwareStatus.table.partNumber') }}:</dt>
+                <dd>{{ tableFormatter(item.partNumber) }}</dd>
+                <!-- Serial number -->
+                <dt>{{ $t('pageHardwareStatus.table.serialNumber') }}:</dt>
+                <dd>{{ tableFormatter(item.serialNumber) }}</dd>
+                <!-- Spare part number -->
+                <dt>{{ $t('pageHardwareStatus.table.sparePartNumber') }}:</dt>
+                <dd>{{ tableFormatter(item.sparePartNumber) }}</dd>
                 <!-- Model -->
                 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
                 <dd>{{ tableFormatter(item.model) }}</dd>
-
-                <!-- Health rollup -->
+                <!-- UUID -->
+                <dt>{{ $t('pageHardwareStatus.table.uuid') }}:</dt>
+                <dd>{{ tableFormatter(item.uuid) }}</dd>
+                <!-- Service entry point UUID -->
                 <dt>
-                  {{ $t('pageHardwareStatus.table.statusHealthRollup') }}:
+                  {{ $t('pageHardwareStatus.table.serviceEntryPointUuid') }}:
                 </dt>
-                <dd>{{ tableFormatter(item.healthRollup) }}</dd>
-
+                <dd>{{ tableFormatter(item.serviceEntryPointUuid) }}</dd>
+              </dl>
+            </b-col>
+            <b-col class="mt-2" sm="6" xl="6">
+              <dl>
                 <!-- Status state -->
                 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
                 <dd>{{ tableFormatter(item.statusState) }}</dd>
-
+                <!-- Power state -->
+                <dt>{{ $t('pageHardwareStatus.table.power') }}:</dt>
+                <dd>{{ tableFormatter(item.powerState) }}</dd>
+                <!-- Health rollup -->
+                <dt>{{ $t('pageHardwareStatus.table.healthRollup') }}:</dt>
+                <dd>{{ tableFormatter(item.healthRollup) }}</dd>
+                <!-- BMC date and time -->
+                <dt>{{ $t('pageHardwareStatus.table.bmcDateTime') }}:</dt>
+                <dd>
+                  {{ item.dateTime | formatDate }}
+                  {{ item.dateTime | formatTime }}
+                </dd>
+                <!-- Reset date and time -->
+                <dt>{{ $t('pageHardwareStatus.table.lastResetTime') }}:</dt>
+                <dd>
+                  {{ item.lastResetTime | formatDate }}
+                  {{ item.lastResetTime | formatTime }}
+                </dd>
+              </dl>
+            </b-col>
+          </b-row>
+          <div class="section-divider mb-3 mt-3"></div>
+          <b-row>
+            <b-col class="mt-2" sm="6" xl="6">
+              <dl>
+                <!-- Manufacturer -->
+                <dt>{{ $t('pageHardwareStatus.table.manufacturer') }}:</dt>
+                <dd>{{ tableFormatter(item.manufacturer) }}</dd>
+                <!-- Description -->
+                <dt>{{ $t('pageHardwareStatus.table.description') }}:</dt>
+                <dd>{{ tableFormatter(item.description) }}</dd>
+                <!-- Manager type -->
+                <dt>{{ $t('pageHardwareStatus.table.managerType') }}:</dt>
+                <dd>{{ tableFormatter(item.managerType) }}</dd>
+              </dl>
+            </b-col>
+            <b-col class="mt-2" sm="6" xl="6">
+              <dl>
+                <!-- Firmware Version  -->
+                <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
+                <dd>{{ item.firmwareVersion }}</dd>
                 <!-- Graphical console -->
-                <dt class="font-weight-bold mt-3 mb-2 float-none">
+                <dt class="mt-1 mb-2 float-none">
                   {{ $t('pageHardwareStatus.table.graphicalConsole') }}
                 </dt>
                 <dt>
@@ -96,12 +134,15 @@
                 <dt>
                   {{ $t('pageHardwareStatus.table.maxConcurrentSessions') }}:
                 </dt>
-                <dd>{{ tableFormatter(item.graphicalConsoleMaxSessions) }}</dd>
+                <dd>
+                  {{ tableFormatter(item.graphicalConsoleMaxSessions) }}
+                </dd>
                 <dt>{{ $t('pageHardwareStatus.table.serviceEnabled') }}:</dt>
-                <dd>{{ tableFormatter(item.graphicalConsoleEnabled) }}</dd>
-
+                <dd>
+                  {{ tableFormatter(item.graphicalConsoleEnabled) }}
+                </dd>
                 <!-- Serial console -->
-                <dt class="font-weight-bold mt-3 mb-2 float-none">
+                <dt class="mt-1 mb-2 float-none">
                   {{ $t('pageHardwareStatus.table.serialConsole') }}
                 </dt>
                 <dt>
@@ -128,9 +169,8 @@
 <script>
 import PageSection from '@/components/Global/PageSection';
 import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
-
 import StatusIcon from '@/components/Global/StatusIcon';
-
+import BVToastMixin from '@/components/Mixins/BVToastMixin';
 import TableRowExpandMixin, {
   expandRowLabel,
 } from '@/components/Mixins/TableRowExpandMixin';
@@ -138,7 +178,7 @@
 
 export default {
   components: { IconChevron, PageSection, StatusIcon },
-  mixins: [TableRowExpandMixin, TableDataFormatterMixin],
+  mixins: [BVToastMixin, TableRowExpandMixin, TableDataFormatterMixin],
   data() {
     return {
       fields: [
@@ -156,16 +196,15 @@
           key: 'health',
           label: this.$t('pageHardwareStatus.table.health'),
           formatter: this.tableFormatter,
-          tdClass: 'text-nowrap',
         },
         {
-          key: 'partNumber',
-          label: this.$t('pageHardwareStatus.table.partNumber'),
+          key: 'locationNumber',
+          label: this.$t('pageHardwareStatus.table.locationNumber'),
           formatter: this.tableFormatter,
         },
         {
-          key: 'serialNumber',
-          label: this.$t('pageHardwareStatus.table.serialNumber'),
+          key: 'identifyLed',
+          label: this.$t('pageHardwareStatus.table.identifyLed'),
           formatter: this.tableFormatter,
         },
       ],
@@ -190,5 +229,20 @@
       this.$root.$emit('hardware-status-bmc-manager-complete');
     });
   },
+  methods: {
+    toggleIdentifyLedValue(row) {
+      this.$store
+        .dispatch('bmc/updateIdentifyLedValue', {
+          uri: row.uri,
+          identifyLed: row.identifyLed,
+        })
+        .catch(({ message }) => this.errorToast(message));
+    },
+    // TO DO: remove hasIdentifyLed method once the following story is merged:
+    // https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/43179
+    hasIdentifyLed(identifyLed) {
+      return typeof identifyLed === 'boolean';
+    },
+  },
 };
 </script>