From d1879c2e393c1e6882de9dd7f04349e4551a6579 Mon Sep 17 00:00:00 2001 From: LordGrey <48840279+Lord-Grey@users.noreply.github.com> Date: Thu, 3 Aug 2023 22:40:25 +0200 Subject: [PATCH] ws281x - Update logic to identify is user is admin (#1623) --- assets/webconfig/js/content_leds.js | 2 +- libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js index 2a95af81..1aec94ab 100755 --- a/assets/webconfig/js/content_leds.js +++ b/assets/webconfig/js/content_leds.js @@ -2069,7 +2069,7 @@ var updateOutputSelectList = function (ledType, discoveryInfo) { case "devRPiPWM": key = ledType; - if (discoveryInfo.devices.length == 0) { + if (!discoveryInfo.isUserAdmin) { enumVals.push("NONE"); enumTitleVals.push($.i18n('edt_dev_spec_devices_discovered_none')); $('#btn_submit_controller').prop('disabled', true); diff --git a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp index 2b67173c..af72304a 100644 --- a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp @@ -159,12 +159,10 @@ QJsonObject LedDeviceWS281x::discover(const QJsonObject& /*params*/) QJsonArray deviceList; - if (SysInfo::isUserAdmin()) - { - //Indicate the general availability of the device, if hyperion is run under root - deviceList << QJsonObject ({{"found",true}}); - devicesDiscovered.insert("devices", deviceList); - } + //Indicate the general availability of the device, if hyperion is run under root + devicesDiscovered.insert("isUserAdmin", SysInfo::isUserAdmin()); + + devicesDiscovered.insert("devices", deviceList); DebugIf(verbose,_log, "devicesDiscovered: [%s]", QString(QJsonDocument(devicesDiscovered).toJson(QJsonDocument::Compact)).toUtf8().constData());