blob: 40cea7e32e059b49c9b1f4bf39b963d23744636b [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"
12 :state="getValidationState($v.selectedDumpType)"
13 >
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';
42
43export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080044 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080045 mixins: [BVToastMixin, VuelidateMixin],
Ed Tanous7d6b44c2024-03-23 14:56:34 -070046 setup() {
47 return {
48 v$: useVuelidate(),
49 };
50 },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080051 data() {
52 return {
53 selectedDumpType: null,
54 dumpTypeOptions: [
55 { value: 'bmc', text: this.$t('pageDumps.form.bmcDump') },
56 { value: 'system', text: this.$t('pageDumps.form.systemDump') },
57 ],
58 };
59 },
60 validations() {
61 return {
62 selectedDumpType: { required },
63 };
64 },
65 methods: {
66 handleSubmit() {
67 this.$v.$touch();
68 if (this.$v.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053069
70 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080071 if (this.selectedDumpType === 'system') {
72 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053073 }
74 // BMC dump initiation
75 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080076 this.$store
77 .dispatch('dumps/createBmcDump')
78 .then(() =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -080079 this.infoToast(this.$t('pageDumps.toast.successStartBmcDump'), {
80 title: this.$t('pageDumps.toast.successStartBmcDumpTitle'),
81 timestamp: true,
Ed Tanous81323992024-02-27 11:26:24 -080082 }),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080083 )
84 .catch(({ message }) => this.errorToast(message));
85 }
86 },
87 showConfirmationModal() {
88 this.$bvModal.show('modal-confirmation');
89 },
90 createSystemDump() {
91 this.$store
92 .dispatch('dumps/createSystemDump')
93 .then(() =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -080094 this.infoToast(this.$t('pageDumps.toast.successStartSystemDump'), {
95 title: this.$t('pageDumps.toast.successStartSystemDumpTitle'),
96 timestamp: true,
Ed Tanous81323992024-02-27 11:26:24 -080097 }),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080098 )
99 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -0800100 },
101 },
102};
103</script>