cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

ADDING CUSTOM TABS TO THE TOP LEVEL NAV BAR with the API

Inspired by wluther​'s post on how to edit the db to create your own custom menu drop downs (Adding Custom Tabs To The Top Level Nav Bar  ) I went ahead and scripted up some tools to simplify the process.

pastedImage_0.png

The basic explanation is that when the menu bars were redone as part of the UX update last year they added a few tables to the database that we will be manipulating to add our own additional toolbars.  Obviously keep in mind that database edits of this nature are unsupported so you should take precautions such as backing up your database before you get in there and start banging around, but once you are comfortable with the concept you may find yourself using it a lot.

Essentially it boils down to adding the drop down menu you want to the table callled WebViewGroup, then adding the link you want to the table called WebView, then linking those objects together via an entry on the table called WebViewGroupWebView.

The first tool I made, AddCustomMenusInteractively.ps1, is just a quick little prompt driven powershell script that will ask you for the name of the menu you want to add entries too, if that menu doesn't exist it creates it.

Then it asks you for the URL and Title you want your link to have.  If you wanted to add multiple new entries just run the tool again and tell it to use the same menu title as you created in the previous runs.  It's currently set up to run it locally on your Orion server and passes through your Windows login credential but you can edit it to work other ways if you need.

pastedImage_2.png

***A fun new trick I recently learned is that any items you add under the Alerts & Activity or the Reports drop downs will also become check boxes in the user account settings, so you can one by one control which menus users have access to***

pastedImage_3.png

The second tool, AddCustomMenuSettingsLinks.ps1, is geared more as a time saving tool for myself.  As the SW admin I spend a ton of time bouncing between the settings menus and having to click into all settings, wait for that to load, then drill down into the next layer(s) that I needed to keep going to be where I want to be always annoyed me.  This adds a pre-populated stack of admin type links to the settings drop down.  I like putting them there because if an account isn't an admin in Orion they won't have that drop down available to them.  You can remove any links you don't need by commenting or deleting them from the big array of them around line 44.  The one big issue I learned when I made this is that can be some graphical glitches if your list is too long because the black background seems to only go to about 2/3 down the screen, the specific limit in terms of how many rows that is varies based on your screen resolution.  For my laptop it looks like about 23 rows is my max unless I zoom way out.  So staying under 20 rows in each menu is probably a reasonable practice there.

pastedImage_3.png   

pastedImage_0.png

I'd love to see anyone else post up whatever cool things you all come up with as far as these menu bars.

-Marc Netterfield

    Loop1 Systems: SolarWinds Training and Professional Services

And for the people who have a hard time downloading the links here is the text of the scripts

######################## AddCustomMenusInteractively ##################################

<#------------- CONNECT TO SWIS -------------#>

# load the snappin if it's not already loaded (step 1)

if (!(Get-PSSnapin | Where-Object { $_.Name -eq "SwisSnapin" })) {

    Add-PSSnapin "SwisSnapin"

}

$hostname = "localhost"

$swis = Connect-Swis -Hostname $hostname -Trusted

#alternative connection method

#$user = "user"

#$password = "pass"

#$swis = connect-swis -host $hostname -username $user -password $password -ignoresslerrors

<#------------- ACTUAL SCRIPT -------------#>

$MenuTitle = Read-Host -Prompt "What is the title of the drop down menu you want to work with?"

# check if that drop down already exiss

$MenuTest = get-swisdata $swis @"

SELECT ID, Name, DefaultTitle, Tags, SortOrder, OrionFeatureName, URI

FROM Orion.Web.ViewGroup

where DefaultTitle = '$MenuTitle'

"@

if (!$MenuTest) {

    $MenuProps = @{

    Name = $MenuTitle.replace(' ','')

    DefaultTitle = $MenuTitle

    Tags = "navigation"

    SortOrder = 99

}

    "`Creating new menu called $MenuTitle"

    $MenuResults = New-SwisObject -SwisConnection $swis -EntityType "Orion.Web.ViewGroup" -Properties $MenuProps

} else {

    $MenuResults = $MenuTest.URI

}

"`Menu called $MenuTitle exists..."

$ViewURL = Read-Host -Prompt "What is the URL you want to add to this menu? (You can provide full URL's or use relative links by starting the address with a '/')"

$ViewTitle = Read-Host -Prompt "What is the title you want to give to this item?"

