From b13d3184e88b1fca7fffbfff544cea2002fa7f2d Mon Sep 17 00:00:00 2001 From: Max Goodhart Date: Fri, 19 Jun 2020 08:15:51 -0700 Subject: [PATCH] Add control button to browse page (for authing/debugging) --- src/node/index.js | 9 ++++++++- src/static/life-ring-regular.svg | 1 + src/web/control.js | 32 +++++++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/static/life-ring-regular.svg diff --git a/src/node/index.js b/src/node/index.js index 360a4c7..9b43f4d 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -1,6 +1,6 @@ import fs from 'fs' import yargs from 'yargs' -import { app, shell } from 'electron' +import { app, shell, BrowserWindow } from 'electron' import { pollPublicData, pollSpreadsheetData, processData } from './data' import StreamWindow from './StreamWindow' @@ -52,6 +52,8 @@ async function main() { const streamWindow = new StreamWindow() streamWindow.init() + let browseWindow = null + const clientState = {} const getInitialState = () => clientState let broadcastState = () => {} @@ -62,6 +64,11 @@ async function main() { streamWindow.setListeningView(msg.viewIdx) } else if (msg.type === 'reload-view') { streamWindow.reloadView(msg.viewIdx) + } else if (msg.type === 'browse') { + if (!browseWindow || browseWindow.isDestroyed()) { + browseWindow = new BrowserWindow() + } + browseWindow.loadURL(msg.url) } } diff --git a/src/static/life-ring-regular.svg b/src/static/life-ring-regular.svg new file mode 100644 index 0000000..3c0f07e --- /dev/null +++ b/src/static/life-ring-regular.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/web/control.js b/src/web/control.js index 57802c9..4e545ee 100644 --- a/src/web/control.js +++ b/src/web/control.js @@ -9,6 +9,7 @@ import '../index.css' import { GRID_COUNT } from '../constants' import SoundIcon from '../static/volume-up-solid.svg' import ReloadIcon from '../static/redo-alt-solid.svg' +import LifeRingIcon from '../static/life-ring-regular.svg' function emptyStateIdxMap() { return new Map( @@ -113,6 +114,15 @@ function App({ wsEndpoint }) { ) }, []) + const handleBrowse = useCallback((url) => { + wsRef.current.send( + JSON.stringify({ + type: 'browse', + url, + }), + ) + }, []) + return (

Stream Wall

@@ -125,10 +135,13 @@ function App({ wsEndpoint }) { {range(0, 3).map((x) => { const idx = 3 * y + x - const { streamId, isListening, state } = stateIdxMap.get(idx) + const { streamId, isListening, url, state } = stateIdxMap.get( + idx, + ) return ( ) })} @@ -165,6 +179,7 @@ function StreamLine({ id, row: { Source, Title, Link, Notes } }) { function GridInput({ idx, + url, onChangeSpace, spaceValue, isDisplaying, @@ -172,6 +187,7 @@ function GridInput({ isListening, onSetListening, onReloadView, + onBrowse, }) { const [editingValue, setEditingValue] = useState() const handleFocus = useCallback((ev) => { @@ -196,18 +212,24 @@ function GridInput({ idx, onReloadView, ]) + const handleBrowseClick = useCallback(() => onBrowse(url), [url, onBrowse]) const handleClick = useCallback((ev) => { ev.target.select() }) return ( - {isDisplaying && ( - + + {isDisplaying && ( - - )} + )} + {isError && ( + + + + )} +