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