Add integrations to dev info page (#4800)

* Add integrations to dev info page

* Fix annoying looking html tags

* What happened here
This commit is contained in:
Paulus Schoutsen 2020-02-07 09:30:38 -08:00 committed by GitHub
parent d1703ba3e8
commit 15e7b8117c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import { HomeAssistant } from "../../../types";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import "./system-health-card"; import "./system-health-card";
import "./integrations-card";
const JS_TYPE = __BUILD__; const JS_TYPE = __BUILD__;
const JS_VERSION = __VERSION__; const JS_VERSION = __VERSION__;
@ -149,6 +150,7 @@ class HaPanelDevInfo extends LitElement {
</div> </div>
<div class="content"> <div class="content">
<system-health-card .hass=${this.hass}></system-health-card> <system-health-card .hass=${this.hass}></system-health-card>
<integrations-card .hass=${this.hass}></integrations-card>
</div> </div>
`; `;
} }
@ -205,7 +207,8 @@ class HaPanelDevInfo extends LitElement {
color: var(--dark-primary-color); color: var(--dark-primary-color);
} }
system-health-card { system-health-card,
integrations-card {
display: block; display: block;
max-width: 600px; max-width: 600px;
margin: 0 auto; margin: 0 auto;

View File

@ -0,0 +1,75 @@
import {
LitElement,
property,
TemplateResult,
html,
customElement,
CSSResult,
css,
} from "lit-element";
import { HomeAssistant } from "../../../types";
import memoizeOne from "memoize-one";
@customElement("integrations-card")
class IntegrationsCard extends LitElement {
@property() public hass!: HomeAssistant;
private _sortedIntegrations = memoizeOne((components: string[]) => {
return components.filter((comp) => !comp.includes(".")).sort();
});
protected render(): TemplateResult {
return html`
<ha-card header="Integrations">
<table class="card-content">
<tbody>
${this._sortedIntegrations(this.hass!.config.components).map(
(domain) => html`
<tr>
<td>${domain}</td>
<td>
<a
href=${`https://www.home-assistant.io/integrations/${domain}`}
target="_blank"
>
Documentation
</a>
</td>
<td>
<a
href=${`https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+${domain}%22`}
target="_blank"
>
Issues
</a>
</td>
</tr>
`
)}
</tbody>
</table>
</ha-card>
`;
}
static get styles(): CSSResult {
return css`
td {
line-height: 2em;
padding: 0 8px;
}
td:first-child {
padding-left: 0;
}
a {
color: var(--primary-color);
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"integrations-card": IntegrationsCard;
}
}

View File

@ -78,7 +78,7 @@ class SystemHealthCard extends LitElement {
} }
return html` return html`
<ha-card header="${this.hass.localize("domain.system_health")}"> <ha-card .header=${this.hass.localize("domain.system_health")}>
<div class="card-content">${sections}</div> <div class="card-content">${sections}</div>
</ha-card> </ha-card>
`; `;