Custom include

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Support_Talea
Posts: 73
Joined: Wed Oct 04, 2017 7:12 am

Custom include

Post by Support_Talea »

Hi,

I have to say that I have not found much valid information.
I would like to implement my own menu inside the nagiosxi through the custom includes.
I found a sample but it works halfway and I can't solve the problem.

https://pastebin.com/k5KJAu14

How do I create a custom identical menu, which closes and opens drop-down?

Regards,
-Federico
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Custom include

Post by ssax »

I was able to get it to work like this:

Code: Select all

$(document).ready(function () {
   $("#leftnav").append(
   '<div class="menusection">' +
    '<div id="mid-menu-home-section-custom" class="menusectiontitle mid-menu-home-section-custom" data-id="menu-home-section-custom">' +
        '<i class="fa fa-chevron-down" title="Collapse menu section"></i> Custom Section</div>' +
    '<ul class="menusection">' +
        '<li class="menulink">' +
            '<a href="http://www.bing.com" target="_new">Bing</a>' +
        '</li>' +
        '<li class="menulink">' +
            '<a href="http://www.google.com" target="_new">Google</a>' +
        '</li>' +
        '<li class="menulink">' +
            '<a href="http://www.yahoo.com" target="_new">Yahoo</a>' +
        '</li>' +
    '</ul>' +
'</div>'
   );

    $(".mid-menu-home-section-custom").click(function(e) {

        // Verify that we aren't clicking a link
        var target = $(e.target);
        if (target.is('a')) { return; }

        var menusection = $(this).parents('.menusection');
        if (menusection.hasClass("menusection-collapsed")) {
            menusection.removeClass("menusection-collapsed");
            menusection.find('.fa.fa-chevron-up').removeClass('fa-chevron-up').addClass('fa-chevron-down').attr('title', '');
            var optsarr = {
                "keyname": "menu_collapse_options",
                "menuid": $(this).data('id'),
                "keyvalue": 1,
                "autoload": false
                };
            var opts = JSON.stringify(optsarr);
            get_ajax_data('setusermeta', opts);
        } else {
            menusection.addClass("menusection-collapsed");
            menusection.find('.fa.fa-chevron-down').removeClass('fa-chevron-down').addClass('fa-chevron-up').attr('title', '');
            var optsarr = {
                "keyname": "menu_collapse_options",
                "menuid": $(this).data('id'),
                "keyvalue": 0,
                "autoload": false
                };
            var opts = JSON.stringify(optsarr);
            get_ajax_data('setusermeta', opts);
        }
    });
});
Support_Talea
Posts: 73
Joined: Wed Oct 04, 2017 7:12 am

Re: Custom include

Post by Support_Talea »

Hi,

great! it works great.
Good work and many greetings.

Regards,
-Federico
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Custom include

Post by scottwilkerson »

Support_Talea wrote:Hi,

great! it works great.
Good work and many greetings.

Regards,
-Federico
Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked