blob: af9df83883d3bbfaa705c382d9f440c23e0c5c1a [file] [log] [blame]
Yoshie Muranaka22d4d522020-12-03 10:58:35 -08001<template>
2 <div class="form-background p-3">
3 <b-form id="form-new-dump" novalidate @submit.prevent="handleSubmit">
4 <b-form-group
5 :label="$t('pageDumps.form.selectDumpType')"
6 label-for="selectDumpType"
7 >
8 <b-form-select
9 id="selectDumpType"
10 v-model="selectedDumpType"
11 :options="dumpTypeOptions"
Surya Vde23ea22024-07-11 15:19:46 +053012 :state="getValidationState(v$.selectedDumpType)"
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080013 >
14 <template #first>
15 <b-form-select-option :value="null" disabled>
16 {{ $t('global.form.selectAnOption') }}
17 </b-form-select-option>
18 </template>
19 </b-form-select>
20 <b-form-invalid-feedback role="alert">
21 {{ $t('global.form.required') }}
22 </b-form-invalid-feedback>
23 </b-form-group>
Yoshie Muranakaf415a082020-12-07 13:04:11 -080024 <alert variant="info" class="mb-3" :show="selectedDumpType === 'system'">
25 {{ $t('pageDumps.form.systemDumpInfo') }}
26 </alert>
jason westoverd36ac8a2025-11-03 20:58:59 -060027 <b-button
28 variant="primary"
29 type="submit"
30 form="form-new-dump"
31 class="mt-3"
32 >
Yoshie Muranakaf415a082020-12-07 13:04:11 -080033 {{ $t('pageDumps.form.initiateDump') }}
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080034 </b-button>
35 </b-form>
jason westoverd36ac8a2025-11-03 20:58:59 -060036 <modal-confirmation v-model="showConfirmation" @ok="createSystemDump" />
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080037 </div>
38</template>
39
40<script>
Ed Tanous7d6b44c2024-03-23 14:56:34 -070041import { useVuelidate } from '@vuelidate/core';
42import { required } from '@vuelidate/validators';
Yoshie Muranakaf415a082020-12-07 13:04:11 -080043import ModalConfirmation from './DumpsModalConfirmation';
44import Alert from '@/components/Global/Alert';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080045import BVToastMixin from '@/components/Mixins/BVToastMixin';
46import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
Surya Vde23ea22024-07-11 15:19:46 +053047import i18n from '@/i18n';
Paul Fertser6e53b142025-01-21 16:19:36 +000048import { useI18n } from 'vue-i18n';
jason westoverd36ac8a2025-11-03 20:58:59 -060049import { useModal } from 'bootstrap-vue-next';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080050
51export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080052 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080053 mixins: [BVToastMixin, VuelidateMixin],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070054 setup() {
jason westoverd36ac8a2025-11-03 20:58:59 -060055 const bvModal = useModal();
Ed Tanous7d6b44c2024-03-23 14:56:34 -070056 return {
57 v$: useVuelidate(),
jason westoverd36ac8a2025-11-03 20:58:59 -060058 bvModal,
Ed Tanous7d6b44c2024-03-23 14:56:34 -070059 };
60 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080061 data() {
62 return {
Paul Fertser6e53b142025-01-21 16:19:36 +000063 $t: useI18n().t,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080064 selectedDumpType: null,
jason westoverd36ac8a2025-11-03 20:58:59 -060065 showConfirmation: false,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080066 dumpTypeOptions: [
jason westoverd2483622025-08-18 09:26:41 -050067 { value: 'bmc', text: i18n.global.t('pageDumps.dumpTypes.bmcDump') },
68 {
69 value: 'system',
70 text: i18n.global.t('pageDumps.dumpTypes.systemDump'),
71 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080072 ],
73 };
74 },
75 validations() {
76 return {
77 selectedDumpType: { required },
78 };
79 },
80 methods: {
81 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053082 this.v$.$touch();
83 if (this.v$.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053084
85 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080086 if (this.selectedDumpType === 'system') {
87 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053088 }
89 // BMC dump initiation
90 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080091 this.$store
92 .dispatch('dumps/createBmcDump')
93 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +053094 this.infoToast(
95 i18n.global.t('pageDumps.toast.successStartBmcDump'),
96 {
97 title: i18n.global.t(
98 'pageDumps.toast.successStartBmcDumpTitle',
99 ),
100 timestamp: true,
101 },
102 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800103 )
104 .catch(({ message }) => this.errorToast(message));
105 }
106 },
107 showConfirmationModal() {
jason westoverd36ac8a2025-11-03 20:58:59 -0600108 this.showConfirmation = true;
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800109 },
110 createSystemDump() {
111 this.$store
112 .dispatch('dumps/createSystemDump')
113 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +0530114 this.infoToast(
115 i18n.global.t('pageDumps.toast.successStartSystemDump'),
116 {
117 title: i18n.global.t(
118 'pageDumps.toast.successStartSystemDumpTitle',
119 ),
120 timestamp: true,
121 },
122 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800123 )
124 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800125 },
126 },
127};
128</script>