2015-07-13 01:57:15 +02:00
|
|
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
|
|
|
|
|
|
|
<dom-module id='more-info-camera'>
|
2016-07-19 10:19:44 +02:00
|
|
|
<template>
|
|
|
|
<style>
|
|
|
|
:host {
|
|
|
|
max-width:640px;
|
|
|
|
}
|
2015-07-13 01:57:15 +02:00
|
|
|
|
2016-07-19 10:19:44 +02:00
|
|
|
.camera-image {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|
2015-07-13 01:57:15 +02:00
|
|
|
|
2017-01-09 01:35:21 +01:00
|
|
|
<img class='camera-image' src="[[computeCameraImageUrl(hass, stateObj, isVisible)]]"
|
2017-01-30 03:34:45 +01:00
|
|
|
on-load='imageLoaded' alt='[[computeStateName(stateObj)]]' />
|
2015-07-13 01:57:15 +02:00
|
|
|
</template>
|
|
|
|
</dom-module>
|
2016-05-29 01:03:51 +02:00
|
|
|
|
|
|
|
<script>
|
|
|
|
Polymer({
|
|
|
|
is: 'more-info-camera',
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
hass: {
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
|
|
|
|
stateObj: {
|
|
|
|
type: Object,
|
|
|
|
},
|
2017-01-09 01:35:21 +01:00
|
|
|
|
|
|
|
isVisible: {
|
|
|
|
type: Boolean,
|
|
|
|
value: true,
|
|
|
|
},
|
2016-05-29 01:03:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
imageLoaded: function () {
|
|
|
|
this.fire('iron-resize');
|
|
|
|
},
|
|
|
|
|
2017-01-30 03:34:45 +01:00
|
|
|
computeStateName: function (stateObj) {
|
|
|
|
return window.hassUtil.computeStateName(stateObj);
|
|
|
|
},
|
|
|
|
|
2017-01-09 01:35:21 +01:00
|
|
|
computeCameraImageUrl: function (hass, stateObj, isVisible) {
|
2016-05-29 01:03:51 +02:00
|
|
|
if (hass.demo) {
|
|
|
|
return '/demo/webcam.jpg';
|
2017-01-09 01:35:21 +01:00
|
|
|
} else if (stateObj && isVisible) {
|
2017-01-30 03:34:45 +01:00
|
|
|
return '/api/camera_proxy_stream/' + stateObj.entity_id +
|
2016-06-12 08:55:43 +02:00
|
|
|
'?token=' + stateObj.attributes.access_token;
|
2016-05-29 01:03:51 +02:00
|
|
|
}
|
2017-01-09 01:35:21 +01:00
|
|
|
// Return an empty image if no stateObj (= dialog not open) or in cleanup mode.
|
2016-05-29 01:03:51 +02:00
|
|
|
return 'data:image/gif;base64,R0lGODlhAQABAAAAACw=';
|
|
|
|
},
|
|
|
|
});
|
2017-01-09 01:35:21 +01:00
|
|
|
</script>
|