mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Add support for JS modules in custom panels. (#1588)
* Added support for JS modules in custom panels. * Update load-custom-panel.js * Corrected syntax * Force push * Fixed EOL * Delete index.html * Fixed tempA href missing module_url name
This commit is contained in:
parent
09f238162e
commit
74185f0beb
@ -47,7 +47,7 @@ class HaPanelCustom extends NavigateMixin(EventsMixin(PolymerElement)) {
|
||||
const config = panel.config._panel_custom;
|
||||
|
||||
const tempA = document.createElement('a');
|
||||
tempA.href = config.html_url || config.js_url;
|
||||
tempA.href = config.html_url || config.js_url || config.module_url;
|
||||
|
||||
if (!config.trust_external && !['localhost', '127.0.0.1', location.hostname].includes(tempA.hostname)) {
|
||||
if (!confirm(`Do you trust the external panel "${config.name}" at "${tempA.href}"?
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { loadJS } from '../../common/dom/load_resource.js';
|
||||
import { loadJS, loadModule } from '../../common/dom/load_resource.js';
|
||||
|
||||
// Make sure we only import every JS-based panel once (HTML import has this built-in)
|
||||
const JS_CACHE = {};
|
||||
@ -20,6 +20,8 @@ export default function loadCustomPanel(panelConfig) {
|
||||
JS_CACHE[panelConfig.js_url] = loadJS(panelConfig.js_url);
|
||||
}
|
||||
return JS_CACHE[panelConfig.js_url];
|
||||
} else if (panelConfig.module_url) {
|
||||
return loadModule(panelConfig.module_url);
|
||||
}
|
||||
return Promise.reject('No valid url found in panel config.');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user