mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
link to updates page (#12423)
This commit is contained in:
parent
ca28178b86
commit
490f84a7b1
@ -131,9 +131,8 @@ class HaConfigDashboard extends LitElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const canInstallUpdates = this._filterUpdateEntitiesWithInstall(
|
const [canInstallUpdates, totalUpdates] =
|
||||||
this.hass.states
|
this._filterUpdateEntitiesWithInstall(this.hass.states);
|
||||||
);
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-app-layout>
|
<ha-app-layout>
|
||||||
@ -177,8 +176,19 @@ class HaConfigDashboard extends LitElement {
|
|||||||
<ha-config-updates
|
<ha-config-updates
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
|
.total=${totalUpdates}
|
||||||
.updateEntities=${canInstallUpdates}
|
.updateEntities=${canInstallUpdates}
|
||||||
></ha-config-updates>
|
></ha-config-updates>
|
||||||
|
${totalUpdates > canInstallUpdates.length
|
||||||
|
? html`<a class="button" href="/config/updates">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.updates.more_updates",
|
||||||
|
{
|
||||||
|
count: totalUpdates - canInstallUpdates.length,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</a>`
|
||||||
|
: ""}
|
||||||
</ha-card>`
|
</ha-card>`
|
||||||
: ""}
|
: ""}
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
@ -259,10 +269,15 @@ class HaConfigDashboard extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private _filterUpdateEntitiesWithInstall = memoizeOne(
|
private _filterUpdateEntitiesWithInstall = memoizeOne(
|
||||||
(entities: HassEntities) =>
|
(entities: HassEntities): [UpdateEntity[], number] => {
|
||||||
this._filterUpdateEntities(entities).filter((entity) =>
|
const updates = this._filterUpdateEntities(entities).filter((entity) =>
|
||||||
updateCanInstall(entity)
|
updateCanInstall(entity)
|
||||||
)
|
);
|
||||||
|
return [
|
||||||
|
updates.slice(0, updates.length === 3 ? updates.length : 2),
|
||||||
|
updates.length,
|
||||||
|
];
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private _showQuickBar(): void {
|
private _showQuickBar(): void {
|
||||||
@ -320,6 +335,11 @@ class HaConfigDashboard extends LitElement {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--primary-text-color);
|
color: var(--primary-text-color);
|
||||||
}
|
}
|
||||||
|
a.button {
|
||||||
|
display: block;
|
||||||
|
color: var(--primary-color);
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
.title {
|
.title {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
|
@ -19,22 +19,20 @@ class HaConfigUpdates extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
public updateEntities?: UpdateEntity[];
|
public updateEntities?: UpdateEntity[];
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) showAll = false;
|
@property({ type: Number })
|
||||||
|
public total?: number;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.updateEntities?.length) {
|
if (!this.updateEntities?.length) {
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updates =
|
const updates = this.updateEntities;
|
||||||
this.showAll || this.updateEntities.length <= 3
|
|
||||||
? this.updateEntities
|
|
||||||
: this.updateEntities.slice(0, 2);
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="title">
|
<div class="title">
|
||||||
${this.hass.localize("ui.panel.config.updates.title", {
|
${this.hass.localize("ui.panel.config.updates.title", {
|
||||||
count: this.updateEntities.length,
|
count: this.total || this.updateEntities.length,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
${updates.map(
|
${updates.map(
|
||||||
@ -70,15 +68,6 @@ class HaConfigUpdates extends LitElement {
|
|||||||
</paper-icon-item>
|
</paper-icon-item>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
${!this.showAll && this.updateEntities.length >= 4
|
|
||||||
? html`
|
|
||||||
<button class="show-more" @click=${this._showAllClicked}>
|
|
||||||
${this.hass.localize("ui.panel.config.updates.more_updates", {
|
|
||||||
count: this.updateEntities!.length - updates.length,
|
|
||||||
})}
|
|
||||||
</button>
|
|
||||||
`
|
|
||||||
: ""}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +77,6 @@ class HaConfigUpdates extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _showAllClicked() {
|
|
||||||
this.showAll = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup[] {
|
static get styles(): CSSResultGroup[] {
|
||||||
return [
|
return [
|
||||||
css`
|
css`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user