Minor UI Tweak
This commit is contained in:
+17
-14
@@ -13,33 +13,36 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Policy model representing policy data and relationships.
|
Policy model representing policy data and relationships.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Policy:
|
# policy.py
|
||||||
def __init__(self, groupid, hidden, name, parent):
|
|
||||||
self.groupid = groupid
|
|
||||||
self.hidden = hidden
|
|
||||||
self.name = name
|
|
||||||
self.parent = parent
|
|
||||||
|
|
||||||
def __repr__(self):
|
from dataclasses import asdict, dataclass, field
|
||||||
# Show all current attributes, including dynamically added ones
|
import json
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(order=True)
|
||||||
|
class Policy:
|
||||||
|
name: str
|
||||||
|
groupid: int = field(compare=False)
|
||||||
|
hidden: bool = field(compare=False)
|
||||||
|
parent: Optional[str] = field(default=None, compare=False)
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
attrs = ", ".join(
|
attrs = ", ".join(
|
||||||
f"{key}={repr(value)}" for key, value in self.__dict__.items()
|
f"{key}={repr(value)}" for key, value in self.__dict__.items()
|
||||||
)
|
)
|
||||||
return f"<Execution({attrs})>"
|
return f"<Execution({attrs})>"
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self) -> dict:
|
||||||
# Return all attributes as a dictionary
|
return asdict(self)
|
||||||
return self.__dict__
|
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self) -> str:
|
||||||
# Convert to JSON string, handling non-serializable types gracefully
|
|
||||||
return json.dumps(self.to_dict(), default=str)
|
return json.dumps(self.to_dict(), default=str)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ class MultiAgentSelector(Widget):
|
|||||||
with Horizontal() as select_buttons:
|
with Horizontal() as select_buttons:
|
||||||
select_buttons.styles.margin = (0, 0, 0, 0)
|
select_buttons.styles.margin = (0, 0, 0, 0)
|
||||||
|
|
||||||
select_all_button = Button("✅ Select All", id="select_all")
|
|
||||||
select_all_button.styles.margin = (1, 1, 0, 1)
|
|
||||||
yield select_all_button
|
|
||||||
|
|
||||||
select_none_button = Button("🚫 Select None", id="select_none")
|
select_none_button = Button("🚫 Select None", id="select_none")
|
||||||
select_none_button.styles.margin = (1, 0, 0, 1)
|
select_none_button.styles.margin = (1, 0, 0, 1)
|
||||||
yield select_none_button
|
yield select_none_button
|
||||||
|
|
||||||
|
select_all_button = Button("✅ Select All", id="select_all")
|
||||||
|
select_all_button.styles.margin = (1, 1, 0, 1)
|
||||||
|
yield select_all_button
|
||||||
|
|
||||||
with Horizontal() as button_row:
|
with Horizontal() as button_row:
|
||||||
button_row.styles.height = "auto"
|
button_row.styles.height = "auto"
|
||||||
button_row.styles.margin = (1, 0, 0, 0)
|
button_row.styles.margin = (1, 0, 0, 0)
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class PolicySelector(Widget):
|
|||||||
with Vertical() as left_side:
|
with Vertical() as left_side:
|
||||||
left_side.styles.width = "1fr"
|
left_side.styles.width = "1fr"
|
||||||
left_side.styles.height = "auto"
|
left_side.styles.height = "auto"
|
||||||
|
left_side.styles.margin = (0, 1, 0, 1)
|
||||||
|
|
||||||
filter_label = Static("Filter Policies:")
|
filter_label = Static("Filter Policies:")
|
||||||
filter_label.styles.margin = (0, 0, 0, 0)
|
filter_label.styles.margin = (0, 0, 0, 0)
|
||||||
@@ -130,7 +131,7 @@ class PolicySelector(Widget):
|
|||||||
apply_button.styles.margin = (0, 0, 1, 0)
|
apply_button.styles.margin = (0, 0, 1, 0)
|
||||||
yield apply_button
|
yield apply_button
|
||||||
|
|
||||||
clear_button = Button("🗑️ Clear Filter", id="clear_filter_button")
|
clear_button = Button("Clear Filter", id="clear_filter_button")
|
||||||
clear_button.styles.width = "100%"
|
clear_button.styles.width = "100%"
|
||||||
clear_button.styles.margin = (0, 0, 1, 0)
|
clear_button.styles.margin = (0, 0, 1, 0)
|
||||||
yield clear_button
|
yield clear_button
|
||||||
@@ -190,6 +191,7 @@ class PolicySelector(Widget):
|
|||||||
policies_list = self.policies.to_dict("records")
|
policies_list = self.policies.to_dict("records")
|
||||||
else:
|
else:
|
||||||
policies_list = self.policies
|
policies_list = self.policies
|
||||||
|
policies_list = sorted(policies_list)
|
||||||
|
|
||||||
self._filtered_policies = []
|
self._filtered_policies = []
|
||||||
self._displayed_policies = [] # Initialize displayed list
|
self._displayed_policies = [] # Initialize displayed list
|
||||||
|
|||||||
Reference in New Issue
Block a user