UI improvements
This commit is contained in:
@@ -21,13 +21,112 @@ CREATE TABLE IF NOT EXISTS clients (
|
||||
country TEXT,
|
||||
last_seen INTEGER,
|
||||
online INTEGER,
|
||||
ping_ms INTEGER
|
||||
ping_ms INTEGER,
|
||||
cpu TEXT,
|
||||
gpu TEXT,
|
||||
ram TEXT,
|
||||
battery_percent INTEGER,
|
||||
battery_charging INTEGER,
|
||||
is_admin INTEGER NOT NULL DEFAULT 0,
|
||||
elevation TEXT,
|
||||
enrollment_status TEXT NOT NULL DEFAULT 'approved',
|
||||
bookmarked INTEGER NOT NULL DEFAULT 0,
|
||||
notifications_muted INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
"""
|
||||
|
||||
ROLES = ["client", "viewer"]
|
||||
OSES = ["windows", "linux", "darwin", "ubuntu", "debian", "arch", "kali", "fedora"]
|
||||
ARCHES = ["amd64", "arm64", "x86", "arm"]
|
||||
OS_PROFILES = [
|
||||
{
|
||||
"os": "Windows 11 Pro 23H2",
|
||||
"arches": ["amd64", "arm64"],
|
||||
"cpus": ["Intel(R) Core(TM) i7-13700H", "Intel(R) Core(TM) i9-13900K", "AMD Ryzen 7 7840U"],
|
||||
"gpus": ["NVIDIA GeForce RTX 4070 Laptop GPU", "Intel Iris Xe Graphics", "AMD Radeon 780M"],
|
||||
"ram": ["16 GB", "32 GB", "64 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
{
|
||||
"os": "Windows 10 Pro 22H2",
|
||||
"arches": ["amd64", "x86"],
|
||||
"cpus": ["Intel(R) Core(TM) i5-10400", "Intel(R) Core(TM) i7-9700K", "AMD Ryzen 5 3600"],
|
||||
"gpus": ["NVIDIA GeForce GTX 1660", "Intel UHD Graphics 630", "AMD Radeon RX 580"],
|
||||
"ram": ["8 GB", "16 GB", "32 GB"],
|
||||
"battery": False,
|
||||
},
|
||||
{
|
||||
"os": "Ubuntu 24.04.1 LTS",
|
||||
"arches": ["amd64", "arm64"],
|
||||
"cpus": ["AMD Ryzen 9 7950X", "Intel(R) Core(TM) i7-12700", "Apple M2"],
|
||||
"gpus": ["NVIDIA GeForce RTX 3060", "AMD Radeon RX 6700 XT", "llvmpipe"],
|
||||
"ram": ["8 GB", "16 GB", "32 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
{
|
||||
"os": "Debian GNU/Linux 12 (bookworm)",
|
||||
"arches": ["amd64", "arm64"],
|
||||
"cpus": ["Intel(R) Xeon(R) CPU E5-2670", "AMD EPYC 7282", "Intel(R) Core(TM) i5-8250U"],
|
||||
"gpus": ["virtio_gpu", "Intel UHD Graphics 620", "NVIDIA T400"],
|
||||
"ram": ["4 GB", "8 GB", "16 GB"],
|
||||
"battery": False,
|
||||
},
|
||||
{
|
||||
"os": "Fedora Linux 40 (Workstation Edition)",
|
||||
"arches": ["amd64"],
|
||||
"cpus": ["AMD Ryzen 7 5800X", "Intel(R) Core(TM) Ultra 7 155H"],
|
||||
"gpus": ["AMD Radeon RX 6800", "Intel Arc Graphics"],
|
||||
"ram": ["16 GB", "32 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
{
|
||||
"os": "Arch Linux",
|
||||
"arches": ["amd64"],
|
||||
"cpus": ["AMD Ryzen 5 7600X", "Intel(R) Core(TM) i5-13600K"],
|
||||
"gpus": ["NVIDIA GeForce RTX 3080", "AMD Radeon RX 7900 XT"],
|
||||
"ram": ["16 GB", "32 GB", "64 GB"],
|
||||
"battery": False,
|
||||
},
|
||||
{
|
||||
"os": "Kali GNU/Linux Rolling",
|
||||
"arches": ["amd64", "arm64"],
|
||||
"cpus": ["Intel(R) Core(TM) i7-8650U", "AMD Ryzen 5 PRO 4650U"],
|
||||
"gpus": ["Intel UHD Graphics 620", "VMware SVGA II Adapter"],
|
||||
"ram": ["4 GB", "8 GB", "16 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
{
|
||||
"os": "Linux Mint 22",
|
||||
"arches": ["amd64"],
|
||||
"cpus": ["AMD Ryzen 7 5700U", "Intel(R) Core(TM) i5-1135G7"],
|
||||
"gpus": ["AMD Radeon Graphics", "Intel Iris Xe Graphics"],
|
||||
"ram": ["8 GB", "16 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
{
|
||||
"os": "Red Hat Enterprise Linux 9.4",
|
||||
"arches": ["amd64"],
|
||||
"cpus": ["Intel(R) Xeon(R) Silver 4210", "AMD EPYC 7313P"],
|
||||
"gpus": ["Matrox G200e", "NVIDIA T1000"],
|
||||
"ram": ["32 GB", "64 GB", "128 GB"],
|
||||
"battery": False,
|
||||
},
|
||||
{
|
||||
"os": "openSUSE Tumbleweed",
|
||||
"arches": ["amd64"],
|
||||
"cpus": ["AMD Ryzen 9 7900", "Intel(R) Core(TM) i7-13700"],
|
||||
"gpus": ["AMD Radeon RX 7600", "Intel Arc A770"],
|
||||
"ram": ["16 GB", "32 GB"],
|
||||
"battery": False,
|
||||
},
|
||||
{
|
||||
"os": "macOS 14.5",
|
||||
"arches": ["arm64", "amd64"],
|
||||
"cpus": ["Apple M2", "Apple M2 Pro", "Apple M3 Max", "Intel(R) Core(TM) i9-9980HK"],
|
||||
"gpus": ["Apple GPU", "AMD Radeon Pro 5500M"],
|
||||
"ram": ["8 GB", "16 GB", "32 GB", "64 GB"],
|
||||
"battery": True,
|
||||
},
|
||||
]
|
||||
COUNTRIES = [
|
||||
"US",
|
||||
"GB",
|
||||
@@ -73,10 +172,11 @@ def random_version() -> str:
|
||||
def random_row(now_ms: int, online_rate: float) -> Tuple:
|
||||
client_id = uuid.uuid4().hex
|
||||
hwid = uuid.uuid4().hex
|
||||
role = random.choice(ROLES)
|
||||
role = "client" if random.random() > 0.02 else random.choice(ROLES)
|
||||
host = random_host()
|
||||
os_name = random.choice(OSES)
|
||||
arch = random.choice(ARCHES)
|
||||
profile = random.choice(OS_PROFILES)
|
||||
os_name = profile["os"]
|
||||
arch = random.choice(profile.get("arches") or ARCHES)
|
||||
version = random_version()
|
||||
user = random_user()
|
||||
monitors = random.randint(1, 3)
|
||||
@@ -84,6 +184,20 @@ def random_row(now_ms: int, online_rate: float) -> Tuple:
|
||||
last_seen = now_ms - random.randint(0, 7 * 24 * 60 * 60 * 1000)
|
||||
online = 1 if random.random() < online_rate else 0
|
||||
ping_ms = random.choice([None, random.randint(10, 400), random.randint(400, 2000)])
|
||||
cpu = random.choice(profile["cpus"])
|
||||
gpu = random.choice(profile["gpus"])
|
||||
ram = random.choice(profile["ram"])
|
||||
battery_percent = None
|
||||
battery_charging = None
|
||||
if profile.get("battery") and random.random() < 0.72:
|
||||
battery_percent = random.randint(7, 100)
|
||||
battery_charging = 1 if random.random() < 0.38 else 0
|
||||
is_admin = 1 if random.random() < 0.22 else 0
|
||||
elevation = random.choice(["user", "admin", "system", None])
|
||||
if is_admin and elevation == "user":
|
||||
elevation = "admin"
|
||||
bookmarked = 1 if random.random() < 0.08 else 0
|
||||
notifications_muted = 1 if random.random() < 0.05 else 0
|
||||
return (
|
||||
client_id,
|
||||
hwid,
|
||||
@@ -98,6 +212,16 @@ def random_row(now_ms: int, online_rate: float) -> Tuple:
|
||||
last_seen,
|
||||
online,
|
||||
ping_ms,
|
||||
cpu,
|
||||
gpu,
|
||||
ram,
|
||||
battery_percent,
|
||||
battery_charging,
|
||||
is_admin,
|
||||
elevation,
|
||||
"approved",
|
||||
bookmarked,
|
||||
notifications_muted,
|
||||
)
|
||||
|
||||
|
||||
@@ -117,9 +241,30 @@ def batched_rows(
|
||||
|
||||
def ensure_schema(conn: sqlite3.Connection) -> None:
|
||||
conn.execute(SCHEMA)
|
||||
columns = {
|
||||
row[1] for row in conn.execute("PRAGMA table_info(clients)").fetchall()
|
||||
}
|
||||
additions = {
|
||||
"cpu": "TEXT",
|
||||
"gpu": "TEXT",
|
||||
"ram": "TEXT",
|
||||
"battery_percent": "INTEGER",
|
||||
"battery_charging": "INTEGER",
|
||||
"is_admin": "INTEGER NOT NULL DEFAULT 0",
|
||||
"elevation": "TEXT",
|
||||
"enrollment_status": "TEXT NOT NULL DEFAULT 'approved'",
|
||||
"bookmarked": "INTEGER NOT NULL DEFAULT 0",
|
||||
"notifications_muted": "INTEGER NOT NULL DEFAULT 0",
|
||||
}
|
||||
for name, decl in additions.items():
|
||||
if name not in columns:
|
||||
conn.execute(f"ALTER TABLE clients ADD COLUMN {name} {decl}")
|
||||
|
||||
|
||||
def seed(db_path: str, count: int, truncate: bool, online_rate: float) -> None:
|
||||
parent = os.path.dirname(os.path.abspath(db_path))
|
||||
if parent:
|
||||
os.makedirs(parent, exist_ok=True)
|
||||
conn = sqlite3.connect(db_path)
|
||||
try:
|
||||
ensure_schema(conn)
|
||||
@@ -127,8 +272,8 @@ def seed(db_path: str, count: int, truncate: bool, online_rate: float) -> None:
|
||||
conn.execute("DELETE FROM clients")
|
||||
conn.commit()
|
||||
sql = (
|
||||
"INSERT INTO clients (id, hwid, role, host, os, arch, version, user, monitors, country, last_seen, online, ping_ms) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
"INSERT INTO clients (id, hwid, role, host, os, arch, version, user, monitors, country, last_seen, online, ping_ms, cpu, gpu, ram, battery_percent, battery_charging, is_admin, elevation, enrollment_status, bookmarked, notifications_muted) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
)
|
||||
total = 0
|
||||
for batch in batched_rows(count, online_rate=online_rate):
|
||||
@@ -164,7 +309,7 @@ def main() -> None:
|
||||
"--count",
|
||||
type=int,
|
||||
default=100000,
|
||||
help="How many rows to insert (default: 10000)",
|
||||
help="How many rows to insert (default: 100000)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--truncate", action="store_true", help="Delete existing rows before seeding"
|
||||
|
||||
Reference in New Issue
Block a user