-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add hassio supervisor and os update notice #3798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
739c047
Add hassio supervisor and os update notice
bramkragten b220f27
Cleanup
bramkragten faf6cc6
Update hassio-dashboard.ts
bramkragten fa79adf
Fix styling
bramkragten 287b96f
Check if system has HassOs
bramkragten 935223e
Remove unused import
bramkragten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,150 @@ | ||
| import { | ||
| LitElement, | ||
| TemplateResult, | ||
| html, | ||
| CSSResult, | ||
| css, | ||
| property, | ||
| customElement, | ||
| } from "lit-element"; | ||
|
|
||
| import { HomeAssistant } from "../../../src/types"; | ||
| import { | ||
| HassioHomeAssistantInfo, | ||
| HassioHassOSInfo, | ||
| HassioSupervisorInfo, | ||
| } from "../../../src/data/hassio"; | ||
|
|
||
| import { hassioStyle } from "../resources/hassio-style"; | ||
|
|
||
| import "@material/mwc-button"; | ||
| import "@polymer/paper-card/paper-card"; | ||
| import "../../../src/components/buttons/ha-call-api-button"; | ||
| import "../components/hassio-card-content"; | ||
|
|
||
| @customElement("hassio-update") | ||
| export class HassioUpdate extends LitElement { | ||
| @property() public hass?: HomeAssistant; | ||
|
|
||
| @property() public hassInfo: HassioHomeAssistantInfo; | ||
| @property() public hassOsInfo!: HassioHassOSInfo; | ||
| @property() public supervisorInfo: HassioSupervisorInfo; | ||
|
|
||
| @property() public error?: string; | ||
|
|
||
| protected render(): TemplateResult | void { | ||
| if ( | ||
| this.hassInfo.version === this.hassInfo.last_version && | ||
| this.supervisorInfo.version === this.supervisorInfo.last_version && | ||
| this.hassOsInfo.version === this.hassOsInfo.version_latest | ||
| ) { | ||
| return html``; | ||
| } | ||
|
|
||
| return html` | ||
| <div class="content"> | ||
| ${this.error | ||
| ? html` | ||
| <div class="error">Error: ${this.error}</div> | ||
| ` | ||
| : ""} | ||
| <div class="card-group"> | ||
| ${this._renderUpdateCard( | ||
| "Home Assistant", | ||
| this.hassInfo.version, | ||
| this.hassInfo.last_version, | ||
| "hassio/homeassistant/update", | ||
| `https://${ | ||
| this.hassInfo.last_version.includes("b") ? "rc" : "www" | ||
| }.home-assistant.io/latest-release-notes/` | ||
| )} | ||
| ${this._renderUpdateCard( | ||
| "Hass.io Supervisor", | ||
| this.supervisorInfo.version, | ||
| this.supervisorInfo.last_version, | ||
| "hassio/supervisor/update", | ||
| `https://github.com//home-assistant/hassio/releases/tag/${ | ||
| this.supervisorInfo.last_version | ||
| }` | ||
| )} | ||
| ${this._renderUpdateCard( | ||
| "HassOS", | ||
| this.hassOsInfo.version, | ||
| this.hassOsInfo.version_latest, | ||
| "hassio/hassos/update", | ||
| `https://github.com//home-assistant/hassos/releases/tag/${ | ||
| this.hassOsInfo.version_latest | ||
| }` | ||
| )} | ||
| </div> | ||
| </div> | ||
| `; | ||
| } | ||
|
|
||
| private _renderUpdateCard( | ||
| name: string, | ||
| curVersion: string, | ||
| lastVersion: string, | ||
| apiPath: string, | ||
| releaseNotesUrl: string | ||
| ): TemplateResult { | ||
| if (lastVersion === curVersion) { | ||
| return html``; | ||
| } | ||
| return html` | ||
| <paper-card heading="${name} update available! 🎉"> | ||
| <div class="card-content"> | ||
| ${name} ${lastVersion} is available and you are currently running | ||
| ${name} ${curVersion}. | ||
| </div> | ||
| <div class="card-actions"> | ||
| <ha-call-api-button | ||
| .hass=${this.hass} | ||
| .path=${apiPath} | ||
| @hass-api-called=${this._apiCalled} | ||
| > | ||
| Update | ||
| </ha-call-api-button> | ||
| <a href="${releaseNotesUrl}" target="_blank"> | ||
| <mwc-button>Release notes</mwc-button> | ||
| </a> | ||
| </div> | ||
| </paper-card> | ||
| `; | ||
| } | ||
|
|
||
| private _apiCalled(ev) { | ||
| if (ev.detail.success) { | ||
| this.error = ""; | ||
| return; | ||
| } | ||
|
|
||
| const response = ev.detail.response; | ||
|
|
||
| typeof response.body === "object" | ||
| ? (this.error = response.body.message || "Unknown error") | ||
| : (this.error = response.body); | ||
| } | ||
|
|
||
| static get styles(): CSSResult[] { | ||
| return [ | ||
| hassioStyle, | ||
| css` | ||
| :host { | ||
| width: 33%; | ||
| } | ||
| paper-card { | ||
| display: inline-block; | ||
| margin-bottom: 32px; | ||
| } | ||
| .errors { | ||
| color: var(--google-red-500); | ||
| padding: 16px; | ||
| } | ||
| a { | ||
| text-decoration: none; | ||
| } | ||
| `, | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -13,9 +13,11 @@ import { HomeAssistant } from "../../src/types"; | |
| import { | ||
| fetchHassioSupervisorInfo, | ||
| fetchHassioHostInfo, | ||
| fetchHassioHassOsInfo, | ||
| fetchHassioHomeAssistantInfo, | ||
| HassioSupervisorInfo, | ||
| HassioHostInfo, | ||
| HassioHassOSInfo, | ||
| HassioHomeAssistantInfo, | ||
| fetchHassioAddonInfo, | ||
| createHassioSession, | ||
|
|
@@ -66,6 +68,7 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) { | |
|
|
||
| @property() private _supervisorInfo: HassioSupervisorInfo; | ||
| @property() private _hostInfo: HassioHostInfo; | ||
| @property() private _hassOsInfo?: HassioHassOSInfo; | ||
| @property() private _hassInfo: HassioHomeAssistantInfo; | ||
|
|
||
| protected firstUpdated(changedProps: PropertyValues) { | ||
|
|
@@ -113,6 +116,7 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) { | |
| supervisorInfo: this._supervisorInfo, | ||
| hostInfo: this._hostInfo, | ||
| hassInfo: this._hassInfo, | ||
| hassOsInfo: this._hassOsInfo, | ||
| route, | ||
| }); | ||
| } else { | ||
|
|
@@ -121,6 +125,7 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) { | |
| el.supervisorInfo = this._supervisorInfo; | ||
| el.hostInfo = this._hostInfo; | ||
| el.hassInfo = this._hassInfo; | ||
| el.hassOsInfo = this._hassOsInfo; | ||
| el.route = route; | ||
| } | ||
| } | ||
|
|
@@ -131,13 +136,15 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) { | |
| return; | ||
| } | ||
|
|
||
| const [supervisorInfo, hostInfo, hassInfo] = await Promise.all([ | ||
| const [supervisorInfo, hostInfo, hassOsInfo, hassInfo] = await Promise.all([ | ||
| fetchHassioSupervisorInfo(this.hass), | ||
| fetchHassioHostInfo(this.hass), | ||
| fetchHassioHassOsInfo(this.hass), | ||
| fetchHassioHomeAssistantInfo(this.hass), | ||
| ]); | ||
| this._supervisorInfo = supervisorInfo; | ||
| this._hostInfo = hostInfo; | ||
| this._hassOsInfo = hassOsInfo; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it's only needed in the updater card, maybe we should just fetch that data there ? |
||
| this._hassInfo = hassInfo; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can start using
hass!pretty much everywhere, it's always there :)