alpha v0.941
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from flask import flash, redirect, render_template, request, url_for
|
||||
|
||||
|
||||
@@ -72,6 +74,7 @@ def computers_list(
|
||||
SELECT c.id, c.inventory_number, c.brand, c.model, c.serial_number, c.type,
|
||||
c.cpu_brand, c.cpu_model, c.gpu_model, c.memory_size, c.memory_type,
|
||||
c.storage_size, c.motherboard, c.os, c.rustdesk_id, c.rustdesk_password,
|
||||
c.hostname, c.ip_address, c.mac_address, c.is_online, c.last_seen,
|
||||
c.cabinet_id, cab.name AS cabinet_name,
|
||||
c.note, c.date_in_operation, c.date_added
|
||||
FROM computers c
|
||||
@@ -89,7 +92,17 @@ def computers_list(
|
||||
c.id
|
||||
"""
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
raw_rows = cur.fetchall()
|
||||
now = datetime.now()
|
||||
offline_after = timedelta(minutes=5)
|
||||
rows = []
|
||||
for row in raw_rows:
|
||||
last_seen = row[19]
|
||||
is_online = bool(row[18])
|
||||
if last_seen and now - last_seen > offline_after:
|
||||
is_online = False
|
||||
status_label = "Online" if is_online else "Offline"
|
||||
rows.append(tuple(row) + (status_label,))
|
||||
total_computers = len(rows)
|
||||
laptops_count = 0
|
||||
pcs_count = 0
|
||||
|
||||
Reference in New Issue
Block a user