Skip to content
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

Landing page #22598

Merged
merged 34 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0f542fc
Add landing-page project
wendevlin Oct 21, 2024
6ef7e79
Add landing-page-prepare
wendevlin Oct 21, 2024
3e8d7ef
Add landing-page-network
wendevlin Oct 22, 2024
5d12632
Add logs to landing-page
wendevlin Oct 23, 2024
a662728
Improve landing-page build
wendevlin Oct 23, 2024
677956e
Improve landing-page logs and detail dialogs
wendevlin Oct 24, 2024
f221ac0
Add es5 build for landing-page
wendevlin Oct 29, 2024
31905b7
Add download_full_logs at landing-page
wendevlin Oct 30, 2024
7ea448c
Change dev build for landing-page
wendevlin Oct 30, 2024
10997c7
Fix landing-page build, do it like hassio
wendevlin Nov 4, 2024
67cd512
Remove compress from landing-page build
wendevlin Nov 4, 2024
7776534
Migrate landing-page eslint config
wendevlin Nov 19, 2024
88457d1
Add landing-page project
wendevlin Oct 21, 2024
0963ec1
Add landing-page-prepare
wendevlin Oct 21, 2024
487bc8e
Add landing-page-network
wendevlin Oct 22, 2024
16a2ff3
Add logs to landing-page
wendevlin Oct 23, 2024
6f6d188
Improve landing-page build
wendevlin Oct 23, 2024
7d6986b
Improve landing-page logs and detail dialogs
wendevlin Oct 24, 2024
b86e7a4
Add download_full_logs at landing-page
wendevlin Oct 30, 2024
8081d47
Fix landing-page build, do it like hassio
wendevlin Nov 4, 2024
ba1abed
Remove compress from landing-page build
wendevlin Nov 4, 2024
bb1e86e
Remove .eslintrc from landing-page
wendevlin Nov 19, 2024
37f7b42
Merge branch 'dev' of github.com:home-assistant/frontend into landing…
wendevlin Nov 19, 2024
b4ed00e
Fix landing-page CI translation issue
wendevlin Nov 19, 2024
48886c6
Remove landing-page supervisor logs
wendevlin Nov 19, 2024
dc83b6b
Fix onboarding-welcome-links LocalizeFunc type
wendevlin Nov 19, 2024
51978f8
Add landing-page log streaming
wendevlin Nov 20, 2024
5c0dbaf
Fix landing-page-logs error-check regex - github-advanced-security
wendevlin Nov 20, 2024
3b3a32f
Add landing-page dns error alert, improve try catch
wendevlin Nov 20, 2024
9aef546
Fix landing-page keep show installer when _getNetworkInfoError
wendevlin Nov 20, 2024
87ad9fd
Fix landing-page download logs
wendevlin Nov 20, 2024
1989850
Use observer logs for download in landing-page
wendevlin Nov 20, 2024
8ad6873
Add error message to landing-page dns set fail
wendevlin Nov 20, 2024
9106d26
Remove unused _observerFallback
wendevlin Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,38 @@
"instanceLimit": 1
}
},
{
"label": "Develop Landing Page",
"type": "gulp",
"task": "develop-landing-page",
"problemMatcher": {
"owner": "ha-build",
"source": "ha-build",
"fileLocation": "absolute",
"severity": "error",
"pattern": [
{
"regexp": "(SyntaxError): (.+): (.+) \\((\\d+):(\\d+)\\)",
"severity": 1,
"file": 2,
"message": 3,
"line": 4,
"column": 5
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "Changes detected. Starting compilation",
"endsPattern": "Build done @"
}
},

"isBackground": true,
"group": "build",
"runOptions": {
"instanceLimit": 1
}
},
{
"label": "Develop Demo",
"type": "gulp",
Expand Down
13 changes: 13 additions & 0 deletions build-scripts/bundle.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,17 @@ module.exports.config = {
},
};
},

landingPage({ isProdBuild, latestBuild }) {
return {
name: "landing-page" + nameSuffix(latestBuild),
entry: {
entrypoint: path.resolve(paths.landingPage_dir, "src/entrypoint.js"),
},
outputPath: outputPath(paths.landingPage_output_root, latestBuild),
publicPath: publicPath(latestBuild),
isProdBuild,
latestBuild,
};
},
};
11 changes: 11 additions & 0 deletions build-scripts/gulp/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ gulp.task(
])
)
);

gulp.task(
"clean-landing-page",
gulp.parallel("clean-translations", async () =>
deleteSync([
paths.landingPage_output_root,
paths.landingPage_build,
paths.build_dir,
])
)
);
22 changes: 22 additions & 0 deletions build-scripts/gulp/entry-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ gulp.task(
)
);

