blob: 8dca96ed4256538ed6aa3e4f40c7ff2163cd3151 [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 >
Surya Vde23ea22024-07-11 15:19:46 +053047 {{ $filters.formatDate(lastPowerOperationTime) }}
48 {{ $filters.formatTime(lastPowerOperationTime) }}
Dixsie Wolmersbb316062020-08-04 19:17:33 -050049 </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>
Huy Le Anha5dbf552025-01-13 07:35:35 +000058 <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 >
Aravinth S99fe2282025-08-20 15:08:17 +053062 <boot-settings :is-button-disable="isButtonDisable" />
Yoshie Muranakac05ff642020-02-26 14:23:15 -080063 </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"
Aravinth S99fe2282025-08-20 15:08:17 +053081 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053082 @click="powerOn"
83 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080084 {{ $t('pageServerPowerOperations.powerOn') }}
85 </b-button>
86 </template>
Yoshie Muranakae9fc6122020-08-10 15:12:09 -070087 <template v-else>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080088 <!-- Reboot server options -->
89 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
90 <b-form-group
91 :label="$t('pageServerPowerOperations.rebootServer')"
92 >
93 <b-form-radio
94 v-model="form.rebootOption"
95 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053096 data-test-id="serverPowerOperations-radio-rebootOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080097 value="orderly"
98 >
Shubhi Garg918526f2024-09-19 17:08:28 +053099 {{ $t('pageServerPowerOperations.gracefulRestart') }}
100 <info-tooltip
101 :title="$t('pageServerPowerOperations.gracefulRestartInfo')"
102 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800103 </b-form-radio>
104 <b-form-radio
105 v-model="form.rebootOption"
106 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530107 data-test-id="serverPowerOperations-radio-rebootImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800108 value="immediate"
109 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530110 {{ $t('pageServerPowerOperations.forceRestart') }}
111 <info-tooltip
112 :title="$t('pageServerPowerOperations.forceRestartInfo')"
113 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800114 </b-form-radio>
115 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530116 <b-button
117 variant="primary"
118 type="submit"
119 data-test-id="serverPowerOperations-button-reboot"
Aravinth S99fe2282025-08-20 15:08:17 +0530120 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530121 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800122 {{ $t('pageServerPowerOperations.reboot') }}
123 </b-button>
124 </b-form>
125 <!-- Shutdown server options -->
126 <b-form novalidate @submit.prevent="shutdownServer">
127 <b-form-group
128 :label="$t('pageServerPowerOperations.shutdownServer')"
129 >
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-shutdownOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800134 value="orderly"
135 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530136 {{ $t('pageServerPowerOperations.gracefulShutdown') }}
137 <info-tooltip
138 :title="
139 $t('pageServerPowerOperations.gracefulShutdownInfo')
140 "
141 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800142 </b-form-radio>
143 <b-form-radio
144 v-model="form.shutdownOption"
145 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530146 data-test-id="serverPowerOperations-radio-shutdownImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800147 value="immediate"
148 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530149 {{ $t('pageServerPowerOperations.forceOff') }}
150 <info-tooltip
151 :title="$t('pageServerPowerOperations.forceOffInfo')"
152 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800153 </b-form-radio>
154 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530155 <b-button
156 variant="primary"
157 type="submit"
158 data-test-id="serverPowerOperations-button-shutDown"
Aravinth S99fe2282025-08-20 15:08:17 +0530159 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530160 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800161 {{ $t('pageServerPowerOperations.shutDown') }}
162 </b-button>
163 </b-form>
164 </template>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800165 </page-section>
166 </b-col>
167 </b-row>
168 </b-container>
169</template>
170
171<script>
SurenNewaread8438b2020-08-20 18:32:28 +0530172import PageTitle from '@/components/Global/PageTitle';
173import PageSection from '@/components/Global/PageSection';
174import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800175import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700176import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
SurenNewaread8438b2020-08-20 18:32:28 +0530177import Alert from '@/components/Global/Alert';
Shubhi Garg918526f2024-09-19 17:08:28 +0530178import InfoTooltip from '@/components/Global/InfoTooltip';
Surya Vde23ea22024-07-11 15:19:46 +0530179import { useI18n } from 'vue-i18n';
180import i18n from '@/i18n';
Aravinth S99fe2282025-08-20 15:08:17 +0530181import { privilegesId } from '@/store/modules/GlobalStore';
182import { mapGetters } from 'vuex';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800183
184export default {
185 name: 'ServerPowerOperations',
Shubhi Garg918526f2024-09-19 17:08:28 +0530186 components: { PageTitle, PageSection, BootSettings, Alert, InfoTooltip },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700187 mixins: [BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500188 beforeRouteLeave(to, from, next) {
189 this.hideLoader();
190 next();
191 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800192 data() {
193 return {
Surya Vde23ea22024-07-11 15:19:46 +0530194 $t: useI18n().t,
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800195 form: {
196 rebootOption: 'orderly',
Derick Montague602e98a2020-10-21 16:20:00 -0500197 shutdownOption: 'orderly',
198 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800199 };
200 },
201 computed: {
Aravinth S99fe2282025-08-20 15:08:17 +0530202 ...mapGetters('global', ['userPrivilege']),
203 isButtonDisable() {
204 return this.userPrivilege === privilegesId.readOnly;
205 },
Derick Montague71114fe2021-05-06 18:17:34 -0500206 serverStatus() {
207 return this.$store.getters['global/serverStatus'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800208 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800209 isOperationInProgress() {
210 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800211 },
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500212 lastPowerOperationTime() {
213 return this.$store.getters['controls/lastPowerOperationTime'];
214 },
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800215 oneTimeBootEnabled() {
Derick Montague71114fe2021-05-06 18:17:34 -0500216 return this.$store.getters['serverBootSettings/overrideEnabled'];
Derick Montague602e98a2020-10-21 16:20:00 -0500217 },
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530218 hasBootSourceOptions() {
Ed Tanous81323992024-02-27 11:26:24 -0800219 let bootOptions =
220 this.$store.getters['serverBootSettings/bootSourceOptions'];
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530221 return bootOptions.length !== 0;
222 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800223 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700224 created() {
225 this.startLoader();
Derick Montague602e98a2020-10-21 16:20:00 -0500226 const bootSettingsPromise = new Promise((resolve) => {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530227 this.$root.$on('server-power-operations-boot-settings-complete', () =>
Ed Tanous81323992024-02-27 11:26:24 -0800228 resolve(),
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500229 );
230 });
231 Promise.all([
Derick Montague71114fe2021-05-06 18:17:34 -0500232 this.$store.dispatch('serverBootSettings/getBootSettings'),
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500233 this.$store.dispatch('controls/getLastPowerOperationTime'),
Derick Montague602e98a2020-10-21 16:20:00 -0500234 bootSettingsPromise,
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500235 ]).finally(() => this.endLoader());
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700236 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800237 methods: {
238 powerOn() {
Derick Montague71114fe2021-05-06 18:17:34 -0500239 this.$store.dispatch('controls/serverPowerOn');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800240 },
241 rebootServer() {
Surya Vde23ea22024-07-11 15:19:46 +0530242 const modalMessage = i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800243 'pageServerPowerOperations.modal.confirmRebootMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800244 );
245 const modalOptions = {
Surya Vde23ea22024-07-11 15:19:46 +0530246 title: i18n.global.t(
247 'pageServerPowerOperations.modal.confirmRebootTitle',
248 ),
249 okTitle: i18n.global.t('global.action.confirm'),
250 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000251 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800252 };
253
254 if (this.form.rebootOption === 'orderly') {
255 this.$bvModal
256 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500257 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500258 if (confirmed) this.$store.dispatch('controls/serverSoftReboot');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800259 });
260 } else if (this.form.rebootOption === 'immediate') {
261 this.$bvModal
262 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500263 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500264 if (confirmed) this.$store.dispatch('controls/serverHardReboot');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800265 });
266 }
267 },
268 shutdownServer() {
Surya Vde23ea22024-07-11 15:19:46 +0530269 const modalMessage = i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800270 'pageServerPowerOperations.modal.confirmShutdownMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800271 );
272 const modalOptions = {
Surya Vde23ea22024-07-11 15:19:46 +0530273 title: i18n.global.t(
274 'pageServerPowerOperations.modal.confirmShutdownTitle',
275 ),
276 okTitle: i18n.global.t('global.action.confirm'),
277 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000278 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800279 };
280
281 if (this.form.shutdownOption === 'orderly') {
282 this.$bvModal
283 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500284 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500285 if (confirmed) this.$store.dispatch('controls/serverSoftPowerOff');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800286 });
287 }
288 if (this.form.shutdownOption === 'immediate') {
289 this.$bvModal
290 .msgBoxConfirm(modalMessage, modalOptions)
Derick Montague602e98a2020-10-21 16:20:00 -0500291 .then((confirmed) => {
Derick Montague71114fe2021-05-06 18:17:34 -0500292 if (confirmed) this.$store.dispatch('controls/serverHardPowerOff');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800293 });
294 }
Derick Montague602e98a2020-10-21 16:20:00 -0500295 },
296 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800297};
298</script>