From 97c9440a33be948da04c5b3cb286920cf57b027a Mon Sep 17 00:00:00 2001 From: Mike Lowis Date: Mon, 18 Mar 2024 13:51:03 -0400 Subject: [PATCH] fixed up svgs to point to the correct locations and have correct credentials --- atv/assets/control.svg | 206 +++++++++++++---------------- atv/assets/index.html | 2 +- atv/assets/ui.js | 29 +++-- atv/assets/wifi.svg | 290 ++++++++++++++++++++--------------------- atv/lib/atv/channel.rb | 19 ++- atv/lib/atv/player.rb | 4 +- atv/lib/atv/server.rb | 2 +- 7 files changed, 274 insertions(+), 278 deletions(-) diff --git a/atv/assets/control.svg b/atv/assets/control.svg index e7dae0a..bcaf5b4 100644 --- a/atv/assets/control.svg +++ b/atv/assets/control.svg @@ -11,10 +11,12 @@ + - + + @@ -25,8 +27,12 @@ - - + + + + + + @@ -35,10 +41,9 @@ - - + @@ -49,10 +54,10 @@ + - - + @@ -63,7 +68,6 @@ - @@ -75,11 +79,10 @@ - + - @@ -101,7 +104,6 @@ - @@ -110,81 +112,76 @@ - + + - - - - - - + - + - + + + - - - + - + - - + + + - - - - - - - + + + + + - - - - + + + + + + + + + - + - + - - - - + + + - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + @@ -192,34 +189,32 @@ - - - + - - + + - + + - - - - + + - - + + + @@ -229,12 +224,10 @@ - - + + - - @@ -242,18 +235,18 @@ - - - + + + + - - - + + @@ -265,60 +258,49 @@ - + - - + - + - - - - - + - - + - + - - - - - - - - - - - - - + + + + + + - + - - + + + + @@ -329,13 +311,11 @@ - - - + diff --git a/atv/assets/index.html b/atv/assets/index.html index f51496a..4e6ba39 100644 --- a/atv/assets/index.html +++ b/atv/assets/index.html @@ -86,7 +86,7 @@ const connect = ()=>{ ws.onmessage = (event)=>{ const msg = JSON.parse(event.data); - if (msg["cmd"] != "queue") + if (msg["cmd"] != "queue" && msg["cmd"] != "items" && msg["cmd"] != "get_items" && msg["cmd"] != "enqueue") { console.log(msg); const prev = current; diff --git a/atv/assets/ui.js b/atv/assets/ui.js index b30c941..f8bdc38 100644 --- a/atv/assets/ui.js +++ b/atv/assets/ui.js @@ -2,7 +2,7 @@ const UI = (()=>{ const self = {}; let queue = []; - let items = {}; + let items = []; let path = []; const showBrowser = ()=>{ @@ -51,9 +51,15 @@ const UI = (()=>{ self.browse_up = ()=>{ path.pop(); - refreshItems(); + Client.send("get_items", { path: path }); + }; + + const linkDown = (dir)=>{ + path.push(dir); + Client.send("get_items", { path: path }); }; + const refreshQueue = ()=>{ if (queue.length > 0) { queueList.innerHTML = ""; @@ -75,23 +81,18 @@ const UI = (()=>{ return root; }; - const linkDown = (dir)=>{ - path.push(dir); - refreshItems(); - }; - const refreshItems = ()=>{ - const dir = getLocalRoot(); currDir.innerText = (path[path.length - 1] || "Root"); - itemList.innerText = ""; - for (const item in dir) { + for (const item of items) { const el = document.createElement("div"); - el.innerText = item; - if ('path' in dir[item]) { - el.onclick = ()=>{ self.enqueue(dir[item].path); }; + el.innerText = item.name; + console.log(item); + console.log('path' in item); + if ('path' in item) { + el.onclick = ()=>{ self.enqueue(item.path); }; } else { - el.onclick = ()=>{ linkDown(item); }; + el.onclick = ()=>{ linkDown(item.name); }; } itemList.appendChild(el); } diff --git a/atv/assets/wifi.svg b/atv/assets/wifi.svg index d9cca23..da36cf1 100644 --- a/atv/assets/wifi.svg +++ b/atv/assets/wifi.svg @@ -11,13 +11,12 @@ - - + - + + - @@ -29,12 +28,10 @@ - - + - - + @@ -43,12 +40,15 @@ + + - + + - + @@ -59,10 +59,14 @@ + + + - + + @@ -75,12 +79,6 @@ - - - - - - @@ -90,10 +88,12 @@ + - + + - + @@ -118,229 +118,223 @@ - - + - + + - - + - - + - - + - - + + - - + + - - - - + + + - - - - + + + - - + + + - + + - - + + + + - - - + + - + + - + + - + - - + - - + + + - - + + + + + + + - + + + + + - + - + + - + + - - + - + + - - - + - - - + + + - - + - + - - + - + + + + - + - - - - + + + - + + - + + - + + - - - - + - + - - + + - - + - - + + + - - - - + + - - - - - - - + - - - + - - + - + - - - - @@ -348,85 +342,93 @@ + + - - + + + - - + + - - - + + - - + + + + - + + + - - + - + + + + - - - + - - + - - + + + + + + - - - + + @@ -437,19 +439,17 @@ - + - + + - - + - - diff --git a/atv/lib/atv/channel.rb b/atv/lib/atv/channel.rb index 42a2c26..7b06f25 100644 --- a/atv/lib/atv/channel.rb +++ b/atv/lib/atv/channel.rb @@ -80,8 +80,23 @@ module ATV end end - def items() - { "items" => filedata[:tree] } + def items(path = []) + tree = filedata[:tree] + path.each do |dir| + tree = tree[dir] || {} + end + items = tree.map do |e| + data = { "name" => e[0] } + if e[1]["path"] + data["type"] = "file" + data["path"] = e[1]["path"] + else + data["type"] = "dir" + end + data + end + pp items + { "items" => items } end def queue() diff --git a/atv/lib/atv/player.rb b/atv/lib/atv/player.rb index 973dceb..9738974 100644 --- a/atv/lib/atv/player.rb +++ b/atv/lib/atv/player.rb @@ -56,8 +56,8 @@ module ATV }) end - def items() - @channels[@channel].items + def items(path = []) + @channels[@channel].items(path) end def queue() diff --git a/atv/lib/atv/server.rb b/atv/lib/atv/server.rb index 5fe6a3e..34cab9d 100644 --- a/atv/lib/atv/server.rb +++ b/atv/lib/atv/server.rb @@ -79,7 +79,7 @@ module ATV end def on_get_items(client, data) - client_send(client, "items", @@player.items) + client_send(client, "items", @@player.items(data["path"] || [])) end def on_get_queue(client, data) -- 2.54.0