Add panel mode (#1383)

This commit is contained in:
Paulus Schoutsen 2018-07-02 14:17:48 -04:00 committed by GitHub
parent 66ae61374d
commit 66803cd4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,8 @@ import '../../components/ha-start-voice-button.js';
import { loadModule, loadJS } from '../../common/dom/load_resource.js'; import { loadModule, loadJS } from '../../common/dom/load_resource.js';
import './hui-view.js'; import './hui-view.js';
import createCardElement from './common/create-card-element.js';
// JS should only be imported once. Modules and HTML are safe. // JS should only be imported once. Modules and HTML are safe.
const JS_CACHE = {}; const JS_CACHE = {};
@ -163,12 +165,20 @@ class HUIRoot extends NavigateMixin(EventsMixin(PolymerElement)) {
if (root.lastChild) { if (root.lastChild) {
root.removeChild(root.lastChild); root.removeChild(root.lastChild);
} }
const view = document.createElement('hui-view');
view.setProperties({ const viewConfig = this.config.views[this._curView];
hass: this.hass,
config: this.config.views[this._curView], let view;
columns: this.columns,
}); 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); root.appendChild(view);
} }