From 6ea10b4fd4908ee8c4a48a8b0362a279a5b55d32 Mon Sep 17 00:00:00 2001
From: roly <Rolyli.Li@luxshare-ict.com>
Date: Wed, 13 Nov 2024 14:45:30 +0800
Subject: [PATCH] Webui support fan board cpld verison display

---
 src/locales/en-US.json                        |  2 ++
 src/store/modules/Operations/FirmwareStore.js | 12 +++++++++
 .../Operations/Firmware/FirmwareCardsCPLD.vue | 27 +++++++++++++++----
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 23821a1..b695955 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -329,6 +329,8 @@
         "cardBodyVersion": "Version",
         "cardTitleBackup": "Backup image",
         "cardTitleRunning": "Running image",
+        "cardTitleMBCpld": "Mother Board CPLD",
+        "cardTitleFBCpld": "Fan Board CPLD",
         "sectionTitleBmcCards": "BMC",
         "sectionTitleBmcCardsCombined": "BMC and server",
         "sectionTitleHostCards": "Host",
diff --git a/src/store/modules/Operations/FirmwareStore.js b/src/store/modules/Operations/FirmwareStore.js
index a90e1a5..f03b425 100644
--- a/src/store/modules/Operations/FirmwareStore.js
+++ b/src/store/modules/Operations/FirmwareStore.js
@@ -7,6 +7,7 @@ const FirmwareStore = {
     bmcFirmware: [],
     hostFirmware: [],
     cpldFirmware: [],
+    fbcpldFirmware: [],
     bmcActiveFirmwareId: null,
     hostActiveFirmwareId: null,
     applyTime: null,
@@ -41,6 +42,11 @@ const FirmwareStore = {
         (firmware) => firmware.id === 'cpld_active'
       );
     },
+    fbcpldFirmware: (state) => {
+      return state.fbcpldFirmware.find(
+        (firmware) => firmware.id === 'fb_cpld_active'
+      );
+    },
   },
   mutations: {
     setActiveBmcFirmwareId: (state, id) => (state.bmcActiveFirmwareId = id),
@@ -48,6 +54,7 @@ const FirmwareStore = {
     setBmcFirmware: (state, firmware) => (state.bmcFirmware = firmware),
     setHostFirmware: (state, firmware) => (state.hostFirmware = firmware),
     setCPLDFirmware: (state, firmware) => (state.cpldFirmware = firmware),
+    setFBCPLDFirmware: (state, firmware) => (state.fbcpldFirmware = firmware),
     setApplyTime: (state, applyTime) => (state.applyTime = applyTime),
     setHttpPushUri: (state, httpPushUri) => (state.httpPushUri = httpPushUri),
     setTftpUploadAvailable: (state, tftpAvailable) =>
@@ -90,6 +97,7 @@ const FirmwareStore = {
           const bmcFirmware = [];
           const hostFirmware = [];
           const cpldFirmware = [];
+          const fbcpldFirmware = [];
           response.forEach(({ data }) => {
             const firmwareType = data?.RelatedItem?.[0]?.['@odata.id']
               .split('/')
@@ -109,10 +117,14 @@ const FirmwareStore = {
             if (item.id === 'cpld_active') {
               cpldFirmware.push(item);
             }
+            if (item.id === 'fb_cpld_active') {
+              fbcpldFirmware.push(item);
+            }
           });
           commit('setBmcFirmware', bmcFirmware);
           commit('setHostFirmware', hostFirmware);
           commit('setCPLDFirmware', cpldFirmware);
+          commit('setFBCPLDFirmware', fbcpldFirmware);
         })
         .catch((error) => {
           console.log(error);
diff --git a/src/views/Operations/Firmware/FirmwareCardsCPLD.vue b/src/views/Operations/Firmware/FirmwareCardsCPLD.vue
index baaec3e..ccc76a9 100755
--- a/src/views/Operations/Firmware/FirmwareCardsCPLD.vue
+++ b/src/views/Operations/Firmware/FirmwareCardsCPLD.vue
@@ -5,12 +5,23 @@
       <b-card>
         <template #header>
           <p class="font-weight-bold m-0">
-            {{ $t('pageFirmware.cardTitleRunning') }}
+            {{ $t('pageFirmware.cardTitleMBCpld') }}
           </p>
         </template>
         <dl class="mb-0">
           <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt>
-          <dd class="mb-0">{{ runningVersion }}</dd>
+          <dd class="mb-0">{{ MBCPLDVersion }}</dd>
+        </dl>
+      </b-card>
+      <b-card>
+        <template #header>
+          <p class="font-weight-bold m-0">
+            {{ $t('pageFirmware.cardTitleFBCpld') }}
+          </p>
+        </template>
+        <dl class="mb-0">
+          <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt>
+          <dd class="mb-0">{{ FBCPLDVersion }}</dd>
         </dl>
       </b-card>
     </b-card-group>
@@ -23,11 +34,17 @@ import PageSection from '@/components/Global/PageSection';
 export default {
   components: { PageSection },
   computed: {
-    running() {
+    mbcpld() {
       return this.$store.getters['firmware/cpldFirmware'];
     },
-    runningVersion() {
-      return this.running?.version || '--';
+    MBCPLDVersion() {
+      return this.mbcpld?.version || '--';
+    },
+    fbcpld() {
+      return this.$store.getters['firmware/fbcpldFirmware'];
+    },
+    FBCPLDVersion() {
+      return this.fbcpld?.version || '--';
     },
   },
 };
-- 
2.25.1

