From 66803cd4ebc9c4c309820dd0b6729b5c422bc173 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 2 Jul 2018 14:17:48 -0400 Subject: [PATCH] Add panel mode (#1383) --- src/panels/lovelace/hui-root.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/panels/lovelace/hui-root.js b/src/panels/lovelace/hui-root.js index 218ead4b54..b4a2733488 100644 --- a/src/panels/lovelace/hui-root.js +++ b/src/panels/lovelace/hui-root.js @@ -20,6 +20,8 @@ import '../../components/ha-start-voice-button.js'; import { loadModule, loadJS } from '../../common/dom/load_resource.js'; import './hui-view.js'; +import createCardElement from './common/create-card-element.js'; + // JS should only be imported once. Modules and HTML are safe. const JS_CACHE = {}; @@ -163,12 +165,20 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) { if (root.lastChild) { root.removeChild(root.lastChild); } - const view = document.createElement('hui-view'); - view.setProperties({ - hass: this.hass, - config: this.config.views[this._curView], - columns: this.columns, - }); + + const viewConfig = this.config.views[this._curView]; + + let view; + + if (viewConfig.panel) { + view = createCardElement(viewConfig.cards[0]); + } else { + view = document.createElement('hui-view'); + view.config = viewConfig; + view.columns = this.columns; + } + + view.hass = this.hass; root.appendChild(view); }