mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
refactor(instances): the VM lists' scripts load from static files
The VM lists lose their inline scripts and handlers: host_groups.js collapses a host's VMs in the grouped list, new_vm_dialog.js reads the new-VM dialog's CPU bars and capacity lines, and console_window.js (loaded by every page) opens a console button's window, on the lists and on the VM page alike. A list row's Start no longer calls the please-wait dialog, which the list pages do not have (the call only raised an error). The VM page's URL placeholders take the __name__ form the other pages use.
This commit is contained in:
parent
e143fe353a
commit
946629b035
11 changed files with 98 additions and 91 deletions
|
|
@ -10,6 +10,7 @@ import unittest
|
|||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
from computes.models import Compute
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
|
@ -95,7 +96,8 @@ class CreateDialogCpuTestCase(TestCase):
|
|||
@unittest.skipUnless(shutil.which("node"), "node is not installed")
|
||||
def test_the_dialog_reads_host_by_host_two_at_a_time(self):
|
||||
page = self.page()
|
||||
script = next(s for s in html.fromstring(page).xpath("//script[not(@src)]/text()") if "show.bs.modal" in s)
|
||||
self.assertIn("/static/js/new_vm_dialog.js", html.fromstring(page).xpath("//script/@src"))
|
||||
script = (settings.BASE_DIR / "static/js/new_vm_dialog.js").read_text()
|
||||
cpu = [reverse("compute_graph", args=[c.id]) for c in self.computes]
|
||||
line = [reverse("compute_capacity", args=[c.id]) for c in self.computes]
|
||||
js = RUN.replace("SCRIPT", json.dumps(script)).replace("CPU_URLS", json.dumps(cpu)).replace("LINE_URLS", json.dumps(line))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue