From 05d96b772c59f385b3a0f959350c990c39b85d8f Mon Sep 17 00:00:00 2001 From: TheWitness Date: Sat, 10 Oct 2026 17:08:40 -0400 Subject: [PATCH] fix(hmib): scale Device Dashboard host picker via AJAX callback; stop header hover reflow - Device picker: replace the '; + // Device picker: a Cacti drop_callback (select2 AJAX) that searches Host MIB + // devices server-side via ?action=ajax_hosts, so installs with tens of + // thousands of hosts never materialize the full option list in the DOM. + $host_name = db_fetch_cell_prepared('SELECT description FROM host WHERE id = ?', [$host_id]); + + form_start('hmib.php', 'hmib_dashboard_device_form'); + + html_start_box('', '100%', '', '3', 'center', ''); + + draw_edit_form([ + 'config' => ['no_form_tag' => true], + 'fields' => [ + 'hmib_dashboard_host' => [ + 'method' => 'drop_callback', + 'action' => 'ajax_hosts', + 'id' => $host_id, + 'sql' => 'SELECT ' . db_qstr($host_id) . ' AS id, ' . db_qstr((string) $host_name) . ' AS name', + 'friendly_name' => __('Device', 'hmib'), + 'description' => __('Search Host MIB devices as you type to open that device\'s dashboard.', 'hmib'), + 'value' => $host_id, + 'size' => 40, + 'max_length' => 64 + ] + ] + ]); - $hosts = db_fetch_assoc("SELECT host.id, host.description - FROM plugin_hmib_hrSystem AS hrs - INNER JOIN host ON host.id = hrs.host_id - WHERE host.description != '' - ORDER BY host.description"); + html_end_box(false); - if (cacti_sizeof($hosts)) { - foreach ($hosts as $host) { - print ''; - } - } + form_end(); - print ''; + print '
'; print ''; print '