blob: 441217f20fda2e736cd40aa9e091eb1ce29b95dc [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'">
43 <b-button variant="primary" @click="powerOn">
44 {{ $t('pageServerPowerOperations.powerOn') }}
45 </b-button>
46 </template>
47 <template v-else-if="hostStatus === 'on'">
48 <!-- Reboot server options -->
49 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
50 <b-form-group
51 :label="$t('pageServerPowerOperations.rebootServer')"
52 >
53 <b-form-radio
54 v-model="form.rebootOption"
55 name="reboot-option"
56 value="orderly"
57 >
58 {{ $t('pageServerPowerOperations.orderlyReboot') }}
59 </b-form-radio>
60 <b-form-radio
61 v-model="form.rebootOption"
62 name="reboot-option"
63 value="immediate"
64 >
65 {{ $t('pageServerPowerOperations.immediateReboot') }}
66 </b-form-radio>
67 </b-form-group>
68 <b-button variant="primary" type="submit">
69 {{ $t('pageServerPowerOperations.reboot') }}
70 </b-button>
71 </b-form>
72 <!-- Shutdown server options -->
73 <b-form novalidate @submit.prevent="shutdownServer">
74 <b-form-group
75 :label="$t('pageServerPowerOperations.shutdownServer')"
76 >
77 <b-form-radio
78 v-model="form.shutdownOption"
79 name="shutdown-option"
80 value="orderly"
81 >
82 {{ $t('pageServerPowerOperations.orderlyShutdown') }}
83 </b-form-radio>
84 <b-form-radio
85 v-model="form.shutdownOption"
86 name="shutdown-option"
87 value="immediate"
88 >
89 {{ $t('pageServerPowerOperations.immediateShutdown') }}
90 </b-form-radio>
91 </b-form-group>
92 <b-button variant="primary" type="submit">
93 {{ $t('pageServerPowerOperations.shutDown') }}
94 </b-button>
95 </b-form>
96 </template>
97 <template v-else>
98 {{ $t('global.status.notAvailable') }}
99 </template>
100 </page-section>
101 </b-col>
102 </b-row>
103 </b-container>
104</template>
105
106<script>
107import PageTitle from '../../../components/Global/PageTitle';
108import PageSection from '../../../components/Global/PageSection';
109import BVToastMixin from '../../../components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800110import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700111import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800112
113export default {
114 name: 'ServerPowerOperations',
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800115 components: { PageTitle, PageSection, BootSettings },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700116 mixins: [BVToastMixin, LoadingBarMixin],
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800117 data() {
118 return {
119 form: {
120 rebootOption: 'orderly',
121 shutdownOption: 'orderly'
122 }
123 };
124 },
125 computed: {
126 hostStatus() {
127 return this.$store.getters['global/hostStatus'];
128 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800129 isOperationInProgress() {
130 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800131 },
132 oneTimeBootEnabled() {
133 return this.$store.getters['hostBootSettings/overrideEnabled'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800134 }
135 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700136 created() {
137 this.startLoader();
138 },
139 beforeRouteLeave(to, from, next) {
140 this.hideLoader();
141 next();
142 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800143 methods: {
144 powerOn() {
145 this.$store.dispatch('controls/hostPowerOn');
146 },
147 rebootServer() {
148 const modalMessage = this.$t(
149 'pageServerPowerOperations.modal.confirmRebootMessage'
150 );
151 const modalOptions = {
152 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
153 okTitle: this.$t('global.action.confirm')
154 };
155
156 if (this.form.rebootOption === 'orderly') {
157 this.$bvModal
158 .msgBoxConfirm(modalMessage, modalOptions)
159 .then(confirmed => {
160 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
161 });
162 } else if (this.form.rebootOption === 'immediate') {
163 this.$bvModal
164 .msgBoxConfirm(modalMessage, modalOptions)
165 .then(confirmed => {
166 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
167 });
168 }
169 },
170 shutdownServer() {
171 const modalMessage = this.$t(
172 'pageServerPowerOperations.modal.confirmShutdownMessage'
173 );
174 const modalOptions = {
175 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
176 okTitle: this.$t('global.action.confirm')
177 };
178
179 if (this.form.shutdownOption === 'orderly') {
180 this.$bvModal
181 .msgBoxConfirm(modalMessage, modalOptions)
182 .then(confirmed => {
183 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
184 });
185 }
186 if (this.form.shutdownOption === 'immediate') {
187 this.$bvModal
188 .msgBoxConfirm(modalMessage, modalOptions)
189 .then(confirmed => {
190 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
191 });
192 }
193 }
194 }
195};
196</script>