Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 1 | <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 Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 24 | <alert variant="info" class="mb-3" :show="selectedDumpType === 'system'"> |
| 25 | {{ $t('pageDumps.form.systemDumpInfo') }} |
| 26 | </alert> |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 27 | <b-button variant="primary" type="submit" form="form-new-dump"> |
Yoshie Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 28 | {{ $t('pageDumps.form.initiateDump') }} |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 29 | </b-button> |
| 30 | </b-form> |
Yoshie Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 31 | <modal-confirmation @ok="createSystemDump" /> |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 32 | </div> |
| 33 | </template> |
| 34 | |
| 35 | <script> |
| 36 | import { required } from 'vuelidate/lib/validators'; |
| 37 | |
Yoshie Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 38 | import ModalConfirmation from './DumpsModalConfirmation'; |
| 39 | import Alert from '@/components/Global/Alert'; |
| 40 | |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 41 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
| 42 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; |
| 43 | |
| 44 | export default { |
Yoshie Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 45 | components: { Alert, ModalConfirmation }, |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 46 | mixins: [BVToastMixin, VuelidateMixin], |
| 47 | data() { |
| 48 | return { |
| 49 | selectedDumpType: null, |
| 50 | dumpTypeOptions: [ |
| 51 | { value: 'bmc', text: this.$t('pageDumps.form.bmcDump') }, |
| 52 | { value: 'system', text: this.$t('pageDumps.form.systemDump') }, |
| 53 | ], |
| 54 | }; |
| 55 | }, |
| 56 | validations() { |
| 57 | return { |
| 58 | selectedDumpType: { required }, |
| 59 | }; |
| 60 | }, |
| 61 | methods: { |
| 62 | handleSubmit() { |
| 63 | this.$v.$touch(); |
| 64 | if (this.$v.$invalid) return; |
Yoshie Muranaka | f415a08 | 2020-12-07 13:04:11 -0800 | [diff] [blame] | 65 | if (this.selectedDumpType === 'system') { |
| 66 | this.showConfirmationModal(); |
| 67 | } else { |
| 68 | this.$store |
| 69 | .dispatch('dumps/createBmcDump') |
| 70 | .then(() => |
| 71 | this.infoToast( |
| 72 | this.$t('pageDumps.toast.successStartBmcDump'), |
| 73 | this.$t('pageDumps.toast.successStartBmcDumpTitle') |
| 74 | ) |
| 75 | ) |
| 76 | .catch(({ message }) => this.errorToast(message)); |
| 77 | } |
| 78 | }, |
| 79 | showConfirmationModal() { |
| 80 | this.$bvModal.show('modal-confirmation'); |
| 81 | }, |
| 82 | createSystemDump() { |
| 83 | this.$store |
| 84 | .dispatch('dumps/createSystemDump') |
| 85 | .then(() => |
| 86 | this.infoToast( |
| 87 | this.$t('pageDumps.toast.successStartSystemDump'), |
| 88 | this.$t('pageDumps.toast.successStartSystemDumpTitle') |
| 89 | ) |
| 90 | ) |
| 91 | .catch(({ message }) => this.errorToast(message)); |
Yoshie Muranaka | 22d4d52 | 2020-12-03 10:58:35 -0800 | [diff] [blame] | 92 | }, |
| 93 | }, |
| 94 | }; |
| 95 | </script> |