blob: 7e61b96503dde2abc69853d6be38d3cac466fce1 [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: [
Surya Vde23ea22024-07-11 15:19:46 +053058 { value: 'bmc', text: i18n.global.t('pageDumps.form.bmcDump') },
59 { value: 'system', text: i18n.global.t('pageDumps.form.systemDump') },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080060 ],
61 };
62 },
63 validations() {
64 return {
65 selectedDumpType: { required },
66 };
67 },
68 methods: {
69 handleSubmit() {
Surya Vde23ea22024-07-11 15:19:46 +053070 this.v$.$touch();
71 if (this.v$.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053072
73 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080074 if (this.selectedDumpType === 'system') {
75 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053076 }
77 // BMC dump initiation
78 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080079 this.$store
80 .dispatch('dumps/createBmcDump')
81 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +053082 this.infoToast(
83 i18n.global.t('pageDumps.toast.successStartBmcDump'),
84 {
85 title: i18n.global.t(
86 'pageDumps.toast.successStartBmcDumpTitle',
87 ),
88 timestamp: true,
89 },
90 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080091 )
92 .catch(({ message }) => this.errorToast(message));
93 }
94 },
95 showConfirmationModal() {
96 this.$bvModal.show('modal-confirmation');
97 },
98 createSystemDump() {
99 this.$store
100 .dispatch('dumps/createSystemDump')
101 .then(() =>
Surya Vde23ea22024-07-11 15:19:46 +0530102 this.infoToast(
103 i18n.global.t('pageDumps.toast.successStartSystemDump'),
104 {
105 title: i18n.global.t(
106 'pageDumps.toast.successStartSystemDumpTitle',
107 ),
108 timestamp: true,
109 },
110 ),
Yoshie Muranakaf415a082020-12-07 13:04:11 -0800111 )
112 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800113 },
114 },
115};
116</script>