|
259 | 259 | }); |
260 | 260 |
|
261 | 261 | if (containerUrls.length) { |
262 | | - let req = $.ajax({ |
263 | | - context : this, |
264 | | - type : 'post', |
265 | | - url : this.icinga.config.baseUrl + '/icingadb/migrate/monitoring-url', |
266 | | - headers : { 'Accept': 'application/json' }, |
267 | | - contentType : 'application/json', |
268 | | - data : JSON.stringify(containerUrls) |
269 | | - }); |
| 262 | + fetch( |
| 263 | + this.icinga.config.baseUrl + '/icingadb/migrate/monitoring-url', |
| 264 | + { |
| 265 | + method : 'POST', |
| 266 | + headers : |
| 267 | + { |
| 268 | + 'Accept': 'application/json', |
| 269 | + 'Content-Type' : 'application/json', |
| 270 | + 'X-Requested-With': 'XMLHttpRequest' |
| 271 | + }, |
| 272 | + body : JSON.stringify(containerUrls), |
| 273 | + } |
| 274 | + ) |
| 275 | + .then(response => { |
| 276 | + if (! response.ok) { |
| 277 | + throw new Error('Network response was not OK'); |
| 278 | + } |
270 | 279 |
|
271 | | - req.urls = urls; |
272 | | - req.urlIndexToContainerId = containerIds; |
273 | | - req.done(this.processUrlMigrationResults); |
274 | | - req.always(() => this.changeUrlMigrationReadyState(true)); |
| 280 | + return response.json(); |
| 281 | + }) |
| 282 | + .then(data => this.processUrlMigrationResults(data, urls, containerIds)) |
| 283 | + .catch(error => console.error('Request failed:', error)) |
| 284 | + .finally(() => this.changeBackendSupportReadyState(true)); |
275 | 285 | } else { |
276 | 286 | // All urls have already been migrated once, show popup immediately |
277 | 287 | this.addSuggestions(urls); |
278 | 288 | this.changeUrlMigrationReadyState(true); |
279 | 289 | } |
280 | 290 | } |
281 | 291 |
|
282 | | - processUrlMigrationResults(data, textStatus, req) { |
| 292 | + processUrlMigrationResults(data, urls, urlIndexToContainerId) { |
283 | 293 | let _this = this; |
284 | 294 | let result, containerId; |
285 | 295 |
|
|
295 | 305 | } |
296 | 306 |
|
297 | 307 | result.forEach((migratedUrl, i) => { |
298 | | - containerId = req.urlIndexToContainerId[i]; |
299 | | - this.knownMigrations[req.urls[containerId]] = migratedUrl; |
| 308 | + containerId = urlIndexToContainerId[i]; |
| 309 | + this.knownMigrations[urls[containerId]] = migratedUrl; |
300 | 310 | }); |
301 | 311 |
|
302 | | - this.addSuggestions(req.urls); |
| 312 | + this.addSuggestions(urls); |
303 | 313 | } |
304 | 314 |
|
305 | 315 | prepareBackendCheckboxForm(modules) { |
|
315 | 325 | }); |
316 | 326 |
|
317 | 327 | if (moduleNames.length) { |
318 | | - let req = $.ajax({ |
319 | | - context : this, |
320 | | - type : 'post', |
321 | | - url : this.icinga.config.baseUrl + '/icingadb/migrate/backend-support', |
322 | | - headers : { 'Accept': 'application/json' }, |
323 | | - contentType : 'application/json', |
324 | | - data : JSON.stringify(moduleNames) |
325 | | - }); |
| 328 | + fetch( |
| 329 | + this.icinga.config.baseUrl + '/icingadb/migrate/backend-support', |
| 330 | + { |
| 331 | + method : 'POST', |
| 332 | + headers : |
| 333 | + { |
| 334 | + 'Accept': 'application/json', |
| 335 | + 'Content-Type' : 'application/json' , |
| 336 | + 'X-Requested-With': 'XMLHttpRequest' |
| 337 | + }, |
| 338 | + body : JSON.stringify(moduleNames), |
| 339 | + } |
| 340 | + ) |
| 341 | + .then(response => { |
| 342 | + if (! response.ok) { |
| 343 | + throw new Error('Network response was not OK'); |
| 344 | + } |
326 | 345 |
|
327 | | - req.modules = modules; |
328 | | - req.moduleIndexToContainerId = containerIds; |
329 | | - req.done(this.processBackendSupportResults); |
330 | | - req.always(() => this.changeBackendSupportReadyState(true)); |
| 346 | + return response.json(); |
| 347 | + }) |
| 348 | + .then(data => this.processBackendSupportResults(data, modules, containerIds)) |
| 349 | + .catch(error => console.error('Request failed:', error)) |
| 350 | + .finally(() => this.changeBackendSupportReadyState(true)); |
331 | 351 | } else { |
332 | 352 | // All modules have already been checked once, show popup immediately |
333 | 353 | this.setupBackendCheckboxForm(modules); |
334 | 354 | this.changeBackendSupportReadyState(true); |
335 | 355 | } |
336 | 356 | } |
337 | 357 |
|
338 | | - processBackendSupportResults(data, textStatus, req) { |
| 358 | + processBackendSupportResults(data, modules, moduleIndexToContainerId) { |
339 | 359 | let result = data.data; |
340 | 360 |
|
341 | 361 | result.forEach((state, i) => { |
342 | | - let containerId = req.moduleIndexToContainerId[i]; |
343 | | - this.knownBackendSupport[req.modules[containerId]] = state; |
| 362 | + let containerId = moduleIndexToContainerId[i]; |
| 363 | + this.knownBackendSupport[modules[containerId]] = state; |
344 | 364 | }); |
345 | 365 |
|
346 | | - this.setupBackendCheckboxForm(req.modules); |
| 366 | + this.setupBackendCheckboxForm(modules); |
347 | 367 | } |
348 | 368 |
|
349 | 369 | setupBackendCheckboxForm(modules) { |
|
359 | 379 | if (Object.keys(supportedModules).length) { |
360 | 380 | this.backendSupportRelated = { ...this.backendSupportRelated, ...supportedModules }; |
361 | 381 |
|
362 | | - let req = $.ajax({ |
363 | | - context : this, |
364 | | - type : 'get', |
365 | | - url : this.icinga.config.baseUrl + '/icingadb/migrate/checkbox-state?showCompact' |
366 | | - }); |
| 382 | + fetch( |
| 383 | + this.icinga.config.baseUrl + '/icingadb/migrate/checkbox-state?showCompact', |
| 384 | + { |
| 385 | + headers : |
| 386 | + { |
| 387 | + 'X-Requested-With': 'XMLHttpRequest' |
| 388 | + } |
| 389 | + } |
| 390 | + ) |
| 391 | + .then(response => { |
| 392 | + if (! response.ok) { |
| 393 | + throw new Error('Network response was not OK'); |
| 394 | + } |
367 | 395 |
|
368 | | - req.done(this.setCheckboxState); |
| 396 | + return response.text(); |
| 397 | + }) |
| 398 | + .then(html => this.setCheckboxState(html)) |
| 399 | + .catch(error => console.error('Request failed:', error)) |
369 | 400 | } |
370 | 401 | } |
371 | 402 |
|
372 | | - setCheckboxState(html, textStatus, req) { |
| 403 | + setCheckboxState(html) { |
| 404 | + console.log(html); |
373 | 405 | let form = this.Popup().querySelector('.suggestion-area > #setAsBackendForm'); |
374 | 406 | if (! form) { |
375 | 407 | form = notjQuery.render(html); |
|
0 commit comments