Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 1 | <template> |
Yoshie Muranaka | 3111b6f | 2020-04-21 19:48:38 -0700 | [diff] [blame] | 2 | <b-container fluid="xl"> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 3 | <page-title /> |
Yoshie Muranaka | f7aa7f9 | 2020-04-27 10:12:15 -0700 | [diff] [blame] | 4 | <b-row class="mb-4"> |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 5 | <b-col md="8" xl="6"> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 6 | <page-section |
| 7 | :section-title="$t('pageServerPowerOperations.currentStatus')" |
| 8 | > |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 9 | <b-row> |
| 10 | <b-col> |
| 11 | <dl> |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 12 | <dt>{{ $t('pageServerPowerOperations.serverStatus') }}</dt> |
SurenNeware | 84ea7ab | 2021-02-17 19:06:06 +0530 | [diff] [blame] | 13 | <dd |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 14 | v-if="serverStatus === 'on'" |
SurenNeware | 84ea7ab | 2021-02-17 19:06:06 +0530 | [diff] [blame] | 15 | data-test-id="powerServerOps-text-hostStatus" |
| 16 | > |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 17 | {{ $t('global.status.on') }} |
| 18 | </dd> |
SurenNeware | 84ea7ab | 2021-02-17 19:06:06 +0530 | [diff] [blame] | 19 | <dd |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 20 | v-else-if="serverStatus === 'off'" |
SurenNeware | 84ea7ab | 2021-02-17 19:06:06 +0530 | [diff] [blame] | 21 | data-test-id="powerServerOps-text-hostStatus" |
| 22 | > |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 23 | {{ $t('global.status.off') }} |
| 24 | </dd> |
glukhov.mikhail | ed7278a | 2022-09-26 11:17:57 +0300 | [diff] [blame] | 25 | <dd |
| 26 | v-else-if="serverStatus === 'diagnosticMode'" |
| 27 | data-test-id="powerServerOps-text-hostStatus" |
| 28 | > |
| 29 | {{ $t('global.status.diagnosticMode') }} |
| 30 | </dd> |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 31 | <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> |
SurenNeware | 84ea7ab | 2021-02-17 19:06:06 +0530 | [diff] [blame] | 43 | <dd |
| 44 | v-if="lastPowerOperationTime" |
| 45 | data-test-id="powerServerOps-text-lastPowerOp" |
| 46 | > |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 47 | {{ lastPowerOperationTime | formatDate }} |
| 48 | {{ lastPowerOperationTime | formatTime }} |
| 49 | </dd> |
| 50 | <dd v-else>--</dd> |
| 51 | </dl> |
| 52 | </b-col> |
| 53 | </b-row> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 54 | </page-section> |
| 55 | </b-col> |
| 56 | </b-row> |
| 57 | <b-row> |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 58 | <b-col v-if="hasBootSourceOptions" sm="8" md="6" xl="4"> |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 59 | <page-section |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 60 | :section-title="$t('pageServerPowerOperations.serverBootSettings')" |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 61 | > |
| 62 | <boot-settings /> |
| 63 | </page-section> |
| 64 | </b-col> |
| 65 | <b-col sm="8" md="6" xl="7"> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 66 | <page-section |
| 67 | :section-title="$t('pageServerPowerOperations.operations')" |
| 68 | > |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 69 | <alert :show="oneTimeBootEnabled" variant="warning"> |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 70 | {{ $t('pageServerPowerOperations.oneTimeBootWarning') }} |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 71 | </alert> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 72 | <template v-if="isOperationInProgress"> |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 73 | <alert variant="info"> |
| 74 | {{ $t('pageServerPowerOperations.operationInProgress') }} |
| 75 | </alert> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 76 | </template> |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 77 | <template v-else-if="serverStatus === 'off'"> |
Sukanya Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 78 | <b-button |
| 79 | variant="primary" |
| 80 | data-test-id="serverPowerOperations-button-powerOn" |
| 81 | @click="powerOn" |
| 82 | > |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 83 | {{ $t('pageServerPowerOperations.powerOn') }} |
| 84 | </b-button> |
| 85 | </template> |
Yoshie Muranaka | e9fc612 | 2020-08-10 15:12:09 -0700 | [diff] [blame] | 86 | <template v-else> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 87 | <!-- 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 Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 95 | data-test-id="serverPowerOperations-radio-rebootOrderly" |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 96 | 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 Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 103 | data-test-id="serverPowerOperations-radio-rebootImmediate" |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 104 | value="immediate" |
| 105 | > |
| 106 | {{ $t('pageServerPowerOperations.immediateReboot') }} |
| 107 | </b-form-radio> |
| 108 | </b-form-group> |
Sukanya Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 109 | <b-button |
| 110 | variant="primary" |
| 111 | type="submit" |
| 112 | data-test-id="serverPowerOperations-button-reboot" |
| 113 | > |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 114 | {{ $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 Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 125 | data-test-id="serverPowerOperations-radio-shutdownOrderly" |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 126 | 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 Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 133 | data-test-id="serverPowerOperations-radio-shutdownImmediate" |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 134 | value="immediate" |
| 135 | > |
| 136 | {{ $t('pageServerPowerOperations.immediateShutdown') }} |
| 137 | </b-form-radio> |
| 138 | </b-form-group> |
Sukanya Pandey | 8d29eb4 | 2020-07-17 12:42:46 +0530 | [diff] [blame] | 139 | <b-button |
| 140 | variant="primary" |
| 141 | type="submit" |
| 142 | data-test-id="serverPowerOperations-button-shutDown" |
| 143 | > |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 144 | {{ $t('pageServerPowerOperations.shutDown') }} |
| 145 | </b-button> |
| 146 | </b-form> |
| 147 | </template> |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 148 | </page-section> |
| 149 | </b-col> |
| 150 | </b-row> |
| 151 | </b-container> |
| 152 | </template> |
| 153 | |
| 154 | <script> |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 155 | import PageTitle from '@/components/Global/PageTitle'; |
| 156 | import PageSection from '@/components/Global/PageSection'; |
| 157 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 158 | import BootSettings from './BootSettings'; |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 159 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 160 | import Alert from '@/components/Global/Alert'; |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 161 | |
| 162 | export default { |
| 163 | name: 'ServerPowerOperations', |
SurenNeware | ad8438b | 2020-08-20 18:32:28 +0530 | [diff] [blame] | 164 | components: { PageTitle, PageSection, BootSettings, Alert }, |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 165 | mixins: [BVToastMixin, LoadingBarMixin], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 166 | beforeRouteLeave(to, from, next) { |
| 167 | this.hideLoader(); |
| 168 | next(); |
| 169 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 170 | data() { |
| 171 | return { |
| 172 | form: { |
| 173 | rebootOption: 'orderly', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 174 | shutdownOption: 'orderly', |
| 175 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 176 | }; |
| 177 | }, |
| 178 | computed: { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 179 | serverStatus() { |
| 180 | return this.$store.getters['global/serverStatus']; |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 181 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 182 | isOperationInProgress() { |
| 183 | return this.$store.getters['controls/isOperationInProgress']; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 184 | }, |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 185 | lastPowerOperationTime() { |
| 186 | return this.$store.getters['controls/lastPowerOperationTime']; |
| 187 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 188 | oneTimeBootEnabled() { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 189 | return this.$store.getters['serverBootSettings/overrideEnabled']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 190 | }, |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 191 | hasBootSourceOptions() { |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 192 | let bootOptions = |
| 193 | this.$store.getters['serverBootSettings/bootSourceOptions']; |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 194 | return bootOptions.length !== 0; |
| 195 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 196 | }, |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 197 | created() { |
| 198 | this.startLoader(); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 199 | const bootSettingsPromise = new Promise((resolve) => { |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 200 | this.$root.$on('server-power-operations-boot-settings-complete', () => |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 201 | resolve(), |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 202 | ); |
| 203 | }); |
| 204 | Promise.all([ |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 205 | this.$store.dispatch('serverBootSettings/getBootSettings'), |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 206 | this.$store.dispatch('controls/getLastPowerOperationTime'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 207 | bootSettingsPromise, |
Dixsie Wolmers | bb31606 | 2020-08-04 19:17:33 -0500 | [diff] [blame] | 208 | ]).finally(() => this.endLoader()); |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 209 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 210 | methods: { |
| 211 | powerOn() { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 212 | this.$store.dispatch('controls/serverPowerOn'); |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 213 | }, |
| 214 | rebootServer() { |
| 215 | const modalMessage = this.$t( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 216 | 'pageServerPowerOperations.modal.confirmRebootMessage', |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 217 | ); |
| 218 | const modalOptions = { |
| 219 | title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 220 | okTitle: this.$t('global.action.confirm'), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 221 | cancelTitle: this.$t('global.action.cancel'), |
Paul Fertser | d1ef18e | 2024-04-06 08:04:14 +0000 | [diff] [blame^] | 222 | autoFocusButton: 'ok', |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | if (this.form.rebootOption === 'orderly') { |
| 226 | this.$bvModal |
| 227 | .msgBoxConfirm(modalMessage, modalOptions) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 228 | .then((confirmed) => { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 229 | if (confirmed) this.$store.dispatch('controls/serverSoftReboot'); |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 230 | }); |
| 231 | } else if (this.form.rebootOption === 'immediate') { |
| 232 | this.$bvModal |
| 233 | .msgBoxConfirm(modalMessage, modalOptions) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 234 | .then((confirmed) => { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 235 | if (confirmed) this.$store.dispatch('controls/serverHardReboot'); |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 236 | }); |
| 237 | } |
| 238 | }, |
| 239 | shutdownServer() { |
| 240 | const modalMessage = this.$t( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 241 | 'pageServerPowerOperations.modal.confirmShutdownMessage', |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 242 | ); |
| 243 | const modalOptions = { |
| 244 | title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 245 | okTitle: this.$t('global.action.confirm'), |
Sukanya Pandey | 3835713 | 2020-12-22 13:40:59 +0530 | [diff] [blame] | 246 | cancelTitle: this.$t('global.action.cancel'), |
Paul Fertser | d1ef18e | 2024-04-06 08:04:14 +0000 | [diff] [blame^] | 247 | autoFocusButton: 'ok', |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | if (this.form.shutdownOption === 'orderly') { |
| 251 | this.$bvModal |
| 252 | .msgBoxConfirm(modalMessage, modalOptions) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 253 | .then((confirmed) => { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 254 | if (confirmed) this.$store.dispatch('controls/serverSoftPowerOff'); |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 255 | }); |
| 256 | } |
| 257 | if (this.form.shutdownOption === 'immediate') { |
| 258 | this.$bvModal |
| 259 | .msgBoxConfirm(modalMessage, modalOptions) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 260 | .then((confirmed) => { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 261 | if (confirmed) this.$store.dispatch('controls/serverHardPowerOff'); |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 262 | }); |
| 263 | } |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 264 | }, |
| 265 | }, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 266 | }; |
| 267 | </script> |