blob: 17257d1ecc2df109a274eb4e42360c2e54b55a31 [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>
Yoshie Muranakaf415a082020-12-07 13:04:11 -080031 <modal-confirmation @ok="createSystemDump" />
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080032 </div>
33</template>
34
35<script>
Ed Tanous7d6b44c2024-03-23 14:56:34 -070036import { useVuelidate } from '@vuelidate/core';
37import { required } from '@vuelidate/validators';
Yoshie Muranakaf415a082020-12-07 13:04:11 -080038import ModalConfirmation from './DumpsModalConfirmation';
39import Alert from '@/components/Global/Alert';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080040import BVToastMixin from '@/components/Mixins/BVToastMixin';
41import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
Surya Vde23ea22024-07-11 15:19:46 +053042import i18n from '@/i18n';
Paul Fertser6e53b142025-01-21 16:19:36 +000043import { useI18n } from 'vue-i18n';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080044
45export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080046 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080047 mixins: [BVToastMixin, VuelidateMixin],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070048 setup() {
49 return {
50 v$: useVuelidate(),
51 };
52 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080053 data() {
54 return {
Paul Fertser6e53b142025-01-21 16:19:36 +000055 $t: useI18n().t,
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080056 selectedDumpType: null,
57 dumpTypeOptions: [
jason westoverd2483622025-08-18 09:26:41 -050058 { value: 'bmc', text: i18n.global.t('pageDumps.dumpTypes.bmcDump') },
59 {
60 value: 'system',
61 text: i18n.global.t('pageDumps.dumpTypes.systemDump'),
62 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080063 ],
64 };
65 },
66 validations() {
67 return {
68 selectedDumpType: { required },
69 };
70 },
71 methods: {
72 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053073 this.v$.$touch();
74 if (this.v$.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053075
76 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080077 if (this.selectedDumpType === 'system') {
78 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053079 }
80 // BMC dump initiation
81 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080082 this.$store
83 .dispatch('dumps/createBmcDump')
84 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +053085 this.infoToast(
86 i18n.global.t('pageDumps.toast.successStartBmcDump'),
87 {
88 title: i18n.global.t(
89 'pageDumps.toast.successStartBmcDumpTitle',
90 ),
91 timestamp: true,
92 },
93 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080094 )
95 .catch(({ message }) => this.errorToast(message));
96 }
97 },
98 showConfirmationModal() {
99 this.$bvModal.show('modal-confirmation');
100 },
101 createSystemDump() {
102 this.$store
103 .dispatch('dumps/createSystemDump')
104 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +0530105 this.infoToast(
106 i18n.global.t('pageDumps.toast.successStartSystemDump'),
107 {
108 title: i18n.global.t(
109 'pageDumps.toast.successStartSystemDumpTitle',
110 ),
111 timestamp: true,
112 },
113 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800114 )
115 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800116 },
117 },
118};
119</script>