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