luci-app-banip: sync with update 1.5.6-5
authorDirk Brenken <[email protected]>
Sat, 14 Jun 2025 17:50:04 +0000 (19:50 +0200)
committerDirk Brenken <[email protected]>
Sat, 14 Jun 2025 17:50:34 +0000 (19:50 +0200)
Signed-off-by: Dirk Brenken <[email protected]>
(cherry picked from commit 2ac7444d33426d8483f57dc5efc5fa38d1491943)

applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js

index 27067cf138c8182de192269adc678bf40fbaec41..13fab6042ba7fc3b8b219071b4072a7b9ee33883 100644 (file)
@@ -98,7 +98,8 @@ function handleAction(report, ev) {
                                                'class': 'cbi-checkbox',
                                                'data-update': 'click change',
                                                'type': 'checkbox',
-                                               'id': 'filter',
+                                               'id': 'chkFilter',
+                                               'disabled': 'disabled',
                                                'value': 'true'
                                        }),
                                        E('span', { 'style': 'margin-left: .5em;' }, _('Show only Set elements with hits'))
@@ -124,7 +125,7 @@ function handleAction(report, ev) {
                                E('button', {
                                        'class': 'btn cbi-button-action',
                                        'click': ui.createHandlerFn(this, function (ev) {
-                                               const checkbox = document.getElementById('filter');
+                                               const checkbox = document.getElementById('chkFilter');
                                                const isChecked = checkbox.checked;
                                                let set = document.getElementById('set').value;
                                                if (set) {
@@ -140,10 +141,16 @@ function handleAction(report, ev) {
                                }, _('Show Content'))
                        ])
                ]);
+               if (uci.get('banip', 'global', 'ban_nftcount') === '1') {
+                       const chk = document.querySelector('#chkFilter');
+                       if (chk) {
+                               chk.removeAttribute('disabled');
+                       }
+               }
                document.getElementById('set').focus();
        }
        if (ev === 'map') {
-               let md = ui.showModal(null, [
+               const modal = ui.showModal(null, [
                        E('div', { id: 'mapModal',
                                                style: 'position: relative;' }, [
                                E('iframe', {
@@ -171,7 +178,7 @@ function handleAction(report, ev) {
                                }, _('Map Reset'))
                        ])
                ]);
-               md.style.maxWidth = '90%';
+               modal.style.maxWidth = '90%';
                document.getElementById('mapModal').focus();
        }
 }
@@ -235,7 +242,7 @@ return view.extend({
                }
                cbi_update_table(tblSets, rowSets);
 
-               return E('div', { 'class': 'cbi-map', 'id': 'cbimap' }, [
+               const page = E('div', { 'class': 'cbi-map', 'id': 'cbimap' }, [
                        E('div', { 'class': 'cbi-section' }, [
                                E('p', _('This report shows the latest NFT Set statistics, press the \'Refresh\' button to get a new one. \
                                        You can also display the specific content of Sets, search for suspicious IPs and finally, these IPs can also be displayed on a map.')),
@@ -286,13 +293,9 @@ return view.extend({
                                E('button', {
                                        'class': 'btn cbi-button cbi-button-apply',
                                        'style': 'float:none;margin-right:.4em;',
+                                       'id': 'btnMap',
+                                       'disabled': 'disabled',
                                        'click': ui.createHandlerFn(this, function () {
-                                               if (uci.get('banip', 'global', 'ban_nftcount') !== '1' || uci.get('banip', 'global', 'ban_map') !== '1') {
-                                                       if (!notMsg) {
-                                                               notMsg = true;
-                                                               return ui.addNotification(null, E('p', _('GeoIP Map is not enabled!')), 'info');
-                                                       }
-                                               }
                                                if (content[1] && content[1].length > 1) {
                                                        sessionStorage.setItem('mapData', JSON.stringify(content[1]));
                                                        return handleAction(report, 'map');
@@ -333,9 +336,16 @@ return view.extend({
                                                                location.reload();
                                                        })
                                        }
-                               }, [_('Refresh')]),
+                               }, [_('Refresh')])
                        ])
                ]);
+               if (uci.get('banip', 'global', 'ban_nftcount') === '1' && uci.get('banip', 'global', 'ban_map') === '1') {
+                       const btn = page.querySelector('#btnMap');
+                       if (btn) {
+                               btn.removeAttribute('disabled');
+                       }
+               }
+               return page;
        },
        handleSaveApply: null,
        handleSave: null,