@@ -40,20 +40,35 @@ const setup = (props, context) => {
40
40
41
41
const advancedPromise = $store .dispatch (' $_bases/getAdvanced' ) // prefetch advanced configuration
42
42
43
+ const catchWithError = message => {
44
+ return () => {
45
+ isLoading .value = false
46
+ invalidFeedback .value = message
47
+ progressFeedback .value = null
48
+ }
49
+ }
50
+
43
51
const onComplete = () => {
44
52
isLoading .value = true
53
+ invalidFeedback .value = null
45
54
progressFeedback .value = i18n .t (' Applying configuration' )
46
- $store .dispatch (' cluster/restartSystemService' , { id: ' packetfence-config' }).then (() => {
55
+ $store .dispatch (' cluster/restartSystemService' , { id: ' packetfence-config' }).catch (catchWithError (i18n .t (' Failed to restart packetfence-config' ))).then (() => {
56
+ invalidFeedback .value = null
47
57
progressFeedback .value = i18n .t (' Enabling PacketFence' )
48
- return $store .dispatch (' cluster/updateSystemd' , { id: ' pf' }).then (() => {
58
+ return $store .dispatch (' cluster/updateSystemd' , { id: ' pf' }).catch (catchWithError (i18n .t (' Failed to update systemd' ))).then (() => {
59
+ invalidFeedback .value = null
49
60
progressFeedback .value = i18n .t (' Starting PacketFence' )
50
- return $store .dispatch (' cluster/restartService' , { id: ' pfperl-api' }).then (() => {
51
- return $store .dispatch (' cluster/restartService' , { id: ' haproxy-admin' }).then (() => {
52
- return $store .dispatch (' cluster/startService' , { id: ' pf' }).then (() => {
61
+ return $store .dispatch (' cluster/restartService' , { id: ' pfperl-api' }).catch (catchWithError (i18n .t (' Failed to restart pfperl-api' ))).then (() => {
62
+ invalidFeedback .value = null
63
+ return $store .dispatch (' cluster/restartService' , { id: ' haproxy-admin' }).catch (catchWithError (i18n .t (' Failed to restart haproxy-admin' ))).then (() => {
64
+ invalidFeedback .value = null
65
+ return $store .dispatch (' cluster/startService' , { id: ' pf' }).catch (catchWithError (i18n .t (' Failed to start packetfence services' ))).then (() => {
66
+ invalidFeedback .value = null
53
67
progressFeedback .value = i18n .t (' Disabling Configurator' )
54
68
return advancedPromise .then (data => {
55
69
data .configurator = ' disabled'
56
- return $store .dispatch (' $_bases/updateAdvanced' , data).then (() => {
70
+ return $store .dispatch (' $_bases/updateAdvanced' , data).catch (catchWithError (i18n .t (' Failed to update advanced' ))).then (() => {
71
+ invalidFeedback .value = null
57
72
progressFeedback .value = i18n .t (' Redirecting to login page' )
58
73
setTimeout (() => {
59
74
window .location .href = ' /'
@@ -64,9 +79,6 @@ const setup = (props, context) => {
64
79
})
65
80
})
66
81
})
67
- .catch (() => {
68
- progressFeedback .value = null
69
- })
70
82
.finally (() => {
71
83
isLoading .value = false
72
84
})
0 commit comments