$ViewProps = @{

    Name = $ViewTitle.replace(' ','-')

    DefaultTitle = $ViewTitle

    Type = "legacy"

    URL = $ViewURL

    IsCustom = "True"

    SortOrder = 0

    OpenInNewWindow = "False"

}

"`Creating new menu item called $ViewTitle under $MenuTitle"

$ViewResults = New-SwisObject -SwisConnection $swis -EntityType "Orion.Web.View" -Properties $ViewProps

$MenuID = get-swisdata $swis @"

SELECT ID FROM Orion.Web.ViewGroup where uri = '$MenuResults'

"@

$ViewID = get-swisdata $swis @"

SELECT ID FROM Orion.Web.View where uri = '$ViewResults'

"@

$LinkViewtoGroup = Invoke-SwisVerb $swis 'Orion.Reporting' 'ExecuteSQL' @"

INSERT WebViewGroupWebView (WebViewGroupID, WebViewID, SortOrder)

VALUES ($MenuID,$ViewID,0)

"@

$ClearCache = Invoke-SwisVerb $swis 'Orion.Web.Menu' 'ClearCache' -Arguments ""

############################## End #########################################

######################## AddCustomMenSettingsLinks ##################################

<#------------- CONNECT TO SWIS -------------#>

# load the snappin if it's not already loaded (step 1)

if (!(Get-PSSnapin | Where-Object { $_.Name -eq "SwisSnapin" })) {

    Add-PSSnapin "SwisSnapin"

}

$hostname = "localhost"

$swis = Connect-Swis -Hostname $hostname -Trusted

#alternative connection method

#$user = "user"

#$password = "pass"

#$swis = connect-swis -host $hostname -username $user -password $password -ignoresslerrors

<#------------- ACTUAL SCRIPT -------------#>

$MenuTitle = "Settings"

# check if that drop down already exiss

$MenuTest = get-swisdata $swis @"

SELECT ID, Name, DefaultTitle, Tags, SortOrder, OrionFeatureName, URI

FROM Orion.Web.ViewGroup

where DefaultTitle = '$MenuTitle'

"@

if (!$MenuTest) {

    $MenuProps = @{

    Name = $MenuTitle.replace(' ','')

    DefaultTitle = $MenuTitle

    Tags = "navigation"

    SortOrder = 99

}

    "`Creating new menu called $MenuTitle"

    $MenuResults = New-SwisObject -SwisConnection $swis -EntityType "Orion.Web.ViewGroup" -Properties $MenuProps

} else {

    $MenuResults = $MenuTest.URI

}

"`Menu called $MenuTitle exists..."

$Links = @(

    @{ URL = "/Orion/Nodes/Add/Default.aspx"; Title = "Add Node";},

    @{ URL = "/Orion/AgentManagement/Admin/ManageAgents.aspx"; Title = "Manage Agents";},

    @{ URL = "/Orion/Admin/Accounts/Accounts.aspx"; Title = "Manage Orion Accounts";},

    @{ URL = "/Orion/Alerts/Default.aspx"; Title = "Manage Alerts";},

    @{ URL = "/Orion/Admin/PollingSettings.aspx"; Title = "Polling Settings";},

    @{ URL = "/Orion/Admin/Credentials/CredentialManager.aspx"; Title = "Manage Orion Credentials - Windows";},

    @{ URL = "/Orion/Admin/Credentials/SNMPCredentialManager.aspx"; Title = "Manage Orion Credentials - SNMPv3";},

    @{ URL = "/Orion/Admin/CPE/Default.aspx"; Title = "Manage Custom Properties";},

    @{ URL = "/Orion/Admin/CPE/InlineEditor.aspx"; Title = "Edit Custom Properties";},

    @{ URL = "/Orion/Admin/DependenciesView.aspx"; Title = "Manage Dependencies";},

    @{ URL = "/Orion/Admin/Containers/Default.aspx"; Title = "Manage Groups";},

    @{ URL = "/Orion/Reports/Default.aspx"; Title = "Manage Reports";},

    @{ URL = "/Orion/Admin/ListViews.aspx"; Title = "Manage Views";},

    @{ URL = "/Orion/WorldMap/Manage.aspx?"; Title = "Manage Worldwide Map";},

    @{ URL = "/Orion/APM/Admin/Default.aspx"; Title = "SAM Settings";},

    @{ URL = "/Orion/APM/Admin/Applications/Default.aspx"; Title = "Manage Assigned Applications";},

    @{ URL = "/Orion/APM/Admin/ApplicationTemplates.aspx"; Title = "Manage Application Templates";},

    @{ URL = "/Orion/APM/Admin/Components/Templates.aspx"; Title = "Manage Application Components";},

    @{ URL = "/Orion/NCM/Admin/Default.aspx"; Title = "NCM Settings";},

    @{ URL = "/Orion/TrafficAnalysis/Admin/NetflowSettings.aspx"; Title = "NTA Settings";},

    @{ URL = "/Orion/Admin/Details/ModulesDetailsHost.aspx"; Title = "License Details";}

)

