blob: 281bbef46e03befd82457aeadbe5248882093cd9 [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 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -05009 <b-row>
10 <b-col>
11 <dl>
Derick Montague71114fe2021-05-06 18:17:34 -050012 <dt>{{ $t('pageServerPowerOperations.serverStatus') }}</dt>
SurenNeware84ea7ab2021-02-17 19:06:06 +053013 <dd
Derick Montague71114fe2021-05-06 18:17:34 -050014 v-if="serverStatus === 'on'"
SurenNeware84ea7ab2021-02-17 19:06:06 +053015 data-test-id="powerServerOps-text-hostStatus"
16 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -050017 {{ $t('global.status.on') }}
18 </dd>
SurenNeware84ea7ab2021-02-17 19:06:06 +053019 <dd
Derick Montague71114fe2021-05-06 18:17:34 -050020 v-else-if="serverStatus === 'off'"
SurenNeware84ea7ab2021-02-17 19:06:06 +053021 data-test-id="powerServerOps-text-hostStatus"
22 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -050023 {{ $t('global.status.off') }}
24 </dd>
glukhov.mikhailed7278a2022-09-26 11:17:57 +030025 <dd
26 v-else-if="serverStatus === 'diagnosticMode'"
27 data-test-id="powerServerOps-text-hostStatus"
28 >
29 {{ $t('global.status.diagnosticMode') }}
30 </dd>
Dixsie Wolmersbb316062020-08-04 19:17:33 -050031 <dd v-else>
32 {{ $t('global.status.notAvailable') }}
33 </dd>
34 </dl>
35 </b-col>
36 </b-row>
37 <b-row>
38 <b-col>
39 <dl>
40 <dt>
41 {{ $t('pageServerPowerOperations.lastPowerOperation') }}
42 </dt>
SurenNeware84ea7ab2021-02-17 19:06:06 +053043 <dd
44 v-if="lastPowerOperationTime"
45 data-test-id="powerServerOps-text-lastPowerOp"
46 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -050047 {{ lastPowerOperationTime | formatDate }}
48 {{ lastPowerOperationTime | formatTime }}
49 </dd>
50 <dd v-else>--</dd>
51 </dl>
52 </b-col>
53 </b-row>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080054 </page-section>
55 </b-col>
56 </b-row>
57 <b-row>
Sukanya Pandey7f6edb62021-03-30 19:49:08 +053058 <b-col v-if="hasBootSourceOptions" sm="8" md="6" xl="4">
Yoshie Muranakac05ff642020-02-26 14:23:15 -080059 <page-section
Derick Montague71114fe2021-05-06 18:17:34 -050060 :section-title="$t('pageServerPowerOperations.serverBootSettings')"
Yoshie Muranakac05ff642020-02-26 14:23:15 -080061 >
62 <boot-settings />
63 </page-section>
64 </b-col>
65 <b-col sm="8" md="6" xl="7">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080066 <page-section
67 :section-title="$t('pageServerPowerOperations.operations')"
68 >
SurenNewaread8438b2020-08-20 18:32:28 +053069 <alert :show="oneTimeBootEnabled" variant="warning">
Yoshie Muranakac05ff642020-02-26 14:23:15 -080070 {{ $t('pageServerPowerOperations.oneTimeBootWarning') }}
SurenNewaread8438b2020-08-20 18:32:28 +053071 </alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080072 <template v-if="isOperationInProgress">
SurenNewaread8438b2020-08-20 18:32:28 +053073 <alert variant="info">
74 {{ $t('pageServerPowerOperations.operationInProgress') }}
75 </alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080076 </template>
Derick Montague71114fe2021-05-06 18:17:34 -050077 <template v-else-if="serverStatus === 'off'">
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053078 <b-button
79 variant="primary"
80 data-test-id="serverPowerOperations-button-powerOn"
81 @click="powerOn"
82 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080083 {{ $t('pageServerPowerOperations.powerOn') }}
84 </b-button>
85 </template>
Yoshie Muranakae9fc6122020-08-10 15:12:09 -070086 <template v-else>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080087 <!-- Reboot server options -->
88 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
89 <b-form-group
90 :label="$t('pageServerPowerOperations.rebootServer')"
91 >
92 <b-form-radio
93 v-model="form.rebootOption"
94 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053095 data-test-id="serverPowerOperations-radio-rebootOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080096 value="orderly"
97 >
98 {{ $t('pageServerPowerOperations.orderlyReboot') }}
99 </b-form-radio>
100 <b-form-radio
101 v-model="form.rebootOption"
102 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530103 data-test-id="serverPowerOperations-radio-rebootImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800104 value="immediate"
105 >
106 {{ $t('pageServerPowerOperations.immediateReboot') }}
107 </b-form-radio>
108 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530109 <b-button
110 variant="primary"
111 type="submit"
112 data-test-id="serverPowerOperations-button-reboot"
113 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800114 {{ $t('pageServerPowerOperations.reboot') }}
115 </b-button>
116 </b-form>
117 <!-- Shutdown server options -->
118 <b-form novalidate @submit.prevent="shutdownServer">
119 <b-form-group
120 :label="$t('pageServerPowerOperations.shutdownServer')"
121 >
122 <b-form-radio
123 v-model="form.shutdownOption"
124 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530125 data-test-id="serverPowerOperations-radio-shutdownOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800126 value="orderly"
127 >
128 {{ $t('pageServerPowerOperations.orderlyShutdown') }}
129 </b-form-radio>
130 <b-form-radio
131 v-model="form.shutdownOption"
132 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530133 data-test-id="serverPowerOperations-radio-shutdownImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800134 value="immediate"
135 >
136 {{ $t('pageServerPowerOperations.immediateShutdown') }}
137 </b-form-radio>
138 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530139 <b-button
140 variant="primary"
141 type="submit"
142 data-test-id="serverPowerOperations-button-shutDown"
143 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800144 {{ $t('pageServerPowerOperations.shutDown') }}
145 </b-button>
146 </b-form>
147 </template>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800148 </page-section>
149 </b-col>
150 </b-row>
151 </b-container>
152</template>
153
154<script>
SurenNewaread8438b2020-08-20 18:32:28 +0530155import PageTitle from '@/components/Global/PageTitle';
156import PageSection from '@/components/Global/PageSection';
157import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800158import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700159import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
SurenNewaread8438b2020-08-20 18:32:28 +0530160import Alert from '@/components/Global/Alert';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800161
162export default {
163 name: 'ServerPowerOperations',
SurenNewaread8438b2020-08-20 18:32:28 +0530164 components: { PageTitle, PageSection, BootSettings, Alert },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700165 mixins: [BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500166 beforeRouteLeave(to, from, next) {
167 this.hideLoader();
168 next();
169 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800170 data() {
171 return {
172 form: {
173 rebootOption: 'orderly',
Derick Montague602e98a2020-10-21 16:20:00 -0500174 shutdownOption: 'orderly',
175 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800176 };
177 },
178 computed: {
Derick Montague71114fe2021-05-06 18:17:34 -0500179 serverStatus() {
180 return this.$store.getters['global/serverStatus'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800181 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800182 isOperationInProgress() {
183 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800184 },
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500185 lastPowerOperationTime() {
186 return this.$store.getters['controls/lastPowerOperationTime'];
187 },
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800188 oneTimeBootEnabled() {
Derick Montague71114fe2021-05-06 18:17:34 -0500189 return this.$store.getters['serverBootSettings/overrideEnabled'];
Derick Montague602e98a2020-10-21 16:20:00 -0500190 },
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530191 hasBootSourceOptions() {
Ed Tanous81323992024-02-27 11:26:24 -0800192 let bootOptions =
193 this.$store.getters['serverBootSettings/bootSourceOptions'];
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530194 return bootOptions.length !== 0;
195 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800196 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700197 created() {
198 this.startLoader();
Derick Montague602e98a2020-10-21 16:20:00 -0500199 const bootSettingsPromise = new Promise((resolve) => {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530200 this.$root.$on('server-power-operations-boot-settings-complete', () =>
Ed Tanous81323992024-02-27 11:26:24 -0800201 resolve(),
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500202 );
203 });
204 Promise.all([
Derick Montague71114fe2021-05-06 18:17:34 -0500205 this.$store.dispatch('serverBootSettings/getBootSettings'),
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500206 this.$store.dispatch('controls/getLastPowerOperationTime'),
Derick Montague602e98a2020-10-21 16:20:00 -0500207 bootSettingsPromise,
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500208 ]).finally(() => this.endLoader());
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700209 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800210 methods: {
211 powerOn() {
Derick Montague71114fe2021-05-06 18:17:34 -0500212 this.$store.dispatch('controls/serverPowerOn');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800213 },
214 rebootServer() {
215 const modalMessage = this.$t(
Ed Tanous81323992024-02-27 11:26:24 -0800216 'pageServerPowerOperations.modal.confirmRebootMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800217 );
218 const modalOptions = {
219 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
Derick Montague602e98a2020-10-21 16:20:00 -0500220 okTitle: this.$t('global.action.confirm'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530221 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000222 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800223 };
224
225 if (this.form.rebootOption === 'orderly') {
226 this.$bvModal
227 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500228 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500229 if (confirmed) this.$store.dispatch('controls/serverSoftReboot');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800230 });
231 } else if (this.form.rebootOption === 'immediate') {
232 this.$bvModal
233 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500234 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500235 if (confirmed) this.$store.dispatch('controls/serverHardReboot');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800236 });
237 }
238 },
239 shutdownServer() {
240 const modalMessage = this.$t(
Ed Tanous81323992024-02-27 11:26:24 -0800241 'pageServerPowerOperations.modal.confirmShutdownMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800242 );
243 const modalOptions = {
244 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
Derick Montague602e98a2020-10-21 16:20:00 -0500245 okTitle: this.$t('global.action.confirm'),
Sukanya Pandey38357132020-12-22 13:40:59 +0530246 cancelTitle: this.$t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000247 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800248 };
249
250 if (this.form.shutdownOption === 'orderly') {
251 this.$bvModal
252 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500253 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500254 if (confirmed) this.$store.dispatch('controls/serverSoftPowerOff');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800255 });
256 }
257 if (this.form.shutdownOption === 'immediate') {
258 this.$bvModal
259 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500260 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500261 if (confirmed) this.$store.dispatch('controls/serverHardPowerOff');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800262 });
263 }
Derick Montague602e98a2020-10-21 16:20:00 -0500264 },
265 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800266};
267</script>