From 826bd8f524f8b80c54228ae30a6ad56d7a084846 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Mon, 2 Dec 2024 09:29:13 +1100 Subject: [PATCH] NEWDEV_replace_preset_icon --- front/plugins/newdev_template/config.json | 28 +++++++++++++++++++++++ server/device.py | 15 ++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index 09b2c4d7..12856f72 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -265,6 +265,34 @@ } ] }, + { + "function": "replace_preset_icon", + "type": { + "dataType": "boolean", + "elements": [ + { + "elementType": "input", + "elementOptions": [{ "type": "checkbox" }], + "transformers": [] + } + ] + }, + "default_value": false, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "Overwrite Preset Icon" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "If checked, the application replaces the preset icon in NEWDEV_devIcon with a pre-assigned vendor or device icon if found. If this is checked, avoid manually assigning this icon to devices, as it may be replaced." + } + ] + }, { "function": "devMac", "type": { diff --git a/server/device.py b/server/device.py index a256799c..c5ce47c6 100755 --- a/server/device.py +++ b/server/device.py @@ -452,11 +452,18 @@ def update_devices_data_from_scan (db): # Guess ICONS recordsToUpdate = [] - query = """SELECT * FROM Devices - WHERE devIcon in ('', 'null') - OR devIcon IS NULL""" + default_icon = get_setting_value('NEWDEV_devIcon') - + + if get_setting_value('NEWDEV_replace_preset_icon'): + query = f"""SELECT * FROM Devices + WHERE devIcon in ('', 'null', '{default_icon}') + OR devIcon IS NULL""" + else: + query = """SELECT * FROM Devices + WHERE devIcon in ('', 'null') + OR devIcon IS NULL""" + for device in sql.execute (query) : # Conditional logic for devIcon guessing devIcon = guess_icon(device['devVendor'], device['devMac'], device['devLastIP'], device['devName'], default_icon)