@@ -10,6 +10,13 @@ export function getFirstElementByNameAsInput(name: string): HTMLInputElement {
1010 return document . getElementsByName ( name ) [ 0 ] as HTMLInputElement
1111}
1212
13+ function replaceIcon ( img : HTMLImageElement , new_icon : string ) {
14+ const imgData = img . getAttribute ( 'data' )
15+ if ( imgData ) {
16+ img . setAttribute ( 'data' , imgData . replace ( / ( .* " i c o n " : " ) .* ( " .* ) / , `$1${ new_icon } $2` ) )
17+ }
18+ }
19+
1320export function start_test ( ident : string , hostname : string , transid : string ) {
1421 const log = document . getElementById ( ident + '_log' ) as HTMLImageElement
1522 const img = document . getElementById ( ident + '_img' ) as HTMLImageElement
@@ -84,7 +91,7 @@ export function start_test(ident: string, hostname: string, transid: string) {
8491 '&snmp_retries=' +
8592 encodeURIComponent ( getFirstElementByNameAsInput ( 'vs_rules_p_snmp_retries' ) . value )
8693
87- img . src = img . src . replace ( / ( . * \/ i c o n _ ) . * ( \. s v g $ ) / i , '$1reload$2 ' )
94+ replaceIcon ( img , 'reload ' )
8895 add_class ( img , 'reloading' )
8996
9097 log . innerHTML = '...'
@@ -124,10 +131,10 @@ function handle_host_diag_result(data: { hostname: string; ident: string }, resp
124131 text = response . result . output
125132 }
126133
127- img . src = img . src . replace ( / ( . * \/ i c o n _ ) . * ( \. s v g $ ) / i , '$1' + new_icon + '$2' )
134+ replaceIcon ( img , new_icon )
128135 log . innerText = text
129136
130- retry . src = retry . src . replace ( / ( . * \/ i c o n _ ) . * ( \. s v g $ ) / i , '$1reload$2 ' )
137+ replaceIcon ( retry , 'reload ' )
131138 retry . style . display = 'inline'
132139 ; ( retry . parentNode as HTMLAnchorElement ) . href =
133140 `javascript:cmk.host_diagnose.start_test(${ data . ident } , ${ data . hostname } , ${ response . result . next_transid } );`
0 commit comments