1111"use strict" ;
1212
1313let table ;
14+ const toasts = { } ;
1415
1516function reloadClientSuggestions ( ) {
1617 $ . ajax ( {
@@ -370,7 +371,8 @@ function addClient() {
370371 "warning" ,
371372 "" ,
372373 "Warning" ,
373- "Input is neither a valid IP or MAC address nor a valid host name!"
374+ "Input is neither a valid IP or MAC address nor a valid host name!" ,
375+ null
374376 ) ;
375377 return ;
376378 }
@@ -380,11 +382,11 @@ function addClient() {
380382
381383 if ( ips . length === 0 ) {
382384 utils . enableAll ( ) ;
383- utils . showAlert ( "warning" , "" , "Warning" , "Please specify a client IP or MAC address" ) ;
385+ utils . showAlert ( "warning" , "" , "Warning" , "Please specify a client IP or MAC address" , null ) ;
384386 return ;
385387 }
386388
387- utils . showAlert ( "info" , "" , "Adding client(s)..." , ipStr ) ;
389+ toasts [ ips ] = utils . showAlert ( "info" , "" , "Adding client(s)..." , ipStr , null ) ;
388390
389391 $ . ajax ( {
390392 url : document . body . dataset . apiurl + "/clients" ,
@@ -395,7 +397,7 @@ function addClient() {
395397 data : JSON . stringify ( { client : ips , comment, groups : group } ) ,
396398 success ( data ) {
397399 utils . enableAll ( ) ;
398- utils . listsAlert ( "client" , ips , data ) ;
400+ utils . listsAlert ( "client" , ips , data , toasts [ ips ] ) ;
399401 reloadClientSuggestions ( ) ;
400402 $ ( "#new_comment" ) . val ( "" ) ;
401403 table . ajax . reload ( null , false ) ;
@@ -407,7 +409,7 @@ function addClient() {
407409 error ( data , exception ) {
408410 apiFailure ( data ) ;
409411 utils . enableAll ( ) ;
410- utils . showAlert ( "error" , "" , "Error while adding new client" , data . responseText ) ;
412+ utils . showAlert ( "error" , "" , "Error while adding new client" , data . responseText , toasts [ ips ] ) ;
411413 console . log ( exception ) ; // eslint-disable-line no-console
412414 } ,
413415 } ) ;
@@ -442,7 +444,7 @@ function editClient() {
442444
443445 utils . disableAll ( ) ;
444446 const clientDecoded = utils . hexDecode ( client ) ;
445- utils . showAlert ( "info" , "" , "Editing client..." , clientDecoded ) ;
447+ toasts [ client ] = utils . showAlert ( "info" , "" , "Editing client..." , clientDecoded , null ) ;
446448 $ . ajax ( {
447449 url : document . body . dataset . apiurl + "/clients/" + encodeURIComponent ( clientDecoded ) ,
448450 method : "put" ,
@@ -455,7 +457,7 @@ function editClient() {
455457 } ) ,
456458 success ( data ) {
457459 utils . enableAll ( ) ;
458- processGroupResult ( data , "client" , done , notDone ) ;
460+ processGroupResult ( data , "client" , done , notDone , toasts [ client ] ) ;
459461 table . ajax . reload ( null , false ) ;
460462 } ,
461463 error ( data , exception ) {
@@ -465,7 +467,8 @@ function editClient() {
465467 "error" ,
466468 "" ,
467469 "Error while " + notDone + " client " + clientDecoded ,
468- data . responseText
470+ data . responseText ,
471+ toasts [ client ]
469472 ) ;
470473 console . log ( exception ) ; // eslint-disable-line no-console
471474 } ,
0 commit comments