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