Skip to content

Commit

Permalink
[Reco] Unify layout to be similar to the Broadcaster
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Jul 10, 2024
1 parent 77b907d commit 9af70e4
Show file tree
Hide file tree
Showing 23 changed files with 257 additions and 336 deletions.
1 change: 1 addition & 0 deletions broadcaster/assets/js/player.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
console.log("dupa");
const audioDevices = document.getElementById('audioDevices');
const videoDevices = document.getElementById('videoDevices');
const maxVideoBitrate = document.getElementById('maxVideoBitrate');
Expand Down
10 changes: 5 additions & 5 deletions broadcaster/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"bunch": {:hex, :bunch, "1.6.1", "5393d827a64d5f846092703441ea50e65bc09f37fd8e320878f13e63d410aec7", [:mix], [], "hexpm", "286cc3add551628b30605efbe2fca4e38cc1bea89bcd0a1a7226920b3364fe4a"},
"bunch_native": {:hex, :bunch_native, "0.5.0", "8ac1536789a597599c10b652e0b526d8833348c19e4739a0759a2bedfd924e63", [:mix], [{:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "24190c760e32b23b36edeb2dc4852515c7c5b3b8675b1a864e0715bdd1c8f80d"},
"bundlex": {:hex, :bundlex, "1.5.1", "a85890a9d0a70366afa538c8589a4ba75e1319d32a771e1f5f3b7566beea9c26", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:req, "~> 0.4.0", [hex: :req, repo: "hexpm", optional: false]}, {:zarex, "~> 1.0", [hex: :zarex, repo: "hexpm", optional: false]}], "hexpm", "aae447d63230fe1f3b788c429ac02bc696f30163d0f23f52fcfe6ed38372c7ea"},
"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},
"castore": {:hex, :castore, "1.0.8", "dedcf20ea746694647f883590b82d9e96014057aff1d44d03ec90f36a5c0dc6e", [:mix], [], "hexpm", "0b2b66d2ee742cb1d9cb8c8be3b43c3a70ee8651f37b75a8b982e036752983f1"},
"crc": {:hex, :crc, "0.10.5", "ee12a7c056ac498ef2ea985ecdc9fa53c1bfb4e53a484d9f17ff94803707dfd8", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3e673b6495a9525c5c641585af1accba59a1eb33de697bedf341e247012c2c7f"},
"dns_cluster": {:hex, :dns_cluster, "0.1.3", "0bc20a2c88ed6cc494f2964075c359f8c2d00e1bf25518a6a6c7fd277c9b0c66", [:mix], [], "hexpm", "46cb7c4a1b3e52c7ad4cbe33ca5079fbde4840dedeafca2baf77996c2da1bc33"},
"elixir_make": {:hex, :elixir_make, "0.8.4", "4960a03ce79081dee8fe119d80ad372c4e7badb84c493cc75983f9d3bc8bde0f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "6e7f1d619b5f61dfabd0a20aa268e575572b542ac31723293a4c1a567d5ef040"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
"esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"},
"ex_dtls": {:hex, :ex_dtls, "0.15.1", "34b3600ff13eebf6c96be033005cc110ea5beef98394631365ec26b493df80c5", [:mix], [{:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "9cfebdfe9111c0f68c77667cb9366e4a6f17e8a240975ffd100148de57478a29"},
"ex_dtls": {:hex, :ex_dtls, "0.15.2", "6c8c0f8eb67525216551bd3e0322ab33c9d851d56ef3e065efab4fd277a8fbb9", [:mix], [{:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "6b852bc926bbdc9c1b9c4ecc6cfc73a89d4e106042802cefea2c1503072a9f2a"},
"ex_ice": {:hex, :ex_ice, "0.7.1", "3ad14f7281ece304dfee227e332b8a67d93d5857602a8a4300a826c250af136e", [:mix], [{:elixir_uuid, "~> 1.0", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:ex_stun, "~> 0.2.0", [hex: :ex_stun, repo: "hexpm", optional: false]}, {:ex_turn, "~> 0.1.0", [hex: :ex_turn, repo: "hexpm", optional: false]}], "hexpm", "78e6bc4abb5294dcf0a474d0a91e78a829916291d846a0e255867dc5db8733e7"},
"ex_libsrtp": {:hex, :ex_libsrtp, "0.7.2", "211bd89c08026943ce71f3e2c0231795b99cee748808ed3ae7b97cd8d2450b6b", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "2e20645d0d739a4ecdcf8d4810a0c198120c8a2f617f2b75b2e2e704d59f492a"},
"ex_rtcp": {:hex, :ex_rtcp, "0.4.0", "f9e515462a9581798ff6413583a25174cfd2101c94a2ebee871cca7639886f0a", [:mix], [], "hexpm", "28956602cf210d692fcdaf3f60ca49681634e1deb28ace41246aee61ee22dc3b"},
Expand All @@ -24,10 +24,10 @@
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized"]},
"hpax": {:hex, :hpax, "0.2.0", "5a58219adcb75977b2edce5eb22051de9362f08236220c9e859a47111c194ff5", [:mix], [], "hexpm", "bea06558cdae85bed075e6c036993d43cd54d447f76d8190a8db0dc5893fa2f1"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"jason": {:hex, :jason, "1.4.3", "d3f984eeb96fe53b85d20e0b049f03e57d075b5acda3ac8d465c969a2536c17b", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "9a90e868927f7c777689baa16d86f4d0e086d968db5c05d917ccff6d443e58a3"},
"membrane_precompiled_dependency_provider": {:hex, :membrane_precompiled_dependency_provider, "0.1.2", "8af73b7dc15ba55c9f5fbfc0453d4a8edfb007ade54b56c37d626be0d1189aba", [:mix], [{:bundlex, "~> 1.4", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "7fe3e07361510445a29bee95336adde667c4162b76b7f4c8af3aeb3415292023"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"mint": {:hex, :mint, "1.6.1", "065e8a5bc9bbd46a41099dfea3e0656436c5cbcb6e741c80bd2bad5cd872446f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4fc518dcc191d02f433393a72a7ba3f6f94b101d094cb6bf532ea54c89423780"},
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
"mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"},
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
"nimble_ownership": {:hex, :nimble_ownership, "0.3.1", "99d5244672fafdfac89bfad3d3ab8f0d367603ce1dc4855f86a1c75008bce56f", [:mix], [], "hexpm", "4bf510adedff0449a1d6e200e43e57a814794c8b5b6439071274d248d272a549"},
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
Expand Down
11 changes: 11 additions & 0 deletions reco/assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
@import "tailwindcss/utilities";

/* This file is for your main application CSS */

/* Hiding scrollbar for IE, Edge and Firefox */
main {
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE and Edge */
}

main::-webkit-scrollbar {
display: none;
}

7 changes: 6 additions & 1 deletion reco/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import { Socket } from "phoenix"
import { LiveSocket } from "phoenix_live_view"
import topbar from "../vendor/topbar"

import { Room } from "./room.js"

let Hooks = {}
Hooks.Room = Room

let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken } })
let liveSocket = new LiveSocket("/live", Socket, { params: { _csrf_token: csrfToken }, hooks: Hooks })

// Show progress bar on live navigation and form submits
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" })
Expand Down
21 changes: 13 additions & 8 deletions reco/assets/js/reco.js → reco/assets/js/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ let socket;
let channel;
let pc;

async function run() {
console.log("Starting");
async function connect() {
console.log("Connecting");
button.onclick = disconnect;

localStream = await navigator.mediaDevices.getUserMedia({
audio: true,
Expand All @@ -34,13 +35,13 @@ async function run() {
socket.connect();

channel = socket.channel("room:" + roomId, {});
channel.onClose(_ => { window.location.href = "/reco" });
channel.onClose(_ => { window.location.href = "/" });

channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => {
console.log("Unable to join", resp);
window.location.href = "/reco";
window.location.href = "/";
})

channel.on("signaling", msg => {
Expand All @@ -56,7 +57,7 @@ async function run() {
channel.on("imgReco", msg => {
const pred = msg['predictions'][0];
imgpred.innerText = pred['label'];
imgscore.innerText = pred['score'];
imgscore.innerText = pred['score'].toFixed(3);
})

channel.on("sessionTime", msg => {
Expand All @@ -75,8 +76,8 @@ async function run() {
channel.push("signaling", JSON.stringify(offer));
}

button.onclick = () => {
console.log("Leaving");
function disconnect() {
console.log("Disconnecting");
localStream.getTracks().forEach(track => track.stop());
videoPlayer.srcObject = null;

Expand All @@ -93,4 +94,8 @@ button.onclick = () => {
}
}

run();
export const Room = {
mounted() {
connect();
}
}
2 changes: 1 addition & 1 deletion reco/assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
theme: {
extend: {
colors: {
brand: "#FD4F00",
brand: "#4339AC",
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions reco/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ config :esbuild,
version: "0.17.11",
default: [
args:
~w(js/app.js js/reco.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
~w(js/app.js js/room.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]

# Configure tailwind (the version is required)
config :tailwind,
version: "3.3.2",
version: "3.4.4",
default: [
args: ~w(
--config=tailwind.config.js
Expand Down
14 changes: 14 additions & 0 deletions reco/lib/reco/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ defmodule Reco.Application do

@max_rooms Application.compile_env!(:reco, :max_rooms)

@version Mix.Project.config()[:version]

@spec version() :: String.t()
def version() do
"v#{@version} #{commit()}"
end

defp commit() do
case System.cmd("git", ["rev-parse", "--short", "HEAD"]) do
{hash, 0} -> "(#{String.trim(hash)})"
_ -> ""
end
end

@impl true
def start(_type, _args) do
children = [
Expand Down
32 changes: 20 additions & 12 deletions reco/lib/reco_web/components/layouts/app.html.heex
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
<header class="px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-center border-b border-zinc-100 py-4 text-sm">
<div class="flex flex-col lg:flex-row items-center justify-between border-b border-brand/15 py-3 text-sm">
<div class="flex items-center gap-4">
<a href="https://github.com/elixir-webrtc/ex_webrtc">
<img src={~p"/images/logo.svg"} width="36" />
<a href="/">
<img src={~p"/images/logo.svg"} width="225" />
</a>
</div>
<div class="flex items-center content-center gap-4 font-semibold leading-6 text-zinc-900">
<a href="https://github.com/elixir-webrtc/ex_webrtc" class="hover:text-zinc-700">
GitHub
</a>
<a href="https://hexdocs.pm/ex_webrtc/" class="hover:text-zinc-700">
Documentation
</a>
<div class="flex">
<div class="flex items-center gap-4 font-semibold leading-6 text-brand/80">
<a href="https://github.com/elixir-webrtc/ex_webrtc" class="hover:text-brand">
GitHub
</a>
<a
href="https://hexdocs.pm/ex_webrtc/readme.html"
class="rounded-lg bg-brand/10 px-2 py-1 hover:bg-brand/20"
>
Docs <span aria-hidden="true">&rarr;</span>
</a>
</div>
</div>
</div>
</header>
<main class="p-72 px-4 py-8 sm:px-6 lg:px-8">
<div class="mx-auto max-w-2xl">
<main class="flex flex-1 justify-center overflow-scroll">
<div class="h-full py-7 px-7 w-[800px]">
<.flash_group flash={@flash} />
<%= @inner_content %>
</div>
</main>
<footer class="flex flex-row px-4 py-2 lg:justify-start justify-center font-semibold text-brand/80">
<%= Reco.Application.version() %>
</footer>
6 changes: 3 additions & 3 deletions reco/lib/reco_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content={get_csrf_token()} />
<.live_title suffix=" · Phoenix Framework">
<%= assigns[:page_title] || "Reco" %>
<.live_title suffix=" · Reco">
<%= assigns[:page_title] %>
</.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
</script>
</head>
<body class="bg-white antialiased">
<body class="bg-white antialiased h-svh flex flex-col">
<%= @inner_content %>
</body>
</html>
9 changes: 0 additions & 9 deletions reco/lib/reco_web/controllers/page_controller.ex

This file was deleted.

5 changes: 0 additions & 5 deletions reco/lib/reco_web/controllers/page_html.ex

This file was deleted.

Loading

0 comments on commit 9af70e4

Please sign in to comment.