blob: b27aebac0eb05f2f62f45c08b18e083556fc2004 [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>
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080027 <b-button variant="primary" type="submit" form="form-new-dump">
Yoshie Muranakaf415a082020-12-07 13:04:11 -080028 {{ $t('pageDumps.form.initiateDump') }}
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080029 </b-button>
30 </b-form>
tiwari-nishante1420032025-09-01 12:11:14 +053031 <modal-confirmation
32 :require-confirmation="selectedDumpType === 'system'"
33 @ok="createSystemDump"
34 />
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080035 </div>
36</template>
37
38<script>
Ed Tanous7d6b44c2024-03-23 14:56:34 -070039import { useVuelidate } from '@vuelidate/core';
40import { required } from '@vuelidate/validators';
Yoshie Muranakaf415a082020-12-07 13:04:11 -080041import ModalConfirmation from './DumpsModalConfirmation';
42import Alert from '@/components/Global/Alert';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080043import BVToastMixin from '@/components/Mixins/BVToastMixin';
44import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
Surya Vde23ea22024-07-11 15:19:46 +053045import i18n from '@/i18n';
Paul Fertser6e53b142025-01-21 16:19:36 +000046import { useI18n } from 'vue-i18n';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080047
48export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080049 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080050 mixins: [BVToastMixin, VuelidateMixin],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070051 setup() {
52 return {
53 v$: useVuelidate(),
54 };
55 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080056 data() {
57 return {
Paul Fertser6e53b142025-01-21 16:19:36 +000058 $t: useI18n().t,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080059 selectedDumpType: null,
60 dumpTypeOptions: [
jason westoverd2483622025-08-18 09:26:41 -050061 { value: 'bmc', text: i18n.global.t('pageDumps.dumpTypes.bmcDump') },
62 {
63 value: 'system',
64 text: i18n.global.t('pageDumps.dumpTypes.systemDump'),
65 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080066 ],
67 };
68 },
69 validations() {
70 return {
71 selectedDumpType: { required },
72 };
73 },
74 methods: {
75 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053076 this.v$.$touch();
77 if (this.v$.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053078
79 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080080 if (this.selectedDumpType === 'system') {
81 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053082 }
83 // BMC dump initiation
84 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080085 this.$store
86 .dispatch('dumps/createBmcDump')
87 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +053088 this.infoToast(
89 i18n.global.t('pageDumps.toast.successStartBmcDump'),
90 {
91 title: i18n.global.t(
92 'pageDumps.toast.successStartBmcDumpTitle',
93 ),
94 timestamp: true,
95 },
96 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080097 )
98 .catch(({ message }) => this.errorToast(message));
99 }
100 },
101 showConfirmationModal() {
102 this.$bvModal.show('modal-confirmation');
103 },
104 createSystemDump() {
105 this.$store
106 .dispatch('dumps/createSystemDump')
107 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +0530108 this.infoToast(
109 i18n.global.t('pageDumps.toast.successStartSystemDump'),
110 {
111 title: i18n.global.t(
112 'pageDumps.toast.successStartSystemDumpTitle',
113 ),
114 timestamp: true,
115 },
116 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800117 )
118 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800119 },
120 },
121};
122</script>