$Order = 1

foreach ($Link in $links) {

    $ViewURL = $Link.URL

    $ViewTitle = $Link.Title

    $ViewProps = @{

        Name = $ViewTitle.replace(' ','-')

        DefaultTitle = $ViewTitle

        Type = "legacy"

        URL = $ViewURL

        IsCustom = "True"

        SortOrder = $Order++ # alternatively you can set all your rows to have the same order and Orion will sort alphabetically

        OpenInNewWindow = "False"

    }

    "`Creating new menu item called $ViewTitle under $MenuTitle"

    $ViewResults = New-SwisObject -SwisConnection $swis -EntityType "Orion.Web.View" -Properties $ViewProps

    $MenuID = get-swisdata $swis " SELECT ID FROM Orion.Web.ViewGroup where uri = '$MenuResults' "

    $ViewID = get-swisdata $swis " SELECT ID FROM Orion.Web.View where uri = '$ViewResults' "

    $LinkViewtoGroup = Invoke-SwisVerb $swis 'Orion.Reporting' 'ExecuteSQL' @"

INSERT WebViewGroupWebView (WebViewGroupID, WebViewID, SortOrder)

VALUES ($MenuID,$ViewID,$Order)

"@

}

$ClearCache = Invoke-SwisVerb $swis 'Orion.Web.Menu' 'ClearCache' -Arguments ""

############################## End #########################################

Attachments
Comments

SCHWEET!!!!!!!!!!!!!!!

You do great work, sir. Thank you so very much!

Slick!  Great work as always, Marc!

This is wonderful. Is it possible to activate this new menu per account and not to have all the user access it ?

Cheers

There is a column in the db for a limitationid, but I haven't yet had time to play with it to see what results I got

I finally got back around to playing with this a bit more.

So as far as I have been able to tell you cant hide the menu bar directly if you create your own custom ones then they show up for everyone.  A trick I did find was that if you make changes to the built in Alerts & Activity or the Reports menu then each row you add gets added to their account settings with a yes/no option on if that user can see them.  If you set all the options for a particular menu to no then that whole menu disappears.  So basically this gives us two menus we can hijack to do any crazy user specific stuff we want.  I can't figure out how to make my own diy menu drop down exhibit that same behavior, but manipulating the Alerts and Reports menus does get us a good chunk of the way there.

We have up to two menus that we can control completely what shows up on a per user basis, or if the drop down even appears, plus the settings menu only shows up for people who are overall admins in Orion, plus we can custom roll our own menus that would be generically visible to all users.

Scratch that, I learned a way to trick the GUI to give my menus the superpower of being adjustable on a per user.  The tool doesn't do this (yet?) but if you just rename your custom menu bar as alerts or reports then anything you create will also get added to the user account settings as well

The name that shows up in the GUI is the DefaultTitle so it really doesn't matter what we call the one in the back end.

pastedImage_1.png

Thank you!!

Very nice piece of work 🙂

I've two questions:

How could a menu item be deleted. Do I have to remove them to do every step backward?

Do you ever tried to create a sub menu?

 

After Having some time I found a way to remove a menu item from a custom menu:

$ViewID = Get-SwisData  $swis "Select ViewID from Orion.Views where ViewTitle = '[Name of your menu item]'"
$ViewURL = "/Orion/APM/Summary.aspx?ViewID=$($viewID)"
$URI = Get-SwisData $swis "Select URI from Orion.Web.View where URL='$($ViewUrl)'"
if ($URI) {
    $ret = Remove-SwisObject $swis -Uri $URI
    $ret = Invoke-SwisVerb $swis 'Orion.Web.Menu' 'ClearCache' -Arguments ""
}
 
After that it is gone. Also the values we added via SQL. 
Version history
Revision #:
1 of 1
Last update:
‎11-28-2018 08:31 AM
Updated by: