mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-26 23:12:48 -05:00
Add control button to browse page (for authing/debugging)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import yargs from 'yargs'
|
import yargs from 'yargs'
|
||||||
import { app, shell } from 'electron'
|
import { app, shell, BrowserWindow } from 'electron'
|
||||||
|
|
||||||
import { pollPublicData, pollSpreadsheetData, processData } from './data'
|
import { pollPublicData, pollSpreadsheetData, processData } from './data'
|
||||||
import StreamWindow from './StreamWindow'
|
import StreamWindow from './StreamWindow'
|
||||||
@@ -52,6 +52,8 @@ async function main() {
|
|||||||
const streamWindow = new StreamWindow()
|
const streamWindow = new StreamWindow()
|
||||||
streamWindow.init()
|
streamWindow.init()
|
||||||
|
|
||||||
|
let browseWindow = null
|
||||||
|
|
||||||
const clientState = {}
|
const clientState = {}
|
||||||
const getInitialState = () => clientState
|
const getInitialState = () => clientState
|
||||||
let broadcastState = () => {}
|
let broadcastState = () => {}
|
||||||
@@ -62,6 +64,11 @@ async function main() {
|
|||||||
streamWindow.setListeningView(msg.viewIdx)
|
streamWindow.setListeningView(msg.viewIdx)
|
||||||
} else if (msg.type === 'reload-view') {
|
} else if (msg.type === 'reload-view') {
|
||||||
streamWindow.reloadView(msg.viewIdx)
|
streamWindow.reloadView(msg.viewIdx)
|
||||||
|
} else if (msg.type === 'browse') {
|
||||||
|
if (!browseWindow || browseWindow.isDestroyed()) {
|
||||||
|
browseWindow = new BrowserWindow()
|
||||||
|
}
|
||||||
|
browseWindow.loadURL(msg.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
src/static/life-ring-regular.svg
Normal file
1
src/static/life-ring-regular.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="life-ring" class="svg-inline--fa fa-life-ring fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M256 504c136.967 0 248-111.033 248-248S392.967 8 256 8 8 119.033 8 256s111.033 248 248 248zm-103.398-76.72l53.411-53.411c31.806 13.506 68.128 13.522 99.974 0l53.411 53.411c-63.217 38.319-143.579 38.319-206.796 0zM336 256c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zm91.28 103.398l-53.411-53.411c13.505-31.806 13.522-68.128 0-99.974l53.411-53.411c38.319 63.217 38.319 143.579 0 206.796zM359.397 84.72l-53.411 53.411c-31.806-13.505-68.128-13.522-99.973 0L152.602 84.72c63.217-38.319 143.579-38.319 206.795 0zM84.72 152.602l53.411 53.411c-13.506 31.806-13.522 68.128 0 99.974L84.72 359.398c-38.319-63.217-38.319-143.579 0-206.796z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 895 B |
@@ -9,6 +9,7 @@ import '../index.css'
|
|||||||
import { GRID_COUNT } from '../constants'
|
import { GRID_COUNT } from '../constants'
|
||||||
import SoundIcon from '../static/volume-up-solid.svg'
|
import SoundIcon from '../static/volume-up-solid.svg'
|
||||||
import ReloadIcon from '../static/redo-alt-solid.svg'
|
import ReloadIcon from '../static/redo-alt-solid.svg'
|
||||||
|
import LifeRingIcon from '../static/life-ring-regular.svg'
|
||||||
|
|
||||||
function emptyStateIdxMap() {
|
function emptyStateIdxMap() {
|
||||||
return new Map(
|
return new Map(
|
||||||
@@ -113,6 +114,15 @@ function App({ wsEndpoint }) {
|
|||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const handleBrowse = useCallback((url) => {
|
||||||
|
wsRef.current.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: 'browse',
|
||||||
|
url,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Stream Wall</h1>
|
<h1>Stream Wall</h1>
|
||||||
@@ -125,10 +135,13 @@ function App({ wsEndpoint }) {
|
|||||||
<StyledGridLine>
|
<StyledGridLine>
|
||||||
{range(0, 3).map((x) => {
|
{range(0, 3).map((x) => {
|
||||||
const idx = 3 * y + x
|
const idx = 3 * y + x
|
||||||
const { streamId, isListening, state } = stateIdxMap.get(idx)
|
const { streamId, isListening, url, state } = stateIdxMap.get(
|
||||||
|
idx,
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<GridInput
|
<GridInput
|
||||||
idx={idx}
|
idx={idx}
|
||||||
|
url={url}
|
||||||
onChangeSpace={handleSetView}
|
onChangeSpace={handleSetView}
|
||||||
spaceValue={streamId}
|
spaceValue={streamId}
|
||||||
isError={state.matches('error')}
|
isError={state.matches('error')}
|
||||||
@@ -136,6 +149,7 @@ function App({ wsEndpoint }) {
|
|||||||
isListening={isListening}
|
isListening={isListening}
|
||||||
onSetListening={handleSetListening}
|
onSetListening={handleSetListening}
|
||||||
onReloadView={handleReloadView}
|
onReloadView={handleReloadView}
|
||||||
|
onBrowse={handleBrowse}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@@ -165,6 +179,7 @@ function StreamLine({ id, row: { Source, Title, Link, Notes } }) {
|
|||||||
|
|
||||||
function GridInput({
|
function GridInput({
|
||||||
idx,
|
idx,
|
||||||
|
url,
|
||||||
onChangeSpace,
|
onChangeSpace,
|
||||||
spaceValue,
|
spaceValue,
|
||||||
isDisplaying,
|
isDisplaying,
|
||||||
@@ -172,6 +187,7 @@ function GridInput({
|
|||||||
isListening,
|
isListening,
|
||||||
onSetListening,
|
onSetListening,
|
||||||
onReloadView,
|
onReloadView,
|
||||||
|
onBrowse,
|
||||||
}) {
|
}) {
|
||||||
const [editingValue, setEditingValue] = useState()
|
const [editingValue, setEditingValue] = useState()
|
||||||
const handleFocus = useCallback((ev) => {
|
const handleFocus = useCallback((ev) => {
|
||||||
@@ -196,18 +212,24 @@ function GridInput({
|
|||||||
idx,
|
idx,
|
||||||
onReloadView,
|
onReloadView,
|
||||||
])
|
])
|
||||||
|
const handleBrowseClick = useCallback(() => onBrowse(url), [url, onBrowse])
|
||||||
const handleClick = useCallback((ev) => {
|
const handleClick = useCallback((ev) => {
|
||||||
ev.target.select()
|
ev.target.select()
|
||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<StyledGridContainer>
|
<StyledGridContainer>
|
||||||
{isDisplaying && (
|
<StyledGridButtons side="left">
|
||||||
<StyledGridButtons side="left">
|
{isDisplaying && (
|
||||||
<StyledButton onClick={handleReloadClick}>
|
<StyledButton onClick={handleReloadClick}>
|
||||||
<ReloadIcon />
|
<ReloadIcon />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</StyledGridButtons>
|
)}
|
||||||
)}
|
{isError && (
|
||||||
|
<StyledButton onClick={handleBrowseClick}>
|
||||||
|
<LifeRingIcon />
|
||||||
|
</StyledButton>
|
||||||
|
)}
|
||||||
|
</StyledGridButtons>
|
||||||
<StyledGridButtons side="right">
|
<StyledGridButtons side="right">
|
||||||
<ListeningButton
|
<ListeningButton
|
||||||
isListening={isListening}
|
isListening={isListening}
|
||||||
|
|||||||
Reference in New Issue
Block a user