5
5
:label =" $t('pageDumps.form.selectDumpType')"
6
6
label-for =" selectDumpType"
7
7
>
8
+ <template #label >
9
+ {{ $t('pageDumps.form.selectDumpType') }}
10
+ <info-tooltip :title =" $t('pageDumps.form.selectDumpTypeTooltip')" />
11
+ </template >
8
12
<b-form-select
9
13
id =" selectDumpType"
10
14
v-model =" selectedDumpType"
11
15
:options =" dumpTypeOptions"
12
16
:state =" getValidationState($v.selectedDumpType)"
17
+ @change =" updateDumpInfo"
13
18
>
14
19
<template #first >
15
20
<b-form-select-option :value =" null" disabled >
21
26
{{ $t('global.form.required') }}
22
27
</b-form-invalid-feedback >
23
28
</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
+
27
63
<b-button variant =" primary" type =" submit" form =" form-new-dump" >
28
64
{{ $t('pageDumps.form.initiateDump') }}
29
65
</b-button >
33
69
</template >
34
70
35
71
<script >
36
- import { required } from ' vuelidate/lib/validators' ;
72
+ import { required , requiredIf } from ' vuelidate/lib/validators' ;
37
73
import ModalConfirmation from ' ./DumpsModalConfirmation' ;
38
- import Alert from ' @/components/Global/Alert' ;
74
+ import InfoTooltip from ' @/components/Global/InfoTooltip' ;
75
+ import InputPasswordToggle from ' @/components/Global/InputPasswordToggle' ;
39
76
import BVToastMixin from ' @/components/Mixins/BVToastMixin' ;
40
77
import VuelidateMixin from ' @/components/Mixins/VuelidateMixin.js' ;
41
78
42
79
export default {
43
- components: { Alert , ModalConfirmation },
80
+ components: { InfoTooltip, InputPasswordToggle , ModalConfirmation },
44
81
mixins: [BVToastMixin, VuelidateMixin],
45
82
data () {
46
83
return {
47
84
selectedDumpType: null ,
85
+ resourceSelectorValue: null ,
86
+ resourcePassword: null ,
48
87
dumpTypeOptions: [
49
88
{ value: ' bmc' , text: this .$t (' pageDumps.form.bmcDump' ) },
89
+ { value: ' resource' , text: this .$t (' pageDumps.form.resourceDump' ) },
50
90
{ value: ' system' , text: this .$t (' pageDumps.form.systemDump' ) },
51
91
],
52
92
};
53
93
},
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
+ },
54
105
validations () {
55
106
return {
56
107
selectedDumpType: { required },
108
+ resourcePassword: {
109
+ required: requiredIf (
110
+ () => this .isServiceUser && this .selectedDumpType === ' resource'
111
+ ),
112
+ },
57
113
};
58
114
},
59
115
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
+ },
60
125
handleSubmit () {
61
126
this .$v .$touch ();
62
127
if (this .$v .$invalid ) return ;
@@ -65,12 +130,28 @@ export default {
65
130
if (this .selectedDumpType === ' system' ) {
66
131
this .showConfirmationModal ();
67
132
}
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
+ }
68
149
// BMC dump initiation
69
150
else if (this .selectedDumpType === ' bmc' ) {
70
151
this .$store
71
152
.dispatch (' dumps/createBmcDump' )
72
153
.then (() =>
73
- this .infoToast (this .$t (' pageDumps.toast.successStartBmcDump ' ), {
154
+ this .infoToast (this .$t (' pageDumps.toast.successStartDump ' ), {
74
155
title: this .$t (' pageDumps.toast.successStartBmcDumpTitle' ),
75
156
timestamp: true ,
76
157
})
@@ -85,7 +166,7 @@ export default {
85
166
this .$store
86
167
.dispatch (' dumps/createSystemDump' )
87
168
.then (() =>
88
- this .infoToast (this .$t (' pageDumps.toast.successStartSystemDump ' ), {
169
+ this .infoToast (this .$t (' pageDumps.toast.successStartDump ' ), {
89
170
title: this .$t (' pageDumps.toast.successStartSystemDumpTitle' ),
90
171
timestamp: true ,
91
172
})
0 commit comments