diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a14c06..e38a18a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ChangeLog --- develop --- +* feature: Make the Fleet Dashboard the first tab and the default landing view on the Host MIB interface * feature: Add a Fleet (Summary) Dashboard reached by a dashboard glyph on the Summary tab's Device Type rows: a draggable, add/remove card grid scoped to all devices or one OS type, with min/avg/max bullet charts (CPU/memory/swap/processes/uptime), a device-status stacked bar, OS type distribution, storage utilization, fleet stat tiles, and top processes by CPU and by memory; scope, card order, expanded state and refresh interval persist per user * issue: Fix 'Uncaught TypeError: runCollector(): Argument #2 ($lastrun) must be of type float, null given' in the poller when a collector's *_lastrun/*_freq setting has never been written (e.g. a task's first run); runCollector() now accepts null and normalizes it * issue: Fix the per-device Dashboard Storage, Per-Processor Load, Hardware and Installed Software cards rendering empty because they filtered on 'present = 1' while the underlying Storage/Hardware/Inventory tabs never did, and add a Process Use History card diff --git a/hmib.php b/hmib.php index 81cb03a..16e0e80 100644 --- a/hmib.php +++ b/hmib.php @@ -25,7 +25,7 @@ chdir('../../'); include('./include/auth.php'); -set_default_action('summary'); +set_default_action('summary_dashboard'); if (get_request_var('action') == 'ajax_hosts') { get_allowed_ajax_hosts(true, false, 'h.id IN (SELECT host_id FROM plugin_hmib_hrSystem)'); @@ -2909,7 +2909,8 @@ function clearFilter() { /** * Renders the top tabbed navigation bar for this page's views - * (summary/devices/storage/hardware/running/history/software/graphs), + * (summary_dashboard/summary/devices/storage/hardware/running/history/software/graphs, + * plus the conditional per-device dashboard tab), * highlighting whichever tab corresponds to the current action. Called * from this script's main flow at the top of every rendered view. * @@ -2923,6 +2924,7 @@ function hmib_tabs(): void { // present a tabbed interface $tabs = [ + 'summary_dashboard' => __esc('Fleet Dashboard', 'hmib'), 'summary' => __esc('Summary', 'hmib'), 'devices' => __esc('Devices', 'hmib'), 'storage' => __esc('Storage', 'hmib'), @@ -2936,9 +2938,8 @@ function hmib_tabs(): void { // set the default tab $current_tab = get_request_var('action'); - // The stateful Dashboard tabs only appear once opened from their glyph: the - // Fleet Dashboard from the Summary tab, the per-device Dashboard from Devices. - $show_fleet = ($current_tab == 'summary_dashboard' || read_user_setting('hmib_summary_type', '') !== ''); + // The Fleet Dashboard is the landing tab and is always present. The per-device + // Dashboard tab only appears once opened from its glyph on the Devices tab. $show_device = ($current_tab == 'dashboard' || (int) read_user_setting('hmib_dashboard_host', 0) > 0); $ordered = []; @@ -2946,10 +2947,6 @@ function hmib_tabs(): void { foreach ($tabs as $tab_key => $tab_label) { $ordered[$tab_key] = $tab_label; - if ($tab_key == 'summary' && $show_fleet) { - $ordered['summary_dashboard'] = __esc('Fleet Dashboard', 'hmib'); - } - if ($tab_key == 'devices' && $show_device) { $ordered['dashboard'] = __esc('Dashboard', 'hmib'); } @@ -2975,8 +2972,8 @@ function hmib_tabs(): void { * Renders the Host MIB dashboard/summary view: an overview of monitored * device counts by status/OS type, top running processes, and other * aggregate statistics, driven by this view's filter request - * variables. Called from this script's main request-dispatch switch as - * the default view (action=summary or no action). + * variables. Called from this script's main request-dispatch switch + * when action=summary. * * @return void * @@ -5431,7 +5428,8 @@ function hmib_summary_card_ajax(): string { * uptime, OS type distribution and top processes by CPU/memory) scoped to all * devices or a single OS type. Card order, expanded state, the selected OS type * and the auto-refresh interval persist per user. Called from this script's main - * request-dispatch switch when action=summary_dashboard. + * request-dispatch switch when action=summary_dashboard, and as the default + * landing view when no action is supplied. * * @return void * diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index 1928286..6c05e39 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -1297,6 +1297,14 @@ msgstr "" msgid "Host MIB Inventory Summary" msgstr "" +#: setup.php +msgid "Host MIB Device Dashboard" +msgstr "" + +#: setup.php +msgid "Host MIB Fleet Dashboard" +msgstr "" + #: setup.php msgid "Host MIB Details" msgstr "" diff --git a/setup.php b/setup.php index 604e2df..f6cfcb4 100644 --- a/setup.php +++ b/setup.php @@ -536,16 +536,19 @@ function hmib_config_arrays(): void { /** * Draw_navigation_text hook: registers the breadcrumb/navigation title * entries for this plugin's hmib.php and hmib_types.php pages and their - * sub-views. Called by Cacti's navigation framework via the - * 'draw_navigation_text' hook. + * sub-views (including the Fleet Dashboard landing view + * summary_dashboard and the per-device dashboard). Called by Cacti's + * navigation framework via the 'draw_navigation_text' hook. * * @param array $nav The navigation entries array being built up. * * @return array The $nav array with this plugin's entries added. */ function hmib_draw_navigation_text($nav): array { + $nav['hmib.php:summary_dashboard'] = ['title' => __('Host MIB Fleet Dashboard', 'hmib'), 'mapping' => '', 'url' => 'hmib.php', 'level' => '0']; $nav['hmib.php:summary'] = ['title' => __('Host MIB Inventory Summary', 'hmib'), 'mapping' => '', 'url' => 'hmib.php', 'level' => '0']; $nav['hmib.php:devices'] = ['title' => __('Host MIB Details', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0']; + $nav['hmib.php:dashboard'] = ['title' => __('Host MIB Device Dashboard', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0']; $nav['hmib.php:storage'] = ['title' => __('Host MIB Storage', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0']; $nav['hmib.php:hardware'] = ['title' => __('Host MIB Hardware', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0']; $nav['hmib.php:running'] = ['title' => __('Host MIB Running Processes', 'hmib'), 'mapping' => '', 'url' => '', 'level' => '0']; diff --git a/tests/Unit/HmibNavigationTest.php b/tests/Unit/HmibNavigationTest.php index 0cc595f..4faf4ea 100644 --- a/tests/Unit/HmibNavigationTest.php +++ b/tests/Unit/HmibNavigationTest.php @@ -18,9 +18,10 @@ expect($nav)->toHaveKey('other.php:'); - foreach (array('hmib.php:summary', 'hmib.php:devices', 'hmib_types.php:', 'hmib_types.php:edit') as $key) { + foreach (array('hmib.php:summary_dashboard', 'hmib.php:summary', 'hmib.php:devices', 'hmib.php:dashboard', 'hmib_types.php:', 'hmib_types.php:edit') as $key) { expect($nav)->toHaveKey($key); } + expect($nav['hmib.php:summary_dashboard']['url'])->toBe('hmib.php'); expect($nav['hmib_types.php:']['url'])->toBe('hmib_types.php'); });