(list, btn)
| 430 | } |
| 431 | |
| 432 | async installModels(list, btn) { |
| 433 | btn.classList.add("cmm-btn-loading"); |
| 434 | this.showError(""); |
| 435 | |
| 436 | let needRefresh = false; |
| 437 | let errorMsg = ""; |
| 438 | |
| 439 | let target_items = []; |
| 440 | |
| 441 | let batch = {}; |
| 442 | |
| 443 | for (const item of list) { |
| 444 | this.grid.scrollRowIntoView(item); |
| 445 | target_items.push(item); |
| 446 | |
| 447 | if (!this.focusInstall(item)) { |
| 448 | this.grid.onNextUpdated(() => { |
| 449 | this.focusInstall(item); |
| 450 | }); |
| 451 | } |
| 452 | |
| 453 | this.showStatus(`Install ${item.name} ...`); |
| 454 | |
| 455 | const data = item.originalData; |
| 456 | data.ui_id = item.hash; |
| 457 | |
| 458 | |
| 459 | if(batch['install_model']) { |
| 460 | batch['install_model'].push(data); |
| 461 | } |
| 462 | else { |
| 463 | batch['install_model'] = [data]; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | this.install_context = {btn: btn, targets: target_items}; |
| 468 | |
| 469 | if(errorMsg) { |
| 470 | this.showError(errorMsg); |
| 471 | show_message("[Installation Errors]\n"+errorMsg); |
| 472 | |
| 473 | // reset |
| 474 | for(let k in target_items) { |
| 475 | const item = target_items[k]; |
| 476 | this.grid.updateCell(item, "installed"); |
| 477 | } |
| 478 | } |
| 479 | else { |
| 480 | this.batch_id = generateUUID(); |
| 481 | batch['batch_id'] = this.batch_id; |
| 482 | |
| 483 | const res = await api.fetchApi(`/v2/manager/queue/batch`, { |
| 484 | method: 'POST', |
| 485 | body: JSON.stringify(batch) |
| 486 | }); |
| 487 | |
| 488 | let failed = await res.json(); |
| 489 |
no test coverage detected