blob: 0a9b0589827a7fe1824e73b4c4df282e3937606c [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>
36import { required } from 'vuelidate/lib/validators';
Yoshie Muranakaf415a082020-12-07 13:04:11 -080037import ModalConfirmation from './DumpsModalConfirmation';
38import Alert from '@/components/Global/Alert';
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080039import BVToastMixin from '@/components/Mixins/BVToastMixin';
40import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
41
42export default {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080043 components: { Alert, ModalConfirmation },
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080044 mixins: [BVToastMixin, VuelidateMixin],
45 data() {
46 return {
47 selectedDumpType: null,
48 dumpTypeOptions: [
49 { value: 'bmc', text: this.$t('pageDumps.form.bmcDump') },
50 { value: 'system', text: this.$t('pageDumps.form.systemDump') },
51 ],
52 };
53 },
54 validations() {
55 return {
56 selectedDumpType: { required },
57 };
58 },
59 methods: {
60 handleSubmit() {
61 this.$v.$touch();
62 if (this.$v.$invalid) return;
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053063
64 // System dump initiation
Yoshie Muranakaf415a082020-12-07 13:04:11 -080065 if (this.selectedDumpType === 'system') {
66 this.showConfirmationModal();
Sukanya Pandeye39b95d2021-08-23 18:11:02 +053067 }
68 // BMC dump initiation
69 else if (this.selectedDumpType === 'bmc') {
Yoshie Muranakaf415a082020-12-07 13:04:11 -080070 this.$store
71 .dispatch('dumps/createBmcDump')
72 .then(() =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -080073 this.infoToast(this.$t('pageDumps.toast.successStartBmcDump'), {
74 title: this.$t('pageDumps.toast.successStartBmcDumpTitle'),
75 timestamp: true,
Ed Tanous81323992024-02-27 11:26:24 -080076 }),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080077 )
78 .catch(({ message }) => this.errorToast(message));
79 }
80 },
81 showConfirmationModal() {
82 this.$bvModal.show('modal-confirmation');
83 },
84 createSystemDump() {
85 this.$store
86 .dispatch('dumps/createSystemDump')
87 .then(() =>
Yoshie Muranakaf92e2962021-02-09 12:41:53 -080088 this.infoToast(this.$t('pageDumps.toast.successStartSystemDump'), {
89 title: this.$t('pageDumps.toast.successStartSystemDumpTitle'),
90 timestamp: true,
Ed Tanous81323992024-02-27 11:26:24 -080091 }),
Yoshie Muranakaf415a082020-12-07 13:04:11 -080092 )
93 .catch(({ message }) => this.errorToast(message));
Yoshie Muranaka22d4d522020-12-03 10:58:35 -080094 },
95 },
96};
97</script>