Adding Custom Menu Items
- Retrieve and remove the standard sidebar menu items except for the login menu, add a
rootMenuItem
and configure the sidebar menu to open automatically when the app loads by running:// SidebarMenuModifier.ts
export class SidebarMenuModifier {
// ...
constructor(private ivApi: ApiInterface) {
const menuItems = this.ivApi.sidebarMenu.service.items;
// Remove all entries besides the login one, and include the new nested one
menuItems.splice(1, menuItems.length, this.rootMenuItem);
// Automatically open the menu once finished modifying it
ivApi.sidebarMenu.service.openMenu();
}
} - Instantiate the
SidebarMenuModifier
in the main application fileindex.ts
by running:// index.ts
// ...
import {SidebarMenuModifier} from "./SidebarMenuModifier";
class TestApp
{
//..
getApi("https://iviondemo.iv.navvis.com/")
.then((iv: ApiInterface) => {
this.ivApi = iv;
new SidebarMenuModifier(iv);
});
}
}
// ..