Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 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"> |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 9 | {{ $t('pageFirmware.cardTitleRunning') }} |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 10 | </p> |
| 11 | </template> |
| 12 | <dl class="mb-0"> |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 13 | <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 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"> |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 22 | {{ $t('pageFirmware.cardTitleBackup') }} |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 23 | </p> |
| 24 | </template> |
| 25 | <dl> |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 26 | <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt> |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 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 |
MichalX Szopinski | f65cc7b | 2021-07-12 10:56:16 +0200 | [diff] [blame] | 36 | v-if="!switchToBackupImageDisabled" |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 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" |
Kenneth Fullbright | c3cf361 | 2022-01-27 18:55:00 -0600 | [diff] [blame] | 42 | :disabled="isPageDisabled || !backup || !isServerOff" |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 43 | > |
| 44 | <icon-switch class="d-none d-sm-inline-block" /> |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 45 | {{ $t('pageFirmware.cardActionSwitchToRunning') }} |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 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> |
| 55 | import IconSwitch from '@carbon/icons-vue/es/arrows--horizontal/20'; |
| 56 | import PageSection from '@/components/Global/PageSection'; |
| 57 | import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; |
| 58 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
| 59 | |
| 60 | import ModalSwitchToRunning from './FirmwareModalSwitchToRunning'; |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 61 | import { useI18n } from 'vue-i18n'; |
| 62 | import i18n from '@/i18n'; |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 63 | |
| 64 | export default { |
| 65 | components: { IconSwitch, ModalSwitchToRunning, PageSection }, |
| 66 | mixins: [BVToastMixin, LoadingBarMixin], |
| 67 | props: { |
| 68 | isPageDisabled: { |
| 69 | required: true, |
| 70 | type: Boolean, |
| 71 | default: false, |
| 72 | }, |
Kenneth Fullbright | c3cf361 | 2022-01-27 18:55:00 -0600 | [diff] [blame] | 73 | isServerOff: { |
| 74 | required: true, |
| 75 | type: Boolean, |
| 76 | default: false, |
| 77 | }, |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 78 | }, |
| 79 | data() { |
| 80 | return { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 81 | $t: useI18n().t, |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 82 | loading, |
MichalX Szopinski | f65cc7b | 2021-07-12 10:56:16 +0200 | [diff] [blame] | 83 | switchToBackupImageDisabled: |
| 84 | process.env.VUE_APP_SWITCH_TO_BACKUP_IMAGE_DISABLED === 'true', |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 85 | }; |
| 86 | }, |
| 87 | computed: { |
| 88 | isSingleFileUploadEnabled() { |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 89 | return this.$store.getters['firmware/isSingleFileUploadEnabled']; |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 90 | }, |
| 91 | sectionTitle() { |
| 92 | if (this.isSingleFileUploadEnabled) { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 93 | return i18n.global.t('pageFirmware.sectionTitleBmcCardsCombined'); |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 94 | } |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 95 | return i18n.global.t('pageFirmware.sectionTitleBmcCards'); |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 96 | }, |
| 97 | running() { |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 98 | return this.$store.getters['firmware/activeBmcFirmware']; |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 99 | }, |
| 100 | backup() { |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 101 | return this.$store.getters['firmware/backupBmcFirmware']; |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 102 | }, |
| 103 | runningVersion() { |
| 104 | return this.running?.version || '--'; |
| 105 | }, |
| 106 | backupVersion() { |
| 107 | return this.backup?.version || '--'; |
| 108 | }, |
| 109 | backupStatus() { |
| 110 | return this.backup?.status || null; |
| 111 | }, |
| 112 | showBackupImageStatus() { |
| 113 | return ( |
| 114 | this.backupStatus === 'Critical' || this.backupStatus === 'Warning' |
| 115 | ); |
| 116 | }, |
| 117 | }, |
| 118 | methods: { |
| 119 | switchToRunning() { |
| 120 | this.startLoader(); |
| 121 | const timerId = setTimeout(() => { |
| 122 | this.endLoader(); |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 123 | this.infoToast( |
| 124 | i18n.global.t('pageFirmware.toast.verifySwitchMessage'), |
| 125 | { |
| 126 | title: i18n.global.t('pageFirmware.toast.verifySwitch'), |
| 127 | refreshAction: true, |
| 128 | }, |
| 129 | ); |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 130 | }, 60000); |
| 131 | |
| 132 | this.$store |
Yoshie Muranaka | 33d755f | 2021-02-18 15:24:14 -0800 | [diff] [blame] | 133 | .dispatch('firmware/switchBmcFirmwareAndReboot') |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 134 | .then(() => |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame^] | 135 | this.infoToast( |
| 136 | i18n.global.t('pageFirmware.toast.rebootStartedMessage'), |
| 137 | { |
| 138 | title: i18n.global.t('pageFirmware.toast.rebootStarted'), |
| 139 | }, |
| 140 | ), |
Yoshie Muranaka | 7bc85e4 | 2021-02-11 09:59:13 -0800 | [diff] [blame] | 141 | ) |
| 142 | .catch(({ message }) => { |
| 143 | this.errorToast(message); |
| 144 | clearTimeout(timerId); |
| 145 | this.endLoader(); |
| 146 | }); |
| 147 | }, |
| 148 | }, |
| 149 | }; |
| 150 | </script> |