URL Custom Panel Entry

I just spent the better part of 4 hours trying to figure out something I thought would be a very simple task. Adding an ICON to the sidebar that sends you to a URL. I was doing this because the UniFI Admin add-on didn’t have an option for a sidebar icon. So here’s what I did.

Step 1: Add this to your configuration.yaml (You can also use !include and group your config in another file like I did but for simplicity of explanation see below)

## Unifi Admin
panel_custom:
  - name: UniFi Admin
    sidebar_title: UniFi Admin
    sidebar_icon: mdi:alpha-u-box
    url_path: unifi
    module_url: /local/unifi_redirect.js
    embed_iframe: false
    require_admin: true

Step 2: Create a file in /config/www called unifi_redirect.js (or whatever else you just just be sure to change module_url above)

Step 3: In the file you just created put the following. Adjust to the url of your unifi system.

window.location.replace("https://<url to unifi>/");

Step 4: Reboot

Step 5: Test

That’s it. You should be able to adjust this to whatever URL you needed.

Notes:

  • UniFi doesn’t like being inside an iframe so I pop it out. See step 1 where you can adjust that.
  • In testing there appears to be an undocumented / unimplemented item called html_url. If it’s what I think it was intended to do it would have made step 3 unnecessary.
  • Unfortunately you need to reboot each time you try and test something.

Good Luck!

5 Likes

Great, thanks! As it is a little bit of an annoyance to go back to HA after opening a link in the same tab (at least I need to login again), is there a way to make panel open a new tab? Tried modifying your unifi_redirect.js, but neither works.

window.open(url, '_blank')
or
window.location.assign(url, '_blank')

Any ideas?

1 Like

please tell me if you found out a possible solution

I’ll be honest here, I am a network engineer so web programmer is a hobby at best. I really don’t know how you’d do that. That being said I am about 99% certain ChatGPT would be able to answer that if someone on this board can’t.

Sorry, I only now saw this post. I have the following in unifi_redirect.js

window.open('https://192.168.0.34:8443/manage/default/dashboard', '_blank').focus();

Rest was about changing browser settings so that it opens new tabs instead of windows. Works as expected on Firefox.

1 Like

Found this really helpful 2 years after your post, thanks OP!

1 Like