const LANDING_PAGE_PAGE_ENTRIES = { "index.html": ["entrypoint"] };

gulp.task(
"gen-pages-landing-page-dev",
genPagesDevTask(
LANDING_PAGE_PAGE_ENTRIES,
paths.landingPage_dir,
paths.landingPage_output_root
)
);

gulp.task(
"gen-pages-landing-page-prod",
genPagesProdTask(
LANDING_PAGE_PAGE_ENTRIES,
paths.landingPage_dir,
paths.landingPage_output_root,
paths.landingPage_output_latest,
paths.landingPage_output_es5
)
);

const HASSIO_PAGE_ENTRIES = { "entrypoint.js": ["entrypoint"] };

gulp.task(
Expand Down
16 changes: 16 additions & 0 deletions build-scripts/gulp/gather-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ gulp.task("copy-translations-supervisor", async () => {
copyTranslations(staticDir);
});

gulp.task("copy-translations-landing-page", async () => {
const staticDir = paths.landingPage_output_static;
copyTranslations(staticDir);
});

gulp.task("copy-static-supervisor", async () => {
const staticDir = paths.hassio_output_static;
copyLocaleData(staticDir);
Expand Down Expand Up @@ -199,3 +204,14 @@ gulp.task("copy-static-gallery", async () => {
copyLocaleData(paths.gallery_output_static);
copyMdiIcons(paths.gallery_output_static);
});

gulp.task("copy-static-landing-page", async () => {
// Copy landing-page static files
fs.copySync(
path.resolve(paths.landingPage_dir, "public"),
paths.landingPage_output_root
);

copyFonts(paths.landingPage_output_static);
copyTranslations(paths.landingPage_output_static);
});
41 changes: 41 additions & 0 deletions build-scripts/gulp/landing-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import gulp from "gulp";
import "./clean.js";
import "./compress.js";
import "./entry-html.js";
import "./gather-static.js";
import "./gen-icons-json.js";
import "./translations.js";
import "./webpack.js";

gulp.task(
"develop-landing-page",
gulp.series(
async function setEnv() {
process.env.NODE_ENV = "development";
},
"clean-landing-page",
"translations-enable-merge-backend",
"build-landing-page-translations",
"copy-translations-landing-page",
"build-locale-data",
"copy-static-landing-page",
"gen-pages-landing-page-dev",
"webpack-watch-landing-page"
)
);

gulp.task(
"build-landing-page",
gulp.series(
async function setEnv() {
process.env.NODE_ENV = "production";
},
"clean-landing-page",
"build-landing-page-translations",
"copy-translations-landing-page",
"build-locale-data",
"copy-static-landing-page",
"webpack-prod-landing-page",
"gen-pages-landing-page-prod"
)
);
18 changes: 14 additions & 4 deletions build-scripts/gulp/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@ const createMasterTranslation = () =>

const FRAGMENTS = ["base"];

const toggleSupervisorFragment = async () => {
FRAGMENTS[0] = "supervisor";
const setFragment = (fragment) => async () => {
FRAGMENTS[0] = fragment;
};

const panelFragment = (fragment) =>
fragment !== "base" && fragment !== "supervisor";
fragment !== "base" &&
fragment !== "supervisor" &&
fragment !== "landing-page";

const HASHES = new Map();

Expand Down Expand Up @@ -224,6 +226,9 @@ const createTranslations = async () => {
case "supervisor":
// Supervisor key is at the top level
return [flatten(data.supervisor), ""];
case "landing-page":
// landing-page key is at the top level
return [flatten(data["landing-page"]), ""];
default:
// Create a fragment with only the given panel
return [
Expand Down Expand Up @@ -322,5 +327,10 @@ gulp.task(

gulp.task(
"build-supervisor-translations",
gulp.series(toggleSupervisorFragment, "build-translations")
gulp.series(setFragment("supervisor"), "build-translations")
);

gulp.task(
"build-landing-page-translations",
gulp.series(setFragment("landing-page"), "build-translations")
);
30 changes: 30 additions & 0 deletions build-scripts/gulp/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
createDemoConfig,
createGalleryConfig,
createHassioConfig,
createLandingPageConfig,
} from "../webpack.cjs";

const bothBuilds = (createConfigFunc, params) => [
Expand Down Expand Up @@ -41,6 +42,7 @@ const runDevServer = async ({
contentBase,
port,
listenHost = undefined,
proxy = undefined,
}) => {
if (listenHost === undefined) {
// For dev container, we need to listen on all hosts
Expand All @@ -56,6 +58,7 @@ const runDevServer = async ({
directory: contentBase,
watch: true,
},
proxy,
},
compiler
);
Expand Down Expand Up @@ -199,3 +202,30 @@ gulp.task("webpack-prod-gallery", () =>
})
)
);

gulp.task("webpack-watch-landing-page", () => {
// This command will run forever because we don't close compiler
webpack(
process.env.ES5
? bothBuilds(createLandingPageConfig, { isProdBuild: false })
: createLandingPageConfig({ isProdBuild: false, latestBuild: true })
).watch({ poll: isWsl }, doneHandler());

gulp.watch(
path.join(paths.translations_src, "en.json"),
gulp.series(
"build-landing-page-translations",
"copy-translations-landing-page"
)
);
});

gulp.task("webpack-prod-landing-page", () =>
prodBuild(
bothBuilds(createLandingPageConfig, {
isProdBuild: true,
isStatsBuild: env.isStatsBuild(),
isTestBuild: env.isTestBuild(),
})
)
);
16 changes: 16 additions & 0 deletions build-scripts/paths.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ module.exports = {
),
gallery_output_static: path.resolve(__dirname, "../gallery/dist/static"),

landingPage_dir: path.resolve(__dirname, "../landing-page"),
landingPage_build: path.resolve(__dirname, "../landing-page/build"),
landingPage_output_root: path.resolve(__dirname, "../landing-page/dist"),
landingPage_output_latest: path.resolve(
__dirname,
"../landing-page/dist/frontend_latest"
),
landingPage_output_es5: path.resolve(
__dirname,
"../landing-page/dist/frontend_es5"
),
landingPage_output_static: path.resolve(
__dirname,
"../landing-page/dist/static"
),

hassio_dir: path.resolve(__dirname, "../hassio"),
hassio_output_root: path.resolve(__dirname, "../hassio/build"),
hassio_output_static: path.resolve(__dirname, "../hassio/build/static"),
Expand Down
4 changes: 4 additions & 0 deletions build-scripts/webpack.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,15 @@ const createHassioConfig = ({
const createGalleryConfig = ({ isProdBuild, latestBuild }) =>
createWebpackConfig(bundle.config.gallery({ isProdBuild, latestBuild }));

const createLandingPageConfig = ({ isProdBuild, latestBuild }) =>
createWebpackConfig(bundle.config.landingPage({ isProdBuild, latestBuild }));

module.exports = {
createAppConfig,
createDemoConfig,
createCastConfig,
createHassioConfig,
createGalleryConfig,
createLandingPageConfig,
createWebpackConfig,
};
44 changes: 44 additions & 0 deletions landing-page/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Home Assistant OS Landingpage

On initial startup of Home Assistant, HAOS needs to download Home Assistant core before the setup can start.
In this time the [home-assistant/landingpage](https://github.com/home-assistant/landingpage) is serving a "Preparing Home Assistant" page.

## Functionality

- Progress bar to show download
- Show / hide supervisor logs
- Links
- Read our Vision
- Join our community
- Download our app
- DNS issue handler
- if the supervisor is not able to connect to the internet
- Show actions to set dns to google or cloudflare to resolve the issue
- Error handler
- if something with the installation goes wrong, we show the logs

## Develop

It is similar to the core frontend dev.

- frontend repo is building stuff
- landingpage repo can set the frontend repo path and serve the dev frontend

### landingpage dev server

- clone [home-assistant/landingpage](https://github.com/home-assistant/landingpage)
- Add frontend repo as mount to your devcontainer config
- please do not commit this changes, you can remove it after initial dev container build, because the build will keep the options as long as you don't rebuild it.
- `"mounts": ["source=/path/to/hass/frontend,target=/workspaces/frontend,type=bind,consistency=cached"]`
- use the dev container
- start the dev server with following optional env vars:
- `SUPERVISOR_HOST` to have real supervisor data, you can [setup a supervisor remote API access](https://developers.home-assistant.io/docs/supervisor/development/#supervisor-api-access) and set the host of your supervisor. e.g.: `SUPERVISOR_HOST=192.168.0.20:8888`
- `SUPERVISOR_TOKEN` the supervisor api token you get from the Remote API proxy Addon Logs
- `FRONTEND_PATH` the path inside your container should be `/workspaces/frontend`
- example: `SUPERVISOR_TOKEN=abc123 SUPERVISOR_HOST=192.168.0.20:8888 FRONTEND_PATH=/workspaces/frontend go run main.go http.go mdns.go`
- You can also add this into your devcontainer settings, but then it's not so flexible to change if you want to test something else.

### frontend dev server

- install all dependencies
- run `landing-page/script/develop`
8 changes: 8 additions & 0 deletions landing-page/eslintrc.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import rootConfig from "../eslint.config.mjs";

export default [
...rootConfig,
{
rules: {},
},
];
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added landing-page/public/static/icons/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions landing-page/public/static/icons/logo_ohf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions landing-page/public/static/icons/ohf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading