blob: 01fc661e75646b8221ab6c8d5c9d52a92fdbcd5f [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 Muranakafa1512b2020-02-25 15:54:07 -0800111
112export default {
113 name: 'ServerPowerOperations',
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800114 components: { PageTitle, PageSection, BootSettings },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800115 mixins: [BVToastMixin],
116 data() {
117 return {
118 form: {
119 rebootOption: 'orderly',
120 shutdownOption: 'orderly'
121 }
122 };
123 },
124 computed: {
125 hostStatus() {
126 return this.$store.getters['global/hostStatus'];
127 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800128 isOperationInProgress() {
129 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800130 },
131 oneTimeBootEnabled() {
132 return this.$store.getters['hostBootSettings/overrideEnabled'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800133 }
134 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800135 methods: {
136 powerOn() {
137 this.$store.dispatch('controls/hostPowerOn');
138 },
139 rebootServer() {
140 const modalMessage = this.$t(
141 'pageServerPowerOperations.modal.confirmRebootMessage'
142 );
143 const modalOptions = {
144 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
145 okTitle: this.$t('global.action.confirm')
146 };
147
148 if (this.form.rebootOption === 'orderly') {
149 this.$bvModal
150 .msgBoxConfirm(modalMessage, modalOptions)
151 .then(confirmed => {
152 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
153 });
154 } else if (this.form.rebootOption === 'immediate') {
155 this.$bvModal
156 .msgBoxConfirm(modalMessage, modalOptions)
157 .then(confirmed => {
158 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
159 });
160 }
161 },
162 shutdownServer() {
163 const modalMessage = this.$t(
164 'pageServerPowerOperations.modal.confirmShutdownMessage'
165 );
166 const modalOptions = {
167 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
168 okTitle: this.$t('global.action.confirm')
169 };
170
171 if (this.form.shutdownOption === 'orderly') {
172 this.$bvModal
173 .msgBoxConfirm(modalMessage, modalOptions)
174 .then(confirmed => {
175 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
176 });
177 }
178 if (this.form.shutdownOption === 'immediate') {
179 this.$bvModal
180 .msgBoxConfirm(modalMessage, modalOptions)
181 .then(confirmed => {
182 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
183 });
184 }
185 }
186 }
187};
188</script>