updated cel to alerts dialog, updated layout to support resizing, added styles for alert button to be different colors
This commit is contained in:
parent
da9d344c54
commit
fd83861399
3 changed files with 57 additions and 45 deletions
|
@ -8,36 +8,26 @@ from grpc import RpcError
|
||||||
|
|
||||||
from core.api.grpc import core_pb2
|
from core.api.grpc import core_pb2
|
||||||
from coretk.dialogs.dialog import Dialog
|
from coretk.dialogs.dialog import Dialog
|
||||||
from coretk.images import ImageEnum, Images
|
|
||||||
from coretk.themes import PADX, PADY
|
from coretk.themes import PADX, PADY
|
||||||
from coretk.widgets import CodeText
|
from coretk.widgets import CodeText
|
||||||
|
|
||||||
|
|
||||||
class CheckLight(Dialog):
|
class AlertsDialog(Dialog):
|
||||||
def __init__(self, master, app):
|
def __init__(self, master, app):
|
||||||
super().__init__(master, app, "CEL", modal=True)
|
super().__init__(master, app, "Alerts", modal=True)
|
||||||
self.app = app
|
self.app = app
|
||||||
self.tree = None
|
self.tree = None
|
||||||
self.text = None
|
self.text = None
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
self.top.columnconfigure(0, weight=1)
|
||||||
|
self.top.rowconfigure(0, weight=1)
|
||||||
|
self.top.rowconfigure(1, weight=1)
|
||||||
row = 0
|
row = 0
|
||||||
frame = ttk.Frame(self)
|
frame = ttk.Frame(self.top)
|
||||||
frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(0, weight=1)
|
||||||
frame.columnconfigure(1, weight=1)
|
frame.grid(row=row, column=0, sticky="nsew", pady=PADY)
|
||||||
image = Images.get(ImageEnum.ALERT, 18)
|
|
||||||
label = ttk.Label(frame, image=image)
|
|
||||||
label.image = image
|
|
||||||
label.grid(row=0, column=0, sticky="e")
|
|
||||||
label = ttk.Label(frame, text="Check Emulation Light")
|
|
||||||
label.grid(row=0, column=1, sticky="w")
|
|
||||||
frame.grid(row=row, column=0, padx=PADX, pady=PADY, sticky="nsew")
|
|
||||||
row = row + 1
|
|
||||||
|
|
||||||
frame = ttk.Frame(self)
|
|
||||||
frame.columnconfigure(0, weight=1)
|
|
||||||
frame.grid(row=row, column=0, sticky="nsew")
|
|
||||||
self.tree = ttk.Treeview(
|
self.tree = ttk.Treeview(
|
||||||
frame,
|
frame,
|
||||||
columns=("time", "level", "session_id", "node", "source"),
|
columns=("time", "level", "session_id", "node", "source"),
|
||||||
|
@ -86,27 +76,27 @@ class CheckLight(Dialog):
|
||||||
self.tree.configure(xscrollcommand=xscrollbar.set)
|
self.tree.configure(xscrollcommand=xscrollbar.set)
|
||||||
row = row + 1
|
row = row + 1
|
||||||
|
|
||||||
self.text = CodeText(self)
|
self.text = CodeText(self.top)
|
||||||
self.text.config(state=tk.DISABLED)
|
self.text.config(state=tk.DISABLED)
|
||||||
self.text.grid(row=row, column=0, sticky="nsew")
|
self.text.grid(row=row, column=0, sticky="nsew", pady=PADY)
|
||||||
row = row + 1
|
row = row + 1
|
||||||
|
|
||||||
frame = ttk.Frame(self)
|
frame = ttk.Frame(self.top)
|
||||||
|
frame.grid(row=row, column=0, sticky="nsew")
|
||||||
frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(0, weight=1)
|
||||||
frame.columnconfigure(1, weight=1)
|
frame.columnconfigure(1, weight=1)
|
||||||
frame.columnconfigure(2, weight=1)
|
frame.columnconfigure(2, weight=1)
|
||||||
frame.columnconfigure(3, weight=1)
|
frame.columnconfigure(3, weight=1)
|
||||||
button = ttk.Button(frame, text="Reset CEL", command=self.reset_cel)
|
button = ttk.Button(frame, text="Reset", command=self.reset_alerts)
|
||||||
button.grid(row=0, column=0, sticky="nsew", padx=PADX)
|
button.grid(row=0, column=0, sticky="ew", padx=PADX)
|
||||||
button = ttk.Button(frame, text="View core-daemon log", command=self.daemon_log)
|
button = ttk.Button(frame, text="Daemon Log", command=self.daemon_log)
|
||||||
button.grid(row=0, column=1, sticky="nsew", padx=PADX)
|
button.grid(row=0, column=1, sticky="ew", padx=PADX)
|
||||||
button = ttk.Button(frame, text="View node log")
|
button = ttk.Button(frame, text="Node Log")
|
||||||
button.grid(row=0, column=2, sticky="nsew", padx=PADX)
|
button.grid(row=0, column=2, sticky="ew", padx=PADX)
|
||||||
button = ttk.Button(frame, text="Close", command=self.destroy)
|
button = ttk.Button(frame, text="Close", command=self.destroy)
|
||||||
button.grid(row=0, column=3, sticky="nsew", padx=PADX)
|
button.grid(row=0, column=3, sticky="ew")
|
||||||
frame.grid(row=row, column=0, sticky="nsew")
|
|
||||||
|
|
||||||
def reset_cel(self):
|
def reset_alerts(self):
|
||||||
self.text.delete("1.0", tk.END)
|
self.text.delete("1.0", tk.END)
|
||||||
for item in self.tree.get_children():
|
for item in self.tree.get_children():
|
||||||
self.tree.delete(item)
|
self.tree.delete(item)
|
||||||
|
@ -160,20 +150,22 @@ class DaemonLog(Dialog):
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
frame = ttk.Frame(self)
|
self.top.columnconfigure(0, weight=1)
|
||||||
|
self.top.rowconfigure(1, weight=1)
|
||||||
|
frame = ttk.Frame(self.top)
|
||||||
|
frame.grid(row=0, column=0, sticky="ew", pady=PADY)
|
||||||
frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(0, weight=1)
|
||||||
frame.columnconfigure(1, weight=9)
|
frame.columnconfigure(1, weight=9)
|
||||||
label = ttk.Label(frame, text="File: ")
|
label = ttk.Label(frame, text="File: ")
|
||||||
label.grid(row=0, column=0)
|
label.grid(row=0, column=0)
|
||||||
entry = ttk.Entry(frame, textvariable=self.path, state="disabled")
|
entry = ttk.Entry(frame, textvariable=self.path, state="disabled")
|
||||||
entry.grid(row=0, column=1, sticky="nsew")
|
entry.grid(row=0, column=1, sticky="ew")
|
||||||
frame.grid(row=0, column=0, sticky="nsew")
|
|
||||||
try:
|
try:
|
||||||
file = open("/var/log/core-daemon.log", "r")
|
file = open("/var/log/core-daemon.log", "r")
|
||||||
log = file.readlines()
|
log = file.readlines()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
log = "Log file not found"
|
log = "Log file not found"
|
||||||
text = CodeText(self)
|
text = CodeText(self.top)
|
||||||
text.insert("1.0", log)
|
text.insert("1.0", log)
|
||||||
text.see("end")
|
text.see("end")
|
||||||
text.config(state=tk.DISABLED)
|
text.config(state=tk.DISABLED)
|
|
@ -2,22 +2,21 @@
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from coretk.dialogs.cel import CheckLight
|
from coretk.dialogs.alerts import AlertsDialog
|
||||||
from coretk.images import ImageEnum, Images
|
from coretk.themes import Styles
|
||||||
|
|
||||||
|
|
||||||
class StatusBar(ttk.Frame):
|
class StatusBar(ttk.Frame):
|
||||||
def __init__(self, master, app, **kwargs):
|
def __init__(self, master, app, **kwargs):
|
||||||
super().__init__(master, **kwargs)
|
super().__init__(master, **kwargs)
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
self.status = None
|
self.status = None
|
||||||
self.statusvar = tk.StringVar()
|
self.statusvar = tk.StringVar()
|
||||||
self.progress_bar = None
|
self.progress_bar = None
|
||||||
self.zoom = None
|
self.zoom = None
|
||||||
self.cpu_usage = None
|
self.cpu_usage = None
|
||||||
self.memory = None
|
self.memory = None
|
||||||
self.emulation_light = None
|
self.alerts_button = None
|
||||||
self.running = False
|
self.running = False
|
||||||
self.core_alarms = []
|
self.core_alarms = []
|
||||||
self.draw()
|
self.draw()
|
||||||
|
@ -56,16 +55,13 @@ class StatusBar(ttk.Frame):
|
||||||
)
|
)
|
||||||
self.cpu_usage.grid(row=0, column=3, sticky="ew")
|
self.cpu_usage.grid(row=0, column=3, sticky="ew")
|
||||||
|
|
||||||
image = Images.get(ImageEnum.ALERT, 18)
|
self.alerts_button = ttk.Button(
|
||||||
self.emulation_light = ttk.Button(
|
self, text="Alerts", command=self.click_alerts, style=Styles.green_alert
|
||||||
self, image=image, text="Alert", compound="left"
|
|
||||||
)
|
)
|
||||||
self.emulation_light.image = image
|
self.alerts_button.grid(row=0, column=4, sticky="ew")
|
||||||
self.emulation_light.bind("<Button-1>", self.cel_callback)
|
|
||||||
self.emulation_light.grid(row=0, column=4, sticky="ew")
|
|
||||||
|
|
||||||
def cel_callback(self, event):
|
def click_alerts(self):
|
||||||
dialog = CheckLight(self.app, self.app)
|
dialog = AlertsDialog(self.app, self.app)
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def start_session_callback(self, process_time):
|
def start_session_callback(self, process_time):
|
||||||
|
|
|
@ -13,6 +13,9 @@ class Styles:
|
||||||
tooltip_frame = "Tooltip.TFrame"
|
tooltip_frame = "Tooltip.TFrame"
|
||||||
service_checkbutton = "Service.TCheckbutton"
|
service_checkbutton = "Service.TCheckbutton"
|
||||||
picker_button = "Picker.TButton"
|
picker_button = "Picker.TButton"
|
||||||
|
green_alert = "GAlert.TButton"
|
||||||
|
red_alert = "RAlert.TButton"
|
||||||
|
yellow_alert = "YAlert.TButton"
|
||||||
|
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
|
@ -163,3 +166,24 @@ def update_menu(style, widget):
|
||||||
|
|
||||||
def theme_change(style, event):
|
def theme_change(style, event):
|
||||||
style.configure(Styles.picker_button, font=("TkDefaultFont", 8, "normal"))
|
style.configure(Styles.picker_button, font=("TkDefaultFont", 8, "normal"))
|
||||||
|
style.configure(
|
||||||
|
Styles.green_alert,
|
||||||
|
background="green",
|
||||||
|
padding=0,
|
||||||
|
relief=tk.NONE,
|
||||||
|
font=("TkDefaultFont", 8, "normal"),
|
||||||
|
)
|
||||||
|
style.configure(
|
||||||
|
Styles.yellow_alert,
|
||||||
|
background="yellow",
|
||||||
|
padding=0,
|
||||||
|
relief=tk.NONE,
|
||||||
|
font=("TkDefaultFont", 8, "normal"),
|
||||||
|
)
|
||||||
|
style.configure(
|
||||||
|
Styles.red_alert,
|
||||||
|
background="red",
|
||||||
|
padding=0,
|
||||||
|
relief=tk.NONE,
|
||||||
|
font=("TkDefaultFont", 8, "normal"),
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue