From 6f1faf275313c101da735fb813ae06a29adfe637 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 1 Apr 2025 17:29:27 -0700 Subject: [PATCH] added frontend tuning ability --- src/static/index.html | 7 ++++++- src/static/js/doc.ts | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/static/js/doc.ts diff --git a/src/static/index.html b/src/static/index.html index 1682648..0e833d2 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -11,9 +11,14 @@

Video streams

WebRTC

- +
+ +
+ +
+ \ No newline at end of file diff --git a/src/static/js/doc.ts b/src/static/js/doc.ts new file mode 100644 index 0000000..fa52d58 --- /dev/null +++ b/src/static/js/doc.ts @@ -0,0 +1,46 @@ +const getChannels = () => { + fetch('/api/list').then(async (res) => { + const channelNames: string[] = await res.json() + const radioGroup = document.getElementById('channel-group'); + if (!radioGroup) { + throw new Error("Radio group not found") + } + radioGroup.innerHTML = '' + channelNames.forEach((channelName,index) => { + const id = `radio-${index}`; + + const input = document.createElement('input'); + input.type = "radio" + input.name = 'grp'; + input.value = channelName; + input.id = id + + + const lbl = document.createElement("label"); + lbl.htmlFor = id; + lbl.textContent = channelName; + + // Wrap in a div or line + const wrapper = document.createElement("div"); + wrapper.appendChild(input); + wrapper.appendChild(lbl); + + + + radioGroup.appendChild(wrapper) + }) + }).catch(err => { + console.log("nope ",err) + }) +} + +const tune = () =>{ + const choice = document.querySelector('input[name="grp"]:checked') + const channel = choice?.value; + if(channel){ + fetch(`/api/tune/${channel}`, {method:'PUT'}) + } + +} + +getChannels(); \ No newline at end of file