"Apps", 'class' => "navbar-narrow", 'options' => array('mysql' => array('text' => "MySQL", 'url' => generate_url($vars, * 'app' => "mysql"))))) * * @param array $tabbar * * @return null * */ function print_tabbar($tabbar) { $output = '
'; echo $output; } /** * Generate Bootstrap-format navigation bar * * A little messy, but it works and lets us move to having no navbar markup on pages :) * Examples: * print_navbar(array('brand' => "Apps", 'class' => "navbar-narrow", 'options' => array('mysql' => array('text' => "MySQL", 'url' => generate_url($vars, * 'app' => "mysql"))))) * * @param array $vars * * @return void * */ function print_navbar($navbar) { global $config; if (OBSERVIUM_EDITION === 'community' && isset($navbar['community']) && $navbar['community'] === FALSE) { // Skip nonexistent features on a community edition return; } $id = random_string(); // Detect an allowed screen ratio for current browser, cached! $ua_info = detect_browser(); ?> 'alerts', 'status' => 'all' ]); $navbar['options_right']['filters']['url'] = '#'; $navbar['options_right']['filters']['text'] = 'Filter'; $navbar['options_right']['filters']['icon'] = 'filter'; //$navbar['options_right']['filters']['link_opts'] = 'data-hover="dropdown" data-toggle="dropdown"'; // All $navbar['options_right']['filters']['suboptions']['all']['text'] = 'All'; $navbar['options_right']['filters']['suboptions']['all']['icon'] = 'info'; $navbar['options_right']['filters']['suboptions']['all']['url'] = $url_all; if ($all) { //$navbar['options_right']['filters']['class'] = "active"; $navbar['options_right']['filters']['suboptions']['all']['class'] = "active"; $navbar['options_right']['filters']['text'] .= ' (All)'; } $statuses = array_diff($statuses, [ 'all' ]); $filters = [ 'ok' => [ 'icon' => 'ok', 'text' => 'Ok' ], 'failed' => [ 'icon' => 'stop', 'text' => 'Failed' ], 'delayed' => [ 'icon' => 'important', 'text' => 'Delayed' ], 'suppressed' => [ 'icon' => 'shutdown', 'text' => 'Suppressed' ] ]; $filters_text = []; foreach ($filters as $option => $option_array) { $navbar['options_right']['filters']['suboptions'][$option]['text'] = $option_array['text']; $navbar['options_right']['filters']['suboptions'][$option]['icon'] = $option_array['icon']; $link_statuses = $statuses; if (in_array($option, $statuses, TRUE)) { $navbar['options_right']['filters']['suboptions'][$option]['class'] = "active"; if (!$all) { $navbar['options_right']['filters']['class'] = "active"; } $link_statuses = array_diff($link_statuses, [ $option ]); // unset status $filters_text[] = $option_array['text']; $navbar['options_right']['filters']['icon'] = $option_array['icon']; } else { $link_statuses[] = $option; } $navbar['options_right']['filters']['suboptions'][$option]['url'] = generate_url($vars, [ 'page' => 'alerts', 'status' => implode(',', $link_statuses)]); } if ($filters_text) { $navbar['options_right']['filters']['text'] .= ' (' . implode(', ', $filters_text) . ')'; } } function navbar_ports_filter(&$navbar, $vars, $extra = []) { global $config; $filters_array = $vars['filters'] ?? [ 'deleted' => TRUE ]; // List filters $filter_options = []; if ($extra) { foreach ((array)$extra as $port_type) { if (isset($config['port_types'][$port_type])) { $filter_options[$port_type] = 'Hide ' . $config['port_types'][$port_type]['name']; } } $filter_options['divider'] = 'divider'; } $filter_options['up'] = 'Hide UP'; $filter_options['down'] = 'Hide DOWN'; $filter_options['shutdown'] = 'Hide SHUTDOWN'; $filter_options['ignored'] = 'Hide IGNORED'; $filter_options['deleted'] = 'Hide DELETED'; // To be or not to be $filters_array['all'] = TRUE; foreach ($filter_options as $option => $text) { if ($text === 'divider') { continue; } $filters_array['all'] = $filters_array['all'] && $filters_array[$option]; $option_all[$option] = TRUE; } $filter_options['all'] = $filters_array['all'] ? 'Show ALL' : 'Hide ALL'; // Generate filtered links $navbar['options_right']['filters']['text'] = 'Quick Filters'; foreach ($filter_options as $option => $text) { if ($text === 'divider') { $navbar['options_right']['filters']['suboptions'][$option][$text] = $text; continue; } $option_array = array_merge($filters_array, [ $option => TRUE ]); if ($filters_array[$option]) { $text = str_replace('Hide', 'Show', $text); $navbar['options_right']['filters']['class'] .= ' active'; $navbar['options_right']['filters']['suboptions'][$option]['class'] = 'active'; if ($option === 'all') { $option_array = ['disabled' => FALSE]; } else { $option_array[$option] = FALSE; } } elseif ($option === 'all') { $option_array = $option_all; } $navbar['options_right']['filters']['suboptions'][$option]['text'] = $text; $navbar['options_right']['filters']['suboptions'][$option]['url'] = generate_url($vars, [ 'filters' => $option_array ]); } return $filters_array; } // DOCME needs phpdoc block function navbar_location_menu($array) { if ($count = safe_count($array['entries'])) { ksort($array['entries']); } echo(' '); } // DOCME needs phpdoc block function navbar_submenu($entry, $level = 1) { // autoscroll set by navbar-narrow + dropdown-menu, but override max-height echo(str_pad('', ($level - 1) * 2) . '