blob: 41d8cf076ecb4bc2650614f7095a161757206533 [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>
Yoshie Muranakae9fc6122020-08-10 15:12:09 -070051 <template v-else>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080052 <!-- 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>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800113 </page-section>
114 </b-col>
115 </b-row>
116 </b-container>
117</template>
118
119<script>
120import PageTitle from '../../../components/Global/PageTitle';
121import PageSection from '../../../components/Global/PageSection';
122import BVToastMixin from '../../../components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800123import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700124import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800125
126export default {
127 name: 'ServerPowerOperations',
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800128 components: { PageTitle, PageSection, BootSettings },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700129 mixins: [BVToastMixin, LoadingBarMixin],
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800130 data() {
131 return {
132 form: {
133 rebootOption: 'orderly',
134 shutdownOption: 'orderly'
135 }
136 };
137 },
138 computed: {
139 hostStatus() {
140 return this.$store.getters['global/hostStatus'];
141 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800142 isOperationInProgress() {
143 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800144 },
145 oneTimeBootEnabled() {
146 return this.$store.getters['hostBootSettings/overrideEnabled'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800147 }
148 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700149 created() {
150 this.startLoader();
151 },
152 beforeRouteLeave(to, from, next) {
153 this.hideLoader();
154 next();
155 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800156 methods: {
157 powerOn() {
158 this.$store.dispatch('controls/hostPowerOn');
159 },
160 rebootServer() {
161 const modalMessage = this.$t(
162 'pageServerPowerOperations.modal.confirmRebootMessage'
163 );
164 const modalOptions = {
165 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
166 okTitle: this.$t('global.action.confirm')
167 };
168
169 if (this.form.rebootOption === 'orderly') {
170 this.$bvModal
171 .msgBoxConfirm(modalMessage, modalOptions)
172 .then(confirmed => {
173 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
174 });
175 } else if (this.form.rebootOption === 'immediate') {
176 this.$bvModal
177 .msgBoxConfirm(modalMessage, modalOptions)
178 .then(confirmed => {
179 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
180 });
181 }
182 },
183 shutdownServer() {
184 const modalMessage = this.$t(
185 'pageServerPowerOperations.modal.confirmShutdownMessage'
186 );
187 const modalOptions = {
188 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
189 okTitle: this.$t('global.action.confirm')
190 };
191
192 if (this.form.shutdownOption === 'orderly') {
193 this.$bvModal
194 .msgBoxConfirm(modalMessage, modalOptions)
195 .then(confirmed => {
196 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
197 });
198 }
199 if (this.form.shutdownOption === 'immediate') {
200 this.$bvModal
201 .msgBoxConfirm(modalMessage, modalOptions)
202 .then(confirmed => {
203 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
204 });
205 }
206 }
207 }
208};
209</script>