-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature: iFrame widget #2261
Feature: iFrame widget #2261
Conversation
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.
Looks Awesome!
Might consider adding some zoom and transform functionality like this afterwards too. Better allow for positioning etc https://www.w3docs.com/snippets/css/how-to-scale-the-content-of-iframe-element.html |
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.
Thanks for the work. I know it's been requested, but holy cow it's ugly. Are there any use cases where it isn't? Realize that's not your fault, but in general it's not really in line with homepage's POV to support this, we're more about them APIs.
In the meantime, I've noted some code issues, up to you to take care of them now or wait for a final decision about the PR overall.
Yeah I mean, it definitely can be used in a super ugly way. Personally, my use case is for a DVR/NVR stream. I don't think this looks too bad ![]() You will be able to perfectly size the iframe height to your content through the config when Tailwind implement these: |
I think this kind of illustrates possible other uses for iFrames that can integrate in the theme nicely https://dashy.to/docs/showcase/#dipans-dash |
Some rounding on the iframe element might help a little? Past that I can only think of maybe an optional subtle drop shadow perhaps? Let me know if you have some specific ideas |
Yea those are cool. I think it’ll be OK, just want to confer with my associate. We’ve always been pretty strict about styling, but ultimately yea, not much to do about it here. Anyway, I suppose beauty is in the eye of the [self-hosted] beholder... |
Rounding is a good idea yea |
While I personally think this is an anti-feature, I suppose it doesn't hurt anything by existing. As @shamoon said, our documentation is written in a more natural and less exhaustive style, as, honestly, the more text there is, the higher chances of a tl;dr.
Here the correct solution would be to integrate the NVR directly using an API. I know most ONVIF devices have common endpoints, and we already have a mjpeg stream widget. I imagine this PR will be followed up by a Discussion/Issue stating that the iframe makes public facing (insecure) requests, and doesn't use the proxy, making this even more of a mess. |
Yes, had that concern and good point, it's probably worth noting that these requests won't be proxied (yes it's obvious if you think about it but...). I do think the built-in browser protections for iframes mitigate the problem somewhat |
Not sure I'd go as far as anti-feature but would definitely call it an escape hatch. Which could risk becoming a crutch for users and potentially lead to more issues raised. So maybe a disclaimer is necessary. My Unifi stuff does output an RTSP stream so yeah totally agree the correct thing to do would be to have something transcoding to output something that could be ingested by mjpeg but I don't fancy building all that for a simple preview on my homepage. So for now, an easy escape is to just use the unifi preview url on a refresh. I have a couple of similar really basic and naive examples like this too. Here is another example: ![]() Twitch chat provides an embed link for the chat widget. For someone building a streaming focused dashboard for example. I don't think anyone wants to put in the work to integrate with twitch to bring something that they offer in a nice neat package for example. Although I think embeddable panels are on the decline in recent times, there are some custom web dev scenarios I see personally Will update the docs now too |
Head branch was pushed to by a user without write access
Hmm, re the sizes thing, Im not sure how intuitive it is, like its not obvious if a user needs to supply that entire map, and overall I think its just too much. I agree fine-grained control is nice but it's at the cost of simplicity. My inclination would be to use a single value, especially since even with this control it's just never going to perfectly align, I think people will have to accept that. |
Also, please use pre-commit as noted in the guidelines https://gethomepage.dev/v0.7.4/more/development/#code-formatting-with-pre-commit-hooks |
You know what, I think you're right. I have an idea that is even simpler |
Let me know what you think of the refactored approach. Simplified to just allow user to specify tailwind classes on the iframe element |
Yea this is better, pared it down even more—K.I.S.! |
Well, here we are. LMK if you have any concerns. |
Looks good to me, I was erring on the side of making w-full and rounded optional just cause you never know what people might need and destyling can be annoying. This will work for my use cases so if you are happy so am I! |
…250) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/gethomepage/homepage](https://togithub.com/gethomepage/homepage) | minor | `v0.7.4` -> `v0.8.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>gethomepage/homepage (ghcr.io/gethomepage/homepage)</summary> ### [`v0.8.0`](https://togithub.com/gethomepage/homepage/releases/tag/v0.8.0) [Compare Source](https://togithub.com/gethomepage/homepage/compare/v0.7.4...v0.8.0) ####⚠️ Breaking Changes - This release changes the `ping` feature to actually perform a system ping which may yield different results than the previous implementation. The old `ping` has been renamed `siteMonitor` to more accurately reflect what it does. See [the docs](https://gethomepage.dev/v0.8.0/configs/services/#site-monitor). - Homepage is also now more strict about using the correct protocol (e.g. https:// vs http://) for proxied URLs such as widget URLs #### What's Changed - Fix: Tab spacing on mobile by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2209](https://togithub.com/gethomepage/homepage/pull/2209) - Change: Enable `autoSelectFamily` for http(s) requests by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2214](https://togithub.com/gethomepage/homepage/pull/2214) - Feature: true ping, rename old ping to siteMonitor by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2215](https://togithub.com/gethomepage/homepage/pull/2215) - Feature: Added agenda view for calendar, calendar improvements by [@​denispapec](https://togithub.com/denispapec) in [https://github.com/gethomepage/homepage/pull/2216](https://togithub.com/gethomepage/homepage/pull/2216) - Feature: add date formatting option in custom api by [@​equuskk](https://togithub.com/equuskk) in [https://github.com/gethomepage/homepage/pull/2228](https://togithub.com/gethomepage/homepage/pull/2228) - Fix: override some colors for white theme by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2242](https://togithub.com/gethomepage/homepage/pull/2242) - Fix authentik users endpoint URL by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2244](https://togithub.com/gethomepage/homepage/pull/2244) - Fix: octoprint error when progress empty by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2247](https://togithub.com/gethomepage/homepage/pull/2247) - Fix: Synology DownloadStation units by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2249](https://togithub.com/gethomepage/homepage/pull/2249) - Fix: Respect hideErrors for Calendar widget by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2259](https://togithub.com/gethomepage/homepage/pull/2259) - Feature: iFrame widget by [@​Reiss-Cashmore](https://togithub.com/Reiss-Cashmore) in [https://github.com/gethomepage/homepage/pull/2261](https://togithub.com/gethomepage/homepage/pull/2261) - Fix: container memory_stats in podman by [@​idelsink](https://togithub.com/idelsink) in [https://github.com/gethomepage/homepage/pull/2272](https://togithub.com/gethomepage/homepage/pull/2272) - Fix: support Unifi widget with Unifi OS v3.2.5+ by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2281](https://togithub.com/gethomepage/homepage/pull/2281) - Fix: handle immich v1.85.0 breaking change by [@​shamoon](https://togithub.com/shamoon) in [https://github.com/gethomepage/homepage/pull/2284](https://togithub.com/gethomepage/homepage/pull/2284) #### New Contributors - [@​equuskk](https://togithub.com/equuskk) made their first contribution in [https://github.com/gethomepage/homepage/pull/2228](https://togithub.com/gethomepage/homepage/pull/2228) - [@​Reiss-Cashmore](https://togithub.com/Reiss-Cashmore) made their first contribution in [https://github.com/gethomepage/homepage/pull/2261](https://togithub.com/gethomepage/homepage/pull/2261) - [@​idelsink](https://togithub.com/idelsink) made their first contribution in [https://github.com/gethomepage/homepage/pull/2272](https://togithub.com/gethomepage/homepage/pull/2272) **Full Changelog**: gethomepage/homepage@v0.7.4...v0.8.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuNTEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
Greetings, Since there currently is no no widget for NUT UPS monitor I am trying to use the iFrame and get it looking close to the others. I have been trying to solve this on my own without success. How can I change the background color of the iFrame widget? I am trying to get to show in the "lighter" slate color - see the UptimeKuma in the photo below. I belive the code is 2A3445. Since you are the creator of the iFrame widget I was hoping you could answer. Any help is greatly appreciated! |
I'm out at the moment so can't give a full response to this and the other thread I've been tagged in. You want to select the css on the parent container of the iframe. That's what has the theme background in. Which looking at the template, won't be very simple to do. It has generic theme styles applied like bg-theme-200/50 on it which need overriding. Selecting parent CSS from a child is fragile. The iframe itself shouldn't have any background applied as far as I remember. I did want to make the classes applied more explicit but I don't think that's inline with the conventions of this project as much. They tend to err on the side of uniformity FYI @shamoon this is the exact sort of reason why I broke out the w-full and rounding classes and made them explicitly overridable. Cause you just never know what people might want to do and destyling this after the fact will lead to people creating really fragile setups likely to break with updates. Should I bring that back and include the container elements classes as an option too? |
Thanks for the response! I am hoping a remedy can be implemented as I suspect it may be awhile before we see a service widget for NUT UPS tools (https://networkupstools.org/). As of now I am just referencing an internal webpage that NUT provides and then using the iFrame widget to display the data. I had to do a bunch of tweaking of the html page to get the four main pieces of data. I am attempting to keep the "look and feel" of other widgets, so getting the iFrame widget to use the background color of A23445 (slate) should solve the issue for me. I can tweak the tables in the html page and adjust the cell colors to match other widgets. All this could be avoided if we could get a NUT widget :) but that is beyond my capabilities. I know the NUT UPS tool is used by many individual and organizations to monitor their UPS backup batteries etc. Thank you!!! |
It’s not reasonable to expect that we can satisfy every users’ specific needs, they should be balanced with overall ease-of-use, stability, maintenance etc. I don’t think there’s anything particularly “fragile” about using CSS to override any styles. Frankly this is kind of an argument against iframe itself, it’s “messier” because we don’t have much control. I’m not actually suggesting we remove it or anything like that but I don’t see any issue leaving the onus for further customization to the user themselves. also, in general I think folks should really create separate discussions for these separate questions. No one except us maintainers and the PR authors (and anyone subscribed to the PR who likely is not interested in these questions) see these random comments on closed pull requests so asking here means they don’t benefit from any possible wider community input. |
I am in agreement with you 100%! Personally I don't think anything suggested here goes against those principles. It's a very minimal change code wise. Giving the user the ability to control all the classes, optionally, if they choose to. Thus giving them the tools to cater to their own needs. Anyone who doesn't need to, won't need to do any extra config or even worry about the existence of class options. Maintenance and reliability wise, it is a very minimal penalty. Yes it's a couple of extra lines, granted. But the actual functionality here is literally just passing values along a chain or using a default is nothing provided. The fragile part, was in reference to the kind of CSS this person will have to write, in order to do something simple like remove the background of the Container. As far as I can tell the below is the only way to do something as simple as remove the Block components background FYI @adm2k this is probably the piece of CSS you want for now. Replacing "MyServiceName" with the value you set as "id" in your Service config as shown here https://gethomepage.dev/v0.8.0/configs/custom-css-js/
I'm guessing this is pretty obvious why having users write XPath based CSS selectors is not great. Alternatively an easy compromise would just be to add id's to the various child elements in the component and pass through the service name into the id so that they are uniquely selectable. This seems to be within the existing conventions of the project, however, I believe by far this is much worse for the "ease-of-use" principle you outlined, versus making all of the styles for both the iFrame and it's container overridable. I think opening up this configuration and moving the classes to all be overridable would go a long way to making sure the project isn't pestered by future issues about styling the iFrame widget. I don't want the iFrame to become one of those features the maintainers despise because it results in the most "noise" . |
Proposed change
This adds a basic iframe component with customisability for height and some other basic iframe parameters. This widget does deviate from the design guidelines. However I think by the very nature of the Widget it is justifiable.
I am not entirely sure my changes within service-helpers.js are really inline with the projects standards and would appreciate feedback. The component communication flow and organisation of HoCs is....not like anything I've ever come across before and is diffuclt to decipher so if I have not done something in the style of the project please point it out and I'll update.
There is unfortunately no decent way of providing fallback content if the iframe fails to load so right now you just get the default browser response.
Closes #
Resolves
#1227
Type of change
Checklist:
pnpm lint
(see development guidelines).