blob: bfca14cfc2b64d279961ca7e9a43eab9b9a0d576 [file] [log] [blame]
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -08001<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 Muranaka33d755f2021-02-18 15:24:14 -08009 {{ $t('pageFirmware.cardTitleRunning') }}
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080010 </p>
11 </template>
12 <dl class="mb-0">
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080013 <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt>
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080014 <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 Muranaka33d755f2021-02-18 15:24:14 -080022 {{ $t('pageFirmware.cardTitleBackup') }}
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080023 </p>
24 </template>
25 <dl>
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080026 <dt>{{ $t('pageFirmware.cardBodyVersion') }}</dt>
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080027 <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 Szopinskif65cc7b2021-07-12 10:56:16 +020036 v-if="!switchToBackupImageDisabled"
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080037 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 Fullbrightc3cf3612022-01-27 18:55:00 -060042 :disabled="isPageDisabled || !backup || !isServerOff"
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080043 >
44 <icon-switch class="d-none d-sm-inline-block" />
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080045 {{ $t('pageFirmware.cardActionSwitchToRunning') }}
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080046 </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 },
Kenneth Fullbrightc3cf3612022-01-27 18:55:00 -060071 isServerOff: {
72 required: true,
73 type: Boolean,
74 default: false,
75 },
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080076 },
77 data() {
78 return {
79 loading,
MichalX Szopinskif65cc7b2021-07-12 10:56:16 +020080 switchToBackupImageDisabled:
81 process.env.VUE_APP_SWITCH_TO_BACKUP_IMAGE_DISABLED === 'true',
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080082 };
83 },
84 computed: {
85 isSingleFileUploadEnabled() {
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080086 return this.$store.getters['firmware/isSingleFileUploadEnabled'];
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080087 },
88 sectionTitle() {
89 if (this.isSingleFileUploadEnabled) {
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080090 return this.$t('pageFirmware.sectionTitleBmcCardsCombined');
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080091 }
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080092 return this.$t('pageFirmware.sectionTitleBmcCards');
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080093 },
94 running() {
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080095 return this.$store.getters['firmware/activeBmcFirmware'];
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080096 },
97 backup() {
Yoshie Muranaka33d755f2021-02-18 15:24:14 -080098 return this.$store.getters['firmware/backupBmcFirmware'];
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -080099 },
100 runningVersion() {
101 return this.running?.version || '--';
102 },
103 backupVersion() {
104 return this.backup?.version || '--';
105 },
106 backupStatus() {
107 return this.backup?.status || null;
108 },
109 showBackupImageStatus() {
110 return (
111 this.backupStatus === 'Critical' || this.backupStatus === 'Warning'
112 );
113 },
114 },
115 methods: {
116 switchToRunning() {
117 this.startLoader();
118 const timerId = setTimeout(() => {
119 this.endLoader();
Yoshie Muranaka33d755f2021-02-18 15:24:14 -0800120 this.infoToast(this.$t('pageFirmware.toast.verifySwitchMessage'), {
121 title: this.$t('pageFirmware.toast.verifySwitch'),
122 refreshAction: true,
123 });
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -0800124 }, 60000);
125
126 this.$store
Yoshie Muranaka33d755f2021-02-18 15:24:14 -0800127 .dispatch('firmware/switchBmcFirmwareAndReboot')
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -0800128 .then(() =>
Yoshie Muranaka33d755f2021-02-18 15:24:14 -0800129 this.infoToast(this.$t('pageFirmware.toast.rebootStartedMessage'), {
130 title: this.$t('pageFirmware.toast.rebootStarted'),
Ed Tanous81323992024-02-27 11:26:24 -0800131 }),
Yoshie Muranaka7bc85e42021-02-11 09:59:13 -0800132 )
133 .catch(({ message }) => {
134 this.errorToast(message);
135 clearTimeout(timerId);
136 this.endLoader();
137 });
138 },
139 },
140};
141</script>