-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
266 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { customElement, TemplateResult, html, property } from "lit-element"; | ||
|
||
import { HacsRepositoryButton } from "./HacsRepositoryButton"; | ||
import { HACS } from "../../Hacs"; | ||
import { Route } from "../../types"; | ||
|
||
@customElement("hacs-button-goto-integrations") | ||
export class HacsButtonGoToIntegrations extends HacsRepositoryButton { | ||
@property({ type: Object }) public hacs!: HACS; | ||
@property({ type: Object }) public route!: Route; | ||
|
||
render(): TemplateResult | void { | ||
return html` | ||
<mwc-button @click=${this.GoToIntegrations}> | ||
${this.hacs.localize("repository.goto_integrations")} | ||
</mwc-button> | ||
`; | ||
} | ||
|
||
GoToIntegrations() { | ||
this.route.prefix = `/config`; | ||
this.route.path = `/integrations/dashboard`; | ||
this.dispatchEvent( | ||
new CustomEvent("hacs-location-change", { | ||
detail: { value: this.route, force: true }, | ||
bubbles: true, | ||
composed: true | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
LitElement, | ||
customElement, | ||
CSSResultArray, | ||
css, | ||
property | ||
} from "lit-element"; | ||
import { HacsStyle } from "../../style/hacs-style"; | ||
import { | ||
RepositoryData, | ||
Configuration, | ||
Status, | ||
Route, | ||
LovelaceConfig | ||
} from "../../types"; | ||
import { HACS } from "../../Hacs"; | ||
import { HomeAssistant } from "custom-card-helpers"; | ||
|
||
@customElement("hacs-repository-banner") | ||
export class HacsRepositoryBanner extends LitElement { | ||
@property({ type: Object }) public hacs!: HACS; | ||
@property({ type: Object }) public configuration: Configuration; | ||
@property({ type: Object }) public hass!: HomeAssistant; | ||
@property({ type: Object }) public lovelaceconfig: LovelaceConfig; | ||
@property({ type: Object }) public repository!: RepositoryData; | ||
@property({ type: Object }) public route!: Route; | ||
@property({ type: Object }) public status!: Status; | ||
|
||
static get styles(): CSSResultArray { | ||
return [ | ||
HacsStyle, | ||
css` | ||
ha-card { | ||
width: 90%; | ||
margin-left: 5%; | ||
} | ||
ha-card.alert { | ||
background-color: var( | ||
--hacs-status-pending-restart, | ||
var(--google-red-500) | ||
); | ||
color: var(--text-primary-color); | ||
} | ||
ha-card.warning { | ||
background-color: var(--hacs-status-pending-update); | ||
color: var(--primary-text-color); | ||
} | ||
ha-card.info { | ||
background-color: var(--primary-background-color); | ||
color: var(--primary-text-color); | ||
} | ||
` | ||
]; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/components/repositorybanner/IntegrationFirstInstall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { customElement, TemplateResult, html } from "lit-element"; | ||
|
||
import { HacsRepositoryBanner } from "./HacsRepositoryBanner"; | ||
|
||
@customElement("hacs-repository-banner-integration-first-install") | ||
export class RepositoryBannerIntegrationFirstInstall extends HacsRepositoryBanner { | ||
protected render(): TemplateResult | void { | ||
const title = this.hacs.localize("repository_banner.restart_pending"); | ||
|
||
return html` | ||
<ha-card class="info" .header="${title}"> | ||
<div class="card-content"> | ||
${this.hacs.localize("repository_banner.restart")} | ||
</br></br> | ||
${this.hacs.localize("repository_banner.restart")} | ||
${this.hacs.localize("repository_banner.config_flow")} | ||
</br> | ||
${this.hacs.localize("repository_banner.no_restart_required")} 🎉 | ||
</div> | ||
<div class="card-actions"> | ||
<hacs-button-restart-home-assistant | ||
.hacs=${this.hacs} | ||
.hass=${this.hass} | ||
.route=${this.route} | ||
></hacs-button-restart-home-assistant> | ||
<hacs-button-goto-integrations | ||
.hacs=${this.hacs} | ||
.route=${this.route} | ||
></hacs-button-goto-integrations> | ||
</div> | ||
</ha-card> | ||
`; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/components/repositorybanner/IntegrationPendingRestart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { customElement, TemplateResult, html } from "lit-element"; | ||
|
||
import { HacsRepositoryBanner } from "./HacsRepositoryBanner"; | ||
|
||
@customElement("hacs-repository-banner-integration-pending-restart") | ||
export class RepositoryBannerIntegrationPendingRestart extends HacsRepositoryBanner { | ||
protected render(): TemplateResult | void { | ||
const title = this.hacs.localize("repository_banner.restart_pending"); | ||
|
||
return html` | ||
<ha-card class="info" .header="${title}"> | ||
<div class="card-content"> | ||
${this.hacs.localize("repository_banner.restart")} | ||
</div> | ||
<div class="card-actions"> | ||
<hacs-button-restart-home-assistant | ||
.hacs=${this.hacs} | ||
.hass=${this.hass} | ||
.repository=${this.repository} | ||
.route=${this.route} | ||
></hacs-button-restart-home-assistant> | ||
</div> | ||
</ha-card> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { customElement, TemplateResult, html } from "lit-element"; | ||
|
||
import { HacsRepositoryBanner } from "./HacsRepositoryBanner"; | ||
import { AddedToLovelace } from "../../misc/AddedToLovelace"; | ||
|
||
@customElement("hacs-repository-banner-plugin-not-loaded") | ||
export class RepositoryBannerPluginNotLoaded extends HacsRepositoryBanner { | ||
protected render(): TemplateResult | void { | ||
const title = this.hacs.localize("repository_banner.not_loaded"); | ||
const loaded: boolean = AddedToLovelace( | ||
this.repository, | ||
this.lovelaceconfig, | ||
this.status | ||
); | ||
|
||
if (loaded) return html``; | ||
|
||
return html` | ||
<ha-card class="info" .header="${title}"> | ||
<div class="card-content"> | ||
${this.hacs.localize("repository_banner.plugin_not_loaded")} | ||
</div> | ||
<div class="card-actions"> | ||
<hacs-button-add-to-lovelace | ||
.hacs=${this.hacs} | ||
.hass=${this.hass} | ||
.repository=${this.repository} | ||
.route=${this.route} | ||
></hacs-button-add-to-lovelace> | ||
</div> | ||
</ha-card> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.