Added error handling in frontend debug forms
This commit is contained in:
parent
8c62ae4ce5
commit
ced3d595cc
3 changed files with 43 additions and 25 deletions
|
@ -10,7 +10,11 @@
|
||||||
<polymer-element name="event-fire-dialog" attributes="api">
|
<polymer-element name="event-fire-dialog" attributes="api">
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<ha-action-dialog id="dialog" heading="Fire Event" class='two-column'>
|
<ha-action-dialog
|
||||||
|
id="dialog"
|
||||||
|
heading="Fire Event"
|
||||||
|
class='two-column'
|
||||||
|
closeSelector='[dismissive]'>
|
||||||
|
|
||||||
<div layout horizontal>
|
<div layout horizontal>
|
||||||
<div class='ha-form'>
|
<div class='ha-form'>
|
||||||
|
@ -68,15 +72,15 @@ Polymer({
|
||||||
},
|
},
|
||||||
|
|
||||||
clickFireEvent: function() {
|
clickFireEvent: function() {
|
||||||
var data;
|
try {
|
||||||
|
this.api.fire_event(
|
||||||
if(this.$.inputData.value !== "") {
|
this.$.inputType.value,
|
||||||
data = JSON.parse(this.$.inputData.value);
|
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});
|
||||||
} else {
|
this.$.dialog.close();
|
||||||
data = {};
|
|
||||||
|
} catch (err) {
|
||||||
|
alert("Error parsing JSON: " + err);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.api.fire_event(this.$.inputType.value, data);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
<polymer-element name="service-call-dialog" attributes="api">
|
<polymer-element name="service-call-dialog" attributes="api">
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<ha-action-dialog id="dialog" heading="Call Service">
|
<ha-action-dialog
|
||||||
|
id="dialog"
|
||||||
|
heading="Call Service"
|
||||||
|
closeSelector='[dismissive]'>
|
||||||
|
|
||||||
<core-style ref='ha-dialog'></core-style>
|
<core-style ref='ha-dialog'></core-style>
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@
|
||||||
Polymer({
|
Polymer({
|
||||||
ready: function() {
|
ready: function() {
|
||||||
// to ensure callback methods work..
|
// to ensure callback methods work..
|
||||||
this.serviceSelected = this.serviceSelected.bind(this)
|
this.serviceSelected = this.serviceSelected.bind(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(domain, service, serviceData) {
|
show: function(domain, service, serviceData) {
|
||||||
|
@ -65,16 +68,17 @@ Polymer({
|
||||||
},
|
},
|
||||||
|
|
||||||
clickCallService: function() {
|
clickCallService: function() {
|
||||||
var data;
|
try {
|
||||||
|
|
||||||
if(this.$.inputData.value != "") {
|
|
||||||
data = JSON.parse(this.$.inputData.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.api.call_service(
|
this.api.call_service(
|
||||||
this.$.inputDomain.value,
|
this.$.inputDomain.value,
|
||||||
this.$.inputService.value,
|
this.$.inputService.value,
|
||||||
data);
|
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});
|
||||||
|
|
||||||
|
this.$.dialog.close();
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
alert("Error parsing JSON: " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,12 +9,16 @@
|
||||||
|
|
||||||
<polymer-element name="state-set-dialog" attributes="api">
|
<polymer-element name="state-set-dialog" attributes="api">
|
||||||
<template>
|
<template>
|
||||||
<ha-action-dialog id="dialog" heading="Set State">
|
<ha-action-dialog
|
||||||
|
id="dialog"
|
||||||
|
heading="Set State"
|
||||||
|
closeSelector='[dismissive]'>
|
||||||
|
|
||||||
<core-style ref='ha-dialog'></core-style>
|
<core-style ref='ha-dialog'></core-style>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This dialog will update the representation of the device within Home Assistant. This will not communicate with the actual device.
|
This dialog will update the representation of the device within Home Assistant.<br />
|
||||||
|
This will not communicate with the actual device.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div layout horizontal>
|
<div layout horizontal>
|
||||||
|
@ -81,12 +85,18 @@ Polymer({
|
||||||
this.setStateData(state.attributes);
|
this.setStateData(state.attributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
clickSetState: function() {
|
clickSetState: function(ev) {
|
||||||
this.api.set_state(
|
try {
|
||||||
this.$.inputEntityID.value,
|
this.api.set_state(
|
||||||
this.$.inputState.value,
|
this.$.inputEntityID.value,
|
||||||
JSON.parse(this.$.inputData.value)
|
this.$.inputState.value,
|
||||||
|
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.$.dialog.close();
|
||||||
|
} catch (err) {
|
||||||
|
alert("Error parsing JSON: " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue