mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-10 10:56:34 +00:00
Add support for kiosk mode (#332)
* Add support for kiosk mode * Implement kiosk mode as a panel
This commit is contained in:
parent
12e3afb7b7
commit
b08170e7ff
26
panels/kiosk/ha-panel-kiosk.html
Normal file
26
panels/kiosk/ha-panel-kiosk.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
|
<link rel='import' href='../../src/layouts/partial-cards.html'>
|
||||||
|
|
||||||
|
<dom-module id="ha-panel-kiosk">
|
||||||
|
<template>
|
||||||
|
<partial-cards
|
||||||
|
id='kiosk-states'
|
||||||
|
hass='[[hass]]'
|
||||||
|
show-menu
|
||||||
|
route='[[route]]'
|
||||||
|
panel-visible
|
||||||
|
></partial-cards>
|
||||||
|
</template>
|
||||||
|
</dom-module>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
Polymer({
|
||||||
|
is: 'ha-panel-kiosk',
|
||||||
|
|
||||||
|
properties: {
|
||||||
|
hass: Object,
|
||||||
|
route: Object,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
@ -26,6 +26,11 @@
|
|||||||
data="{{routeData}}"
|
data="{{routeData}}"
|
||||||
tail="{{routeTail}}"
|
tail="{{routeTail}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
|
<app-route
|
||||||
|
route="{{route}}"
|
||||||
|
pattern="/states"
|
||||||
|
tail="{{statesRouteTail}}"
|
||||||
|
></app-route>
|
||||||
<ha-voice-command-dialog
|
<ha-voice-command-dialog
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
id='voiceDialog'
|
id='voiceDialog'
|
||||||
@ -56,7 +61,8 @@
|
|||||||
narrow='[[narrow]]'
|
narrow='[[narrow]]'
|
||||||
hass='[[hass]]'
|
hass='[[hass]]'
|
||||||
show-menu='[[dockedSidebar]]'
|
show-menu='[[dockedSidebar]]'
|
||||||
route='[[route]]'
|
route='[[statesRouteTail]]'
|
||||||
|
show-tabs
|
||||||
></partial-cards>
|
></partial-cards>
|
||||||
|
|
||||||
<partial-panel-resolver
|
<partial-panel-resolver
|
||||||
@ -88,6 +94,7 @@ Polymer({
|
|||||||
},
|
},
|
||||||
routeData: Object,
|
routeData: Object,
|
||||||
routeTail: Object,
|
routeTail: Object,
|
||||||
|
statesRouteTail: Object,
|
||||||
|
|
||||||
dockedSidebar: {
|
dockedSidebar: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<app-route
|
<app-route
|
||||||
route="{{route}}"
|
route="{{route}}"
|
||||||
pattern="/states/:view"
|
pattern="/:view"
|
||||||
data="{{routeData}}"
|
data="{{routeData}}"
|
||||||
active="{{routeMatch}}"
|
active="{{routeMatch}}"
|
||||||
></app-route>
|
></app-route>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<ha-start-voice-button hass='[[hass]]'></ha-start-voice-button>
|
<ha-start-voice-button hass='[[hass]]'></ha-start-voice-button>
|
||||||
</app-toolbar>
|
</app-toolbar>
|
||||||
|
|
||||||
<div sticky hidden$='[[!views.length]]'>
|
<div sticky hidden$='[[areTabsHidden(views, showTabs)]]'>
|
||||||
<paper-tabs
|
<paper-tabs
|
||||||
scrollable
|
scrollable
|
||||||
selected='[[currentView]]'
|
selected='[[currentView]]'
|
||||||
@ -195,6 +195,11 @@ Polymer({
|
|||||||
type: Object,
|
type: Object,
|
||||||
computed: 'computeViewStates(currentView, hass, defaultView)',
|
computed: 'computeViewStates(currentView, hass, defaultView)',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showTabs: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created: function () {
|
created: function () {
|
||||||
@ -220,6 +225,10 @@ Polymer({
|
|||||||
this._columns = Math.max(1, matchColumns - (!this.narrow && this.showMenu));
|
this._columns = Math.max(1, matchColumns - (!this.narrow && this.showMenu));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
areTabsHidden: function (views, showTabs) {
|
||||||
|
return !views.length || !showTabs;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scroll to a specific y coordinate.
|
* Scroll to a specific y coordinate.
|
||||||
*
|
*
|
||||||
@ -305,6 +314,7 @@ Polymer({
|
|||||||
},
|
},
|
||||||
|
|
||||||
hassChanged: function (hass) {
|
hassChanged: function (hass) {
|
||||||
|
if (!hass) return;
|
||||||
var views = window.HAWS.extractViews(hass.states);
|
var views = window.HAWS.extractViews(hass.states);
|
||||||
// If default view present, it's in first index.
|
// If default view present, it's in first index.
|
||||||
if (views.length > 0 && views[0].entity_id === this.DEFAULT_VIEW_ENTITY_ID) {
|
if (views.length > 0 && views[0].entity_id === this.DEFAULT_VIEW_ENTITY_ID) {
|
||||||
|
@ -466,11 +466,11 @@ window.hassUtil.computeStateState = function (stateObj) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.hassUtil.isComponentLoaded = function (hass, component) {
|
window.hassUtil.isComponentLoaded = function (hass, component) {
|
||||||
return hass.config.core.components.indexOf(component) !== -1;
|
return hass && hass.config.core.components.indexOf(component) !== -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.hassUtil.computeLocationName = function (hass) {
|
window.hassUtil.computeLocationName = function (hass) {
|
||||||
return hass.config.core.location_name;
|
return hass && hass.config.core.location_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user