-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
Use unhashed browser urls, fixes #710 #964
Conversation
Job #98: Bundle Size — 10.41MB (~-0.01%).Changed metrics (2/8)
|
At first sight it seems to work well! Small bug though: you have relative URLs in |
Well, that's the same as the webpack devserver does (except for files containing dots, by default) 🤷. I can't think of any side effects when loading the app instead of a 404.
oh, good catch! Actually, I only checked for errorneous requests, not those with invalid content 😳. The conflict
I've had a closer look at all this and did some research. The result being, in short, that working links and relative paths seem to be mutually exclusive 😞. Longer explanation: For relocation, relative paths are required (which is currently the case). For a Framework7 SPA using its own router and the history API to make links work, absolute paths are required (see also similarity to the Vue-cli docs). Since the main UI is a "prebuilt" JS application shipped with OH3, this can't be changed dynamically. The app's "publicPath", set in webpack config, is compiled statically into the app build. Right now it should be generally possible to put the mainUI under an arbitrary subpath (special issues like apache auth put aside - and I don't know about the core services). With this change, this would not be possible anymore, the app could only be served under root ( I found some addons that would allow for a "dynamic" publicpath, like webpack-require-from. This could be used to try to determine a subpath before loading or even load it as config parameter from core. Though, this would require extra work, of course. The only thing I don't fully understand about all this yet, is why the links generated by f7 cannot simply include the hashbang... So, @ghys, unless you know more than I do, I think a decision is required here: Keep up relative pathing, making it possible to have OH3 mapped to arbitrary locations, or making links work ... |
For these cases I believe this could be tackled with rewrite rules in the reverse proxy, at least for now (if a dedicated subdomain cannot be used). That is, intercept
Me neither 🤷
I like the clean URLs without
Found 2 other ones! In the profile page, there are links to |
Actually, it's the other way round: the reverse proxy would intercept /openhab/rest/* and forward it to /rest/* at openHAB 😉 Anyway, I'm currently following up my first idea (rewritehandler) which might eventually solve all this. If that turns out to be an impasse, I will finish this PR off. |
No what I meant is, if you "proxy_pass" openHAB in a subpath e.g. |
Hm, I'm still somehow not able to fit this to my statement you referred to 🤔, which was:
Anyway, I couldn't find a clean solution around this, so I fixed the missing links. The PR is now complete, meaning the hashbang is gone, which makes it possible to open links in new tabs, and relocating the ui is only possible by more complex means like content rewriting. |
Ah, what I forgot to ask, @ghys, with regards to #432: What can still be done with all this, is to (permanently) locate the main UI under some subpath, like "/ui". Any intention of doing so? |
Nah. I like the main UI being served from the root path - I feel it's "cleaner" and tried to make it work that way (it was not as straightforward as you think!). Of course I could cope with OH2 UIs served from their own subpaths but if you want to have an all-encompassing UI I felt it shouldn't be "relegated" to a subpath. |
Btw @hubsif - this PR is now my main system's UI so if it ends up working well you can expect a merge soon. |
Argh. Actually, I did a lot of regex searches in vscode, don't know how I missed |
ok, so I found some more And then there are the sidebar tiles. For me the UIs returned by the server ( [
{
"name": "Basic UI",
"url": "../basicui/app",
"imageUrl": "res/img/basicui.png"
},
{
"name": "HABPanel",
"url": "../habpanel/index.html",
"imageUrl": "../habpanel/tile.png"
}
] This is somewhat inconsistent but works just fine on the home page ("root path"). Is the right sidepanel actually shown anywhere else? |
Yes webpack's openhab-webui/bundles/org.openhab.ui/web/build/webpack.config.js Lines 152 to 157 in 545174f
If you begin navigation from a subpath say |
So, I did some research regarding webpack and that "url-loader" and found out that this plugin actually processes all images referenced in the code and either integrates them inline as base64 or copies them to the target path What actually happens with current settings is that images (>10KB) get "url-loaded" to the I learned that the So, with only doing what's actually required the result now is as follows:
This should eventually fix all issues with image sourcing. Though tests with a real prod-build are still outstanding. |
It was originally named |
ok, so I finalized this with some more small changes:
I just discovered that I cannot build a complete UI package, e.g. BasicUI fails with some (supposedly gulp version related) error. But I created a build for mainUI and HABPanel and it seems just fine. So, I'd say that test is passed. |
Signed-off-by: Hubert Nusser <[email protected]>
Signed-off-by: Hubert Nusser <[email protected]>
Indeed this was an early version when layout pages didn't exist and the overview tab was basically the other apps tiles (similar to OH2's dashboard). I'd say it can be removed. |
Signed-off-by: Hubert Nusser <[email protected]>
Ok. So, I removed everything in "overview-tab" that seemed unused (including Additionally, I rebased this PR for the Jenkins build to succeed. |
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.
Seems all good now - everything seems to work pretty well. I believe it's ready for prime time at last. It might break a few bookmarks and the like for some people, but I'm not worried too much about this considering the benefits. Great change, many thanks!
I think I did it 🕺 😄.
I wanted to make this clean, so it wouldn't require to maintain all pathes in the UIService. I did a lot of research and it turned out to be quite complicated with no experience at all in this osgi bundling and embedded jetty and how to register a rewrite handler with this.
In the end the change is so simple:
getResource
returns null if the resource can't be found (which assume to be those resulting in 404 then). If that's the case, returnindex.html
instead.And no need to take care of any path prefixes, as pathes to other registered contexts don't get routed to this context.