mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Make panels ES5 compatible (#320)
This commit is contained in:
parent
31af2968da
commit
1ad4259213
@ -109,11 +109,11 @@ Polymer({
|
|||||||
return isWide ? 'content' : 'content narrow';
|
return isWide ? 'content' : 'content narrow';
|
||||||
},
|
},
|
||||||
|
|
||||||
computeIsHassbianLoaded(hass) {
|
computeIsHassbianLoaded: function (hass) {
|
||||||
return window.hassUtil.isComponentLoaded(hass, 'config.hassbian');
|
return window.hassUtil.isComponentLoaded(hass, 'config.hassbian');
|
||||||
},
|
},
|
||||||
|
|
||||||
computeIsZwaveLoaded(hass) {
|
computeIsZwaveLoaded: function (hass) {
|
||||||
return window.hassUtil.isComponentLoaded(hass, 'config.zwave');
|
return window.hassUtil.isComponentLoaded(hass, 'config.zwave');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -132,7 +132,7 @@ Polymer({
|
|||||||
mapItems.push(window.L.marker(
|
mapItems.push(window.L.marker(
|
||||||
[entity.attributes.latitude, entity.attributes.longitude],
|
[entity.attributes.latitude, entity.attributes.longitude],
|
||||||
{
|
{
|
||||||
icon,
|
icon: icon,
|
||||||
interactive: false,
|
interactive: false,
|
||||||
title: title,
|
title: title,
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ Polymer({
|
|||||||
mapItems.push(window.L.marker(
|
mapItems.push(window.L.marker(
|
||||||
[entity.attributes.latitude, entity.attributes.longitude],
|
[entity.attributes.latitude, entity.attributes.longitude],
|
||||||
{
|
{
|
||||||
icon,
|
icon: icon,
|
||||||
title: window.hassUtil.computeStateName(entity),
|
title: window.hassUtil.computeStateName(entity),
|
||||||
}
|
}
|
||||||
).addTo(map));
|
).addTo(map));
|
||||||
|
@ -370,50 +370,38 @@ Polymer({
|
|||||||
this.selectedConfigParameter = -1;
|
this.selectedConfigParameter = -1;
|
||||||
this.selectedConfigParameterValue = -1;
|
this.selectedConfigParameterValue = -1;
|
||||||
this.selectedGroup = -1;
|
this.selectedGroup = -1;
|
||||||
var configData = [];
|
|
||||||
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(function (configs) {
|
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(configs).forEach(([key, value]) => {
|
function (configs) {
|
||||||
configData.push({ key, value });
|
this.config = this._objToArray(configs);
|
||||||
});
|
}.bind(this));
|
||||||
this.config = configData;
|
|
||||||
}.bind(this));
|
this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
var valueData = [];
|
function (values) {
|
||||||
this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(function (values) {
|
this.values = this._objToArray(values);
|
||||||
Object.entries(values).forEach(([key, value]) => {
|
}.bind(this));
|
||||||
valueData.push({ key, value });
|
|
||||||
});
|
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
this.values = valueData;
|
function (groups) {
|
||||||
}.bind(this));
|
this.groups = this._objToArray(groups);
|
||||||
var groupData = [];
|
}.bind(this));
|
||||||
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(function (groups) {
|
|
||||||
Object.entries(groups).forEach(([key, value]) => {
|
|
||||||
groupData.push({ key, value });
|
|
||||||
});
|
|
||||||
this.groups = groupData;
|
|
||||||
}.bind(this));
|
|
||||||
var userCodes = [];
|
|
||||||
this.hasNodeUserCodes = false;
|
this.hasNodeUserCodes = false;
|
||||||
this.notifyPath('hasNodeUserCodes');
|
this.notifyPath('hasNodeUserCodes');
|
||||||
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(function (usercodes) {
|
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(usercodes).forEach(([key, value]) => {
|
function (usercodes) {
|
||||||
userCodes.push({ key, value });
|
this.userCodes = this._objToArray(usercodes);
|
||||||
});
|
this.hasNodeUserCodes = this.userCodes.length > 0;
|
||||||
this.userCodes = userCodes;
|
this.notifyPath('hasNodeUserCodes');
|
||||||
if (Object.keys(userCodes).length === 0) {
|
}.bind(this));
|
||||||
this.hasNodeUserCodes = false;
|
|
||||||
} else {
|
|
||||||
this.hasNodeUserCodes = true;
|
|
||||||
}
|
|
||||||
this.notifyPath('hasNodeUserCodes');
|
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
computeSelectedEntityAttrs: function (selectedEntity) {
|
computeSelectedEntityAttrs: function (selectedEntity) {
|
||||||
if (selectedEntity === -1) return 'No entity selected';
|
if (selectedEntity === -1) return 'No entity selected';
|
||||||
var entityAttrs = this.entities[selectedEntity].attributes;
|
var entityAttrs = this.entities[selectedEntity].attributes;
|
||||||
var att = [];
|
var att = [];
|
||||||
Object.entries(entityAttrs).forEach(([key, value]) => {
|
Object.keys(entityAttrs).forEach(function (key) {
|
||||||
att.push(key + ': ' + value);
|
att.push(key + ': ' + entityAttrs[key]);
|
||||||
});
|
});
|
||||||
return att.sort();
|
return att.sort();
|
||||||
},
|
},
|
||||||
@ -460,5 +448,16 @@ Polymer({
|
|||||||
toggleHelp: function () {
|
toggleHelp: function () {
|
||||||
this.showHelp = !this.showHelp;
|
this.showHelp = !this.showHelp;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_objToArray: function (obj) {
|
||||||
|
var array = [];
|
||||||
|
Object.keys(obj).forEach(function (key) {
|
||||||
|
array.push({
|
||||||
|
key: key,
|
||||||
|
value: obj[key],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return array;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -203,13 +203,17 @@ Polymer({
|
|||||||
|
|
||||||
refreshGroups: function (selectedNode) {
|
refreshGroups: function (selectedNode) {
|
||||||
var groupData = [];
|
var groupData = [];
|
||||||
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(function (groups) {
|
this.hass.callApi('GET', 'zwave/groups/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(groups).forEach(([key, value]) => {
|
function (groups) {
|
||||||
groupData.push({ key, value });
|
Object.keys(groups).forEach(function (key) {
|
||||||
});
|
groupData.push({
|
||||||
this.groups = groupData;
|
key: key,
|
||||||
this.selectedGroupChanged(this.selectedGroup);
|
value: groups[key],
|
||||||
}.bind(this));
|
});
|
||||||
|
});
|
||||||
|
this.groups = groupData;
|
||||||
|
this.selectedGroupChanged(this.selectedGroup);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
selectedGroupChanged: function (selectedGroup) {
|
selectedGroupChanged: function (selectedGroup) {
|
||||||
|
@ -300,13 +300,17 @@ Polymer({
|
|||||||
|
|
||||||
refreshConfig: function (selectedNode) {
|
refreshConfig: function (selectedNode) {
|
||||||
var configData = [];
|
var configData = [];
|
||||||
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(function (config) {
|
this.hass.callApi('GET', 'zwave/config/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(config).forEach(([key, value]) => {
|
function (config) {
|
||||||
configData.push({ key, value });
|
Object.keys(config).forEach(function (key) {
|
||||||
});
|
configData.push({
|
||||||
this.config = configData;
|
key: key,
|
||||||
this.selectedConfigParameterChanged(this.selectedConfigParameter);
|
value: config[key],
|
||||||
}.bind(this));
|
});
|
||||||
|
});
|
||||||
|
this.config = configData;
|
||||||
|
this.selectedConfigParameterChanged(this.selectedConfigParameter);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -71,8 +71,8 @@ Polymer({
|
|||||||
if (!this.nodes || selectedNode === -1) return;
|
if (!this.nodes || selectedNode === -1) return;
|
||||||
var nodeAttrs = this.nodes[this.selectedNode].attributes;
|
var nodeAttrs = this.nodes[this.selectedNode].attributes;
|
||||||
var att = [];
|
var att = [];
|
||||||
Object.entries(nodeAttrs).forEach(([key, value]) => {
|
Object.keys(nodeAttrs).forEach(function (key) {
|
||||||
att.push(key + ': ' + value);
|
att.push(key + ': ' + nodeAttrs[key]);
|
||||||
});
|
});
|
||||||
this.selectedNodeAttrs = att.sort();
|
this.selectedNodeAttrs = att.sort();
|
||||||
},
|
},
|
||||||
|
@ -159,13 +159,17 @@ Polymer({
|
|||||||
refreshUserCodes: function (selectedNode) {
|
refreshUserCodes: function (selectedNode) {
|
||||||
this.selectedUserCodeValue = '';
|
this.selectedUserCodeValue = '';
|
||||||
var userCodes = [];
|
var userCodes = [];
|
||||||
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(function (usercodes) {
|
this.hass.callApi('GET', 'zwave/usercodes/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(usercodes).forEach(([key, value]) => {
|
function (usercodes) {
|
||||||
userCodes.push({ key, value });
|
Object.keys(usercodes).forEach(function (key) {
|
||||||
});
|
userCodes.push({
|
||||||
this.userCodes = userCodes;
|
key: key,
|
||||||
this.selectedUserCodeChanged(this.selectedUserCode);
|
value: usercodes[key],
|
||||||
}.bind(this));
|
});
|
||||||
|
});
|
||||||
|
this.userCodes = userCodes;
|
||||||
|
this.selectedUserCodeChanged(this.selectedUserCode);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -120,13 +120,17 @@ Polymer({
|
|||||||
|
|
||||||
refreshValues: function (selectedNode) {
|
refreshValues: function (selectedNode) {
|
||||||
var valueData = [];
|
var valueData = [];
|
||||||
this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(function (values) {
|
this.hass.callApi('GET', 'zwave/values/' + this.nodes[selectedNode].attributes.node_id).then(
|
||||||
Object.entries(values).forEach(([key, value]) => {
|
function (values) {
|
||||||
valueData.push({ key, value });
|
Object.keys(values).forEach(function (key) {
|
||||||
});
|
valueData.push({
|
||||||
this.values = valueData;
|
key: key,
|
||||||
this.selectedValueChanged(this.selectedValue);
|
value: values[key],
|
||||||
}.bind(this));
|
});
|
||||||
|
});
|
||||||
|
this.values = valueData;
|
||||||
|
this.selectedValueChanged(this.selectedValue);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
computeValueNameServiceData: function (newValueNameInput) {
|
computeValueNameServiceData: function (newValueNameInput) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user