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
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
|
||||
"""
|
||||
Policy model representing policy data and relationships.
|
||||
"""
|
||||
|
||||
|
||||
class Policy:
|
||||
def __init__(self, groupid, hidden, name, parent):
|
||||
self.groupid = groupid
|
||||
self.hidden = hidden
|
||||
self.name = name
|
||||
self.parent = parent
|
||||
# policy.py
|
||||
|
||||
def __repr__(self):
|
||||
# Show all current attributes, including dynamically added ones
|
||||
from dataclasses import asdict, dataclass, field
|
||||
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(
|
||||
f"{key}={repr(value)}" for key, value in self.__dict__.items()
|
||||
)
|
||||
return f"<Execution({attrs})>"
|
||||
|
||||
def to_dict(self):
|
||||
# Return all attributes as a dictionary
|
||||
return self.__dict__
|
||||
def to_dict(self) -> dict:
|
||||
return asdict(self)
|
||||
|
||||
def to_json(self):
|
||||
# Convert to JSON string, handling non-serializable types gracefully
|
||||
def to_json(self) -> str:
|
||||
return json.dumps(self.to_dict(), default=str)
|
||||
|
||||
|
||||
|
||||
@@ -79,14 +79,14 @@ class MultiAgentSelector(Widget):
|
||||
with Horizontal() as select_buttons:
|
||||
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.styles.margin = (1, 0, 0, 1)
|
||||
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:
|
||||
button_row.styles.height = "auto"
|
||||
button_row.styles.margin = (1, 0, 0, 0)
|
||||
|
||||
@@ -108,6 +108,7 @@ class PolicySelector(Widget):
|
||||
with Vertical() as left_side:
|
||||
left_side.styles.width = "1fr"
|
||||
left_side.styles.height = "auto"
|
||||
left_side.styles.margin = (0, 1, 0, 1)
|
||||
|
||||
filter_label = Static("Filter Policies:")
|
||||
filter_label.styles.margin = (0, 0, 0, 0)
|
||||
@@ -130,7 +131,7 @@ class PolicySelector(Widget):
|
||||
apply_button.styles.margin = (0, 0, 1, 0)
|
||||
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.margin = (0, 0, 1, 0)
|
||||
yield clear_button
|
||||
@@ -190,6 +191,7 @@ class PolicySelector(Widget):
|
||||
policies_list = self.policies.to_dict("records")
|
||||
else:
|
||||
policies_list = self.policies
|
||||
policies_list = sorted(policies_list)
|
||||
|
||||
self._filtered_policies = []
|
||||
self._displayed_policies = [] # Initialize displayed list
|
||||
|
||||
Reference in New Issue
Block a user