-
-
-
Are you ready to awaken your home, reclaim your privacy and join a worldwide community of tinkerers?
-
Let's get started by creating a user account.
-
+
+ [[localize('ui.panel.page-onboarding.intro')]]
+
-
- [[_error]]
-
+
+ [[localize('ui.panel.page-onboarding.user.intro')]]
+
+
+ [[_computeErrorMsg(localize, _errorMsg)]]
+
+
+
+
`;
}
@@ -106,7 +83,12 @@ class HaOnboarding extends PolymerElement {
_loading: {
type: Boolean,
value: false,
- }
+ },
+ translationFragment: {
+ type: String,
+ value: 'page-onboarding',
+ },
+ _errorMsg: String,
};
}
@@ -117,10 +99,24 @@ class HaOnboarding extends PolymerElement {
this._submitForm();
}
});
- const steps = await callApi('get', 'onboarding');
- if (steps.every(step => step.done)) {
- // Onboarding is done!
- document.location = '/';
+
+ try {
+ const response = await window.stepsPromise;
+
+ if (response.status === 404) {
+ // We don't load the component when onboarding is done
+ document.location = '/';
+ return;
+ }
+
+ const steps = await response.json();
+
+ if (steps.every(step => step.done)) {
+ // Onboarding is done!
+ document.location = '/';
+ }
+ } catch (err) {
+ alert('Something went wrong loading loading onboarding, try refreshing');
}
}
@@ -135,7 +131,12 @@ class HaOnboarding extends PolymerElement {
}
async _submitForm() {
- if (!this._name || !this._username || !this._password) return;
+ if (!this._name || !this._username || !this._password) {
+ this._errorMsg = 'required_fields';
+ return;
+ }
+
+ this._errorMsg = '';
try {
await callApi('post', 'onboarding/users', {
@@ -150,9 +151,13 @@ class HaOnboarding extends PolymerElement {
console.error(err);
this.setProperties({
_loading: false,
- _error: err.message,
+ _errorMsg: err.message,
});
}
}
+
+ _computeErrorMsg(localize, errorMsg) {
+ return localize(`ui.panel.page-onboarding.user.error.${errorMsg}`) || errorMsg;
+ }
}
customElements.define('ha-onboarding', HaOnboarding);
diff --git a/src/translations/en.json b/src/translations/en.json
index 10d8211472..2258387d70 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -752,6 +752,75 @@
"clear_completed": "Clear completed",
"add_item": "Add item",
"microphone_tip": "Tap the microphone on the top right and say “Add candy to my shopping list”"
+ },
+ "page-authorize": {
+ "initializing": "Initializing",
+ "authorizing_client": "You're about to give {clientId} access to your Home Assistant instance.",
+ "logging_in_with": "Logging in with **{authProviderName}**.",
+ "pick_auth_provider": "Or log in with",
+ "abort_intro": "Login aborted",
+ "form": {
+ "working": "Please wait",
+ "unknown_error": "Something went wrong",
+ "providers": {
+ "homeassistant": {
+ "step": {
+ "init": {
+ "data": {
+ "username": "Username",
+ "password": "Password"
+ }
+ }
+ },
+ "error": {
+ "invalid_auth": "Invalid username or password"
+ }
+ },
+ "legacy_api_password": {
+ "step": {
+ "init": {
+ "data": {
+ "password": "API Password"
+ }
+ }
+ },
+ "error": {
+ "invalid_auth": "Invalid API password"
+ },
+ "abort": {
+ "no_api_password_set": "You don't have an API password configured."
+ }
+ },
+ "trusted_networks": {
+ "step": {
+ "init": {
+ "data": {
+ "user": "User"
+ }
+ }
+ },
+ "abort": {
+ "not_whitelisted": "Your computer is not whitelisted."
+ }
+ }
+ }
+ }
+ },
+ "page-onboarding": {
+ "intro": "Are you ready to awaken your home, reclaim your privacy and join a worldwide community of tinkerers?",
+ "user": {
+ "intro": "Let's get started by creating a user account.",
+ "required_field": "Required",
+ "data": {
+ "name": "Name",
+ "username": "Username",
+ "password": "Password"
+ },
+ "create_account": "Create Account",
+ "error": {
+ "required_fields": "Fill in all required fields"
+ }
+ }
}
}
}
diff --git a/webpack.config.js b/webpack.config.js
index b87f785320..a8aea295c6 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -17,12 +17,11 @@ const VERSION = version[0];
const generateJSPage = (entrypoint, latestBuild) => {
return new HtmlWebpackPlugin({
inject: false,
- template: './src/html/extra_page.html.template',
+ template: `./src/html/${entrypoint}.html.template`,
// Default templateParameterGenerator code
// https://github.com/jantimon/html-webpack-plugin/blob/master/index.js#L719
templateParameters: (compilation, assets, option) => ({
latestBuild,
- tag: `ha-${entrypoint}`,
compatibility: assets.chunks.compatibility.entry,
entrypoint: assets.chunks[entrypoint].entry,
hassIconsJS: assets.chunks['hass-icons'].entry,
diff --git a/yarn.lock b/yarn.lock
index 1af3d7dfcc..2274f169aa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9790,6 +9790,10 @@ raw-body@2.3.2:
iconv-lite "0.4.19"
unpipe "1.0.0"
+raw-loader@^0.5.1:
+ version "0.5.1"
+ resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-0.5.1.tgz#0c3d0beaed8a01c966d9787bf778281252a979aa"
+
rc@^1.0.1, rc@^1.1.6, rc@^1.1.7:
version "1.2.7"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.7.tgz#8a10ca30d588d00464360372b890d06dacd02297"