1<template>
2  <b-container fluid="xl">
3    <page-title />
4    <b-row>
5      <b-col md="8" lg="8" xl="6">
6        <page-section>
7          <b-row>
8            <b-col>
9              <dl>
10                <dt>
11                  {{ $t('pageRebootBmc.lastReboot') }}
12                </dt>
13                <dd v-if="lastBmcRebootTime">
14                  {{ lastBmcRebootTime | formatDate }}
15                  {{ lastBmcRebootTime | formatTime }}
16                </dd>
17                <dd v-else>--</dd>
18              </dl>
19            </b-col>
20          </b-row>
21          {{ $t('pageRebootBmc.rebootInformation') }}
22          <b-button
23            variant="primary"
24            class="d-block mt-5"
25            data-test-id="rebootBmc-button-reboot"
26            @click="onClick"
27          >
28            {{ $t('pageRebootBmc.rebootBmc') }}
29          </b-button>
30        </page-section>
31      </b-col>
32    </b-row>
33  </b-container>
34</template>
35
36<script>
37import PageTitle from '@/components/Global/PageTitle';
38import PageSection from '@/components/Global/PageSection';
39import BVToastMixin from '@/components/Mixins/BVToastMixin';
40import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
41
42export default {
43  name: 'RebootBmc',
44  components: { PageTitle, PageSection },
45  mixins: [BVToastMixin, LoadingBarMixin],
46  beforeRouteLeave(to, from, next) {
47    this.hideLoader();
48    next();
49  },
50  computed: {
51    lastBmcRebootTime() {
52      return this.$store.getters['controls/lastBmcRebootTime'];
53    },
54  },
55  created() {
56    this.startLoader();
57    this.$store
58      .dispatch('controls/getLastBmcRebootTime')
59      .finally(() => this.endLoader());
60  },
61  methods: {
62    onClick() {
63      this.$bvModal
64        .msgBoxConfirm(this.$t('pageRebootBmc.modal.confirmMessage'), {
65          title: this.$t('pageRebootBmc.modal.confirmTitle'),
66          okTitle: this.$t('global.action.confirm'),
67          cancelTitle: this.$t('global.action.cancel'),
68        })
69        .then((confirmed) => {
70          if (confirmed) this.rebootBmc();
71        });
72    },
73    rebootBmc() {
74      this.$store
75        .dispatch('controls/rebootBmc')
76        .then((message) => this.successToast(message))
77        .catch(({ message }) => this.errorToast(message));
78    },
79  },
80};
81</script>
82
83<style lang="scss" scoped></style>
84