mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 04:16:34 +00:00
Allow for checking for updates (#12422)
This commit is contained in:
parent
86f39d1d43
commit
2fceb0aeee
@ -11,6 +11,7 @@ import "../../../components/ha-bar";
|
|||||||
import "../../../components/ha-button-menu";
|
import "../../../components/ha-button-menu";
|
||||||
import "../../../components/ha-metric";
|
import "../../../components/ha-metric";
|
||||||
import { updateCanInstall, UpdateEntity } from "../../../data/update";
|
import { updateCanInstall, UpdateEntity } from "../../../data/update";
|
||||||
|
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||||
import "../../../layouts/hass-subpage";
|
import "../../../layouts/hass-subpage";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { showToast } from "../../../util/toast";
|
import { showToast } from "../../../util/toast";
|
||||||
@ -58,18 +59,25 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
${canInstallUpdates.length
|
<div class="card-content">
|
||||||
? html`
|
${canInstallUpdates.length
|
||||||
<ha-config-updates
|
? html`
|
||||||
.hass=${this.hass}
|
<ha-config-updates
|
||||||
.narrow=${this.narrow}
|
.hass=${this.hass}
|
||||||
.updateEntities=${canInstallUpdates}
|
.narrow=${this.narrow}
|
||||||
showAll
|
.updateEntities=${canInstallUpdates}
|
||||||
></ha-config-updates>
|
showAll
|
||||||
`
|
></ha-config-updates>
|
||||||
: html`
|
`
|
||||||
${this.hass.localize("ui.panel.config.updates.no_updates")}
|
: html`
|
||||||
`}
|
${this.hass.localize("ui.panel.config.updates.no_updates")}
|
||||||
|
`}
|
||||||
|
</div>
|
||||||
|
<div class="card-actions">
|
||||||
|
<mwc-button @click=${this._checkUpdates}>
|
||||||
|
${this.hass.localize("ui.panel.config.updates.check_updates")}
|
||||||
|
</mwc-button>
|
||||||
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
</div>
|
</div>
|
||||||
</hass-subpage>
|
</hass-subpage>
|
||||||
@ -107,6 +115,29 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
this._showSkipped = !this._showSkipped;
|
this._showSkipped = !this._showSkipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _checkUpdates(): Promise<void> {
|
||||||
|
const _entities = this._filterUpdateEntities(this.hass.states).map(
|
||||||
|
(entity) => entity.entity_id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (_entities.length) {
|
||||||
|
this._notifyUpdates = true;
|
||||||
|
await this.hass.callService("homeassistant", "update_entity", {
|
||||||
|
entity_id: _entities,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.updates.no_update_entities.title"
|
||||||
|
),
|
||||||
|
text: this.hass.localize(
|
||||||
|
"ui.panel.config.updates.no_update_entities.description"
|
||||||
|
),
|
||||||
|
warning: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private _filterUpdateEntities = memoizeOne((entities: HassEntities) =>
|
private _filterUpdateEntities = memoizeOne((entities: HassEntities) =>
|
||||||
(
|
(
|
||||||
Object.values(entities).filter(
|
Object.values(entities).filter(
|
||||||
@ -152,18 +183,28 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
ha-card {
|
ha-card {
|
||||||
padding: 16px;
|
|
||||||
max-width: 500px;
|
max-width: 500px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
|
||||||
ha-card {
|
|
||||||
margin-bottom: 24px;
|
|
||||||
margin-bottom: max(24px, env(safe-area-inset-bottom));
|
margin-bottom: max(24px, env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
|
.card-actions {
|
||||||
|
height: 48px;
|
||||||
|
border-top: none;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 16px 16px 0 16px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user