blob: de377e1121b0799a75a0e865cb0b4ca39d67b2a8 [file] [log] [blame]
Yoshie Muranakafa1512b2020-02-25 15:54:07 -08001<template>
Yoshie Muranaka3111b6f2020-04-21 19:48:38 -07002 <b-container fluid="xl">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -08003 <page-title />
Yoshie Muranakaf7aa7f92020-04-27 10:12:15 -07004 <b-row class="mb-4">
Yoshie Muranakac05ff642020-02-26 14:23:15 -08005 <b-col md="8" xl="6">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -08006 <page-section
7 :section-title="$t('pageServerPowerOperations.currentStatus')"
8 >
9 <dl>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080010 <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
11 <dd v-if="hostStatus === 'on'">
12 {{ $t('global.status.on') }}
13 </dd>
14 <dd v-else-if="hostStatus === 'off'">
15 {{ $t('global.status.off') }}
16 </dd>
17 <dd v-else>
18 {{ $t('global.status.notAvailable') }}
19 </dd>
20 </dl>
21 </page-section>
22 </b-col>
23 </b-row>
24 <b-row>
Yoshie Muranakac05ff642020-02-26 14:23:15 -080025 <b-col sm="8" md="6" xl="4">
26 <page-section
27 :section-title="$t('pageServerPowerOperations.hostOsBootSettings')"
28 >
29 <boot-settings />
30 </page-section>
31 </b-col>
32 <b-col sm="8" md="6" xl="7">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080033 <page-section
34 :section-title="$t('pageServerPowerOperations.operations')"
35 >
Yoshie Muranakac05ff642020-02-26 14:23:15 -080036 <b-alert :show="oneTimeBootEnabled" variant="warning">
37 {{ $t('pageServerPowerOperations.oneTimeBootWarning') }}
38 </b-alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080039 <template v-if="isOperationInProgress">
40 {{ $t('pageServerPowerOperations.operationInProgress') }}
41 </template>
42 <template v-else-if="hostStatus === 'off'">
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053043 <b-button
44 variant="primary"
45 data-test-id="serverPowerOperations-button-powerOn"
46 @click="powerOn"
47 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080048 {{ $t('pageServerPowerOperations.powerOn') }}
49 </b-button>
50 </template>
51 <template v-else-if="hostStatus === 'on'">
52 <!-- Reboot server options -->
53 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
54 <b-form-group
55 :label="$t('pageServerPowerOperations.rebootServer')"
56 >
57 <b-form-radio
58 v-model="form.rebootOption"
59 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053060 data-test-id="serverPowerOperations-radio-rebootOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080061 value="orderly"
62 >
63 {{ $t('pageServerPowerOperations.orderlyReboot') }}
64 </b-form-radio>
65 <b-form-radio
66 v-model="form.rebootOption"
67 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053068 data-test-id="serverPowerOperations-radio-rebootImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080069 value="immediate"
70 >
71 {{ $t('pageServerPowerOperations.immediateReboot') }}
72 </b-form-radio>
73 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053074 <b-button
75 variant="primary"
76 type="submit"
77 data-test-id="serverPowerOperations-button-reboot"
78 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080079 {{ $t('pageServerPowerOperations.reboot') }}
80 </b-button>
81 </b-form>
82 <!-- Shutdown server options -->
83 <b-form novalidate @submit.prevent="shutdownServer">
84 <b-form-group
85 :label="$t('pageServerPowerOperations.shutdownServer')"
86 >
87 <b-form-radio
88 v-model="form.shutdownOption"
89 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053090 data-test-id="serverPowerOperations-radio-shutdownOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080091 value="orderly"
92 >
93 {{ $t('pageServerPowerOperations.orderlyShutdown') }}
94 </b-form-radio>
95 <b-form-radio
96 v-model="form.shutdownOption"
97 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053098 data-test-id="serverPowerOperations-radio-shutdownImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080099 value="immediate"
100 >
101 {{ $t('pageServerPowerOperations.immediateShutdown') }}
102 </b-form-radio>
103 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530104 <b-button
105 variant="primary"
106 type="submit"
107 data-test-id="serverPowerOperations-button-shutDown"
108 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800109 {{ $t('pageServerPowerOperations.shutDown') }}
110 </b-button>
111 </b-form>
112 </template>
113 <template v-else>
114 {{ $t('global.status.notAvailable') }}
115 </template>
116 </page-section>
117 </b-col>
118 </b-row>
119 </b-container>
120</template>
121
122<script>
123import PageTitle from '../../../components/Global/PageTitle';
124import PageSection from '../../../components/Global/PageSection';
125import BVToastMixin from '../../../components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800126import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700127import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800128
129export default {
130 name: 'ServerPowerOperations',
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800131 components: { PageTitle, PageSection, BootSettings },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700132 mixins: [BVToastMixin, LoadingBarMixin],
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800133 data() {
134 return {
135 form: {
136 rebootOption: 'orderly',
137 shutdownOption: 'orderly'
138 }
139 };
140 },
141 computed: {
142 hostStatus() {
143 return this.$store.getters['global/hostStatus'];
144 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800145 isOperationInProgress() {
146 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800147 },
148 oneTimeBootEnabled() {
149 return this.$store.getters['hostBootSettings/overrideEnabled'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800150 }
151 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700152 created() {
153 this.startLoader();
154 },
155 beforeRouteLeave(to, from, next) {
156 this.hideLoader();
157 next();
158 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800159 methods: {
160 powerOn() {
161 this.$store.dispatch('controls/hostPowerOn');
162 },
163 rebootServer() {
164 const modalMessage = this.$t(
165 'pageServerPowerOperations.modal.confirmRebootMessage'
166 );
167 const modalOptions = {
168 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
169 okTitle: this.$t('global.action.confirm')
170 };
171
172 if (this.form.rebootOption === 'orderly') {
173 this.$bvModal
174 .msgBoxConfirm(modalMessage, modalOptions)
175 .then(confirmed => {
176 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
177 });
178 } else if (this.form.rebootOption === 'immediate') {
179 this.$bvModal
180 .msgBoxConfirm(modalMessage, modalOptions)
181 .then(confirmed => {
182 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
183 });
184 }
185 },
186 shutdownServer() {
187 const modalMessage = this.$t(
188 'pageServerPowerOperations.modal.confirmShutdownMessage'
189 );
190 const modalOptions = {
191 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
192 okTitle: this.$t('global.action.confirm')
193 };
194
195 if (this.form.shutdownOption === 'orderly') {
196 this.$bvModal
197 .msgBoxConfirm(modalMessage, modalOptions)
198 .then(confirmed => {
199 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
200 });
201 }
202 if (this.form.shutdownOption === 'immediate') {
203 this.$bvModal
204 .msgBoxConfirm(modalMessage, modalOptions)
205 .then(confirmed => {
206 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
207 });
208 }
209 }
210 }
211};
212</script>