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