@@ -32,7 +32,6 @@ class EthernetStore extends VuexModule {
3232 @Mutation
3333 setInterfaces ( ethernet_interfaces : EthernetInterface [ ] ) : void {
3434 this . available_interfaces = ethernet_interfaces
35- this . updating_interfaces = false
3635 }
3736
3837 @Action
@@ -52,6 +51,10 @@ class EthernetStore extends VuexModule {
5251 notifier . pushBackError ( 'ETHERNET_ADDRESS_CREATION_FAIL' , error )
5352 throw error
5453 } )
54+ . finally ( async ( ) => {
55+ await this . context . dispatch ( 'refreshInterfaces' )
56+ this . context . commit ( 'setUpdatingInterfaces' , false )
57+ } )
5558 }
5659
5760 @Action
@@ -71,6 +74,10 @@ class EthernetStore extends VuexModule {
7174 notifier . pushError ( 'ETHERNET_ADDRESS_DELETE_FAIL' , error )
7275 throw error
7376 } )
77+ . finally ( async ( ) => {
78+ await this . context . dispatch ( 'refreshInterfaces' )
79+ this . context . commit ( 'setUpdatingInterfaces' , false )
80+ } )
7481 }
7582
7683 @Action
@@ -91,13 +98,16 @@ class EthernetStore extends VuexModule {
9198 notifier . pushBackError ( 'DHCP_SERVER_ADD_FAIL' , error )
9299 throw error
93100 } )
94- . finally ( ( ) => {
101+ . finally ( async ( ) => {
102+ await this . context . dispatch ( 'refreshInterfaces' )
95103 this . context . commit ( 'setUpdatingInterfaces' , false )
96104 } )
97105 }
98106
99107 @Action
100108 async RemoveDHCPServer ( interface_name : string ) : Promise < void > {
109+ this . context . commit ( 'setUpdatingInterfaces' , true )
110+
101111 await back_axios ( {
102112 method : 'delete' ,
103113 url : `${ this . API_URL } /dhcp` ,
@@ -110,6 +120,10 @@ class EthernetStore extends VuexModule {
110120 const message = `Could not remove DHCP server from interface '${ interface_name } ': ${ error . message } .`
111121 notifier . pushError ( 'DHCP_SERVER_REMOVE_FAIL' , message )
112122 } )
123+ . finally ( async ( ) => {
124+ await this . context . dispatch ( 'refreshInterfaces' )
125+ this . context . commit ( 'setUpdatingInterfaces' , false )
126+ } )
113127 }
114128
115129 @Action
@@ -189,6 +203,16 @@ class EthernetStore extends VuexModule {
189203 } )
190204 }
191205
206+ @Action
207+ async refreshInterfaces ( ) : Promise < void > {
208+ try {
209+ const response = await this . context . dispatch ( 'getAvailableEthernetInterfaces' )
210+ this . context . commit ( 'setInterfaces' , response . data )
211+ } catch {
212+ // Errors are already pushed to the notifier by getAvailableEthernetInterfaces.
213+ }
214+ }
215+
192216 @Action
193217 async setInterfacesPriority ( interfaces : { name : string , priority : number } [ ] ) : Promise < void > {
194218 await back_axios ( {
@@ -213,6 +237,8 @@ class EthernetStore extends VuexModule {
213237
214238 @Action
215239 async triggerDynamicIP ( interface_name : string ) : Promise < void > {
240+ this . context . commit ( 'setUpdatingInterfaces' , true )
241+
216242 await back_axios ( {
217243 method : 'post' ,
218244 url : `${ this . API_URL } /dynamic_ip` ,
@@ -225,6 +251,10 @@ class EthernetStore extends VuexModule {
225251 const message = `Could not trigger for dynamic IP address on '${ interface_name } ': ${ error . message } .`
226252 notifier . pushError ( 'DYNAMIC_IP_TRIGGER_FAIL' , message )
227253 } )
254+ . finally ( async ( ) => {
255+ await this . context . dispatch ( 'refreshInterfaces' )
256+ this . context . commit ( 'setUpdatingInterfaces' , false )
257+ } )
228258 }
229259}
230260
0 commit comments