summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorYoshie Muranaka <yoshiemuranaka@gmail.com>2020-02-26 02:54:07 +0300
committerGunnar Mills <gmills@us.ibm.com>2020-03-06 06:36:47 +0300
commitfa1512b5fabd3a412a80462971ec1203244971ab (patch)
treecaa44726d1e586e96f0c042534346934b0937b18 /src/views
parentf12e0607f2c1c13113180cfba23bffe837b5c109 (diff)
downloadwebui-vue-fa1512b5fabd3a412a80462971ec1203244971ab.tar.xz
Add power operations page
Add route, component and Control requests to enable power operations (power on, soft and hard reboot, soft and hard power off). This rewrite includes updates to use Redfish endpoints. Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com> Change-Id: I54784b8cc1b6260e44e708c260ea4a531fc0a629
Diffstat (limited to 'src/views')
-rw-r--r--src/views/Control/ServerPowerOperations/ServerPowerOperations.vue184
-rw-r--r--src/views/Control/ServerPowerOperations/index.js2
2 files changed, 186 insertions, 0 deletions
diff --git a/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue b/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue
new file mode 100644
index 00000000..c9b02b3e
--- /dev/null
+++ b/src/views/Control/ServerPowerOperations/ServerPowerOperations.vue
@@ -0,0 +1,184 @@
+<template>
+ <b-container fluid>
+ <page-title />
+ <b-row>
+ <b-col md="8" lg="8" xl="6">
+ <page-section
+ :section-title="$t('pageServerPowerOperations.currentStatus')"
+ >
+ <dl>
+ <dt>{{ $t('pageServerPowerOperations.hostname') }}</dt>
+ <dd>{{ hostname }}</dd>
+ </dl>
+ <dl>
+ <dt>{{ $t('pageServerPowerOperations.hostStatus') }}</dt>
+ <dd v-if="hostStatus === 'on'">
+ {{ $t('global.status.on') }}
+ </dd>
+ <dd v-else-if="hostStatus === 'off'">
+ {{ $t('global.status.off') }}
+ </dd>
+ <dd v-else>
+ {{ $t('global.status.notAvailable') }}
+ </dd>
+ </dl>
+ </page-section>
+ </b-col>
+ </b-row>
+ <b-row>
+ <b-col md="8" lg="7" xl="8">
+ <page-section
+ :section-title="$t('pageServerPowerOperations.operations')"
+ >
+ <template v-if="isOperationInProgress">
+ {{ $t('pageServerPowerOperations.operationInProgress') }}
+ </template>
+ <template v-else-if="hostStatus === 'off'">
+ <b-button variant="primary" @click="powerOn">
+ {{ $t('pageServerPowerOperations.powerOn') }}
+ </b-button>
+ </template>
+ <template v-else-if="hostStatus === 'on'">
+ <!-- Reboot server options -->
+ <b-form novalidate class="mb-5" @submit.prevent="rebootServer">
+ <b-form-group
+ :label="$t('pageServerPowerOperations.rebootServer')"
+ >
+ <b-form-radio
+ v-model="form.rebootOption"
+ name="reboot-option"
+ value="orderly"
+ >
+ {{ $t('pageServerPowerOperations.orderlyReboot') }}
+ </b-form-radio>
+ <b-form-radio
+ v-model="form.rebootOption"
+ name="reboot-option"
+ value="immediate"
+ >
+ {{ $t('pageServerPowerOperations.immediateReboot') }}
+ </b-form-radio>
+ </b-form-group>
+ <b-button variant="primary" type="submit">
+ {{ $t('pageServerPowerOperations.reboot') }}
+ </b-button>
+ </b-form>
+ <!-- Shutdown server options -->
+ <b-form novalidate @submit.prevent="shutdownServer">
+ <b-form-group
+ :label="$t('pageServerPowerOperations.shutdownServer')"
+ >
+ <b-form-radio
+ v-model="form.shutdownOption"
+ name="shutdown-option"
+ value="orderly"
+ >
+ {{ $t('pageServerPowerOperations.orderlyShutdown') }}
+ </b-form-radio>
+ <b-form-radio
+ v-model="form.shutdownOption"
+ name="shutdown-option"
+ value="immediate"
+ >
+ {{ $t('pageServerPowerOperations.immediateShutdown') }}
+ </b-form-radio>
+ </b-form-group>
+ <b-button variant="primary" type="submit">
+ {{ $t('pageServerPowerOperations.shutDown') }}
+ </b-button>
+ </b-form>
+ </template>
+ <template v-else>
+ {{ $t('global.status.notAvailable') }}
+ </template>
+ </page-section>
+ </b-col>
+ </b-row>
+ </b-container>
+</template>
+
+<script>
+import PageTitle from '../../../components/Global/PageTitle';
+import PageSection from '../../../components/Global/PageSection';
+import BVToastMixin from '../../../components/Mixins/BVToastMixin';
+
+export default {
+ name: 'ServerPowerOperations',
+ components: { PageTitle, PageSection },
+ mixins: [BVToastMixin],
+ data() {
+ return {
+ form: {
+ rebootOption: 'orderly',
+ shutdownOption: 'orderly'
+ }
+ };
+ },
+ computed: {
+ hostStatus() {
+ return this.$store.getters['global/hostStatus'];
+ },
+ hostname() {
+ return this.$store.getters['global/hostName'];
+ },
+ isOperationInProgress() {
+ return this.$store.getters['controls/isOperationInProgress'];
+ }
+ },
+ created() {
+ this.$store.dispatch('global/getHostName');
+ },
+ methods: {
+ powerOn() {
+ this.$store.dispatch('controls/hostPowerOn');
+ },
+ rebootServer() {
+ const modalMessage = this.$t(
+ 'pageServerPowerOperations.modal.confirmRebootMessage'
+ );
+ const modalOptions = {
+ title: this.$t('pageServerPowerOperations.modal.confirmRebootTitle'),
+ okTitle: this.$t('global.action.confirm')
+ };
+
+ if (this.form.rebootOption === 'orderly') {
+ this.$bvModal
+ .msgBoxConfirm(modalMessage, modalOptions)
+ .then(confirmed => {
+ if (confirmed) this.$store.dispatch('controls/hostSoftReboot');
+ });
+ } else if (this.form.rebootOption === 'immediate') {
+ this.$bvModal
+ .msgBoxConfirm(modalMessage, modalOptions)
+ .then(confirmed => {
+ if (confirmed) this.$store.dispatch('controls/hostHardReboot');
+ });
+ }
+ },
+ shutdownServer() {
+ const modalMessage = this.$t(
+ 'pageServerPowerOperations.modal.confirmShutdownMessage'
+ );
+ const modalOptions = {
+ title: this.$t('pageServerPowerOperations.modal.confirmShutdownTitle'),
+ okTitle: this.$t('global.action.confirm')
+ };
+
+ if (this.form.shutdownOption === 'orderly') {
+ this.$bvModal
+ .msgBoxConfirm(modalMessage, modalOptions)
+ .then(confirmed => {
+ if (confirmed) this.$store.dispatch('controls/hostSoftPowerOff');
+ });
+ }
+ if (this.form.shutdownOption === 'immediate') {
+ this.$bvModal
+ .msgBoxConfirm(modalMessage, modalOptions)
+ .then(confirmed => {
+ if (confirmed) this.$store.dispatch('controls/hostHardPowerOff');
+ });
+ }
+ }
+ }
+};
+</script>
diff --git a/src/views/Control/ServerPowerOperations/index.js b/src/views/Control/ServerPowerOperations/index.js
new file mode 100644
index 00000000..10430047
--- /dev/null
+++ b/src/views/Control/ServerPowerOperations/index.js
@@ -0,0 +1,2 @@
+import ServerPowerOperations from './ServerPowerOperations.vue';
+export default ServerPowerOperations;