The "Add" button has the same `.saveRevServers` CSS class as the other
normal "Save" buttons. This is fine and simplifies the code, as all rows
(including the last one) use the same validation pattern and functions.
The only difference is the `addRevServer` function, used to save the new
values.
Preceding the selector with `tbody`, makes sure only the normal "Save"
buttons will use the `saveRecord()` function.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
- add a placeholder using CSS
- use a javascript to trim undesired spaces. This command also removes the
"hidden" line break automatically added by browsers when the content of
an editable element is cleared/deleted.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
- remove `<input>` tags and add contenteditable attribute to all
editable cells
- rows are always enabled now (no "edit" button to enable them)
- Simplify javascript code:
- use classNames to simplify column selection, instead of unique ids
- use datatables "columnDefs" and "createdCell" to add attributes
- use CSS class "editing" and CSS rules to handle buttons
- remove unused and unnecessary attributes from elements
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Previously, the same function was used to initialize the table and update
the table rows, when lines were added, edited or deleted.
Now, one function initializes the table and another function saves the
changes, shows a message and updates the table to reflect the changes.
The values are "saved and applied" immediately using an AJAX call.
The waitMe overlay is also shown, but the page is NOT reloaded.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
- add functions and buttons to add, modify, undo changes and delete lines
- generate the table using data already on the textarea
- add functions to read textarea contents and parse then into an array
- add functions to update the textarea contents from the table
- hide the textarea. Only the table will be visible
- make sure the table is not shown when the option was set by ENV VARS
- move some help paragraphs to the table legend
- remove usused original help text for the textarea
- use fixed size for all action buttons
- don't use "icheck" styling on the checkboxes in the table
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Add an editable table to edit simple static DHCP leases (consisting of MAC Address, IP and hostname).
All advanced options will still available using the text area.
WebKit-based browsers (Safari, DuckDuckGo on macOS) don't yet support
the ES2024 Unicode Sets `v` regex flag, causing a SyntaxError that
prevents all dashboard JavaScript from executing — stats show `---` and
charts spin indefinitely.
None of the affected patterns use v-exclusive features (set notation
`[A--B]`, `[A&&B]`), so downgrading to `u` is fully equivalent and
restores broad compatibility without any functional change.
Also updates xo.config.js to enforce `requireFlag: "u"` so the linter
stays consistent with the codebase.
Affected files (16 occurrences across 8 files):
- scripts/js/utils.js
- scripts/js/index.js
- scripts/js/footer.js
- scripts/js/groups-domains.js
- scripts/js/settings-teleporter.js
- scripts/js/gravity.js
- scripts/js/groups.js
- scripts/js/groups-clients.js
- scripts/js/groups-lists.js
- scripts/js/settings-dns-records.js
- scripts/js/network.js
- scripts/js/taillog.js
Signed-off-by: Austin Gilmour <gilmoursa@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Now we allow invalid values on the table and highlight them.
This will allow users to find errors in data already saved on pihole.toml.
New parsing rules added - The line is also considered as "advanced" if:
- the line contains an asterisk;
- more than one IP is found;
- more than one Mac Address is found;
- more than one hostname is found.
The table also highlights invalid data onload, before a row is clicked.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Also fix 2 issues on validation functions:
- better regex for validateMAC()
- make sure validateIPv6Brackets() correctly trims the value before
validation
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This function tries to use a simplified version of the dnsmasq code used
to parse dhcp-host options.
Also, use the parse function when we cancel edit operation on a line
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Only accept valid hostnames:
Previously, invalid hostnames were trigerring the cell highlighting,
but invalid entries were still accepted when using the green "save"
button. Now, hostnames are saved only if they pass the validation,
like other values.
Only allow IPv6 enclosed in square brackets:
The previous validation function used to validate IPv6 didn't accept
brackets, resulting in errors when an IPv6 was typed directly on the
table cell. A new function was created to validate IPv6 enclosed in
brackets.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Dinamically created buttons were not showing bootstrap tooltips because
the event listener was created too early, before the buttons were
created (only previuosly existing buttons would show a tooltip).
Now, tooptip() function is called once, on the body element.
This attaches an event listener to the body. Every dynamically created
button will display the tooltip, without the need to call tooltip()
function. We need to manually call .tooltip("hide"), to remove tooltips
when buttons are clicked.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Remove the javascript code used to add and remove "hints" and replace it
with a single CSS pseudo-element after the table, instead of one message
per line. Also, adjust LCARS message position.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
If enabled, the textarea can be edited, which triggers a table rewrite,
resulting in the loss of all unsaved changes made to the table rows.
This commit keeps the textarea disabled until all edited rows are saved.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
- replace DOMContentLoaded listener with a function and call it when needed
- use javascript to update the CSS variable `--num-lines`
- use CSS to calculate the elements height
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
- only show save button when needed
- use fixed size and right aligned text for button column
- highlight cells only on error and remove the highlight when is fixed
- replace a few inline CSS styles with proper HTML tags
- adjust CSS on specific themes
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Fix regex adding `v` flag and fix line breaks to respect maximum lenght
Note: these issues were not previously reported because there was a
previous merge conflict. The prettier test was executed only after the
merge conflict was resolved.
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Resolve merge conflict in style/pi-hole.css (keep both StaticDHCPTable
styles and DNSSEC query log styles).
Address outstanding reviewer feedback:
- Change save button icon from floppy-disk to checkmark to clarify it
confirms the row edit, not a final save
- Update hint text to mention "Save & Apply" is still needed
- Add hostname validation on the hostname cell (rejects spaces, commas,
and other characters invalid in DNS names)
Signed-off-by: Dominik <dl6er@dl6er.de>