From 64bc253e95976f5ecaa9d686f53af57f781fbf72 Mon Sep 17 00:00:00 2001 From: Salvialf Date: Sat, 4 Jul 2026 20:07:59 +0200 Subject: [PATCH 1/5] chore(eqLogic.class.js): code formatting --- core/js/eqLogic.class.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/core/js/eqLogic.class.js b/core/js/eqLogic.class.js index 7f3bb8856b..df1f9fcdcd 100644 --- a/core/js/eqLogic.class.js +++ b/core/js/eqLogic.class.js @@ -34,7 +34,7 @@ if (!isset(jeedom.eqLogic.cache.byId)) { jeedom.eqLogic.cache.byId = Array() } -if(!isset(jeedom.eqLogic.cache.byLogical)){ +if (!isset(jeedom.eqLogic.cache.byLogical)) { jeedom.eqLogic.cache.byLogical = Array() } @@ -270,7 +270,7 @@ jeedom.eqLogic.toHtml = function(_params) { action: 'toHtml', id: _params.id, version: _params.version, - global : _params.global || false + global: _params.global || false } domUtils.ajax(paramsAJAX) } @@ -299,7 +299,7 @@ jeedom.eqLogic.getCmd = function(_params) { paramsAJAX.data = { action: 'byEqLogic', eqLogic_id: _params.id, - ...(_params.typeCmd ? { typeCmd: _params.typeCmd } : {}) + ...(_params.typeCmd ? { typeCmd: _params.typeCmd } : {}) } domUtils.ajax(paramsAJAX) } @@ -333,22 +333,22 @@ jeedom.eqLogic.byId = function(_params) { } jeedom.eqLogic.removeImage = function(_params) { - const paramsRequired = ['id']; - const paramsSpecifics = {}; + const paramsRequired = ['id'] + const paramsSpecifics = {} try { - jeedom.private.checkParamsRequired(_params || {}, paramsRequired); + jeedom.private.checkParamsRequired(_params || {}, paramsRequired) } catch (e) { - (_params.error || paramsSpecifics.error || jeedom.private.default_params.error)(e); - return; + (_params.error || paramsSpecifics.error || jeedom.private.default_params.error)(e) + return } - const params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {}); - const paramsAJAX = jeedom.private.getParamsAJAX(params); - paramsAJAX.url = 'core/ajax/eqLogic.ajax.php'; + const params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {}) + const paramsAJAX = jeedom.private.getParamsAJAX(params) + paramsAJAX.url = 'core/ajax/eqLogic.ajax.php' paramsAJAX.data = { action: 'removeImage', id: _params.id - }; - domUtils.ajax(paramsAJAX); + } + domUtils.ajax(paramsAJAX) } jeedom.eqLogic.byLogical = function(_params) { @@ -425,7 +425,7 @@ jeedom.eqLogic.getSelectModal = function(_options, callback) { args.human = mod_insertEqLogic.getValue() args.id = mod_insertEqLogic.getId() if (args.human.trim() != '') { - callback(args) + callback(args) } document.getElementById('mod_insertEqLogicValue')._jeeDialog.destroy() } @@ -512,7 +512,7 @@ jeedom.eqLogic.refreshValue = function(_params) { jeedomUtils.positionEqLogic(result[i].id) const packer = Packery.data(object_div) if (packer != undefined) packer.destroy() - new Packery(object_div, {isLayoutInstant: true, transitionDuration: 0}) + new Packery(object_div, { isLayoutInstant: true, transitionDuration: 0 }) document.querySelectorAll('div.eqLogic-widget').forEach(function(element, idx) { element.setAttribute('data-order', idx + 1) @@ -548,7 +548,7 @@ jeedom.eqLogic.refreshValue = function(_params) { jeeFrontEnd.plan.cssStyleString = '' } } - break; + break } } } catch (e) { console.error(e) } @@ -592,7 +592,7 @@ jeedom.eqLogic.refreshValue = function(_params) { eqLogic.triggerEvent('create') jeedomUtils.setTileSize('.eqLogic') } else if (typeof jeedomUI !== 'undefined' && typeof jeeFrontEnd?.dashboard?.editWidgetMode == 'function' && document.getElementById('bt_editDashboardWidgetOrder') != null) { - jeeFrontEnd.dashboard.editWidgetMode(jeedomUI?.isEditing,false) + jeeFrontEnd.dashboard.editWidgetMode(jeedomUI?.isEditing, false) } } } From 734b20752f8adab2a45c49e1b2fc2589457cdc3f Mon Sep 17 00:00:00 2001 From: Salvialf Date: Sat, 4 Jul 2026 20:11:53 +0200 Subject: [PATCH 2/5] chore(eqLogic.configure): code formatting --- desktop/modal/eqLogic.configure.php | 182 ++++++++++++++-------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/desktop/modal/eqLogic.configure.php b/desktop/modal/eqLogic.configure.php index 96df24d676..39c9c10ba9 100644 --- a/desktop/modal/eqLogic.configure.php +++ b/desktop/modal/eqLogic.configure.php @@ -56,17 +56,17 @@
- -
-
- {{Général}} + +
+
+ {{Général}}
-
-
+
+
@@ -87,8 +87,8 @@ } ?>
-
-
+
+
@@ -102,8 +102,8 @@ -
-
-
+
+
getStatus('numberTryWithoutSuccess', 0) ?> @@ -115,8 +115,8 @@
getStatus('lastCommunication') ?>
-
-
+
+
@@ -131,22 +131,22 @@
- {{Image}} -
-
- - {{Envoyer}} - - {{Enlever l'image}} -
-
-
-
- -
-
- -
+ {{Image}} +
+
+ + {{Envoyer}} + + {{Enlever l'image}} +
+
+
+
+ +
+
+ +
{{Commandes}} @@ -503,48 +503,48 @@
-
+
{{Vous pouvez trouver ici toute informations complementaires demandées par un plugin sur les équipements Jeedom}}
getSpecialAttributes(); - if (!isset($specialAttributes['eqLogic']) || !is_array($specialAttributes['eqLogic']) || count($specialAttributes['eqLogic']) == 0) { - continue; - } - $spAttr = ' {{Informations complémentaires demandées par}} ' . $plugin->getName() . ''; - foreach ($specialAttributes['eqLogic'] as $key => $config) { - $spAttr .= '
'; - $spAttr .= ''; - $spAttr .= '
'; - switch ($config['type']) { - case 'input': - $spAttr .= ''; - break; - case 'checkbox': - $spAttr .= ''; - break; - case 'number': - $spAttr .= ''; - break; - case 'select': - $spAttr .= ''; - break; - } - $spAttr .= '
'; - $spAttr .= '
'; + try { + $plugins = plugin::listPlugin(true); + foreach ($plugins as $plugin) { + $specialAttributes = $plugin->getSpecialAttributes(); + if (!isset($specialAttributes['eqLogic']) || !is_array($specialAttributes['eqLogic']) || count($specialAttributes['eqLogic']) == 0) { + continue; + } + $spAttr = ' {{Informations complémentaires demandées par}} ' . $plugin->getName() . ''; + foreach ($specialAttributes['eqLogic'] as $key => $config) { + $spAttr .= '
'; + $spAttr .= ''; + $spAttr .= '
'; + switch ($config['type']) { + case 'input': + $spAttr .= ''; + break; + case 'checkbox': + $spAttr .= ''; + break; + case 'number': + $spAttr .= ''; + break; + case 'select': + $spAttr .= ''; + break; } - echo $spAttr; + $spAttr .= '
'; + $spAttr .= '
'; } - } catch (\Exception $e) { + echo $spAttr; } - ?> - + } catch (\Exception $e) { + } + ?> +
@@ -580,10 +580,10 @@ document.querySelectorAll('#md_eqLogicConfigure .advanceWidgetParameterColorTransparent').forEach(_transparent => { _transparent?.triggerEvent('change') }) - - try { - jeeFrontEnd.md_eqLogicConfigure.bckUploader.destroy() - } catch (error) {} + + try { + jeeFrontEnd.md_eqLogicConfigure.bckUploader.destroy() + } catch (error) {} jeeFrontEnd.md_eqLogicConfigure.bckUploader = new jeeFileUploader({ fileInput: document.getElementById('bt_uploadImageEqLogic'), replaceFileInput: false, @@ -594,19 +594,19 @@ jeedomUtils.showAlert({ message: data.result.result, level: 'danger' - }) - return - } - if (isset(data.result.result.filepath)) { - document.querySelector('#md_eqLogicConfigure .eqLogicImg').seen().querySelector('img').src = data.result.result.filepath - } else { - document.querySelector('#md_eqLogicConfigure .eqLogicImg').unseen() - } - jeedomUtils.showAlert({ - message: '{{Image ajoutée avec succès}}', - level: 'success' - }) - } + }) + return + } + if (isset(data.result.result.filepath)) { + document.querySelector('#md_eqLogicConfigure .eqLogicImg').seen().querySelector('img').src = data.result.result.filepath + } else { + document.querySelector('#md_eqLogicConfigure .eqLogicImg').unseen() + } + jeedomUtils.showAlert({ + message: '{{Image ajoutée avec succès}}', + level: 'success' + }) + } }) //Dynamic values: @@ -648,13 +648,13 @@ } }, synchModalToEq: function() { - if(document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="name"]')){ + if (document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="name"]')) { document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="name"]').value = document.querySelector('#eqLogic_information input.eqLogicAttr[data-l1key="name"').value } - if(document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isEnable"]')){ + if (document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isEnable"]')) { document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isEnable"]').checked = document.querySelector('#eqLogic_information input.eqLogicAttr[data-l1key="isEnable"').checked } - if(document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isVisible"]')){ + if (document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isVisible"]')) { document.querySelector('#div_pageContainer input.eqLogicAttr[data-l1key="isVisible"]').checked = document.querySelector('#eqLogic_information input.eqLogicAttr[data-l1key="isVisible"').checked } }, @@ -880,10 +880,10 @@ }) return } - + if (_target = event.target.closest('#bt_removeEqLogicImage')) { - jeeDialog.confirm('{{Êtes-vous sûr de vouloir enlever l\'image cet équipement ?}}', function(result) { - if (result) { + jeeDialog.confirm('{{Êtes-vous sûr de vouloir enlever l\'image cet équipement ?}}', function(result) { + if (result) { jeedom.eqLogic.removeImage({ id: jeephp2js.md_eqLogicConfigure_Info.id, error: function(error) { @@ -908,7 +908,7 @@ }) return } - + }) document.getElementById('eqLogic_information')?.addEventListener('dblclick', function(event) { @@ -992,9 +992,9 @@ var _target = null if (_target = event.target.closest('.eqLogicAttr[data-l1key="configuration"][data-l2key="battery::disable"]')) { - if(document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="battery::disable"]').jeeValue() == 1){ + if (document.querySelector('.eqLogicAttr[data-l1key="configuration"][data-l2key="battery::disable"]').jeeValue() == 1) { document.querySelectorAll('.eqLogicHideNoBattery').unseen(); - }else{ + } else { document.querySelectorAll('.eqLogicHideNoBattery').seen(); } } From 5e034efcd0a201c92188aa44a5353d392b67d42f Mon Sep 17 00:00:00 2001 From: Salvialf Date: Sat, 4 Jul 2026 20:16:41 +0200 Subject: [PATCH 3/5] fix(eqLogic.class.js): centralize remove confirmation and redirect --- core/js/eqLogic.class.js | 74 ++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/core/js/eqLogic.class.js b/core/js/eqLogic.class.js index df1f9fcdcd..be9482d6c8 100644 --- a/core/js/eqLogic.class.js +++ b/core/js/eqLogic.class.js @@ -173,29 +173,67 @@ jeedom.eqLogic.usedBy = function(_params) { jeedom.eqLogic.remove = function(_params) { const paramsRequired = ['id', 'type'] - const paramsSpecifics = { - pre_success: function(data) { - if (isset(jeedom.eqLogic.cache.byId[_params.id])) { - delete jeedom.eqLogic.cache.byId[_params.id] - } - return data - } - } try { jeedom.private.checkParamsRequired(_params || {}, paramsRequired) } catch (e) { - (_params.error || paramsSpecifics.error || jeedom.private.default_params.error)(e) + (_params.error || jeedom.private.default_params.error)(e) return } - const params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {}) - const paramsAJAX = jeedom.private.getParamsAJAX(params) - paramsAJAX.url = 'core/ajax/eqLogic.ajax.php' - paramsAJAX.data = { - action: 'remove', - type: _params.type, - id: _params.id - } - domUtils.ajax(paramsAJAX) + jeedom.eqLogic.getUseBeforeRemove({ + id: _params.id, + error: function(error) { + jeedomUtils.showAlert({ message: error.message, level: 'danger' }) + }, + success: function(data) { + let text = "{{Êtes-vous sûr de vouloir supprimer l'équipement}} " + _params.type + if (_params.name) { + text += ' ' + _params.name + '' + } + text += ' ?' + if (Object.keys(data).length > 0) { + text += '
{{Il est utilisé par:}}
' + let complement = null + for (const i in data) { + complement = ('sourceName' in data[i]) ? ' (' + data[i].sourceName + ')' : '' + text += '- ' + data[i].type + ' : ' + data[i].name + '' + complement + '
' + } + } + jeeDialog.confirm(text, function(result) { + if (!result) return + + // Fires only once the actual removal succeeds server-side: + const paramsSpecifics = { + pre_success: function(data) { + if (isset(jeedom.eqLogic.cache.byId[_params.id])) { + delete jeedom.eqLogic.cache.byId[_params.id] + } + return data + }, + success: function() { + jeeFrontEnd.modifyWithoutSave = false + modifyWithoutSave = false + const vars = getUrlVars() + let url = 'index.php?' + for (const i in vars) { + if (i != 'id' && i != 'removeSuccessFull' && i != 'saveSuccessFull') { + url += i + '=' + vars[i].replace('#', '') + '&' + } + } + jeedomUtils.loadPage(url + 'removeSuccessFull=1') + } + } + const params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {}) + const paramsAJAX = jeedom.private.getParamsAJAX(params) + paramsAJAX.url = 'core/ajax/eqLogic.ajax.php' + paramsAJAX.data = { + action: 'remove', + type: _params.type, + id: _params.id + } + domUtils.ajax(paramsAJAX) + }) + } + }) } jeedom.eqLogic.copy = function(_params) { From 32ccff8b99783e97ca5c808d0aa1208a8c37d1dd Mon Sep 17 00:00:00 2001 From: Salvialf Date: Sat, 4 Jul 2026 20:19:36 +0200 Subject: [PATCH 4/5] fix(plugin.template): delegate equipment removal to jeedom.eqLogic.remove --- core/js/plugin.template.js | 55 +++++--------------------------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/core/js/plugin.template.js b/core/js/plugin.template.js index 68338e2338..585bee22e8 100644 --- a/core/js/plugin.template.js +++ b/core/js/plugin.template.js @@ -98,8 +98,8 @@ if (!jeeFrontEnd.pluginTemplate) { if (isset(data) && isset(data.timeout) && data.timeout == 0) { data.timeout = '' } - if(document.getElementById('img_device') != null && document.querySelector('.eqLogicDisplayCard.active img').getAttribute('src') != ''){ - document.getElementById('img_device').setAttribute("src",document.querySelector('.eqLogicDisplayCard.active img').getAttribute('src')); + if (document.getElementById('img_device') != null && document.querySelector('.eqLogicDisplayCard.active img').getAttribute('src') != '') { + document.getElementById('img_device').setAttribute("src", document.querySelector('.eqLogicDisplayCard.active img').getAttribute('src')) } document.getElementById('div_mainContainer').setJeeValues(data, '.eqLogicAttr') if (!isset(data.category.opening)) try { document.querySelector('input[data-l2key="opening"]').checked = false } catch (e) { } @@ -398,62 +398,21 @@ if (!jeeFrontEnd.pluginTemplate) { removeEqLogic: function() { const eqLogicId = document.querySelector('.eqLogicAttr[data-l1key="id"]').jeeValue() if (eqLogicId != undefined) { - const thisEqType = document.querySelector('.eqLogicDisplayCard[data-eqlogic_id="' + eqLogicId + '"]')?.getAttribute('data-eqLogic_type') - const textEqtype = thisEqType || eqType - jeedom.eqLogic.getUseBeforeRemove({ + const thisEqType = document.querySelector('.eqLogicDisplayCard[data-eqlogic_id="' + eqLogicId + '"]')?.getAttribute('data-eqLogic_type') || eqType + jeedom.eqLogic.remove({ id: eqLogicId, + type: thisEqType, + name: document.querySelector('.eqLogicAttr[data-l1key="name"]').jeeValue(), error: function(error) { jeedomUtils.showAlert({ message: error.message, level: 'danger' }) - }, - success: function(data) { - let text = '{{Êtes-vous sûr de vouloir supprimer l\'équipement}} ' + textEqtype + ' ' + document.querySelector('.eqLogicAttr[data-l1key="name"]').jeeValue() + ' ?' - if (Object.keys(data).length > 0) { - text += '
{{Il est utilisé par:}}
' - let complement = null - for (const i in data) { - complement = '' - if ('sourceName' in data[i]) { - complement = ' (' + data[i].sourceName + ')' - } - text += '- ' + '' + data[i].type + ' : ' + data[i].name + '' + complement + '
' - } - } - text = text.substring(0, text.length - 2) - jeeDialog.confirm(text, function(result) { - if (result) { - jeedom.eqLogic.remove({ - type: thisEqType || eqType, - id: eqLogicId, - error: function(error) { - jeedomUtils.showAlert({ - message: error.message, - level: 'danger' - }) - }, - success: function() { - const vars = getUrlVars() - let url = 'index.php?' - for (const i in vars) { - if (i != 'id' && i != 'removeSuccessFull' && i != 'saveSuccessFull') { - url += i + '=' + vars[i].replace('#', '') + '&' - } - } - jeeFrontEnd.modifyWithoutSave = false - modifyWithoutSave = false - url += 'removeSuccessFull=1' - jeedomUtils.loadPage(url) - } - }) - } - }) } }) } else { jeedomUtils.showAlert({ - message: '{{Veuillez d\'abord sélectionner un}} ' + textEqtype, + message: '{{Veuillez d\'abord sélectionner un}} ' + eqType, level: 'danger' }) } From 9034e0f75f60148ec9866482ba0c46c5f37ade90 Mon Sep 17 00:00:00 2001 From: Salvialf Date: Sat, 4 Jul 2026 20:20:35 +0200 Subject: [PATCH 5/5] fix(eqLogic.configure): simplify remove button using centralized remove --- desktop/modal/eqLogic.configure.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/desktop/modal/eqLogic.configure.php b/desktop/modal/eqLogic.configure.php index 39c9c10ba9..8e51b0e91c 100644 --- a/desktop/modal/eqLogic.configure.php +++ b/desktop/modal/eqLogic.configure.php @@ -843,25 +843,15 @@ jeeFrontEnd.md_eqLogicConfigure.eqlogicSave(event) }) document.getElementById('bt_eqLogicConfigureRemove')?.addEventListener('click', function(event) { - jeeDialog.confirm('{{Êtes-vous sûr de vouloir supprimer cet équipement ?}}', function(result) { - if (result) { - jeedom.eqLogic.remove({ - id: jeephp2js.md_eqLogicConfigure_Info.id, - type: jeephp2js.md_eqLogicConfigure_Info.eqType_name, - error: function(error) { - jeedomUtils.showAlert({ - attachTo: jeeDialog.get('#md_eqLogicConfigure', 'dialog'), - message: error.message, - level: 'danger' - }) - }, - success: function(data) { - jeedomUtils.showAlert({ - attachTo: jeeDialog.get('#md_eqLogicConfigure', 'dialog'), - message: '{{Equipement supprimé avec succès}}', - level: 'success' - }) - } + jeedom.eqLogic.remove({ + id: jeephp2js.md_eqLogicConfigure_Info.id, + type: jeephp2js.md_eqLogicConfigure_Info.eqType_name, + name: jeephp2js.md_eqLogicConfigure_Info.name, + error: function(error) { + jeedomUtils.showAlert({ + attachTo: jeeDialog.get('#md_eqLogicConfigure', 'dialog'), + message: error.message, + level: 'danger' }) } })