mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Remove name and core config steps from onboarding (#17670)
This commit is contained in:
parent
45b04a6188
commit
e8f1a86005
@ -28,7 +28,6 @@ import { onboardCoreConfigStep } from "../data/onboarding";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
||||
import { getLocalLanguage } from "../util/common-translation";
|
||||
import "./onboarding-location";
|
||||
import "./onboarding-name";
|
||||
|
||||
@customElement("onboarding-core-config")
|
||||
class OnboardingCoreConfig extends LitElement {
|
||||
@ -38,8 +37,6 @@ class OnboardingCoreConfig extends LitElement {
|
||||
|
||||
@state() private _working = false;
|
||||
|
||||
@state() private _name?: ConfigUpdateValues["location_name"];
|
||||
|
||||
@state() private _location?: [number, number];
|
||||
|
||||
@state() private _elevation?: string;
|
||||
@ -56,14 +53,9 @@ class OnboardingCoreConfig extends LitElement {
|
||||
|
||||
@state() private _error?: string;
|
||||
|
||||
@state() private _skipCore = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this._name) {
|
||||
return html`<onboarding-name
|
||||
.hass=${this.hass}
|
||||
.onboardingLocalize=${this.onboardingLocalize}
|
||||
@value-changed=${this._nameChanged}
|
||||
></onboarding-name>`;
|
||||
}
|
||||
if (!this._location) {
|
||||
return html`<onboarding-location
|
||||
.hass=${this.hass}
|
||||
@ -71,6 +63,11 @@ class OnboardingCoreConfig extends LitElement {
|
||||
@value-changed=${this._locationChanged}
|
||||
></onboarding-location>`;
|
||||
}
|
||||
if (this._skipCore) {
|
||||
return html`<div class="row center">
|
||||
<ha-circular-progress active></ha-circular-progress>
|
||||
</div>`;
|
||||
}
|
||||
return html`
|
||||
${
|
||||
this._error
|
||||
@ -289,10 +286,6 @@ class OnboardingCoreConfig extends LitElement {
|
||||
this[`_${target.name}`] = target.value;
|
||||
}
|
||||
|
||||
private _nameChanged(ev: CustomEvent) {
|
||||
this._name = ev.detail.value;
|
||||
}
|
||||
|
||||
private async _locationChanged(ev) {
|
||||
this._location = ev.detail.value.location;
|
||||
this._country = ev.detail.value.country;
|
||||
@ -303,6 +296,11 @@ class OnboardingCoreConfig extends LitElement {
|
||||
ev.detail.value.timezone ||
|
||||
Intl.DateTimeFormat?.().resolvedOptions?.().timeZone;
|
||||
this._unitSystem = ev.detail.value.unit_system;
|
||||
if (this._country) {
|
||||
this._skipCore = true;
|
||||
this._save(ev);
|
||||
return;
|
||||
}
|
||||
await this.updateComplete;
|
||||
setTimeout(
|
||||
() => this.renderRoot.querySelector("ha-textfield")!.focus(),
|
||||
@ -324,7 +322,9 @@ class OnboardingCoreConfig extends LitElement {
|
||||
this._working = true;
|
||||
try {
|
||||
await saveCoreConfig(this.hass, {
|
||||
location_name: this._name,
|
||||
location_name: this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.location_name_default"
|
||||
),
|
||||
latitude: this._location[0],
|
||||
longitude: this._location[1],
|
||||
elevation: Number(this._elevationValue),
|
||||
@ -340,6 +340,7 @@ class OnboardingCoreConfig extends LitElement {
|
||||
result,
|
||||
});
|
||||
} catch (err: any) {
|
||||
this._skipCore = false;
|
||||
this._working = false;
|
||||
this._error = err.message;
|
||||
}
|
||||
@ -380,6 +381,10 @@ class OnboardingCoreConfig extends LitElement {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.row > * {
|
||||
margin: 0 8px;
|
||||
}
|
||||
|
@ -1,111 +0,0 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import type { LocalizeFunc } from "../common/translations/localize";
|
||||
import "../components/ha-alert";
|
||||
import "../components/ha-formfield";
|
||||
import "../components/ha-radio";
|
||||
import "../components/ha-textfield";
|
||||
import "../components/map/ha-locations-editor";
|
||||
import { ConfigUpdateValues } from "../data/core";
|
||||
import type { HomeAssistant } from "../types";
|
||||
|
||||
@customElement("onboarding-name")
|
||||
class OnboardingName extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property() public onboardingLocalize!: LocalizeFunc;
|
||||
|
||||
private _name?: ConfigUpdateValues["location_name"];
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<p>
|
||||
${this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.intro",
|
||||
{ name: this.hass.user!.name }
|
||||
)}
|
||||
</p>
|
||||
|
||||
<ha-textfield
|
||||
.label=${this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.location_name"
|
||||
)}
|
||||
.value=${this._nameValue}
|
||||
@change=${this._nameChanged}
|
||||
></ha-textfield>
|
||||
|
||||
<p>
|
||||
${this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.intro_core"
|
||||
)}
|
||||
</p>
|
||||
|
||||
<div class="footer">
|
||||
<mwc-button @click=${this._save} .disabled=${!this._nameValue}>
|
||||
${this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.finish"
|
||||
)}
|
||||
</mwc-button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps) {
|
||||
super.firstUpdated(changedProps);
|
||||
setTimeout(
|
||||
() => this.renderRoot.querySelector("ha-textfield")!.focus(),
|
||||
100
|
||||
);
|
||||
this.addEventListener("keyup", (ev) => {
|
||||
if (ev.key === "Enter") {
|
||||
this._save(ev);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private get _nameValue() {
|
||||
return this._name !== undefined
|
||||
? this._name
|
||||
: this.onboardingLocalize(
|
||||
"ui.panel.page-onboarding.core-config.location_name_default"
|
||||
);
|
||||
}
|
||||
|
||||
private _nameChanged(ev) {
|
||||
this._name = ev.target.value;
|
||||
}
|
||||
|
||||
private async _save(ev) {
|
||||
ev.preventDefault();
|
||||
fireEvent(this, "value-changed", {
|
||||
value: this._nameValue,
|
||||
});
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
ha-textfield {
|
||||
display: block;
|
||||
}
|
||||
p {
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 16px;
|
||||
text-align: right;
|
||||
}
|
||||
a {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"onboarding-name": OnboardingName;
|
||||
}
|
||||
}
|
@ -5702,9 +5702,7 @@
|
||||
}
|
||||
},
|
||||
"core-config": {
|
||||
"intro": "Hello {name}, welcome to Home Assistant. How would you like to name your home?",
|
||||
"intro_core": "We will set up the basics together. You can always change this later in the settings.",
|
||||
"intro_location": "Let's set up the location of your home so that you can display information such as the local weather and use sun-based or presence-based automations. This data is never shared outside of your network.",
|
||||
"intro_location": "Let's set up the location of your home so that you can display information such as the local weather and use sun-based or presence-based automations.",
|
||||
"location_address": "Powered by {openstreetmap} ({osm_privacy_policy}).",
|
||||
"osm_privacy_policy": "Privacy policy",
|
||||
"title_location_detect": "Do you want us to detect your location?",
|
||||
|
Loading…
x
Reference in New Issue
Block a user