blob: c9b02b3e2a92eb3b02e6dd258c399582849273ce [file] [log] [blame]
Yoshie Muranakafa1512b2020-02-25 15:54:07 -08001<template>
2 <b-container fluid>
3 <page-title />
4 <b-row>
5 <b-col md="8" lg="8" xl="6">
6 <page-section
7 :section-title="$t('pageServerPowerOperations.currentStatus')"
8 >
9 <dl>
10 <dt>{{ $t('pageServerPowerOperations.hostname') }}</dt>
11 <dd>{{ hostname }}</dd>
12 </dl>
13 <dl>
14 <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
15 <dd v-if="hostStatus === 'on'">
16 {{ $t('global.status.on') }}
17 </dd>
18 <dd v-else-if="hostStatus === 'off'">
19 {{ $t('global.status.off') }}
20 </dd>
21 <dd v-else>
22 {{ $t('global.status.notAvailable') }}
23 </dd>
24 </dl>
25 </page-section>
26 </b-col>
27 </b-row>
28 <b-row>
29 <b-col md="8" lg="7" xl="8">
30 <page-section
31 :section-title="$t('pageServerPowerOperations.operations')"
32 >
33 <template v-if="isOperationInProgress">
34 {{ $t('pageServerPowerOperations.operationInProgress') }}
35 </template>
36 <template v-else-if="hostStatus === 'off'">
37 <b-button variant="primary" @click="powerOn">
38 {{ $t('pageServerPowerOperations.powerOn') }}
39 </b-button>
40 </template>
41 <template v-else-if="hostStatus === 'on'">
42 <!-- Reboot server options -->
43 <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
44 <b-form-group
45 :label="$t('pageServerPowerOperations.rebootServer')"
46 >
47 <b-form-radio
48 v-model="form.rebootOption"
49 name="reboot-option"
50 value="orderly"
51 >
52 {{ $t('pageServerPowerOperations.orderlyReboot') }}
53 </b-form-radio>
54 <b-form-radio
55 v-model="form.rebootOption"
56 name="reboot-option"
57 value="immediate"
58 >
59 {{ $t('pageServerPowerOperations.immediateReboot') }}
60 </b-form-radio>
61 </b-form-group>
62 <b-button variant="primary" type="submit">
63 {{ $t('pageServerPowerOperations.reboot') }}
64 </b-button>
65 </b-form>
66 <!-- Shutdown server options -->
67 <b-form novalidate @submit.prevent="shutdownServer">
68 <b-form-group
69 :label="$t('pageServerPowerOperations.shutdownServer')"
70 >
71 <b-form-radio
72 v-model="form.shutdownOption"
73 name="shutdown-option"
74 value="orderly"
75 >
76 {{ $t('pageServerPowerOperations.orderlyShutdown') }}
77 </b-form-radio>
78 <b-form-radio
79 v-model="form.shutdownOption"
80 name="shutdown-option"
81 value="immediate"
82 >
83 {{ $t('pageServerPowerOperations.immediateShutdown') }}
84 </b-form-radio>
85 </b-form-group>
86 <b-button variant="primary" type="submit">
87 {{ $t('pageServerPowerOperations.shutDown') }}
88 </b-button>
89 </b-form>
90 </template>
91 <template v-else>
92 {{ $t('global.status.notAvailable') }}
93 </template>
94 </page-section>
95 </b-col>
96 </b-row>
97 </b-container>
98</template>
99
100<script>
101import PageTitle from '../../../components/Global/PageTitle';
102import PageSection from '../../../components/Global/PageSection';
103import BVToastMixin from '../../../components/Mixins/BVToastMixin';
104
105export default {
106 name: 'ServerPowerOperations',
107 components: { PageTitle, PageSection },
108 mixins: [BVToastMixin],
109 data() {
110 return {
111 form: {
112 rebootOption: 'orderly',
113 shutdownOption: 'orderly'
114 }
115 };
116 },
117 computed: {
118 hostStatus() {
119 return this.$store.getters['global/hostStatus'];
120 },
121 hostname() {
122 return this.$store.getters['global/hostName'];
123 },
124 isOperationInProgress() {
125 return this.$store.getters['controls/isOperationInProgress'];
126 }
127 },
128 created() {
129 this.$store.dispatch('global/getHostName');
130 },
131 methods: {
132 powerOn() {
133 this.$store.dispatch('controls/hostPowerOn');
134 },
135 rebootServer() {
136 const modalMessage = this.$t(
137 'pageServerPowerOperations.modal.confirmRebootMessage'
138 );
139 const modalOptions = {
140 title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
141 okTitle: this.$t('global.action.confirm')
142 };
143
144 if (this.form.rebootOption === 'orderly') {
145 this.$bvModal
146 .msgBoxConfirm(modalMessage, modalOptions)
147 .then(confirmed => {
148 if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
149 });
150 } else if (this.form.rebootOption === 'immediate') {
151 this.$bvModal
152 .msgBoxConfirm(modalMessage, modalOptions)
153 .then(confirmed => {
154 if (confirmed) this.$store.dispatch('controls/hostHardReboot');
155 });
156 }
157 },
158 shutdownServer() {
159 const modalMessage = this.$t(
160 'pageServerPowerOperations.modal.confirmShutdownMessage'
161 );
162 const modalOptions = {
163 title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
164 okTitle: this.$t('global.action.confirm')
165 };
166
167 if (this.form.shutdownOption === 'orderly') {
168 this.$bvModal
169 .msgBoxConfirm(modalMessage, modalOptions)
170 .then(confirmed => {
171 if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
172 });
173 }
174 if (this.form.shutdownOption === 'immediate') {
175 this.$bvModal
176 .msgBoxConfirm(modalMessage, modalOptions)
177 .then(confirmed => {
178 if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
179 });
180 }
181 }
182 }
183};
184</script>