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