diff options
Diffstat (limited to 'static/app.js')
| -rw-r--r-- | static/app.js | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/static/app.js b/static/app.js index ca205f3..3599cba 100644 --- a/static/app.js +++ b/static/app.js @@ -1,10 +1,10 @@ /* jshint esversion: 2024, module: true */ -import { ThemeManager } from './theme-manager.js'; import { ApiClient } from './api-client.js'; -import { InterfaceRenderer } from './interface-renderer.js'; import { ConfigManager } from './config-manager.js'; +import { InterfaceRenderer } from './interface-renderer.js'; import { StructuredEditor } from './structured-editor.js'; +import { ThemeManager } from './theme-manager.js'; /** * Main Application Class @@ -160,6 +160,17 @@ class Application { document.addEventListener('touchstart', this.handleTouchStart, { passive: true }); } + // Add event handlers for structured editor + handleAddSection(detail) { + console.log('Add section:', detail); + // Implement section addition logic + } + + handleRemoveSection(detail) { + console.log('Remove section:', detail); + // Implement section removal logic + } + /** * Handle configuration file change * @method handleConfigFileChange @@ -181,6 +192,7 @@ class Application { * Load config for structured editor * @method loadConfigForStructuredEditor */ + async loadConfigForStructuredEditor() { if (!this.structuredEditor) { console.error('Structured editor not initialized'); @@ -189,7 +201,19 @@ class Application { try { const text = await this.apiClient.getText(`/api/config/${encodeURIComponent(this.state.currentConfigFile)}`); - await this.structuredEditor.loadConfiguration(text, this.state.currentConfigFile); + + // Parse configuration and get schema + const { NetworkConfiguration } = await import('./systemd-network.js'); + const config = NetworkConfiguration.fromSystemdConfiguration(text); + const schema = config.getSchema(); + + // Load schema into structured editor + this.structuredEditor.loadSchema(schema, this.state.currentConfigFile); + + // Set up event listeners for structured editor + this.structuredEditor.on('addSection', (event) => this.handleAddSection(event.detail)); + this.structuredEditor.on('removeSection', (event) => this.handleRemoveSection(event.detail)); + } catch (error) { alert(`Failed to load config for structured editor: ${error.message}`); } |
