From 9b66a73efe0a0bd51d9ded00c4e921a09b6de1ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Thu, 3 Dec 2020 22:34:46 +0100
Subject: [PATCH] Inteligentnejsi aktualizace stavu nahravani

---
 templates/live.html.ep | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/templates/live.html.ep b/templates/live.html.ep
index 4336d8e..0cbb79d 100644
--- a/templates/live.html.ep
+++ b/templates/live.html.ep
@@ -5,9 +5,11 @@
 <table id="Streams"
     class="table table--bordered"
     data-row-style="rowStyle"
+    data-unique-id="id"
     data-url="/api/streams?live=true">
   <thead>
     <tr>
+      <th data-field="id" data-visible="false">ID</th>
       <th data-field="name" data-width="60" data-width-unit="%">Stream</th>
       <th data-field="publish_user_name" data-width="30" data-width-unit="%">Vysílá</th>
       <th data-field="recording" data-width="10" data-width-unit="%" data-formatter="formatterRecording">Nahrávání</th>
@@ -26,8 +28,10 @@ $('#Streams').bootstrapTable({
                     url: '/streams/' + row.id + '/recording',
                     data: { action: (value ? 'stop':'start') },
                     success: function(rc) {
-                        var content = formatterRecording(rc.recording, row);
-                        $element.html(content);
+                        $('#Streams').bootstrapTable('updateByUniqueId', {
+                            id: row.id,
+                            row: rc
+                        });
                     }
                 });
             }
@@ -58,7 +62,7 @@ function rowStyle(row, index) {
     }
 }
 
-var ws = new WebSocket('<%= $c->config->{ws_url} %>');
+var ws = new WebSocket('<%= $c->config->{ws_url} %>/streams');
 
 ws.onmessage = function (event) {
   console.log(event.data);
-- 
GitLab