luci-app-statistics: fix prepare values from list vlaues
authorAleksey Kolosov <[email protected]>
Fri, 15 Nov 2024 07:42:55 +0000 (10:42 +0300)
committerPaul Donald <[email protected]>
Thu, 28 Nov 2024 20:17:03 +0000 (21:17 +0100)
If UCI store values as a list instead of an option, conversation for the
collectd configuration is not work correctly. This is due to the use of
a DynamicList type element in the UI (for example, for the RRATimespans
field). For this function argument val receives as array instead of a
string, so no additional conversion is required.

Signed-off-by: Aleksey Kolosov <[email protected]>
applications/luci-app-statistics/root/usr/libexec/stat-genconfig

index d60e1a69edde462b33fd0be73c3c2d4d30807d11..7e9deccb9ee88d38aefd101607ef6ebb7233d005 100755 (executable)
@@ -58,7 +58,7 @@ function parse_units(ustr) {
 
 const preprocess = {
        RRATimespans: function(val) {
-               return join(' ', map(split(val, /\s+/), parse_units));
+               return join(' ', map(type(val) == 'array' ? val :  split(val, /\s+/), parse_units));
        }
 };