Refine entry search and field ordering
This commit is contained in:
parent
563ec7c705
commit
f9d09e7fad
4 changed files with 25 additions and 19 deletions
|
|
@ -215,6 +215,14 @@ class HostsManagerApp(App):
|
||||||
"DNS Name Entry", id="edit-dns-entry-radio"
|
"DNS Name Entry", id="edit-dns-entry-radio"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with Vertical(classes="default-section") as hostnames:
|
||||||
|
hostnames.border_title = "Hostnames (comma-separated)"
|
||||||
|
yield Input(
|
||||||
|
placeholder="Enter hostnames",
|
||||||
|
id="hostname-input",
|
||||||
|
classes="default-input",
|
||||||
|
)
|
||||||
|
|
||||||
with Vertical(
|
with Vertical(
|
||||||
classes="default-section", id="edit-ip-section"
|
classes="default-section", id="edit-ip-section"
|
||||||
) as ip_address:
|
) as ip_address:
|
||||||
|
|
@ -235,14 +243,6 @@ class HostsManagerApp(App):
|
||||||
classes="default-input",
|
classes="default-input",
|
||||||
)
|
)
|
||||||
|
|
||||||
with Vertical(classes="default-section") as hostnames:
|
|
||||||
hostnames.border_title = "Hostnames (comma-separated)"
|
|
||||||
yield Input(
|
|
||||||
placeholder="Enter hostnames",
|
|
||||||
id="hostname-input",
|
|
||||||
classes="default-input",
|
|
||||||
)
|
|
||||||
|
|
||||||
with Vertical(classes="default-section") as comment:
|
with Vertical(classes="default-section") as comment:
|
||||||
comment.border_title = "Comment:"
|
comment.border_title = "Comment:"
|
||||||
yield Input(
|
yield Input(
|
||||||
|
|
|
||||||
|
|
@ -425,9 +425,9 @@ class EditHandler:
|
||||||
active_checkbox = self.app.query_one("#active-checkbox", Checkbox)
|
active_checkbox = self.app.query_one("#active-checkbox", Checkbox)
|
||||||
|
|
||||||
# Build field list based on current entry type
|
# Build field list based on current entry type
|
||||||
fields = [radio_set]
|
fields = [radio_set, hostname_input]
|
||||||
|
|
||||||
# Add IP or DNS field based on visibility
|
# The address field follows Hostnames in the visual editor.
|
||||||
try:
|
try:
|
||||||
ip_section = self.app.query_one("#edit-ip-section")
|
ip_section = self.app.query_one("#edit-ip-section")
|
||||||
if not ip_section.has_class("hidden"):
|
if not ip_section.has_class("hidden"):
|
||||||
|
|
@ -444,8 +444,7 @@ class EditHandler:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Add remaining fields
|
fields.extend([comment_input, active_checkbox])
|
||||||
fields.extend([hostname_input, comment_input, active_checkbox])
|
|
||||||
|
|
||||||
# Find currently focused field and move to next
|
# Find currently focused field and move to next
|
||||||
for i, field in enumerate(fields):
|
for i, field in enumerate(fields):
|
||||||
|
|
@ -471,9 +470,9 @@ class EditHandler:
|
||||||
active_checkbox = self.app.query_one("#active-checkbox", Checkbox)
|
active_checkbox = self.app.query_one("#active-checkbox", Checkbox)
|
||||||
|
|
||||||
# Build field list based on current entry type
|
# Build field list based on current entry type
|
||||||
fields = [radio_set]
|
fields = [radio_set, hostname_input]
|
||||||
|
|
||||||
# Add IP or DNS field based on visibility
|
# The address field follows Hostnames in the visual editor.
|
||||||
try:
|
try:
|
||||||
ip_section = self.app.query_one("#edit-ip-section")
|
ip_section = self.app.query_one("#edit-ip-section")
|
||||||
if not ip_section.has_class("hidden"):
|
if not ip_section.has_class("hidden"):
|
||||||
|
|
@ -490,8 +489,7 @@ class EditHandler:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Add remaining fields
|
fields.extend([comment_input, active_checkbox])
|
||||||
fields.extend([hostname_input, comment_input, active_checkbox])
|
|
||||||
|
|
||||||
# Find currently focused field and move to previous
|
# Find currently focused field and move to previous
|
||||||
for i, field in enumerate(fields):
|
for i, field in enumerate(fields):
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,14 @@ HOSTS_MANAGER_CSS = (
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#filter-summary {
|
||||||
|
width: auto;
|
||||||
|
height: 1;
|
||||||
|
padding: 0 1;
|
||||||
|
content-align: right middle;
|
||||||
|
color: $text-muted;
|
||||||
|
}
|
||||||
|
|
||||||
.hosts-container {
|
.hosts-container {
|
||||||
height: 1fr;
|
height: 1fr;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
|
|
||||||
|
|
@ -168,8 +168,8 @@ class TableHandler:
|
||||||
arrow = "↑" if self.app.sort_ascending else "↓"
|
arrow = "↑" if self.app.sort_ascending else "↓"
|
||||||
hostname_label = f"{arrow} Canonical Hostname"
|
hostname_label = f"{arrow} Canonical Hostname"
|
||||||
|
|
||||||
# Add columns with proper labels (Active, IP, Hostname, DNS)
|
# Keep the canonical hostname beside state for fast table scanning.
|
||||||
table.add_columns(active_label, ip_label, hostname_label, dns_label)
|
table.add_columns(active_label, hostname_label, ip_label, dns_label)
|
||||||
|
|
||||||
# Get visible entries (after filtering)
|
# Get visible entries (after filtering)
|
||||||
visible_entries = self.get_visible_entries()
|
visible_entries = self.get_visible_entries()
|
||||||
|
|
@ -199,7 +199,7 @@ class TableHandler:
|
||||||
active_text = Text("· Inactive", style="dim")
|
active_text = Text("· Inactive", style="dim")
|
||||||
ip_text = Text(entry.ip_address, style="dim")
|
ip_text = Text(entry.ip_address, style="dim")
|
||||||
hostname_text = Text(canonical_hostname, style="dim")
|
hostname_text = Text(canonical_hostname, style="dim")
|
||||||
table.add_row(active_text, ip_text, hostname_text, dns_text)
|
table.add_row(active_text, hostname_text, ip_text, dns_text)
|
||||||
|
|
||||||
def restore_cursor_position(self, previous_entry) -> None:
|
def restore_cursor_position(self, previous_entry) -> None:
|
||||||
"""Restore cursor position after reload, maintaining selection if possible."""
|
"""Restore cursor position after reload, maintaining selection if possible."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue