blob: 7da3084f96de3d7019863dfed91701703a08a4e6 [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';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080043
44export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080045 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080046 mixins: [BVToastMixin, VuelidateMixin],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070047 setup() {
48 return {
49 v$: useVuelidate(),
50 };
51 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080052 data() {
53 return {
54 selectedDumpType: null,
55 dumpTypeOptions: [
Surya Vde23ea22024-07-11 15:19:46 +053056 { value: 'bmc', text: i18n.global.t('pageDumps.form.bmcDump') },
57 { value: 'system', text: i18n.global.t('pageDumps.form.systemDump') },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080058 ],
59 };
60 },
61 validations() {
62 return {
63 selectedDumpType: { required },
64 };
65 },
66 methods: {
67 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053068 this.v$.$touch();
69 if (this.v$.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053070
71 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080072 if (this.selectedDumpType === 'system') {
73 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053074 }
75 // BMC dump initiation
76 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080077 this.$store
78 .dispatch('dumps/createBmcDump')
79 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +053080 this.infoToast(
81 i18n.global.t('pageDumps.toast.successStartBmcDump'),
82 {
83 title: i18n.global.t(
84 'pageDumps.toast.successStartBmcDumpTitle',
85 ),
86 timestamp: true,
87 },
88 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080089 )
90 .catch(({ message }) => this.errorToast(message));
91 }
92 },
93 showConfirmationModal() {
94 this.$bvModal.show('modal-confirmation');
95 },
96 createSystemDump() {
97 this.$store
98 .dispatch('dumps/createSystemDump')
99 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +0530100 this.infoToast(
101 i18n.global.t('pageDumps.toast.successStartSystemDump'),
102 {
103 title: i18n.global.t(
104 'pageDumps.toast.successStartSystemDumpTitle',
105 ),
106 timestamp: true,
107 },
108 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800109 )
110 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800111 },
112 },
113};
114</script>