mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
More frontend code clean up
This commit is contained in:
parent
89f59a758d
commit
24d9856ae6
@ -1,2 +1,2 @@
|
||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "b9bb73c7d937ff2219001668ea739134"
|
||||
VERSION = "10b554c3f2db1c5441d5e74c0f6d8469"
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,6 +20,8 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
var serviceActions = window.hass.serviceActions;
|
||||
|
||||
Polymer({
|
||||
toggleChecked: false,
|
||||
|
||||
@ -47,7 +49,7 @@
|
||||
|
||||
stateObjChanged: function(oldVal, newVal) {
|
||||
if (newVal) {
|
||||
this.toggleChecked = newVal.state === 'on';
|
||||
this.stateChanged(null, newVal.state);
|
||||
}
|
||||
},
|
||||
|
||||
@ -56,7 +58,7 @@
|
||||
},
|
||||
|
||||
forceStateChange: function() {
|
||||
this.stateChanged(this.stateObj.state, this.stateObj.state);
|
||||
this.stateChanged(null, this.stateObj.state);
|
||||
},
|
||||
|
||||
turn_on: function() {
|
||||
@ -64,8 +66,7 @@
|
||||
// with the state. It will be out of sync if our service call did not
|
||||
// result in the entity to be turned on. Since the state is not changing,
|
||||
// the resync is not called automatic.
|
||||
window.hass.serviceActions.callTurnOn(this.stateObj.entityId)
|
||||
.then(this.forceStateChange);
|
||||
serviceActions.callTurnOn(this.stateObj.entityId).then(this.forceStateChange);
|
||||
},
|
||||
|
||||
turn_off: function() {
|
||||
@ -73,10 +74,8 @@
|
||||
// with the state. It will be out of sync if our service call did not
|
||||
// result in the entity to be turned on. Since the state is not changing,
|
||||
// the resync is not called automatic.
|
||||
window.hass.serviceActions.callTurnOff(this.stateObj.entityId)
|
||||
.then(this.forceStateChange);
|
||||
serviceActions.callTurnOff(this.stateObj.entityId).then(this.forceStateChange);
|
||||
},
|
||||
|
||||
});
|
||||
</script>
|
||||
</polymer-element>
|
||||
|
@ -22,12 +22,12 @@
|
||||
<state-card-content stateObj={{stateObj}}></state-card-content>
|
||||
</template>
|
||||
<script>
|
||||
var uiActions = window.hass.uiActions;
|
||||
|
||||
Polymer({
|
||||
|
||||
cardClicked: function() {
|
||||
window.hass.uiActions.showMoreInfoDialog(this.stateObj.entityId);
|
||||
uiActions.showMoreInfoDialog(this.stateObj.entityId);
|
||||
},
|
||||
|
||||
});
|
||||
</script>
|
||||
</polymer-element>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6222eedb4e042fa08c2393ab465bb4e8c8afd5fd
|
||||
Subproject commit 9b5c89e05277c276c941166c582d2cb5159e9425
|
@ -31,6 +31,7 @@
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var uiActions = window.hass.uiActions;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
loaded: false,
|
||||
@ -39,14 +40,16 @@
|
||||
// remove the HTML init message
|
||||
document.getElementById('init').remove();
|
||||
|
||||
this.listenToStores(true);
|
||||
|
||||
// if auth was given, tell the backend
|
||||
if(this.auth) {
|
||||
window.hass.uiActions.validateAuth(this.auth);
|
||||
uiActions.validateAuth(this.auth);
|
||||
}
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this.listenToStores(true);
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
this.stopListeningToStores();
|
||||
},
|
||||
|
@ -147,6 +147,7 @@
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var authActions = window.hass.authActions;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
selected: "states",
|
||||
@ -206,9 +207,8 @@ Polymer(Polymer.mixin({
|
||||
},
|
||||
|
||||
handleLogOutClick: function() {
|
||||
window.hass.authActions.logOut();
|
||||
authActions.logOut();
|
||||
},
|
||||
|
||||
}, storeListenerMixIn));
|
||||
</script>
|
||||
</polymer-element>
|
||||
|
@ -59,6 +59,7 @@
|
||||
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var uiActions = window.hass.uiActions;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
MSG_VALIDATING: "Validating password…",
|
||||
@ -113,9 +114,8 @@
|
||||
validatePassword: function() {
|
||||
this.$.hideKeyboardOnFocus.focus();
|
||||
|
||||
window.hass.uiActions.validateAuth(this.authToken);
|
||||
uiActions.validateAuth(this.authToken);
|
||||
},
|
||||
|
||||
}, storeListenerMixIn));
|
||||
</script>
|
||||
</polymer-element>
|
||||
|
@ -55,6 +55,8 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
var serviceActions = window.hass.serviceActions;
|
||||
|
||||
Polymer({
|
||||
ready: function() {
|
||||
// to ensure callback methods work..
|
||||
@ -72,7 +74,7 @@ Polymer({
|
||||
|
||||
clickCallService: function() {
|
||||
try {
|
||||
window.hass.serviceActions.callService(
|
||||
serviceActions.callService(
|
||||
this.$.inputDomain.value,
|
||||
this.$.inputService.value,
|
||||
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});
|
||||
|
@ -54,6 +54,8 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
var eventActions = window.hass.eventActions;
|
||||
|
||||
Polymer({
|
||||
ready: function() {
|
||||
// to ensure callback methods work..
|
||||
@ -66,10 +68,9 @@ Polymer({
|
||||
|
||||
clickFireEvent: function() {
|
||||
try {
|
||||
window.hass.eventActions.fire(
|
||||
eventActions.fire(
|
||||
this.$.inputType.value,
|
||||
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {});
|
||||
|
||||
} catch (err) {
|
||||
alert("Error parsing JSON: " + err);
|
||||
}
|
||||
|
@ -56,6 +56,9 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
var stateStore = window.hass.stateStore;
|
||||
var stateActions = window.hass.stateActions;
|
||||
|
||||
Polymer({
|
||||
ready: function() {
|
||||
// to ensure callback methods work..
|
||||
@ -82,14 +85,14 @@ Polymer({
|
||||
entitySelected: function(entityId) {
|
||||
this.setEntityId(entityId);
|
||||
|
||||
var state = window.hass.stateStore.get(entityId);
|
||||
var state = stateStore.get(entityId);
|
||||
this.setState(state.state);
|
||||
this.setStateData(state.attributes);
|
||||
},
|
||||
|
||||
clickSetState: function(ev) {
|
||||
try {
|
||||
window.hass.stateActions.set(
|
||||
stateActions.set(
|
||||
this.$.inputEntityID.value,
|
||||
this.$.inputState.value,
|
||||
this.$.inputData.value ? JSON.parse(this.$.inputData.value) : {}
|
||||
|
@ -31,6 +31,8 @@
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var syncActions = window.hass.syncActions;
|
||||
var stateStore = window.hass.stateStore;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
headerTitle: "States",
|
||||
@ -50,8 +52,8 @@
|
||||
this.refreshStates();
|
||||
},
|
||||
|
||||
syncStoreChanged: function() {
|
||||
this.isFetching = window.hass.syncStore.isFetching();
|
||||
syncStoreChanged: function(syncStore) {
|
||||
this.isFetching = syncStore.isFetching();
|
||||
},
|
||||
|
||||
streamStoreChanged: function(streamStore) {
|
||||
@ -74,18 +76,18 @@
|
||||
|
||||
refreshStates: function() {
|
||||
if (this.filter == 'group') {
|
||||
this.states = _.filter(window.hass.stateStore.all(), function(state) {
|
||||
this.states = _.filter(stateStore.all(), function(state) {
|
||||
return state.domain === 'group';
|
||||
});
|
||||
} else {
|
||||
this.states = _.filter(window.hass.stateStore.all(), function(state) {
|
||||
this.states = _.filter(stateStore.all(), function(state) {
|
||||
return state.domain !== 'group';
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleRefreshClick: function() {
|
||||
window.hass.syncActions.sync();
|
||||
syncActions.fetchAll();
|
||||
},
|
||||
}, storeListenerMixIn));
|
||||
</script>
|
||||
|
@ -68,6 +68,8 @@
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
var syncActions = window.hass.syncActions;
|
||||
var serviceActions = window.hass.serviceActions;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
action: "display",
|
||||
@ -91,13 +93,13 @@
|
||||
configure_id: this.stateObj.attributes.configure_id
|
||||
};
|
||||
|
||||
window.hass.serviceActions.callService('configurator', 'configure', data).then(
|
||||
serviceActions.callService('configurator', 'configure', data).then(
|
||||
|
||||
function() {
|
||||
this.action = 'display';
|
||||
|
||||
if (!this.isStreaming) {
|
||||
window.hass.syncActions.start();
|
||||
syncActions.fetchAll();
|
||||
}
|
||||
}.bind(this),
|
||||
|
||||
|
@ -54,6 +54,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
var serviceActions = window.hass.serviceActions;
|
||||
|
||||
Polymer({
|
||||
brightnessSliderValue: 0,
|
||||
|
||||
@ -81,9 +83,9 @@ Polymer({
|
||||
if(isNaN(bri)) return;
|
||||
|
||||
if(bri === 0) {
|
||||
window.hass.serviceActions.callTurnOff(this.stateObj.entityId);
|
||||
serviceActions.callTurnOff(this.stateObj.entityId);
|
||||
} else {
|
||||
window.hass.serviceActions.callService("light", "turn_on", {
|
||||
serviceActions.callService("light", "turn_on", {
|
||||
entity_id: this.stateObj.entityId,
|
||||
brightness: bri
|
||||
});
|
||||
@ -93,7 +95,7 @@ Polymer({
|
||||
colorPicked: function(ev) {
|
||||
var color = ev.detail.rgb;
|
||||
|
||||
window.hass.serviceActions.callService("light", "turn_on", {
|
||||
serviceActions.callService("light", "turn_on", {
|
||||
entity_id: this.stateObj.entityId,
|
||||
rgb_color: [color.r, color.g, color.b]
|
||||
});
|
||||
|
@ -30,11 +30,12 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
var parseDateTime = window.hass.util.parseDateTime;
|
||||
|
||||
Polymer({
|
||||
stateObjChanged: function() {
|
||||
var rising = window.hass.util.parseDateTime(this.stateObj.attributes.next_rising);
|
||||
var setting = window.hass.util.parseDateTime(this.stateObj.attributes.next_setting);
|
||||
var rising = parseDateTime(this.stateObj.attributes.next_rising);
|
||||
var setting = parseDateTime(this.stateObj.attributes.next_setting);
|
||||
|
||||
if(rising > setting) {
|
||||
this.$.sunData.appendChild(this.$.rising);
|
||||
@ -42,7 +43,6 @@ Polymer({
|
||||
this.$.sunData.appendChild(this.$.setting);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
</polymer-element>
|
||||
|
Loading…
x
Reference in New Issue
Block a user