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

Allow resource overrides for main UI. #1359

Merged
merged 1 commit into from
Apr 30, 2022
Merged

Allow resource overrides for main UI. #1359

merged 1 commit into from
Apr 30, 2022

Conversation

splatch
Copy link
Contributor

@splatch splatch commented Apr 25, 2022

This commit solves #551 where user requested a way to customize UI colors or logo.
Now, with OSGi bundle fragment, just like in OH 2.5 it is possible to put new/additional resources.
Just create an OSGi fragment with patch/app/index.html, patch/app/css/xyz.css.
After reload of system, if fragment is matched properly, patched index will take a rule over default one.

This commit solves openhab#551 where user requested a way to customize UI colors or logo.
Now, with OSGi bundle fragment, just like in OH 2.5 it is possible to put new/additional resources.
Just create an OSGi fragment with patch/app/index.html, patch/app/css/xyz.css.
After reload of system, if fragment is matched properly, patched index will take a rule over default one.

Signed-off-by: Łukasz Dywicki <luke@code-house.org>
@splatch splatch requested a review from a team as a code owner April 25, 2022 16:45
Copy link
Member

@ghys ghys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ghys ghys merged commit 1796165 into openhab:main Apr 30, 2022
@digitaldan
Copy link
Contributor

Hey @splatch, i'm not familiar with bundle fragments, do you have an example somewhere that targets either the main ui or paper ui? Just curious how you target a fragment project in eclipse (i assume thats where you start) to work with a specific OH bundle.

@ghys ghys added this to the 3.3 milestone May 1, 2022
@ghys ghys added main ui Main UI enhancement New feature or request labels May 1, 2022
@splatch
Copy link
Contributor Author

splatch commented May 4, 2022

@digitaldan quickest tips I can give you - make sure that module you build have a Fragment-Host header pointing to openhab main ui bundle (org.openhab.ui). Inside IDE/maven module create a src/main/resources/patch/app/index.html, it will then override a main entry point used for browser. The whole trick in this PR is manipulation of bundle classpath so it first looks at patch/ and then own resources/classes. Since compiled OH main ui is packaged inside app/ you need to make all overrides through src/main/resources/patch/app.

I know there are million of things webpack/browser is doing so customization capabilities are fairly limited. You should be starting from copying of index.html used by UI version you have. With this you can start injecting an extra css and maybe other stuff (haven't tested it to be fair) just like you would do with standard HTML stuff ie. <link href="css/extra.css" rel="stylesheet">. Just remember to place it in src/main/resources/patch/app/css/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants