www/caddy: Fix snake_case usage in controller (#4776)

This commit is contained in:
Monviech 2025-06-29 13:01:29 +02:00 committed by GitHub
parent 2bbbc77895
commit 00556eaf28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 20 deletions

View file

@ -40,9 +40,9 @@ class Layer4Controller extends IndexController
$this->view->pick('OPNsense/Caddy/reverse_proxy');
$this->view->formDialogLayer4 = $this->getForm('dialogLayer4');
$this->view->formGridLayer4 = $this->getFormGrid('dialogLayer4', 'Layer4');
$this->view->formGridLayer4 = $this->getFormGrid('dialogLayer4', 'layer4');
$this->view->formDialogLayer4Openvpn = $this->getForm('dialogLayer4Openvpn');
$this->view->formGridLayer4Openvpn = $this->getFormGrid('dialogLayer4Openvpn', 'Layer4Openvpn');
$this->view->formGridLayer4Openvpn = $this->getFormGrid('dialogLayer4Openvpn', 'layer4_openvpn');
}
}

View file

@ -40,21 +40,21 @@ class ReverseProxyController extends IndexController
$this->view->pick('OPNsense/Caddy/reverse_proxy');
$this->view->formDialogReverseProxy = $this->getForm("dialogReverseProxy");
$this->view->formGridReverseProxy = $this->getFormGrid('dialogReverseProxy', 'ReverseProxy');
$this->view->formGridReverseProxy = $this->getFormGrid('dialogReverseProxy', 'reverse_proxy');
$this->view->formDialogSubdomain = $this->getForm("dialogSubdomain");
$this->view->formGridSubdomain = $this->getFormGrid('dialogSubdomain', 'Subdomain');
$this->view->formGridSubdomain = $this->getFormGrid('dialogSubdomain', 'subdomain');
$this->view->formDialogHandle = $this->getForm("dialogHandle");
$this->view->formGridHandle = $this->getFormGrid('dialogHandle', 'Handle');
$this->view->formGridHandle = $this->getFormGrid('dialogHandle', 'handle');
$this->view->formDialogAccessList = $this->getForm("dialogAccessList");
$this->view->formGridAccessList = $this->getFormGrid('dialogAccessList', 'AccessList');
$this->view->formGridAccessList = $this->getFormGrid('dialogAccessList', 'access_list');
$this->view->formDialogBasicAuth = $this->getForm("dialogBasicAuth");
$this->view->formGridBasicAuth = $this->getFormGrid('dialogBasicAuth', 'BasicAuth');
$this->view->formGridBasicAuth = $this->getFormGrid('dialogBasicAuth', 'basic_auth');
$this->view->formDialogHeader = $this->getForm("dialogHeader");
$this->view->formGridHeader = $this->getFormGrid('dialogHeader', 'Header');
$this->view->formGridHeader = $this->getFormGrid('dialogHeader', 'header');
}
}

View file

@ -44,10 +44,6 @@
$(`#maintabs a[href="${location.hash}"]`).tab('show');
});
function to_snake_case(str) {
return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
}
// Bootgrid Setup
const all_grids = {};
@ -161,15 +157,14 @@
}
{% endif %}
const api_grid_id = to_snake_case(grid_id);
all_grids[grid_id] = $("#" + grid_id)
.UIBootgrid({
search: `/api/caddy/reverse_proxy/search_${api_grid_id}/`,
get: `/api/caddy/reverse_proxy/get_${api_grid_id}/`,
set: `/api/caddy/reverse_proxy/set_${api_grid_id}/`,
add: `/api/caddy/reverse_proxy/add_${api_grid_id}/`,
del: `/api/caddy/reverse_proxy/del_${api_grid_id}/`,
toggle: `/api/caddy/reverse_proxy/toggle_${api_grid_id}/`,
search: `/api/caddy/reverse_proxy/search_${grid_id}/`,
get: `/api/caddy/reverse_proxy/get_${grid_id}/`,
set: `/api/caddy/reverse_proxy/set_${grid_id}/`,
add: `/api/caddy/reverse_proxy/add_${grid_id}/`,
del: `/api/caddy/reverse_proxy/del_${grid_id}/`,
toggle: `/api/caddy/reverse_proxy/toggle_${grid_id}/`,
options: {
requestHandler: function (request) {
const selectedDomains = $('#reverseFilter').val();
@ -182,7 +177,7 @@
enabled: function (column) { return "" },
ToDomain: function (column) { return labels.upstream; },
FromDomain: function (column) {
if (grid_id === "Subdomain") {
if (grid_id === "subdomain") {
return labels.subdomain;
} else {
return labels.domain;