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