addIpLists.js 762 B

12345678910111213141516171819202122232425
  1. import { parseAndSortIpLists } from './helpers';
  2. // Populates the "IP address / IP list" select with created IP lists
  3. // on the Add Firewall Rule page
  4. export default function handleAddIpLists() {
  5. const ipListSelect = document.querySelector('.js-ip-list-select');
  6. if (!ipListSelect) {
  7. return;
  8. }
  9. const ipSetLists = parseAndSortIpLists(ipListSelect.dataset.ipsetLists);
  10. const headerOption = document.createElement('option');
  11. headerOption.textContent = 'IPset IP Lists';
  12. headerOption.disabled = true;
  13. ipListSelect.appendChild(headerOption);
  14. ipSetLists.forEach((ipSet) => {
  15. const ipOption = document.createElement('option');
  16. ipOption.textContent = ipSet.name;
  17. ipOption.value = `ipset:${ipSet.name}`;
  18. ipListSelect.appendChild(ipOption);
  19. });
  20. }