@@ -370,7 +370,8 @@ function addClient() {
370370 "warning" ,
371371 "" ,
372372 "Warning" ,
373- "Input is neither a valid IP or MAC address nor a valid host name!"
373+ "Input is neither a valid IP or MAC address nor a valid host name!" ,
374+ null
374375 ) ;
375376 return ;
376377 }
@@ -380,11 +381,13 @@ function addClient() {
380381
381382 if ( ips . length === 0 ) {
382383 utils . enableAll ( ) ;
383- utils . showAlert ( "warning" , "" , "Warning" , "Please specify a client IP or MAC address" ) ;
384+ utils . showAlert ( "warning" , "" , "Warning" , "Please specify a client IP or MAC address" , null ) ;
384385 return ;
385386 }
386387
387- utils . showAlert ( "info" , "" , "Adding client(s)..." , ipStr ) ;
388+ const toasts = { } ;
389+ //eslint-disable-next-line unicorn/no-immediate-mutation
390+ toasts [ ips ] = utils . showAlert ( "info" , "" , "Adding client(s)..." , ipStr , null ) ;
388391
389392 $ . ajax ( {
390393 url : document . body . dataset . apiurl + "/clients" ,
@@ -395,7 +398,7 @@ function addClient() {
395398 data : JSON . stringify ( { client : ips , comment, groups : group } ) ,
396399 success ( data ) {
397400 utils . enableAll ( ) ;
398- utils . listsAlert ( "client" , ips , data ) ;
401+ utils . listsAlert ( "client" , ips , data , toasts [ ips ] ) ;
399402 reloadClientSuggestions ( ) ;
400403 $ ( "#new_comment" ) . val ( "" ) ;
401404 table . ajax . reload ( null , false ) ;
@@ -407,7 +410,7 @@ function addClient() {
407410 error ( data , exception ) {
408411 apiFailure ( data ) ;
409412 utils . enableAll ( ) ;
410- utils . showAlert ( "error" , "" , "Error while adding new client" , data . responseText ) ;
413+ utils . showAlert ( "error" , "" , "Error while adding new client" , data . responseText , toasts [ ips ] ) ;
411414 console . log ( exception ) ; // eslint-disable-line no-console
412415 } ,
413416 } ) ;
@@ -440,9 +443,11 @@ function editClient() {
440443 return ;
441444 }
442445
446+ const toasts = { } ;
447+
443448 utils . disableAll ( ) ;
444449 const clientDecoded = utils . hexDecode ( client ) ;
445- utils . showAlert ( "info" , "" , "Editing client..." , clientDecoded ) ;
450+ toasts [ client ] = utils . showAlert ( "info" , "" , "Editing client..." , clientDecoded , null ) ;
446451 $ . ajax ( {
447452 url : document . body . dataset . apiurl + "/clients/" + encodeURIComponent ( clientDecoded ) ,
448453 method : "put" ,
@@ -455,7 +460,7 @@ function editClient() {
455460 } ) ,
456461 success ( data ) {
457462 utils . enableAll ( ) ;
458- processGroupResult ( data , "client" , done , notDone ) ;
463+ processGroupResult ( data , "client" , done , notDone , toasts [ client ] ) ;
459464 table . ajax . reload ( null , false ) ;
460465 } ,
461466 error ( data , exception ) {
@@ -465,7 +470,8 @@ function editClient() {
465470 "error" ,
466471 "" ,
467472 "Error while " + notDone + " client " + clientDecoded ,
468- data . responseText
473+ data . responseText ,
474+ toasts [ client ]
469475 ) ;
470476 console . log ( exception ) ; // eslint-disable-line no-console
471477 } ,
0 commit comments