Page 1 of 1

Web UI - Search Bar Always Expanded

Posted: Mon Dec 16, 2019 11:19 am
by treesquid
How would i be able to make it so that the search bar is always expanded, which would then not require me to click on the magnifying glass icon every time?
xisearchbar.png

Re: Web UI - Search Bar Always Expanded

Posted: Mon Dec 16, 2019 2:41 pm
by benjaminsmith
Hello @treesquid,

A couple of options for making this happen. You can either use the Custome Includes component to modifying the UI by adding your own CSS and Javascript or you could directly modify the PHP file and remove the hide class. However, this would be overwritten when you upgrade Nagios XI.

1. To learn more about the Customs Includes component, please see the following documentation:

Nagios XI - Using The Custom Includes Component

2. To modify the top-bar, you would edit the /usr/local/nagiosxi/html/includes/header.inc.php file, and go to line 139:

Code: Select all

  <div class="header-right search">
        <div class="search-field hide">
            <form method="post" target="maincontentframe" action="<?php echo get_base_url(); ?>includes/components/xicore/status.php?show=services">
                <input type="hidden" name="navbarsearch" value="1"/>
                <input type="text" class="search-query form-control" name="search" id="navbarSearchBox" value="" placeholder="<?php echo _('Search...'); ?>"/>
            </form>
        </div>
        <a href="#" id="open-search" title="<?php echo _('Search'); ?>"><i class="fa fa-search"></i></a>
    </div>
Here you can remove the hide class from search-field and the <i> tag if desired.

Re: Web UI - Search Bar Always Expanded

Posted: Mon Dec 30, 2019 3:15 pm
by treesquid
Thanks for the info Benjamin, i appreciate the info on how to do it either temporary or permanent (won't change with version update) so that i can make the temp fix now, and when i have time later i can implement the permanent solution.

Would it be possible to modify the hierarchy of the search drop-down results so that if there are results for services, host, hostgroups, etc found it will always display the hostgroup results at the top of the list? I notice there that hostgroup will always show at the bottom currently.
searchbardropdown.png

Re: Web UI - Search Bar Always Expanded

Posted: Mon Dec 30, 2019 4:11 pm
by cdienger
This can be done by editing /usr/local/nagiosxi/html/suggest.php. Starting around line is the suggest_multi() function which has a section to display services, hosts, servicegroups, and hostsgroup. These can be arranged in the order you'd like to see. To move Hostgroups to the top I moved this code:

Code: Select all

// Hostgroups
    $args = array(
        "hostgroup_name" => "lk:" . $query . ";alias=lk:" . $query,
        "brevity" => 1,
        "is_active" => 1,
        'orderby' => 'hostgroup_name:a',
        'records' => 10,
    );

    $res1 = get_hostgroup_objects_xml_output($args);
    $xres1 = simplexml_load_string($res1);

    if ($xres1) {
        foreach ($xres1->hostgroup as $obj) {
            $names[] = (object) array('url' => get_base_url().'/includes/components/xicore/status.php?show=hostgroups&hostgroup='.urlencode(strval($obj->hostgroup_name)),
                                      'value' => strval($obj->hostgroup_name),
                                      'category' => _('Hostgroup'),
                                      'label' => (stripos(strval($obj->hostgroup_name),$query) !== false) ? strval($obj->hostgroup_name) : _('[A] '). strval($obj->alias));
        }
    }

Above the "// Services line".