55 :label =" $t('pageDumps.form.selectDumpType')"
66 label-for =" selectDumpType"
77 >
8+ <template #label >
9+ {{ $t('pageDumps.form.selectDumpType') }}
10+ <info-tooltip :title =" $t('pageDumps.form.selectDumpTypeTooltip')" />
11+ </template >
812 <b-form-select
913 id =" selectDumpType"
1014 v-model =" selectedDumpType"
1115 :options =" dumpTypeOptions"
1216 :state =" getValidationState($v.selectedDumpType)"
17+ @change =" updateDumpInfo"
1318 >
1419 <template #first >
1520 <b-form-select-option :value =" null" disabled >
2126 {{ $t('global.form.required') }}
2227 </b-form-invalid-feedback >
2328 </b-form-group >
24- <alert variant =" info" class =" mb-3" :show =" selectedDumpType === 'system'" >
25- {{ $t('pageDumps.form.systemDumpInfo') }}
26- </alert >
29+ <template v-if =" selectedDumpType === ' resource' " >
30+ <b-form-group label-for =" resourceSelector" >
31+ <template #label >
32+ {{ $t('pageDumps.form.resourceSelector') }}
33+ <info-tooltip
34+ :title =" $t('pageDumps.form.resourceSelectorTooltip')"
35+ />
36+ </template >
37+
38+ <b-form-input id =" resourceSelector" v-model =" resourceSelectorValue" >
39+ </b-form-input >
40+ </b-form-group >
41+ <template v-if =" isServiceUser " >
42+ <b-form-group label-for =" password" >
43+ <template #label >
44+ {{ $t('pageDumps.form.password') }}
45+ <info-tooltip :title =" $t('pageDumps.form.passwordTooltip')" />
46+ </template >
47+ <input-password-toggle >
48+ <b-form-input
49+ id =" password"
50+ v-model =" resourcePassword"
51+ type =" password"
52+ :state =" getValidationState($v.resourcePassword)"
53+ >
54+ </b-form-input >
55+ <b-form-invalid-feedback role =" alert" >
56+ {{ $t('global.form.required') }}
57+ </b-form-invalid-feedback >
58+ </input-password-toggle >
59+ </b-form-group >
60+ </template >
61+ </template >
62+
2763 <b-button variant =" primary" type =" submit" form =" form-new-dump" >
2864 {{ $t('pageDumps.form.initiateDump') }}
2965 </b-button >
3369</template >
3470
3571<script >
36- import { required } from ' vuelidate/lib/validators' ;
72+ import { required , requiredIf } from ' vuelidate/lib/validators' ;
3773import ModalConfirmation from ' ./DumpsModalConfirmation' ;
38- import Alert from ' @/components/Global/Alert' ;
74+ import InfoTooltip from ' @/components/Global/InfoTooltip' ;
75+ import InputPasswordToggle from ' @/components/Global/InputPasswordToggle' ;
3976import BVToastMixin from ' @/components/Mixins/BVToastMixin' ;
4077import VuelidateMixin from ' @/components/Mixins/VuelidateMixin.js' ;
4178
4279export default {
43- components: { Alert , ModalConfirmation },
80+ components: { InfoTooltip, InputPasswordToggle , ModalConfirmation },
4481 mixins: [BVToastMixin, VuelidateMixin],
4582 data () {
4683 return {
4784 selectedDumpType: null ,
85+ resourceSelectorValue: null ,
86+ resourcePassword: null ,
4887 dumpTypeOptions: [
4988 { value: ' bmc' , text: this .$t (' pageDumps.form.bmcDump' ) },
89+ { value: ' resource' , text: this .$t (' pageDumps.form.resourceDump' ) },
5090 { value: ' system' , text: this .$t (' pageDumps.form.systemDump' ) },
5191 ],
5292 };
5393 },
94+ computed: {
95+ currentUser () {
96+ return this .$store .getters [' global/currentUser' ];
97+ },
98+ isServiceUser () {
99+ return this .$store .getters [' global/isServiceUser' ];
100+ },
101+ },
102+ created () {
103+ this .checkForUserData ();
104+ },
54105 validations () {
55106 return {
56107 selectedDumpType: { required },
108+ resourcePassword: {
109+ required: requiredIf (
110+ () => this .isServiceUser && this .selectedDumpType === ' resource'
111+ ),
112+ },
57113 };
58114 },
59115 methods: {
116+ checkForUserData () {
117+ if (! this .currentUser ) {
118+ this .$store .dispatch (' userManagement/getUsers' );
119+ this .$store .dispatch (' global/getCurrentUser' );
120+ }
121+ },
122+ updateDumpInfo () {
123+ this .$emit (' updateDumpInfo' , this .selectedDumpType );
124+ },
60125 handleSubmit () {
61126 this .$v .$touch ();
62127 if (this .$v .$invalid ) return ;
@@ -65,12 +130,28 @@ export default {
65130 if (this .selectedDumpType === ' system' ) {
66131 this .showConfirmationModal ();
67132 }
133+ // Resource dump initiation
134+ else if (this .selectedDumpType === ' resource' ) {
135+ this .$store
136+ .dispatch (' dumps/createResourceDump' , {
137+ resourceSelector: this .resourceSelectorValue ,
138+ // If not logged as service, 'pwd' must be used
139+ resourcePassword: this .resourcePassword || ' pwd' ,
140+ })
141+ .then (() =>
142+ this .infoToast (this .$t (' pageDumps.toast.successStartDump' ), {
143+ title: this .$t (' pageDumps.toast.successStartResourceDumpTitle' ),
144+ timestamp: true ,
145+ })
146+ )
147+ .catch (({ message }) => this .errorToast (message));
148+ }
68149 // BMC dump initiation
69150 else if (this .selectedDumpType === ' bmc' ) {
70151 this .$store
71152 .dispatch (' dumps/createBmcDump' )
72153 .then (() =>
73- this .infoToast (this .$t (' pageDumps.toast.successStartBmcDump ' ), {
154+ this .infoToast (this .$t (' pageDumps.toast.successStartDump ' ), {
74155 title: this .$t (' pageDumps.toast.successStartBmcDumpTitle' ),
75156 timestamp: true ,
76157 })
@@ -85,7 +166,7 @@ export default {
85166 this .$store
86167 .dispatch (' dumps/createSystemDump' )
87168 .then (() =>
88- this .infoToast (this .$t (' pageDumps.toast.successStartSystemDump ' ), {
169+ this .infoToast (this .$t (' pageDumps.toast.successStartDump ' ), {
89170 title: this .$t (' pageDumps.toast.successStartSystemDumpTitle' ),
90171 timestamp: true ,
91172 })
0 commit comments