blob: 95a36d3c3a19fc7efa6d2b1b6396ca84df1861ff [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>
jason westoverd36ac8a2025-11-03 20:58:59 -060012 <dt>
13 {{ $t('pageServerPowerOperations.serverStatus') }}
14 </dt>
SurenNeware84ea7ab2021-02-17 19:06:06 +053015 <dd
Derick Montague71114fe2021-05-06 18:17:34 -050016 v-if="serverStatus === 'on'"
SurenNeware84ea7ab2021-02-17 19:06:06 +053017 data-test-id="powerServerOps-text-hostStatus"
18 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -050019 {{ $t('global.status.on') }}
20 </dd>
SurenNeware84ea7ab2021-02-17 19:06:06 +053021 <dd
Derick Montague71114fe2021-05-06 18:17:34 -050022 v-else-if="serverStatus === 'off'"
SurenNeware84ea7ab2021-02-17 19:06:06 +053023 data-test-id="powerServerOps-text-hostStatus"
24 >
Dixsie Wolmersbb316062020-08-04 19:17:33 -050025 {{ $t('global.status.off') }}
26 </dd>
glukhov.mikhailed7278a2022-09-26 11:17:57 +030027 <dd
28 v-else-if="serverStatus === 'diagnosticMode'"
29 data-test-id="powerServerOps-text-hostStatus"
30 >
31 {{ $t('global.status.diagnosticMode') }}
32 </dd>
Dixsie Wolmersbb316062020-08-04 19:17:33 -050033 <dd v-else>
34 {{ $t('global.status.notAvailable') }}
35 </dd>
36 </dl>
37 </b-col>
38 </b-row>
39 <b-row>
40 <b-col>
41 <dl>
42 <dt>
43 {{ $t('pageServerPowerOperations.lastPowerOperation') }}
44 </dt>
SurenNeware84ea7ab2021-02-17 19:06:06 +053045 <dd
46 v-if="lastPowerOperationTime"
47 data-test-id="powerServerOps-text-lastPowerOp"
48 >
Surya Vde23ea22024-07-11 15:19:46 +053049 {{ $filters.formatDate(lastPowerOperationTime) }}
50 {{ $filters.formatTime(lastPowerOperationTime) }}
Dixsie Wolmersbb316062020-08-04 19:17:33 -050051 </dd>
52 <dd v-else>--</dd>
53 </dl>
54 </b-col>
55 </b-row>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080056 </page-section>
57 </b-col>
58 </b-row>
59 <b-row>
Huy Le Anha5dbf552025-01-13 07:35:35 +000060 <b-col v-if="hasBootSourceOptions" sm="8" md="6" xl="4">
Yoshie Muranakac05ff642020-02-26 14:23:15 -080061 <page-section
Derick Montague71114fe2021-05-06 18:17:34 -050062 :section-title="$t('pageServerPowerOperations.serverBootSettings')"
Yoshie Muranakac05ff642020-02-26 14:23:15 -080063 >
Aravinth S99fe2282025-08-20 15:08:17 +053064 <boot-settings :is-button-disable="isButtonDisable" />
Yoshie Muranakac05ff642020-02-26 14:23:15 -080065 </page-section>
66 </b-col>
67 <b-col sm="8" md="6" xl="7">
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080068 <page-section
69 :section-title="$t('pageServerPowerOperations.operations')"
70 >
SurenNewaread8438b2020-08-20 18:32:28 +053071 <alert :show="oneTimeBootEnabled" variant="warning">
Yoshie Muranakac05ff642020-02-26 14:23:15 -080072 {{ $t('pageServerPowerOperations.oneTimeBootWarning') }}
SurenNewaread8438b2020-08-20 18:32:28 +053073 </alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080074 <template v-if="isOperationInProgress">
SurenNewaread8438b2020-08-20 18:32:28 +053075 <alert variant="info">
76 {{ $t('pageServerPowerOperations.operationInProgress') }}
77 </alert>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080078 </template>
Derick Montague71114fe2021-05-06 18:17:34 -050079 <template v-else-if="serverStatus === 'off'">
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053080 <b-button
81 variant="primary"
82 data-test-id="serverPowerOperations-button-powerOn"
Aravinth S99fe2282025-08-20 15:08:17 +053083 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053084 @click="powerOn"
85 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080086 {{ $t('pageServerPowerOperations.powerOn') }}
87 </b-button>
88 </template>
Yoshie Muranakae9fc6122020-08-10 15:12:09 -070089 <template v-else>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080090 <!-- Reboot server options -->
91 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
92 <b-form-group
93 :label="$t('pageServerPowerOperations.rebootServer')"
94 >
95 <b-form-radio
96 v-model="form.rebootOption"
97 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +053098 data-test-id="serverPowerOperations-radio-rebootOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -080099 value="orderly"
100 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530101 {{ $t('pageServerPowerOperations.gracefulRestart') }}
102 <info-tooltip
103 :title="$t('pageServerPowerOperations.gracefulRestartInfo')"
104 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800105 </b-form-radio>
106 <b-form-radio
107 v-model="form.rebootOption"
108 name="reboot-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530109 data-test-id="serverPowerOperations-radio-rebootImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800110 value="immediate"
111 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530112 {{ $t('pageServerPowerOperations.forceRestart') }}
113 <info-tooltip
114 :title="$t('pageServerPowerOperations.forceRestartInfo')"
115 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800116 </b-form-radio>
117 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530118 <b-button
119 variant="primary"
120 type="submit"
121 data-test-id="serverPowerOperations-button-reboot"
Aravinth S99fe2282025-08-20 15:08:17 +0530122 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530123 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800124 {{ $t('pageServerPowerOperations.reboot') }}
125 </b-button>
126 </b-form>
127 <!-- Shutdown server options -->
128 <b-form novalidate @submit.prevent="shutdownServer">
129 <b-form-group
130 :label="$t('pageServerPowerOperations.shutdownServer')"
131 >
132 <b-form-radio
133 v-model="form.shutdownOption"
134 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530135 data-test-id="serverPowerOperations-radio-shutdownOrderly"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800136 value="orderly"
137 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530138 {{ $t('pageServerPowerOperations.gracefulShutdown') }}
139 <info-tooltip
140 :title="
141 $t('pageServerPowerOperations.gracefulShutdownInfo')
142 "
143 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800144 </b-form-radio>
145 <b-form-radio
146 v-model="form.shutdownOption"
147 name="shutdown-option"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530148 data-test-id="serverPowerOperations-radio-shutdownImmediate"
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800149 value="immediate"
150 >
Shubhi Garg918526f2024-09-19 17:08:28 +0530151 {{ $t('pageServerPowerOperations.forceOff') }}
152 <info-tooltip
153 :title="$t('pageServerPowerOperations.forceOffInfo')"
154 />
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800155 </b-form-radio>
156 </b-form-group>
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530157 <b-button
158 variant="primary"
159 type="submit"
160 data-test-id="serverPowerOperations-button-shutDown"
Aravinth S99fe2282025-08-20 15:08:17 +0530161 :disabled="isButtonDisable"
Sukanya Pandey8d29eb42020-07-17 12:42:46 +0530162 >
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800163 {{ $t('pageServerPowerOperations.shutDown') }}
164 </b-button>
165 </b-form>
166 </template>
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800167 </page-section>
168 </b-col>
169 </b-row>
170 </b-container>
171</template>
172
173<script>
SurenNewaread8438b2020-08-20 18:32:28 +0530174import PageTitle from '@/components/Global/PageTitle';
175import PageSection from '@/components/Global/PageSection';
176import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800177import BootSettings from './BootSettings';
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700178import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
SurenNewaread8438b2020-08-20 18:32:28 +0530179import Alert from '@/components/Global/Alert';
Shubhi Garg918526f2024-09-19 17:08:28 +0530180import InfoTooltip from '@/components/Global/InfoTooltip';
Surya Vde23ea22024-07-11 15:19:46 +0530181import { useI18n } from 'vue-i18n';
182import i18n from '@/i18n';
Aravinth S99fe2282025-08-20 15:08:17 +0530183import { privilegesId } from '@/store/modules/GlobalStore';
184import { mapGetters } from 'vuex';
jason westoverd36ac8a2025-11-03 20:58:59 -0600185import { useModal } from 'bootstrap-vue-next';
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800186
187export default {
188 name: 'ServerPowerOperations',
Shubhi Garg918526f2024-09-19 17:08:28 +0530189 components: { PageTitle, PageSection, BootSettings, Alert, InfoTooltip },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700190 mixins: [BVToastMixin, LoadingBarMixin],
Derick Montague602e98a2020-10-21 16:20:00 -0500191 beforeRouteLeave(to, from, next) {
192 this.hideLoader();
193 next();
194 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600195 setup() {
196 const bvModal = useModal();
197 return { bvModal };
198 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800199 data() {
200 return {
Surya Vde23ea22024-07-11 15:19:46 +0530201 $t: useI18n().t,
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800202 form: {
203 rebootOption: 'orderly',
Derick Montague602e98a2020-10-21 16:20:00 -0500204 shutdownOption: 'orderly',
205 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800206 };
207 },
208 computed: {
Aravinth S99fe2282025-08-20 15:08:17 +0530209 ...mapGetters('global', ['userPrivilege']),
210 isButtonDisable() {
211 return this.userPrivilege === privilegesId.readOnly;
212 },
Derick Montague71114fe2021-05-06 18:17:34 -0500213 serverStatus() {
214 return this.$store.getters['global/serverStatus'];
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800215 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800216 isOperationInProgress() {
217 return this.$store.getters['controls/isOperationInProgress'];
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800218 },
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500219 lastPowerOperationTime() {
220 return this.$store.getters['controls/lastPowerOperationTime'];
221 },
Yoshie Muranakac05ff642020-02-26 14:23:15 -0800222 oneTimeBootEnabled() {
Derick Montague71114fe2021-05-06 18:17:34 -0500223 return this.$store.getters['serverBootSettings/overrideEnabled'];
Derick Montague602e98a2020-10-21 16:20:00 -0500224 },
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530225 hasBootSourceOptions() {
Ed Tanous81323992024-02-27 11:26:24 -0800226 let bootOptions =
227 this.$store.getters['serverBootSettings/bootSourceOptions'];
Sukanya Pandey7f6edb62021-03-30 19:49:08 +0530228 return bootOptions.length !== 0;
229 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800230 },
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700231 created() {
232 this.startLoader();
jason westoverd36ac8a2025-11-03 20:58:59 -0600233 const eventBus = require('@/eventBus').default;
Derick Montague602e98a2020-10-21 16:20:00 -0500234 const bootSettingsPromise = new Promise((resolve) => {
jason westoverd36ac8a2025-11-03 20:58:59 -0600235 eventBus.$once('server-power-operations-boot-settings-complete', resolve);
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500236 });
237 Promise.all([
Derick Montague71114fe2021-05-06 18:17:34 -0500238 this.$store.dispatch('serverBootSettings/getBootSettings'),
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500239 this.$store.dispatch('controls/getLastPowerOperationTime'),
Derick Montague602e98a2020-10-21 16:20:00 -0500240 bootSettingsPromise,
Dixsie Wolmersbb316062020-08-04 19:17:33 -0500241 ]).finally(() => this.endLoader());
Yoshie Muranaka5c977972020-04-30 09:48:23 -0700242 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800243 methods: {
244 powerOn() {
Derick Montague71114fe2021-05-06 18:17:34 -0500245 this.$store.dispatch('controls/serverPowerOn');
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800246 },
247 rebootServer() {
Surya Vde23ea22024-07-11 15:19:46 +0530248 const modalMessage = i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800249 'pageServerPowerOperations.modal.confirmRebootMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800250 );
251 const modalOptions = {
Surya Vde23ea22024-07-11 15:19:46 +0530252 title: i18n.global.t(
253 'pageServerPowerOperations.modal.confirmRebootTitle',
254 ),
255 okTitle: i18n.global.t('global.action.confirm'),
256 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000257 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800258 };
259
260 if (this.form.rebootOption === 'orderly') {
jason westoverd36ac8a2025-11-03 20:58:59 -0600261 this.confirmDialog(modalMessage, modalOptions).then((confirmed) => {
262 if (confirmed) this.$store.dispatch('controls/serverSoftReboot');
263 });
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800264 } else if (this.form.rebootOption === 'immediate') {
jason westoverd36ac8a2025-11-03 20:58:59 -0600265 this.confirmDialog(modalMessage, modalOptions).then((confirmed) => {
266 if (confirmed) this.$store.dispatch('controls/serverHardReboot');
267 });
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800268 }
269 },
270 shutdownServer() {
Surya Vde23ea22024-07-11 15:19:46 +0530271 const modalMessage = i18n.global.t(
Ed Tanous81323992024-02-27 11:26:24 -0800272 'pageServerPowerOperations.modal.confirmShutdownMessage',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800273 );
274 const modalOptions = {
Surya Vde23ea22024-07-11 15:19:46 +0530275 title: i18n.global.t(
276 'pageServerPowerOperations.modal.confirmShutdownTitle',
277 ),
278 okTitle: i18n.global.t('global.action.confirm'),
279 cancelTitle: i18n.global.t('global.action.cancel'),
Paul Fertserd1ef18e2024-04-06 08:04:14 +0000280 autoFocusButton: 'ok',
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800281 };
282
283 if (this.form.shutdownOption === 'orderly') {
jason westoverd36ac8a2025-11-03 20:58:59 -0600284 this.confirmDialog(modalMessage, modalOptions).then((confirmed) => {
285 if (confirmed) this.$store.dispatch('controls/serverSoftPowerOff');
286 });
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800287 }
288 if (this.form.shutdownOption === 'immediate') {
jason westoverd36ac8a2025-11-03 20:58:59 -0600289 this.confirmDialog(modalMessage, modalOptions).then((confirmed) => {
290 if (confirmed) this.$store.dispatch('controls/serverHardPowerOff');
291 });
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800292 }
Derick Montague602e98a2020-10-21 16:20:00 -0500293 },
jason westoverd36ac8a2025-11-03 20:58:59 -0600294 confirmDialog(message, options = {}) {
295 return this.$confirm({ message, ...options });
296 },
Derick Montague602e98a2020-10-21 16:20:00 -0500297 },
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800298};
299</script>