diff --git a/rose/server/web/settings/settings-form.html b/rose/server/web/settings/settings-form.html new file mode 100644 index 00000000..33484de8 --- /dev/null +++ b/rose/server/web/settings/settings-form.html @@ -0,0 +1,15 @@ +
+
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/rose/server/web/settings/settings-form.js b/rose/server/web/settings/settings-form.js index 32543317..a1bab2ca 100644 --- a/rose/server/web/settings/settings-form.js +++ b/rose/server/web/settings/settings-form.js @@ -1,3 +1,34 @@ +// Load the HTML template for the web component +async function loadTemplate(path) { + try { + const response = await fetch(path); + return await response.text(); + } catch (error) { + console.error('Error loading template:', error); + } +} + +// Load the CSS and create a Constructible Stylesheet +async function loadStylesheet(path) { + try { + const response = await fetch(path); + const cssText = await response.text(); + + const sheet = new CSSStyleSheet(); + sheet.replaceSync(cssText); + + return sheet; + } catch (error) { + console.error('Error loading stylesheet:', error); + } +} + +// Load both the template and stylesheet concurrently +const [innerHTML, sheet] = await Promise.all([ + loadTemplate('./settings-form.html'), + loadStylesheet('./settings-form.css') +]); + class SettingsForm extends HTMLElement { constructor() { super(); @@ -5,33 +36,14 @@ class SettingsForm extends HTMLElement { } connectedCallback() { - this.render(); + this.shadowRoot.innerHTML = innerHTML; + this.shadowRoot.adoptedStyleSheets = [sheet]; + this.loadDrivers(); this.shadowRoot.querySelector('#submit-button').addEventListener('click', this.sendDrivers.bind(this)); this.shadowRoot.querySelector('#cancel-button').addEventListener('click', this.cancelSetting.bind(this)); } - render() { - this.shadowRoot.innerHTML = ` - -
-
- - -
-
- - -
-
- - -
-
-
- `; - } - displayError(message) { const errorMessageElement = this.shadowRoot.getElementById('error-message'); errorMessageElement.textContent = message;