Add BMC manager table to hardware status page

Add properties at /redfish/v1/Managers/bmc endpoint in a
table with expandable row to view details.

Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: Ieb32a9b2a535ddd7d24edcb68761c51eace2e5a8
diff --git a/src/components/Mixins/TableDataFormatter.js b/src/components/Mixins/TableDataFormatter.js
index e811f90..027db61 100644
--- a/src/components/Mixins/TableDataFormatter.js
+++ b/src/components/Mixins/TableDataFormatter.js
@@ -18,6 +18,9 @@
         default:
           return '';
       }
+    },
+    tableFormatterArray(value) {
+      return value.join(', ');
     }
   }
 };
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index f58054a..4306534 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -130,26 +130,34 @@
     "dimmSlot": "DIMM slot",
     "fans": "Fans",
     "powerSupplies": "Power supplies",
+    "bmcManager": "BMC manager",
     "chassis": "Chassis",
     "system": "System",
     "table": {
         "assetTag": "Asset tag",
         "chassisType": "Chassis type",
+        "connectTypesSupported": "Connect types supported",
         "description": "Description",
         "efficiencyPercent": "Efficiency percent",
         "firmwareVersion": "Firmware version",
+        "graphicalConsole": "Graphical console",
         "health": "Health",
         "id": "ID",
         "indicatorLed": "Indicator LED",
         "manufacturer": "Manufacturer",
+        "maxConcurrentSessions": "Max concurrent sessions",
         "model": "Model",
         "partNumber": "Part number",
         "powerInputWatts": "Power input watts",
         "powerState": "Power state",
+        "serialConsole": "Serial console",
         "serialNumber": "Serial number",
+        "serviceEnabled": "Service enabled",
+        "serviceEntryPointUuid": "Service entry point UUID",
         "statusHealthRollup": "Status (Health rollup)",
         "statusState": "Status (State)",
-        "systemType": "System type"
+        "systemType": "System type",
+        "uuid": "UUID"
     }
   },
   "pageLdap": {
diff --git a/src/store/index.js b/src/store/index.js
index 0f92175..6ad0539 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -19,6 +19,7 @@
 import MemoryStore from './modules/Health/MemoryStore';
 import FanStore from './modules/Health/FanStore';
 import ChassisStore from './modules/Health/ChassisStore';
+import BmcStore from './modules/Health/BmcStore';
 
 import WebSocketPlugin from './plugins/WebSocketPlugin';
 
@@ -46,7 +47,8 @@
     system: SystemStore,
     memory: MemoryStore,
     fan: FanStore,
-    chassis: ChassisStore
+    chassis: ChassisStore,
+    bmc: BmcStore
   },
   plugins: [WebSocketPlugin]
 });
diff --git a/src/store/modules/Health/BmcStore.js b/src/store/modules/Health/BmcStore.js
new file mode 100644
index 0000000..784bd44
--- /dev/null
+++ b/src/store/modules/Health/BmcStore.js
@@ -0,0 +1,47 @@
+import api from '@/store/api';
+
+const ChassisStore = {
+  namespaced: true,
+  state: {
+    bmc: null
+  },
+  getters: {
+    bmc: state => state.bmc
+  },
+  mutations: {
+    setBmcInfo: (state, data) => {
+      const bmc = {};
+      bmc.description = data.Description;
+      bmc.firmwareVersion = data.FirmwareVersion;
+      bmc.graphicalConsoleConnectTypes =
+        data.GraphicalConsole.ConnectTypesSupported;
+      bmc.graphicalConsoleEnabled = data.GraphicalConsole.ServiceEnabled;
+      bmc.graphicalConsoleMaxSessions =
+        data.GraphicalConsole.MaxConcurrentSessions;
+      bmc.health = data.Status.Health;
+      bmc.healthRollup = data.Status.HealthRollup;
+      bmc.id = data.Id;
+      bmc.model = data.Model;
+      bmc.partNumber = data.PartNumber;
+      bmc.powerState = data.PowerState;
+      bmc.serialConsoleConnectTypes = data.SerialConsole.ConnectTypesSupported;
+      bmc.serialConsoleEnabled = data.SerialConsole.ServiceEnabled;
+      bmc.serialConsoleMaxSessions = data.SerialConsole.MaxConcurrentSessions;
+      bmc.serialNumber = data.SerialNumber;
+      bmc.serviceEntryPointUuid = data.ServiceEntryPointUUID;
+      bmc.statusState = data.Status.State;
+      bmc.uuid = data.UUID;
+      state.bmc = bmc;
+    }
+  },
+  actions: {
+    async getBmcInfo({ commit }) {
+      return await api
+        .get('/redfish/v1/Managers/bmc')
+        .then(({ data }) => commit('setBmcInfo', data))
+        .catch(error => console.log(error));
+    }
+  }
+};
+
+export default ChassisStore;
diff --git a/src/views/Health/HardwareStatus/HardwareStatus.vue b/src/views/Health/HardwareStatus/HardwareStatus.vue
index 598313e..364baad 100644
--- a/src/views/Health/HardwareStatus/HardwareStatus.vue
+++ b/src/views/Health/HardwareStatus/HardwareStatus.vue
@@ -5,6 +5,9 @@
     <!-- System table -->
     <table-system />
 
+    <!-- BMC manager table -->
+    <table-bmc-manager />
+
     <!-- Chassis table -->
     <table-chassis />
 
@@ -25,6 +28,7 @@
 import TablePowerSupplies from './HardwareStatusTablePowerSupplies';
 import TableDimmSlot from './HardwareStatusTableDimmSlot';
 import TableFans from './HardwareStatusTableFans';
+import TableBmcManager from './HardwareStatusTableBmcManager';
 import TableChassis from './HardwareStatusTableChassis';
 import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
 
@@ -35,6 +39,7 @@
     TablePowerSupplies,
     TableSystem,
     TableFans,
+    TableBmcManager,
     TableChassis
   },
   mixins: [LoadingBarMixin],
@@ -43,6 +48,9 @@
     const systemTablePromise = new Promise(resolve => {
       this.$root.$on('hardwareStatus::system::complete', () => resolve());
     });
+    const bmcManagerTablePromise = new Promise(resolve => {
+      this.$root.$on('hardwareStatus::bmcManager::complete', () => resolve());
+    });
     const chassisTablePromise = new Promise(resolve => {
       this.$root.$on('hardwareStatus::chassis::complete', () => resolve());
     });
@@ -61,6 +69,7 @@
     // when page data load complete
     Promise.all([
       systemTablePromise,
+      bmcManagerTablePromise,
       chassisTablePromise,
       dimmSlotTablePromise,
       fansTablePromise,
diff --git a/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue b/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue
new file mode 100644
index 0000000..94dde6d
--- /dev/null
+++ b/src/views/Health/HardwareStatus/HardwareStatusTableBmcManager.vue
@@ -0,0 +1,186 @@
+<template>
+  <page-section :section-title="$t('pageHardwareStatus.bmcManager')">
+    <b-table :items="items" :fields="fields">
+      <!-- Expand chevron icon -->
+      <template v-slot:cell(expandRow)="row">
+        <b-button variant="link" @click="row.toggleDetails">
+          <icon-chevron />
+        </b-button>
+      </template>
+
+      <!-- Health -->
+      <template v-slot:cell(health)="{ value }">
+        <status-icon :status="statusIcon(value)" />
+        {{ value }}
+      </template>
+
+      <template v-slot:row-details="{ item }">
+        <b-container fluid>
+          <b-row>
+            <b-col sm="6">
+              <dl>
+                <!-- Description -->
+                <dt class="d-block">
+                  {{ $t('pageHardwareStatus.table.description') }}:
+                </dt>
+                <dd class="mb-4">
+                  {{ tableFormatter(item.description) }}
+                </dd>
+                <br />
+                <!-- Firmware version -->
+                <dt class="d-block">
+                  {{ $t('pageHardwareStatus.table.firmwareVersion') }}:
+                </dt>
+                <dd class="mb-4">
+                  {{ tableFormatter(item.firmwareVersion) }}
+                </dd>
+                <br />
+                <!-- Service entry point UUID -->
+                <dt class="d-block">
+                  {{ $t('pageHardwareStatus.table.serviceEntryPointUuid') }}:
+                </dt>
+                <dd class="mb-4">
+                  {{ tableFormatter(item.serviceEntryPointUuid) }}
+                </dd>
+                <br />
+                <!-- UUID -->
+                <dt class="d-block">
+                  {{ $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>
+                <br />
+
+                <!-- Model -->
+                <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
+                <dd>{{ tableFormatter(item.model) }}</dd>
+                <br />
+
+                <!-- Health rollup -->
+                <dt>
+                  {{ $t('pageHardwareStatus.table.statusHealthRollup') }}:
+                </dt>
+                <dd>{{ tableFormatter(item.healthRollup) }}</dd>
+                <br />
+
+                <!-- Status state -->
+                <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
+                <dd>{{ tableFormatter(item.statusState) }}</dd>
+                <br />
+
+                <!-- Graphical console -->
+                <dt class="font-weight-bold mt-3 mb-2 d-block">
+                  {{ $t('pageHardwareStatus.table.graphicalConsole') }}
+                </dt>
+                <dt>
+                  {{ $t('pageHardwareStatus.table.connectTypesSupported') }}:
+                </dt>
+                <dd>
+                  {{ tableFormatterArray(item.graphicalConsoleConnectTypes) }}
+                </dd>
+                <br />
+                <dt>
+                  {{ $t('pageHardwareStatus.table.maxConcurrentSessions') }}:
+                </dt>
+                <dd>{{ tableFormatter(item.graphicalConsoleMaxSessions) }}</dd>
+                <br />
+                <dt>{{ $t('pageHardwareStatus.table.serviceEnabled') }}:</dt>
+                <dd>{{ tableFormatter(item.graphicalConsoleEnabled) }}</dd>
+                <br />
+
+                <!-- Serial console -->
+                <dt class="font-weight-bold mt-3 mb-2 d-block">
+                  {{ $t('pageHardwareStatus.table.serialConsole') }}
+                </dt>
+                <dt>
+                  {{ $t('pageHardwareStatus.table.connectTypesSupported') }}:
+                </dt>
+                <dd>
+                  {{ tableFormatterArray(item.serialConsoleConnectTypes) }}
+                </dd>
+                <br />
+                <dt>
+                  {{ $t('pageHardwareStatus.table.maxConcurrentSessions') }}:
+                </dt>
+                <dd>{{ tableFormatter(item.serialConsoleMaxSessions) }}</dd>
+                <br />
+                <dt>{{ $t('pageHardwareStatus.table.serviceEnabled') }}:</dt>
+                <dd>{{ tableFormatter(item.serialConsoleEnabled) }}</dd>
+              </dl>
+            </b-col>
+          </b-row>
+        </b-container>
+      </template>
+    </b-table>
+  </page-section>
+</template>
+
+<script>
+import PageSection from '@/components/Global/PageSection';
+import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
+
+import StatusIcon from '@/components/Global/StatusIcon';
+import TableDataFormatter from '@/components/Mixins/TableDataFormatter';
+
+export default {
+  components: { IconChevron, PageSection, StatusIcon },
+  mixins: [TableDataFormatter],
+  data() {
+    return {
+      fields: [
+        {
+          key: 'expandRow',
+          label: '',
+          tdClass: 'table-row-expand'
+        },
+        {
+          key: 'id',
+          label: this.$t('pageHardwareStatus.table.id'),
+          formatter: this.tableFormatter
+        },
+        {
+          key: 'health',
+          label: this.$t('pageHardwareStatus.table.health'),
+          formatter: this.tableFormatter
+        },
+        {
+          key: 'partNumber',
+          label: this.$t('pageHardwareStatus.table.partNumber'),
+          formatter: this.tableFormatter
+        },
+        {
+          key: 'serialNumber',
+          label: this.$t('pageHardwareStatus.table.serialNumber'),
+          formatter: this.tableFormatter
+        }
+      ]
+    };
+  },
+  computed: {
+    bmc() {
+      return this.$store.getters['bmc/bmc'];
+    },
+    items() {
+      if (this.bmc) {
+        return [this.bmc];
+      } else {
+        return [];
+      }
+    }
+  },
+  created() {
+    this.$store.dispatch('bmc/getBmcInfo').finally(() => {
+      // Emit intial data fetch complete to parent component
+      this.$root.$emit('hardwareStatus::bmcManager::complete');
+    });
+  }
+};
+</script>