luci-app-commands: move URL building to client side
authorJo-Philipp Wich <[email protected]>
Sat, 27 Jul 2024 23:14:46 +0000 (01:14 +0200)
committerJo-Philipp Wich <[email protected]>
Sat, 27 Jul 2024 23:14:46 +0000 (01:14 +0200)
Replace server side dispatcher.build_url() with client side L.url() calls.

Signed-off-by: Jo-Philipp Wich <[email protected]>
applications/luci-app-commands/ucode/template/commands.ut

index 48850598d7a33beb11a286b87533ef1650b2ee3e..f11efe948c79c787badcdb37c8f12d1f94c6d496 100644 (file)
@@ -51,7 +51,7 @@
                        legend.parentNode.style.display = 'block';
                        legend.style.display = 'inline';
 
-                       stxhr.get('{{ dispatcher.build_url('admin/system/commands/run') }}/' + id + (args ? '?args=' + args : ''), null,
+                       stxhr.get(L.url('admin/system/commands/run', id) + (args ? '?args=' + args : ''), null,
                                function(x, st)
                                {
                                        if (st)
@@ -88,7 +88,7 @@
                if (field)
                        args = encodeURIComponent(field.value);
 
-               location.href = '{{ dispatcher.build_url('admin/system/commands/download') }}/' + id + (args ? '/' + args : '');
+               location.href = L.url('admin/system/commands/download', id) + (args ? '/' + args : '');
 
                ev.preventDefault();
        }
 
                if (legend && output)
                {
-                       var prefix = location.protocol + '//' + location.host + '{{ dispatcher.build_url('command') }}/';
+                       var prefix = location.protocol + '//' + location.host + L.url('command') + '/';
                        var suffix = (args ? '?args=' + args : '');
 
                        var link = prefix + id + suffix;