1<template> 2 <div> 3 <page-section :section-title="sectionTitle"> 4 <b-card-group deck> 5 <!-- Running image --> 6 <b-card> 7 <template #header> 8 <p class="font-weight-bold m-0"> 9 {{ $t('pageFirmware.cardTitleRunning') }} 10 </p> 11 </template> 12 <dl class="mb-0"> 13 <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> 14 <dd class="mb-0">{{ runningVersion }}</dd> 15 </dl> 16 </b-card> 17 18 <!-- Backup image --> 19 <b-card> 20 <template #header> 21 <p class="font-weight-bold m-0"> 22 {{ $t('pageFirmware.cardTitleBackup') }} 23 </p> 24 </template> 25 <dl> 26 <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> 27 <dd> 28 <status-icon v-if="showBackupImageStatus" status="danger" /> 29 <span v-if="showBackupImageStatus" class="sr-only"> 30 {{ backupStatus }} 31 </span> 32 {{ backupVersion }} 33 </dd> 34 </dl> 35 <b-btn 36 v-if="!switchToBackupImageDisabled" 37 v-b-modal.modal-switch-to-running 38 data-test-id="firmware-button-switchToRunning" 39 variant="link" 40 size="sm" 41 class="py-0 px-1 mt-2" 42 :disabled="isPageDisabled || !backup" 43 > 44 <icon-switch class="d-none d-sm-inline-block" /> 45 {{ $t('pageFirmware.cardActionSwitchToRunning') }} 46 </b-btn> 47 </b-card> 48 </b-card-group> 49 </page-section> 50 <modal-switch-to-running :backup="backupVersion" @ok="switchToRunning" /> 51 </div> 52</template> 53 54<script> 55import IconSwitch from '@carbon/icons-vue/es/arrows--horizontal/20'; 56import PageSection from '@/components/Global/PageSection'; 57import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; 58import BVToastMixin from '@/components/Mixins/BVToastMixin'; 59 60import ModalSwitchToRunning from './FirmwareModalSwitchToRunning'; 61 62export default { 63 components: { IconSwitch, ModalSwitchToRunning, PageSection }, 64 mixins: [BVToastMixin, LoadingBarMixin], 65 props: { 66 isPageDisabled: { 67 required: true, 68 type: Boolean, 69 default: false, 70 }, 71 }, 72 data() { 73 return { 74 loading, 75 switchToBackupImageDisabled: 76 process.env.VUE_APP_SWITCH_TO_BACKUP_IMAGE_DISABLED === 'true', 77 }; 78 }, 79 computed: { 80 isSingleFileUploadEnabled() { 81 return this.$store.getters['firmware/isSingleFileUploadEnabled']; 82 }, 83 sectionTitle() { 84 if (this.isSingleFileUploadEnabled) { 85 return this.$t('pageFirmware.sectionTitleBmcCardsCombined'); 86 } 87 return this.$t('pageFirmware.sectionTitleBmcCards'); 88 }, 89 running() { 90 return this.$store.getters['firmware/activeBmcFirmware']; 91 }, 92 backup() { 93 return this.$store.getters['firmware/backupBmcFirmware']; 94 }, 95 runningVersion() { 96 return this.running?.version || '--'; 97 }, 98 backupVersion() { 99 return this.backup?.version || '--'; 100 }, 101 backupStatus() { 102 return this.backup?.status || null; 103 }, 104 showBackupImageStatus() { 105 return ( 106 this.backupStatus === 'Critical' || this.backupStatus === 'Warning' 107 ); 108 }, 109 }, 110 methods: { 111 switchToRunning() { 112 this.startLoader(); 113 const timerId = setTimeout(() => { 114 this.endLoader(); 115 this.infoToast(this.$t('pageFirmware.toast.verifySwitchMessage'), { 116 title: this.$t('pageFirmware.toast.verifySwitch'), 117 refreshAction: true, 118 }); 119 }, 60000); 120 121 this.$store 122 .dispatch('firmware/switchBmcFirmwareAndReboot') 123 .then(() => 124 this.infoToast(this.$t('pageFirmware.toast.rebootStartedMessage'), { 125 title: this.$t('pageFirmware.toast.rebootStarted'), 126 }) 127 ) 128 .catch(({ message }) => { 129 this.errorToast(message); 130 clearTimeout(timerId); 131 this.endLoader(); 132 }); 133 }, 134 }, 135}; 136</script> 137