1<template>
2  <b-container fluid="xl">
3    <page-title />
4    <alerts-server-power
5      v-if="isServerPowerOffRequired"
6      :is-server-off="isServerOff"
7    />
8
9    <!-- Firmware cards -->
10    <b-row>
11      <b-col xl="10">
12        <!-- BMC Firmware -->
13        <bmc-cards :is-page-disabled="isPageDisabled" />
14
15        <!-- Host Firmware -->
16        <host-cards v-if="!isSingleFileUploadEnabled" />
17      </b-col>
18    </b-row>
19
20    <!-- Update firmware-->
21    <page-section
22      :section-title="$t('pageFirmware.sectionTitleUpdateFirmware')"
23    >
24      <b-row>
25        <b-col sm="8" md="6" xl="4">
26          <!-- Update form -->
27          <form-update
28            :is-server-off="isServerOff"
29            :is-page-disabled="isPageDisabled"
30          />
31        </b-col>
32      </b-row>
33    </page-section>
34  </b-container>
35</template>
36
37<script>
38import AlertsServerPower from './FirmwareAlertServerPower';
39import BmcCards from './FirmwareCardsBmc';
40import FormUpdate from './FirmwareFormUpdate';
41import HostCards from './FirmwareCardsHost';
42import PageSection from '@/components/Global/PageSection';
43import PageTitle from '@/components/Global/PageTitle';
44
45import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin';
46
47export default {
48  name: 'FirmwareSingleImage',
49  components: {
50    AlertsServerPower,
51    BmcCards,
52    FormUpdate,
53    HostCards,
54    PageSection,
55    PageTitle,
56  },
57  mixins: [LoadingBarMixin],
58  beforeRouteLeave(to, from, next) {
59    this.hideLoader();
60    next();
61  },
62  data() {
63    return {
64      loading,
65      isServerPowerOffRequired:
66        process.env.VUE_APP_SERVER_OFF_REQUIRED === 'true',
67    };
68  },
69  computed: {
70    serverStatus() {
71      return this.$store.getters['global/serverStatus'];
72    },
73    isServerOff() {
74      return this.serverStatus === 'off' ? true : false;
75    },
76    isSingleFileUploadEnabled() {
77      return this.$store.getters['firmware/isSingleFileUploadEnabled'];
78    },
79    isPageDisabled() {
80      if (this.isServerPowerOffRequired) {
81        return !this.isServerOff || this.loading || this.isOperationInProgress;
82      }
83      return this.loading || this.isOperationInProgress;
84    },
85  },
86  created() {
87    this.startLoader();
88    this.$store
89      .dispatch('firmware/getFirmwareInformation')
90      .finally(() => this.endLoader());
91  },
92};
93</script>
94