From b5ec309ccb75011f25878e524930f1240ba9cf58 Mon Sep 17 00:00:00 2001 From: Micha Albert Date: Sun, 28 Jul 2024 23:20:03 +0000 Subject: [PATCH] make the tiling system aware of active stream --- stream/tiling-frontend/package.json | 3 + stream/tiling-frontend/postcss.config.js | 6 ++ stream/tiling-frontend/src/App.svelte | 109 +++++++++++++--------- stream/tiling-frontend/src/app.css | 3 + stream/tiling-frontend/src/main.ts | 1 + stream/tiling-frontend/tailwind.config.js | 9 ++ 6 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 stream/tiling-frontend/postcss.config.js create mode 100644 stream/tiling-frontend/src/app.css create mode 100644 stream/tiling-frontend/tailwind.config.js diff --git a/stream/tiling-frontend/package.json b/stream/tiling-frontend/package.json index f2b1860..be14666 100644 --- a/stream/tiling-frontend/package.json +++ b/stream/tiling-frontend/package.json @@ -12,8 +12,11 @@ "devDependencies": { "@sveltejs/vite-plugin-svelte": "^3.1.1", "@tsconfig/svelte": "^5.0.4", + "autoprefixer": "^10.4.19", + "postcss": "^8.4.40", "svelte": "^4.2.18", "svelte-check": "^3.8.1", + "tailwindcss": "^3.4.7", "tslib": "^2.6.3", "typescript": "^5.2.2", "vite": "^5.3.1" diff --git a/stream/tiling-frontend/postcss.config.js b/stream/tiling-frontend/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/stream/tiling-frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/stream/tiling-frontend/src/App.svelte b/stream/tiling-frontend/src/App.svelte index 10704c6..6f671d7 100644 --- a/stream/tiling-frontend/src/App.svelte +++ b/stream/tiling-frontend/src/App.svelte @@ -18,13 +18,15 @@ name: string; }[] | null = null; + let activePaths: string[] = []; + onMount(() => { const fetchData = async () => { try { const activeStreamResponse = await fetch( "http://localhost:8000/api/v1/active_stream", ); - activeStream = await activeStreamResponse.text(); + activeStream = (await activeStreamResponse.text()).replaceAll('"', ""); const pathListResponse = await fetch( "http://localhost:9997/v3/paths/list", ); @@ -36,7 +38,6 @@ delete newData[i].bytesSent; } } - console.log(videos); videos = Object.fromEntries( Object.entries(videos).filter(([_, v]) => v != null), ); @@ -44,9 +45,13 @@ if (JSON.stringify(newData) !== JSON.stringify(pathData)) { console.log("Data changed"); pathData = newData; + for (let pathIdx = 0; pathIdx < pathData?.length! - 1; pathIdx++) { + if (pathData![pathIdx].ready) { + activePaths.push(pathData![pathIdx].name); + } + } setTimeout(() => { for (const video in videos) { - console.log(video); const hlsInstance = new hls({ progressive: false }); hlsInstance.loadSource( `http://localhost:8888/${video}/index.m3u8`, @@ -75,45 +80,73 @@ >
-
-

+
+

OnBoard Live Design Stream

Hack Club {#if pathData?.map((path) => path.ready).includes(true)} -
- {#each pathData as path} - {#if path.ready} - - - {/if} - {/each} -
- {:else} -
-

+ + +

+ {/if} + + {#if activePaths.length > 1} +
+ + +
+
+ {#each pathData as path} + {#if path.ready && path.name !== activeStream} + + + {/if} + {/each} +
+ {/if} + {:else} +
+

No one is here yet!
Check back later

{/if}

Join at
diff --git a/stream/tiling-frontend/src/app.css b/stream/tiling-frontend/src/app.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/stream/tiling-frontend/src/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/stream/tiling-frontend/src/main.ts b/stream/tiling-frontend/src/main.ts index d5f003c..e51ccf8 100644 --- a/stream/tiling-frontend/src/main.ts +++ b/stream/tiling-frontend/src/main.ts @@ -1,4 +1,5 @@ import App from './App.svelte' +import './app.css' const app = new App({ target: document.getElementById('app')!, diff --git a/stream/tiling-frontend/tailwind.config.js b/stream/tiling-frontend/tailwind.config.js new file mode 100644 index 0000000..13207cc --- /dev/null +++ b/stream/tiling-frontend/tailwind.config.js @@ -0,0 +1,9 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./src/**/*.{html,js,svelte,ts}'], + theme: { + extend: {}, + }, + plugins: [], +} +