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