]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Log view: don't redraw when fetching 1000 log entries.
authorBram Matthys <redacted>
Fri, 5 May 2023 11:02:18 +0000 (13:02 +0200)
committerBram Matthys <redacted>
Fri, 5 May 2023 11:02:57 +0000 (13:02 +0200)
Instead, for historical logs, redraw every 100 events.
Then do an explicit redraw/sync. And then start the live ones.

Otherwise the CPU of the user browsing the panel is not happy :D

api/log.php
js/unrealircd-admin.js

index 12f053d9622f29b2f0f0def4ba7b5e9b849bf5e7..fdce5918974c525f0dc695cc97d94610e26f7130 100644 (file)
@@ -11,8 +11,18 @@ $response = $rpc->log()->getAll();
 if ($response !== false)
 {
     /* Only supported in later UnrealIRCd versions */
+    $cnt = 0;
     foreach($response as $r)
+    {
+        $r = (ARRAY)$r;
+        $cnt++;
+        if (($cnt % 100) != 0)
+            $r["sync_option"] = "no_sync";
         send_sse($r);
+    }
 }
 
+$r = ["sync_option"=>"sync_now"];
+send_sse($r);
+
 api_log_loop(["all", "!debug"]);
index 5d28b9b3b326b5cd6c6ca3a2751882a01a4daaf3..635cba40e9b9e48b0870d13f0bc0552b799b4407 100644 (file)
@@ -148,13 +148,19 @@ function NewLogEntry(e)
     } catch(e) {
         return;
     }
-    //$('#data_list_table').DataTable()
-    data_list_table.row.add({
-        'Time':data.timestamp,
-        'Level':data.level,
-        'Subsystem':data.subsystem,
-        'Event':data.event_id,
-        'Message':data.msg}).draw(true);
+
+    if (data.sync_option != "sync_now")
+    {
+        data_list_table.row.add({
+            'Time':data.timestamp,
+            'Level':data.level,
+            'Subsystem':data.subsystem,
+            'Event':data.event_id,
+            'Message':data.msg});
+        if (data.sync_option == "no_sync")
+            return;
+    }
+    data_list_table.draw(true);
     data_list_table.rows().invalidate();
     data_list_table.searchPanes.rebuildPane();
 }