luci-app-ddns: fix fileUpload
authorPaul Donald <newtwen+github@gmail.com>
Sat, 7 Dec 2024 01:31:54 +0000 (02:31 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Sat, 7 Dec 2024 01:32:11 +0000 (02:32 +0100)
some extra validation checks for "custom" service type
uci.set(..., null) -> uci.unset()

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js

index 405468cc7585a91042568467140a325686ec108d..95451be6f0d9bf8f83cd747326ddbca61ec379a0 100644 (file)
@@ -514,7 +514,8 @@ return view.extend({
                        service_name.value('-',"📝 " + _("custom") );
                        Object.keys(_this.services).sort().forEach(name => service_name.value(name));
                        service_name.validate = function(section_id, value) {
-                               if (value == '') return _("Select a service");
+                               if (value == '-') return true;
+                               if (!value) return _("Select a service");
                                if (!s2.service_supported) return _("Service doesn't support this IP type");
                                return true;
                        };
@@ -639,14 +640,15 @@ return view.extend({
                                };
                                service_name.write = function(section_id, service) {
                                        if (service != '-') {
-                                               uci.set('ddns', section_id, 'update_url', null);
-                                               uci.set('ddns', section_id, 'update_script', null);
+                                               uci.unset('ddns', section_id, 'update_url');
+                                               uci.unset('ddns', section_id, 'update_script');
                                                return uci.set('ddns', section_id, 'service_name', service);
                                        }
-                                       return uci.set('ddns', section_id, 'service_name', null);
+                                       return uci.unset('ddns', section_id, 'service_name');
                                };
                                service_name.validate = function(section_id, value) {
-                                       if (value == '') return _("Select a service");
+                                       if (value == '-') return true;
+                                       if (!value) return _("Select a service");
                                        if (!s.service_available) return _('Service not installed');
                                        if (!s.service_supported) return _("Service doesn't support this IP type");
                                        return true;
@@ -710,7 +712,7 @@ return view.extend({
                                                _("Custom update-script"),
                                                _("Custom update script for updating your DDNS Provider."));
                                        o.root_directory = '/usr/lib/ddns/';
-                                       o.browser = true;
+                                       o.datatype = 'file';
                                        o.show_hidden = true;
                                        o.enable_upload = true;
                                        o.enable_remove = true;