blob: 4efaebc680a7e7cb0052cf70854b0c90990610f4 [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 />
4 <b-row>
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>
10 <dt>{{ $t('pageServerPowerOperations.hostname') }}</dt>
11 <dd>{{ hostname }}</dd>
12 </dl>
13 <dl>
14 <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
15 <dd v-if="hostStatus === 'on'">
16 {{ $t('global.status.on') }}
17 </dd>
18 <dd v-else-if="hostStatus === 'off'">
19 {{ $t('global.status.off') }}
20 </dd>
21 <dd v-else>
22 {{ $t('global.status.notAvailable') }}
23 </dd>
24 </dl>
25 </page-section>
26 </b-col>
27 </b-row>
28 <b-row>
Yoshie Muranakac05ff642020-02-26 14:23:15 -080029 <b-col sm="8" md="6" xl="4">
30 <page-section
31 :section-title="$t('pageServerPowerOperations.hostOsBootSettings')"
32 >
33 <boot-settings />
34 </page-section>
35 </b-col>
36 <b-col sm="8" md="6" xl="7">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080037 <page-section
38 :section-title="$t('pageServerPowerOperations.operations')"
39 >
Yoshie Muranakac05ff642020-02-26 14:23:15 -080040 <b-alert :show="oneTimeBootEnabled" variant="warning">
41 {{ $t('pageServerPowerOperations.oneTimeBootWarning') }}
42 </b-alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080043 <template v-if="isOperationInProgress">
44 {{ $t('pageServerPowerOperations.operationInProgress') }}
45 </template>
46 <template v-else-if="hostStatus === 'off'">
47 <b-button variant="primary" @click="powerOn">
48 {{ $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"
60 value="orderly"
61 >
62 {{ $t('pageServerPowerOperations.orderlyReboot') }}
63 </b-form-radio>
64 <b-form-radio
65 v-model="form.rebootOption"
66 name="reboot-option"
67 value="immediate"
68 >
69 {{ $t('pageServerPowerOperations.immediateReboot') }}
70 </b-form-radio>
71 </b-form-group>
72 <b-button variant="primary" type="submit">
73 {{ $t('pageServerPowerOperations.reboot') }}
74 </b-button>
75 </b-form>
76 <!-- Shutdown server options -->
77 <b-form novalidate @submit.prevent="shutdownServer">
78 <b-form-group
79 :label="$t('pageServerPowerOperations.shutdownServer')"
80 >
81 <b-form-radio
82 v-model="form.shutdownOption"
83 name="shutdown-option"
84 value="orderly"
85 >
86 {{ $t('pageServerPowerOperations.orderlyShutdown') }}
87 </b-form-radio>
88 <b-form-radio
89 v-model="form.shutdownOption"
90 name="shutdown-option"
91 value="immediate"
92 >
93 {{ $t('pageServerPowerOperations.immediateShutdown') }}
94 </b-form-radio>
95 </b-form-group>
96 <b-button variant="primary" type="submit">
97 {{ $t('pageServerPowerOperations.shutDown') }}
98 </b-button>
99 </b-form>
100 </template>
101 <template v-else>
102 {{ $t('global.status.notAvailable') }}
103 </template>
104 </page-section>
105 </b-col>
106 </b-row>
107 </b-container>
108</template>
109
110<script>
111import PageTitle from '../../../components/Global/PageTitle';
112import PageSection from '../../../components/Global/PageSection';
113import BVToastMixin from '../../../components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800114import BootSettings from './BootSettings';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800115
116export default {
117 name: 'ServerPowerOperations',
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800118 components: { PageTitle, PageSection, BootSettings },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800119 mixins: [BVToastMixin],
120 data() {
121 return {
122 form: {
123 rebootOption: 'orderly',
124 shutdownOption: 'orderly'
125 }
126 };
127 },
128 computed: {
129 hostStatus() {
130 return this.$store.getters['global/hostStatus'];
131 },
132 hostname() {
133 return this.$store.getters['global/hostName'];
134 },
135 isOperationInProgress() {
136 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800137 },
138 oneTimeBootEnabled() {
139 return this.$store.getters['hostBootSettings/overrideEnabled'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800140 }
141 },
142 created() {
143 this.$store.dispatch('global/getHostName');
144 },
145 methods: {
146 powerOn() {
147 this.$store.dispatch('controls/hostPowerOn');
148 },
149 rebootServer() {
150 const modalMessage = this.$t(
151 'pageServerPowerOperations.modal.confirmRebootMessage'
152 );
153 const modalOptions = {
154 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
155 okTitle: this.$t('global.action.confirm')
156 };
157
158 if (this.form.rebootOption === 'orderly') {
159 this.$bvModal
160 .msgBoxConfirm(modalMessage, modalOptions)
161 .then(confirmed => {
162 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
163 });
164 } else if (this.form.rebootOption === 'immediate') {
165 this.$bvModal
166 .msgBoxConfirm(modalMessage, modalOptions)
167 .then(confirmed => {
168 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
169 });
170 }
171 },
172 shutdownServer() {
173 const modalMessage = this.$t(
174 'pageServerPowerOperations.modal.confirmShutdownMessage'
175 );
176 const modalOptions = {
177 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
178 okTitle: this.$t('global.action.confirm')
179 };
180
181 if (this.form.shutdownOption === 'orderly') {
182 this.$bvModal
183 .msgBoxConfirm(modalMessage, modalOptions)
184 .then(confirmed => {
185 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
186 });
187 }
188 if (this.form.shutdownOption === 'immediate') {
189 this.$bvModal
190 .msgBoxConfirm(modalMessage, modalOptions)
191 .then(confirmed => {
192 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
193 });
194 }
195 }
196 }
197};
198</script>