Show errors on dashboard when something went wrong.

https://www.pivotaltracker.com/story/show/145310923
This commit is contained in:
Paulus Schoutsen 2017-05-11 21:52:14 -07:00
parent 9bde68c4cc
commit a4f7caef81
3 changed files with 82 additions and 0 deletions

View File

@ -16,6 +16,10 @@
.info td:nth-child(2) {
text-align: right;
}
.errors {
color: var(--google-red-500);
margin-top: 16px;
}
</style>
<template>
<paper-card heading="Home Assistant">
@ -30,6 +34,9 @@
<td>[[data.last_version]]</td>
</tr>
</table>
<template is='dom-if' if='[[errors]]'>
<div class='errors'>Error: [[errors]]</div>
</template>
</div>
<div class="card-actions">
<template is='dom-if' if='[[computeUpdateAvailable(data)]]'>
@ -63,6 +70,25 @@ Polymer({
},
},
listeners: {
'hass-api-called': 'apiCalled',
},
apiCalled: function (ev) {
if (ev.detail.success) {
this.errors = null;
return;
}
var response = ev.detail.response;
if (typeof response.body === 'object') {
this.errors = response.body.message || 'Unknown error';
} else {
this.errors = response.body;
}
},
computeUpdateAvailable: function (data) {
return data.version !== data.last_version;
},

View File

@ -15,6 +15,10 @@
.info td:nth-child(2) {
text-align: right;
}
.errors {
color: var(--google-red-500);
margin-top: 16px;
}
</style>
<template>
<paper-card heading="Host OS">
@ -41,6 +45,9 @@
<td>[[data.last_version]]</td>
</tr>
</table>
<template is='dom-if' if='[[errors]]'>
<div class='errors'>Error: [[errors]]</div>
</template>
</div>
<div class="card-actions">
<template is='dom-if' if='[[computeUpdateAvailable(data)]]'>
@ -74,6 +81,27 @@ Polymer({
type: Object,
value: {},
},
errors: String,
},
listeners: {
'hass-api-called': 'apiCalled',
},
apiCalled: function (ev) {
if (ev.detail.success) {
this.errors = null;
return;
}
var response = ev.detail.response;
if (typeof response.body === 'object') {
this.errors = response.body.message || 'Unknown error';
} else {
this.errors = response.body;
}
},
computeUpdateAvailable: function (data) {

View File

@ -15,6 +15,10 @@
.info td:nth-child(2) {
text-align: right;
}
.errors {
color: var(--google-red-500);
margin-top: 16px;
}
</style>
<template>
<paper-card heading="Supervisor">
@ -33,6 +37,9 @@
<td>[[data.last_version]]</td>
</tr>
</table>
<template is='dom-if' if='[[errors]]'>
<div class='errors'>Error: [[errors]]</div>
</template>
</div>
<div class="card-actions">
<paper-button on-tap='supervisorLogsTapped'>View logs</paper-button>
@ -65,6 +72,27 @@ Polymer({
type: Object,
value: {},
},
errors: String,
},
listeners: {
'hass-api-called': 'apiCalled',
},
apiCalled: function (ev) {
if (ev.detail.success) {
this.errors = null;
return;
}
var response = ev.detail.response;
if (typeof response.body === 'object') {
this.errors = response.body.message || 'Unknown error';
} else {
this.errors = response.body;
}
},
computeUpdateAvailable: function (data) {