Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/class/Monitoring.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2627,7 +2627,11 @@ public function getCmdReplace(string $cmdName, array $cmdOptions, &$replace) {
$replace[$cmdNamePrefix . '_averageHistory#'] = $isCmdObject ? $cmd->getConfiguration($cmdName . '_averageHistory') : '-';
$replace[$cmdNamePrefix . '_minHistory#'] = $isCmdObject ? $cmd->getConfiguration($cmdName . '_minHistory') : '-';
$replace[$cmdNamePrefix . '_maxHistory#'] = $isCmdObject ? $cmd->getConfiguration($cmdName . '_maxHistory') : '-';
$replace[$cmdNamePrefix . '_tendance#'] = ($isCmdObject && $cmd->getConfiguration($cmdName . '_tendance', '') !== '') ? ' <i style="color: var(--al-info-color) !important;" class="fas fa-' . $cmd->getConfiguration($cmdName . '_tendance') . '"></i>' : '';
// Utiliser htmlspecialchars pour échapper les attributs HTML afin d'éviter les conflits avec les guillemets
$tendanceIcon = ($isCmdObject && $cmd->getConfiguration($cmdName . '_tendance', '') !== '')
? ' <i style=&quot;color: var(--al-info-color) !important;&quot; class=&quot;fas fa-' . $cmd->getConfiguration($cmdName . '_tendance') . '&quot;></i>'
: '';
$replace[$cmdNamePrefix . '_tendance#'] = $tendanceIcon;
}
];

Expand Down
46 changes: 37 additions & 9 deletions desktop/js/Monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,33 +396,61 @@ function printEqLogic(_eqLogic) {
}
}

buildSelectHost(_eqLogic.configuration.SSHHostId)
// Build SSH host select
const buildPromise = buildSelectHost(_eqLogic.configuration.SSHHostId)

// Toggle add/edit button based on SSH host selection
const sshHostSelect = document.querySelector('.sshmanagerHelper[data-helper="list"]')
if (sshHostSelect) {
// Remove existing listener to avoid duplicates
sshHostSelect.removeEventListener('change', toggleSSHButtons)
// Attach listener
sshHostSelect.addEventListener('change', toggleSSHButtons)
// Initialize button display
toggleSSHButtons({ currentTarget: sshHostSelect })

// Initialize button display - pass the value directly instead of waiting
if (buildPromise && buildPromise.then) {
buildPromise.then(() => {
toggleSSHButtons(_eqLogic.configuration.SSHHostId)
})
} else {
// Fallback if buildSelectHost didn't return a promise
toggleSSHButtons(_eqLogic.configuration.SSHHostId)
}
}
}

/**
* Toggle between add and edit SSH buttons based on selection
* @param {Event|string|number} eventOrValue - Either a change event or a direct value (SSHHostId)
*/
function toggleSSHButtons(event) {
const selectedValue = event.currentTarget.value
function toggleSSHButtons(eventOrValue) {
let selectedValue

// Check if it's a direct value (string/number) or an event object
if (typeof eventOrValue === 'string' || typeof eventOrValue === 'number') {
selectedValue = eventOrValue
} else if (eventOrValue?.target || eventOrValue?.currentTarget) {
// It's an event, extract value from it
selectedValue = eventOrValue.target?.value ?? eventOrValue.currentTarget?.value ?? eventOrValue.value
}

// If still no value, read directly from the select element as fallback
if (!selectedValue) {
const sshHostSelect = document.querySelector('.sshmanagerHelper[data-helper="list"]')
selectedValue = sshHostSelect?.value
}

const addBtn = document.querySelector('.sshmanagerHelper[data-helper="add"]')
const editBtn = document.querySelector('.sshmanagerHelper[data-helper="edit"]')

if (selectedValue && selectedValue !== '') {
// Host selected → show edit, hide add
addBtn?.unseen()
editBtn?.seen()
if (addBtn) addBtn.style.display = 'none'
if (editBtn) editBtn.style.display = 'block'
} else {
// No host selected → show add, hide edit
addBtn?.seen()
editBtn?.unseen()
if (addBtn) addBtn.style.display = 'block'
if (editBtn) editBtn.style.display = 'none'
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugin_info/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "Monitoring",
"name": "Monitoring",
"pluginVersion": "3.4.2",
"pluginVersion": "3.4.3",
"description": {
"fr_FR": "Plugin permettant le monitoring des équipements locaux et distants (via SSH). Le plugin affichera les informations systèmes d'équipements sous Linux ou Synology (Distribution, CPU, Mémoire, Disques, Swap).",
"en_US": "Plugin to monitor local and remote equipments (through SSH). The plugin will display system informations from Linux or Synology (Distribution, CPU, Memory, Disks, Swap).",
Expand Down